[jboss-user] [JBoss Microcontainer] - Cyclic dependencies

Ales Justin do-not-reply at jboss.com
Fri Aug 20 08:47:00 EDT 2010


Ales Justin [http://community.jboss.org/people/alesj] replied to the discussion

"Cyclic dependencies"

To view the discussion, visit: http://community.jboss.org/message/558337#558337

--------------------------------------------------------------
> >From what I've read, MC can do cyclic injections, but can't do cyclic dependencies (<depends>) , true?
Injection is also just a dependency.
We can do whatever you can do programatically.
It's the different states that make this happen.

e.g. if A depends on B and B depends on A, both at ctor, then of course it's impossible to solve this

class A {
   A(B b) {}
}

class B {
   B(A a) {}
}

but if you set the A into B via setter (which gets populated at different state), then it would work.

class B {
   B() {}

  void setA(A a) {}
}

The same goes for <demand> which can take the state at which you depend on target,
while you can also declare target's state.
*  http://anonsvn.jboss.org/repos/jbossas/projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java http://anonsvn.jboss.org/repos/jbossas/projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java

<depends> is slightly different, as it has this states already "hardcoded" -- same functionality as you're used from old JMX kernel.

> I just started with MC so I am not yet too aware of what terms like Installed mean from the MC POV.
> 
MC state machine works on top of linear states:

   public AbstractController()
   {
      addState(ControllerState.NOT_INSTALLED, null);
      addState(ControllerState.PRE_INSTALL, null);
      addState(ControllerState.DESCRIBED, null);
      addState(ControllerState.INSTANTIATED, null);
      addState(ControllerState.CONFIGURED, null);
      addState(ControllerState.CREATE, null);
      addState(ControllerState.START, null);
      addState(ControllerState.INSTALLED, null);


While you can dynamically add new states -- see DeployersImpl.

> Could you pls point me to some good material explaining this issue, and perhaps the types of relations in MC?
*  http://anonsvn.jboss.org/repos/jbossas/projects/presentations/trunk/microcontainer/ http://anonsvn.jboss.org/repos/jbossas/projects/presentations/trunk/microcontainer/
*  http://java.dzone.com/articles/a-look-inside-jboss-microconta-0 http://java.dzone.com/articles/a-look-inside-jboss-microconta-0

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

Reply to this message by going to Community
[http://community.jboss.org/message/558337#558337]

Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2114]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100820/d431769a/attachment-0001.html 


More information about the jboss-user mailing list