1 Reply Latest reply on Jul 26, 2013 9:28 AM by Tomaz Cerar

    Invoking service on startup

    Alexander Hartner Expert

      In JBoss 4/5 our application required some special initialisation which we implemeted via a startup service using jboss-service.xml file:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <server>

        <mbean code="com.abc.jboss.StartupService" name="startup.abc.com:service=Startup">

          <depends>jboss.j2ee:ear=ABCEJB.ear,jar=ABC.jar,name=AdministratorBean,service=EJB3</depends>

        </mbean>

        <mbean code="org.jboss.varia.scheduler.Scheduler" name="scheduler.abc.com:service=Scheduler">

          <depends>jboss.j2ee:ear=ABCEJB.ear,jar=ABC.jar,name=AdministratorBean,service=EJB3</depends>

          <attribute name="StartAtStartup">true</attribute>

          <attribute name="SchedulableClass">com.abc.jboss.ScheduledService</attribute>

          <attribute name="InitialStartDate">NOW</attribute>

          <attribute name="SchedulePeriod">30000</attribute>

          <attribute name="InitialRepetitions">-1</attribute>

        </mbean>

        <mbean code="com.ABC.backend.jmx.NotificationCenter"

                 name="NotificationCenter:name=notificationCenter">

          <depends>jboss.j2ee:ear=ABCEJB.ear,jar=ABC.jar,name=AdministratorBean,service=EJB3</depends>

        </mbean>

      </server>

      However for JBoss 7 I haven't been able to find a similar solution. Any pointers on how best to implement this in JBoss 7.2 ? Note that some services require specific ejbs to be available so it should only start this service once the application is deployed.