Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomatically starting a JBoss service (MBean)
    primarykey
    data
    text
    <p>I'm trying to build a JBoss service that should be started automatically, each time the server is initiated.</p> <p>I've got the following class structure for my service:</p> <pre><code>public interface CumbiaXPMServiceMBean extends org.jboss.system.ServiceMBean public class CumbiaXPMService extends org.jboss.system.ServiceMBeanSupport implements CumbiaXPMServiceMBean </code></pre> <p>I've also got the following configuration file -- jboss-service.xml -- for my service :</p> <pre><code>&lt;server&gt; &lt;mbean code="uniandes.cumbia.xpm.jboss.CumbiaXPMService" name="jcumbia:service=JCumbiaEngine"&gt; &lt;depends&gt;jcumbia:service=cumbiaConsole&lt;/depends&gt; &lt;attribute name="LocationInCumbia" attributeClass="java.lang.String"&gt;XPMEngine&lt;/attribute&gt; &lt;/mbean&gt; &lt;/server&gt; </code></pre> <p>My question is: how do I automatically start this service?</p> <p>I expected that JBoss will call the method start( ) as part as the loading process, but it is not: I've got a lot of loggin code in my start( ) method, but I haven't seen any output.</p> <p>However, when I look at the MBean status using the JMXConsole, its state (StateString) is 'Started'.</p> <p><strong>Problem Solved</strong></p> <p>I found the solution to my problem. I was overriding the methods start( ), stop( ), destroy( ) and create( ); nevertheless, since I'm extending the abstract class ServiceMBeanSupport, I should be overriding the methods startService( ), stopService( ), etc.</p> <p>I just moved my code from the method start( ) to the method startService( ) and now everything is behaving as I needed: as soon as its dependencies are fulfilled, my service is started and the method startService( ) is executed.</p> <p>I think the conclusion is: although the life-cycle of an MBean involves calling create( ), start( ), stop( ) and destroy( ), the implementation of the abstract class ServiceMBeanSupport uses those methods to handle the life cycle. Nevertheless, it provides the protected methods *Service( ) in order to allow the programmer to participate in the life cycle.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload