<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Cyclic dependencies
</h3>
<span style="margin-bottom: 10px;">
reply from <a href="http://community.jboss.org/people/alesj">Ales Justin</a> in <i>JBoss Microcontainer</i> - <a href="http://community.jboss.org/message/558337#558337">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><blockquote class="jive-quote">>From what I've read, MC can do cyclic injections, but can't do cyclic dependencies (<depends>) , true?</blockquote><p>Injection is also just a dependency.<br/>We can do whatever you can do programatically.<br/>It's the different states that make this happen.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>e.g. if A depends on B and B depends on A, both at ctor, then of course it's impossible to solve this</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>class A {<br/>   A(B b) {}<br/>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>class B {<br/>   B(A a) {}<br/>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>but if you set the A into B via setter (which gets populated at different state), then it would work.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>class B {<br/>   B() {}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  void setA(A a) {}<br/>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The same goes for <demand> which can take the state at which you depend on target,<br/>while you can also declare target's state.</p><p><span>* </span><a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbossas/projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java" target="_blank">http://anonsvn.jboss.org/repos/jbossas/projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><depends> is slightly different, as it has this states already "hardcoded" -- same functionality as you're used from old JMX kernel.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote">I just started with MC so I am not yet too aware of what terms like Installed mean from the MC POV.<br/></blockquote><p>MC state machine works on top of linear states:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-java">   <font color="navy"><b>public</b></font> AbstractController()
   <font color="navy">{</font>
      addState(ControllerState.NOT_INSTALLED, <font color="navy"><b>null</b></font>);
      addState(ControllerState.PRE_INSTALL, <font color="navy"><b>null</b></font>);
      addState(ControllerState.DESCRIBED, <font color="navy"><b>null</b></font>);
      addState(ControllerState.INSTANTIATED, <font color="navy"><b>null</b></font>);
      addState(ControllerState.CONFIGURED, <font color="navy"><b>null</b></font>);
      addState(ControllerState.CREATE, <font color="navy"><b>null</b></font>);
      addState(ControllerState.START, <font color="navy"><b>null</b></font>);
      addState(ControllerState.INSTALLED, <font color="navy"><b>null</b></font>);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>While you can dynamically add new states -- see DeployersImpl.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote">Could you pls point me to some good material explaining this issue, and perhaps the types of relations in MC?</blockquote><p><span>* </span><a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbossas/projects/presentations/trunk/microcontainer/" target="_blank">http://anonsvn.jboss.org/repos/jbossas/projects/presentations/trunk/microcontainer/</a></p><p><span>* </span><a class="jive-link-external-small" href="http://java.dzone.com/articles/a-look-inside-jboss-microconta-0" target="_blank">http://java.dzone.com/articles/a-look-inside-jboss-microconta-0</a></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/558337#558337">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Microcontainer at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2114">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>