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/m...
Helper
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/microcontaine...
| 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/m...
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131393#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...