If i have n number of deployers in a chain, is there a specific order these 
deployers follow while deploying an unit?

Right now, i have the following scenario:

public class FirstDeployer extends AbstractDeployer
  | {
  | 
  |   public FirstDeployer()
  |   {
  |     setStage(REAL);
  |   
  |     // our only input is JBossMetaData
  |     setInput(JBossMetaData.class);
  | 
  |     // we generate FirstOutput.class as the output
  |     setOutput(FirstOutput.class);
  |   }
  | 
  |   public void deploy(DeploymentUnit unit)
  |   {
  |     // do something and add output
  |     unit.addAttachment(FirstOutput.class);
  |   }
  | 
  | }
  | 
  | 
  | 

public class SecondDeployer extends AbstractRealDeployerWithInput<JBossMetaData>
  | {
  | 
  |   public SecondDeployer()
  |   {
  |     // set a visitor
  |     setDeploymentVisitor(new SimpleVisitor());
  | 
  |     // we generate SecondOutput.class as the output
  |     setOutput(SecondOutput.class);
  |   }
  | 
  |   private class SimpleVisitor implements DeploymentVisitor<JBossMetaData>
  |   {
  |     public void deploy(DeploymentUnit unit, JBossMetaData jbmeta)
  |     {
  |       // we generate SecondOutput.class as the output
  |       unit.addAttachment(SecondOutput.class);
  |     }
  | 
  |   }
  | 
  | }
  | 


public class FinalDeployer extends AbstractDeployer
  | {
  | 
  |   public FinalDeployer()
  |   {
  |     setStage(REAL);
  |   
  |     // we rely on 2 inputs 
  |     // 1) FisrtOutput.class Generated from FirstDeployer
  |     // 2) SecondOutput.class generated from SecondDeployer
  |     addInput(FirstOutput.class);
  |     addInput(SecondOutput.class);
  | 
  |     // we generate FinalOutput.class as the output
  |     setOutput(FinalOutput.class);
  |   }
  | 
  |   public void deploy(DeploymentUnit unit)
  |   {
  |     // we expect both the inputs to be present in the unit at this point
  |     FirstOutput one = unit.getAttachment(FirstOutput.class);
  |     SecondOutput second = unit.getAttachment(SecondOutput.class);
  |   }
  | 
  | }
  | 
  | 
  | 

As can be seen:

* There are 3 deployers - FirstDeployer, SecondDeployer and FinalDeployer. Each 
are for the REAL stage.
* The FirstDeployer generates FirstOutput.class as output
* The SecondDeployer generates SecondOutput.class as output
* Ordering between FirstDeployer and SecondDeployer is NOT of concern in this 
example, since each one is independent
* The FinalDeployer expects 2 inputs - one from FirstDeployer and one from 
SecondDeployer. Ordering IS important here. So when FinalDeployer is invoked, 
for deploying the unit, it expects both the inputs to be available (as 
attachments) in the unit. So both the FirstDeployer and SecondDeployer should 
have processed the unit before reaching the FinalDeployer.

However, from what i see, the FinalDeployer is invoked before the 
SecondDeployer and hence when the FinalDeployer tries to get hold of 
SecondOutput, it gets a null.

Shouldn't the inputs add some sort of dependency/ordering within the deployers? 
More importantly, since the FinalDeployer relies on 2 inputs, shouldn't it be 
called only after *both* inputs are available? Right now, from the logs it 
appears to me that this FinalDeployer is being invoked when atleast one of the 
input is available.

As a ugly hack (for testing) i set the relative order for the FinalDeployer and 
i see that it gets called after both the FirstDeployer and SecondDeployer are 
invoked (the original intention).

public class FinalDeployer extends AbstractDeployer
  | {
  | 
  |   public FinalDeployer()
  |   {
  |     setStage(REAL);
  |   
  |     // we rely on 2 inputs 
  |     // 1) FisrtOutput.class Generated from FirstDeployer
  |     // 2) SecondOutput.class generated from SecondDeployer
  |     addInput(FirstOutput.class);
  |     addInput(SecondOutput.class);
  | 
  |     // we generate FinalOutput.class as the output
  |     setOutput(FinalOutput.class);
  | 
  |     // let's go last
  |     setRelativeOrder(Integer.MAX_VALUE);
  |   }
  | ...
  | 
  | }
  | 
  | 
By the way, the setRelativeOrder - what is it relative to?



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

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4217498
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to