Version 4

    How can an MBean depend on a SessionBean?

     

    You can specify a dependency between the MBean and the Container that

    contains the SessionBean (which is an MBean itself following the JBoss

    lifecycle model), for example:

     

    The archive jboss-media-entity-ejb.jar contains a session bean called

    MediaEntityManager. When the archive is deployed the following MBean

    will be created and will be visible through the jmx-console:

      jboss.j2ee:module=jboss-media-entity-ejb.jar,service=EjbModule
    

    Specifying the dependency is then easy:

       ...
       <mbean code="my.mbean.class" name="mydomain:name=myname">
         ...
         <depends>jboss.j2ee:module=jboss-media-entity-ejb.jar,service=EjbModule</depends>
       </mbean>
       ...
    

    Your MBean will only be started after the container (and as a result

    the contained SessionBean) has been started, so you can lookup its name

    in JNDI, call its methods, etc.

     

     

    An update.

     

    Sometimes, it just happens that an archive gets deployed but SessionBeans it contains do not (for various reasons: unresolved dependencies, programmatic error, etc.).

     

    In this case, dependency on jboss.j2ee:module=jboss-media-entity-ejb.jar,service=EjbModule won't do any good.

     

    If a SessionBean to depend upon, however, has a remote interface, adding a dependency on jboss.j2ee:jndiName=<remote interface JNDI name>,service=EJB seems a better alternative.

     

    Referenced by: