I am trying to understand the usage of setInput()/setInputs()/addInput() APIs 
on the deployers:


  |    public void setInput(Class<?> input)
  | 
  |    public void setInputs(Set<String> inputs)
  | 
  |    public void setInputs(String... inputs)
  | 
  |    public void setInputs(Class<?>... inputs)
  | 
  |    public void addInput(String input)
  | 
  |    public void addInput(Class<?> input)
  | 

I thought i had understood the usage the last time Emanuel mentioned about this 
here http://www.jboss.org/index.html?module=bb&op=viewtopic&t=156725#4236298

But after seeing the behaviour of setInput(Class<?> input), i am not sure 
again. I tried this in a simple deployer:

  | // Just a test deployer
  | MyDeployer extends AbstractDeployer
  | {
  | 
  |   MyDeployer()
  |   {
  |     // let's add a requirement on an attachment in the unit of type 
String.class
  |     setInput(String.class);
  |   }
  | ...
  | }
  | 

Then there was a different deployer which added a attachment of type String to 
the unit. However none of the units ever got passed to this deployer. So 
looking into the MC code, i see that the check for relevance does this:


  |    protected boolean isRelevant(Deployer deployer, DeploymentUnit unit, 
boolean isTopLevel, boolean isComponent)
  |    {
  |       ...
  |       if (deployer.isAllInputs() == false)
  |       {
  |          // No attachment for the input type
  |          Class<?> input = deployer.getInput();
  |          if (input != null && unit.getAttachment(input) == null)
  |             return false;
  | 
  |       }
  |       return true;
  |    }
  | 

deployer.getInput returns String.class which is passed to 
unit.getAttachment(String.class) which ultimately does this:

  | public <T> T getAttachment(Class<T> type)
  |    {
  |       if (type == null)
  |          throw new IllegalArgumentException("Null type");
  |       return getAttachment(type.getName(), type); 
  |    }
  | 

The code finally ends up looking for an attachment with the name 
"java.lang.String" key. So unless the unit has an attachment with the key named 
"java.lang.String" the deployer is not going to be called.

So what is the expected behaviour of setInput(Class<?> clazz). If it was 
intended to use the classname as the attachment key, then any reason why the 
API expects a Class<?> instead of a String?

Also, how does the addInput API influence the deployers? 



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

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

Reply via email to