[jboss-user] [JBoss Microcontainer] New message: "Processed BMD as an input to a deployer"

jaikiran pai do-not-reply at jboss.com
Tue Feb 23 08:09:42 EST 2010


User development,

A new message was posted in the thread "Processed BMD as an input to a deployer":

http://community.jboss.org/message/527897#527897

Author  : jaikiran pai
Profile : http://community.jboss.org/people/jaikiran

Message:
--------------------------------------------------------------
I am trying to create a chain of deployers which would allow me to do something like the following:
 
- DeployerA in POST_CLASSLOADER phase would attach some metadata XYZ to a unit and *also* attach the same XYZ as a BeanMetaData to the unit, so that some of the fields marked with @Inject get processed appropriately.
 
- DeployerB in REAL phase adds XYZ as an input and expects a completely processed XYZ (i.e. the @Inject within XYZ to have been completed) when the deploy method is called.
 
The pseudo-code:
 
public class DeployerA extends AbstractDeployer
{
   public DeployerA()
   {
      // Set the Stage to post-CL
      this.setStage(DeploymentStages.POST_CLASSLOADER);
 
      this.setInput(blah.class);
      
       // we output XYZ     
      this.addOutput(XYZ.class);
      // we also output XYZ as BMD
      this.addOutput(BeanMetaData.class);
      
   }
 
   /**
    * @see org.jboss.deployers.spi.deployer.Deployer#deploy(org.jboss.deployers.structure.spi.DeploymentUnit)
    */
   @Override
   public void deploy(DeploymentUnit unit) throws DeploymentException
   {
     
 
      XYZ output = new XYZ();
      // add as a attachment
      unit.addAttachment(XYZ.class, output);
      
      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("blahbmd", output.getClass().getName());
      builder.setConstructorValue(output);
      // attach XYZ as a BMD
      unit.addAttachment(BeanMetaData.class + ":" + "blahbmd", builder.getBeanMetaData());
   }
 
}

 
public class DeployerB extends AbstractSimpleRealDeployer
{
 
   
   public DeployerB()
   {
      // input
      super(XYZ.class);
      
      
   }
 
   
   @Override
   public void deploy(DeploymentUnit unit, XYZ mcProcessedXYZ) throws DeploymentException
   {
             // here we expect a XYZ which has been processed for @Inject points by MC
             Object injectedField = mcProcessedXYZ.getInjectedField();
   }
 
}
 

 
So the DeployerB is expecting an input which is already processed as a BMD. However, from what i see, the DeployerB gets called before any of the processing happens on XYZ. So, although the unit has XYZ has an attachment, when it gets processed in DeployerB, it's not injected with any injectable fields. I can see that the injection into XYZ takes place after this DeployerB is done with the processing.
 
I am sure that i am not doing it right. So is there a way wherein i can achieve what i am trying to do?
 
P.S: incallback for XYZ is not an option because i need "deployer" semantics in this usecase.
 

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/527897#527897




More information about the jboss-user mailing list