[jboss-user] [Microcontainer] - Re: OneToMany relationships

alesj do-not-reply at jboss.com
Mon Jan 28 16:38:30 EST 2008


This is best explained with MainDeployer and Deployers example:

Instead of having each Deployer to call


  | <install bean="MainDeployer" method="addDeployer">
  |    <parameter>this</parameter>
  | </install>
  | <install bean="MainDeployer" method="removeDeployer">
  |    <parameter>this</parameter>
  | </install>
  | 

You can just add this:


  | <bean name="MainDeployer" ...>
  |    <incallback method="addDeployer"/>
  |    <uncallback method="removeDeployer"/>
  | </bean>
  | 

The callback idea is to check the type of method's parameter - in this case Deployer interface - and when a matching bean (by type --> instance of) is installed/uninstalled, you execute this callback.

So when a new Deployer bean is installed, it is automa(t|g)ically added to MainDeployer.

Exchange MainDeployer with Employee and Deployer with Address, and there you go. ;-)

All MC IoC xml elements have matching annotation support. In this case @Install/@Uninstall.

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

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



More information about the jboss-user mailing list