1 Reply Latest reply on Oct 26, 2009 5:35 PM by alesj

    Optional depends?

    pferraro

      Is there a way to express an optional dependency between beans? e.g. install bean A before bean B, but only if bean A exists.
      In psuedo-markup:

      <bean name="A" class="...">
       <!-- A depends on B, if B exists -->
       <depends optional="true">B</depends>
      </bean>
      <bean name="B" class="..."/>


      The "optional" aspect would be transparent if it were possible to describe the dependency within the guardian bean, instead of the dependent bean.
      e.g. In pseudo-markup:
      <bean name="A" class="..."/>
      <bean name="B" class="...">
       <!-- A depends on B, but dependency is described in B, instead of A -->
       <dependent>A</dependent>
      </bean>


      The use case for this in the AS is mod_cluster, whose service bean must be installed before (and undeployed after) the WebServer bean. Normally, this would be expressed as jbossweb depends on mod_cluster, but jbossweb should not require mod_cluster. Thoughts?

        • 1. Re: Optional depends?
          alesj

          To make this work w/o ugly hacks you simply need double configuration.
          Where in one of them you actually have a mock mod_cluster supply.

          Otherwise this is pretty much hackish to achieve,
          as you still heavily depend on deployment order.

          e.g.
          jbossweb is deployed first, at that time mod_cluster is not present in any state,
          hence optional dependency is satisfied and afterwards never re-invoked.
          But if the order was different you would wire up that optional dependency.

          To make this "work" you would have to hack around the cleanup code
          in order not to leave something hanging at the end and get incomplete deployment error.

          With some mock object you always have proper order,
          where in the mock case all you do is tag some bean as mod_cluster supplier.

          We have an optional inject, but this is/should mostly be used when you know
          you have a phase split - trying to optionally inject something from deployers/ into deploy/ beans.