[jboss-dev-forums] [Deployers on JBoss (Deployers/JBoss)] - Re: Deploying multiple service through the ServiceDeployer

adrian@jboss.org do-not-reply at jboss.com
Fri Feb 22 08:43:19 EST 2008


No, you don't create the components yourself.
You leave that to the component deployer.

The key part is that the attachment doesn't have to be named ServiceMetaData.class.getName(). Most people call it that,
but that's just a convention.
(It's always called that at the component level though).

The component deployer looks for any attachment that implements the
type, it's doesn't care what it is called and creates a component for it.

JMX component deployer
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeploymentDeployer.java?revision=63732&view=markup

Helper
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractComponentDeployer.java?revision=67198&view=markup


  |    protected void deployComponents(DeploymentUnit unit) throws DeploymentException
  |    {
  |       if (compVisitor == null)
  |          return;
  | 
  |       Set<? extends C> components = unit.getAllMetaData(getOutput());
  |       for (C component : components)
  |          compVisitor.deploy(unit, component);
  |    }
  | 

And because it uses a visitor pattern, it knows how to unwind errors.

Your version suffers from the usual, "I'm not going to bother to tidyup
if I get an error part way through" bug. Which is just going to lead to
"InstanceAlreadyExists" errors in the MBeanServer when you try to redeploy.

>From a brief look at the code you posted, 
it breaks the following basic design princples of the deployers

1) It sidesteps the deployer chain with one deployer calling another directly
2) Since the metadata is deleted it won't be available to the management tool
3) It doesn't create components for the individual services, so there's no
way the IncompleteDeploymentException to know which MBeans are part of 
the deployment and give a reasonable error message.

Finally, there already is a ServiceMetaDataSet, its called a ServiceDeployment
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/trunk/system-jmx/src/main/org/jboss/system/metadata/ServiceDeployment.java?revision=65120&view=markup

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

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



More information about the jboss-dev-forums mailing list