[jboss-user] [JBoss Microcontainer Development] New message: "Re: Activating OnDemand beans from child controller"

Kabir Khan do-not-reply at jboss.com
Fri Jan 15 06:04:03 EST 2010


User development,

A new message was posted in the thread "Activating OnDemand beans from child controller":

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

Author  : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com

Message:
--------------------------------------------------------------
> mailto:kabir.khan at jboss.com wrote:
>  
> Fixing http://lists.jboss.org/pipermail/jboss-development/2010-January/015434.html I am adding a ScopedOnDemandDependencyTestCase (extends OnDemandDependencyTestCase similar to (Scoped)DuplicateAliasTestCase), but have found a deeper problem. If an OnDemand bean is installed in the main controller and is depended on by a bean in a child controller the OnDemand bean never gets activated and the child controller bean's dependency never resolved. 
> I install Bean1 with OnDemand, goes to Describe state
> I install scoped Bean2 with Automatic and a dependency on Bean1, goes to Instantiated state fine
>  
> When trying to move Bean2 to Configured state it does not resolve for the following reasons:
> When enabling ondemand beans in AbstractDependencyItem.resolve(), it was looking at the wrong controller, I changed:
>  
>          *if* (unresolvedContext != *null* && ControllerMode.ON_DEMAND.equals(unresolvedContext.getMode()))
>          {
>             *try*
>             {
>                controller.enableOnDemand(unresolvedContext);
> 
> 
>  
> 
> to
> 
>  
>         *if* (unresolvedContext != *null* && ControllerMode.ON_DEMAND.equals(unresolvedContext.getMode()))
>          {
>             *try*
>             {
>                unresolvedContext.getController().enableOnDemand(unresolvedContext);
> 
> 
>  
> 
>  
> 
> Now Bean1 correctly gets its requiredState set to INSTALLED. Unfortunately this is not enough.
> 
>  
> 
> In the normal/unscoped mode the mechanism is that AbstractDI.resolve() returns false, and we end up back in the resolveContexts() loop which finds Bean1 is not in its requiredState (INSTALLED).
> 
>  
> 
> In the scoped test, it does not get picked up since Bean2 was installed in the scoped controller whose resolveContexts() does not involve the main controller so Bean1 is never found.
> 
>  
> 
> I'll see if I can fix this
> 
>  
 
After a trying a few different things what I have now is.
-Leaving DependencyItem as is
-Modifying AbstractController.enableOnDemand() to set onDemandEnabled for the initiating controller (i.e. scoped in this case) and also for the controller the OnDemand context actually belongs to.
-Modifying the AbstractController.resolveContexts() loop to record if onDemandEnabled was true, and if it was when finishing the loop to call resolveContexts() on the parent controller.

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

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




More information about the jboss-user mailing list