POJO Lifecycle methods

 Just as for "normal" MBeans in JBoss, Service POJOs support lifecycle management, but you don't need to create all these methods. You can pick and choose only those needed by your Service.

If  present in the service, the container will call these methods as follows:

create() - called by the server when the service is created and all the services it depends upon have been created too. At this point the service (and all the services it depends on) is installed in the JMX server, but is not yet fully functional.

start() - called by the server when the service is started and all the services it depends upon have been started too. At this point the service (and all the services it depends on) is fully functional.

stop() - called by the server when the service is stopped. At this point the service (and all the services that depend on it) is no longer fully operational.

destroy() - called by the server when the service is destroyed and removed from the MBean server. At this point all the MBeans that depend on the

Packaging and deploying

Packaging your Service is just a matter of compiling the classes and putting them in a jar file (You can even choose to deploy them as exploder jar folder which is easier for development use)

If you're using an Eclipse based tool simply add to your Project--->Properties--->Java Build Path the library jboss-annotations-ejb3.jar which is found in your JBOSS_HOME/client folder.

If you're compiling with the console just throw a

javac -classpath c:\jboss-4.2.0.GA\client\jboss-annotations-ejb3.jar;. -d . *.java

(Change the JBoss location to your JBoss Home).

Now jar everything:

jar cvf Calculate.jar sample

and copy the Calculate.jar in the "deploy" directory of JBoss. If everything was done correctly you should see in the server logs...

11:03:02,546 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=Calculate.jar,name=CalculateInterestMBean,service=EJB3 with dependencies:
11:03:02,593 INFO [EJBContainer] STARTED EJB: sample.jmx.CalculateInterestMBean
ejbName: CalculateInterestMBean
11:03:02,609 INFO [STDOUT] CalculateInterestMBean - Creating
11:03:02,625 INFO [JmxKernelAbstraction]creating wrapper delegate for: org.jboss.ejb3.service.ServiceContainer
11:03:02,625 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=Calculate.jar,name=FinancialAdvisorMBean,service=EJB3 with dependencies:
11:03:02,625 INFO [JmxKernelAbstraction] sampleJMX:service=calculateInterest
11:03:02,687 INFO [EJBContainer] STARTED EJB: sample.jmx.FinancialAdvisorMBean ejbName: FinancialAdvisorMBean
11:03:02,703 INFO [STDOUT] FinancialAdvisorMBean - Creating
11:03:02,718 INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.2.0.GA/server/default/deploy/Calculate.jar/

 

0
0
0
s2sdefault

Related articles available on mastertheboss.com

How to a dump of JNDI tree with JMX console ?

#2 JBoss Howto. This is the recipe of the day

How to configure JBoss to bind to a different IP ?

If you want to change the jboss.bind.address property use the&nbs

How to shut down JBoss from remote ?

JBoss recipe of the day

How to create multiple instances of an Mbean?

  Supposing you need two instances of an MBean, let's say one fo

JBoss classloader issues

By default JBoss (prior to version 3.2) uses a flat class loading

jboss.xml reference

JBoss xml reference   JBoss AS uses a set of custom xml de