[jboss-dev-forums] [Design of POJO Server] - Re: JSR77 View

alesj do-not-reply at jboss.com
Thu Oct 16 09:41:28 EDT 2008


"scott.stark at jboss.org" wrote : 
  | WAR = JBossWebMetaData attachment
  | 
As I want to make as little change / code as possible
I'm trying to use old code as much as I can.

But it looks like I'm gonna be stuck as I have hard time getting
ObjecName(s) from metadata.

This is how my effort to port WebModule jsr77 handling looks like:

  | public class WebModuleJSR277Deployer extends AbstractVFSJSR277Deployer<JBossWebMetaData>
  | {
  |    public WebModuleJSR277Deployer()
  |    {
  |       super(JBossWebMetaData.class);
  |    }
  | 
  |    protected void deployJsr77(MBeanServer server, VFSDeploymentUnit unit, JBossWebMetaData metaData) throws Throwable
  |    {
  |       String warName = unit.getSimpleName();
  |       ObjectName webModuleService = null; // TODO
  |       String earName = FactoryUtils.findEarParent(unit);
  |       ObjectName jsr77Name = WebModule.create(server, earName, warName, unit.getRoot().toURL(), webModuleService);
  |       putObjectName(unit, WebModule.class.getName(), jsr77Name);
  |       Iterable<ObjectName> servlets = null; // TODO
  |       for (ObjectName servletName : servlets)
  |       {
  |          try
  |          {
  |             createServlet(server, unit, jsr77Name, servletName);
  |          }
  |          catch (Throwable e)
  |          {
  |             log.debug("Failed to create JSR-77 servlet: " + servletName, e);
  |          }
  |       }
  |    }
  | 
  |    protected void undeployJsr77(MBeanServer server, VFSDeploymentUnit unit, JBossWebMetaData metaData)
  |    {
  |       ObjectName jsr77Name = getObjectName(unit, WebModule.class.getName());
  |       log.debug("Destroy module: " + jsr77Name);
  |       Iterable<ObjectName> servlets = null; // TODO
  |       for (ObjectName servletName : servlets)
  |       {
  |          try
  |          {
  |             destroyServlet(server, unit, servletName);
  |          }
  |          catch (Throwable e)
  |          {
  |             log.debug("Failed to destroy JSR-77 servlet: " + servletName, e);
  |          }
  |       }
  | 
  |       if (jsr77Name != null)
  |       {
  |          WebModule.destroy(server, jsr77Name);
  |       }
  |    }
  | 
  |    /**
  |     * Create JSR-77 Servlet
  |     *
  |     * @param mbeanServer        the MBeanServer context
  |     * @param unit the deployment unit
  |     * @param webModuleName      the JSR77 name of the servlet's WebModule
  |     * @param servletServiceName The jboss servlet mbean name
  |     * @return servlet's jsr77 object name
  |     */
  |    public ObjectName createServlet(MBeanServer mbeanServer, VFSDeploymentUnit unit, ObjectName webModuleName, ObjectName servletServiceName)
  |    {
  |       ObjectName jsr77Name = null;
  |       // We don't currently have a web container mbean
  |       ObjectName webContainerName = null;
  |       try
  |       {
  |          log.debug("Creating servlet: " + servletServiceName);
  |          String servletName = servletServiceName.getKeyProperty("name");
  |          if (servletName != null)
  |          {
  |             // Only treat resources with names as potential servlets
  |             jsr77Name = Servlet.create(mbeanServer, webModuleName, webContainerName, servletServiceName);
  |             putObjectName(unit, servletServiceName.getCanonicalName(), jsr77Name);
  |             log.debug("Created servlet: " + servletServiceName + ", module: " + jsr77Name);
  |          }
  |       }
  |       catch (Exception e)
  |       {
  |          log.debug("Failed to create servlet: " + servletServiceName, e);
  |       }
  | 
  |       return jsr77Name;
  |    }
  | 
  |    /**
  |     * Destroy JSR-77 Servlet
  |     *
  |     * @param server        the MBeanServer context
  |     * @param unit the deployment unit
  |     * @param servletServiceName The jboss servlet mbean name
  |     */
  |    public void destroyServlet(MBeanServer server, VFSDeploymentUnit unit, ObjectName servletServiceName)
  |    {
  |       ObjectName jsr77Name = getObjectName(unit, servletServiceName.getCanonicalName());
  |       log.debug("Destroy container: " + servletServiceName + ", module: " + jsr77Name);
  |       if (jsr77Name != null)
  |       {
  |          Servlet.destroy(server, jsr77Name);
  |       }
  |    }
  | }
  | 

It's the TODOs that I don't know how to get / create.
And I guess I'm gonna face the same problems in EJB, JCA, RAR, ...

Perhaps in this case I could even get WebModule ObjectName.
>From (making it static) AbstractWarDeployer::getObjectName(JBossWebMetaData).
But then in TomcatDeployment, we create another ObjectName, 
and set it to WebApplication instance (WebApplication::setAppData).
Which one is it? ;-)

Or is my approach with deployers + metadata completely wrong? :-)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4182658#4182658

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4182658



More information about the jboss-dev-forums mailing list