-
1. Re: Jboss AS 7.1 application startup/stop service
sfcoy Feb 21, 2012 7:55 AM (in response to sony2006)1 of 1 people found this helpfulHow about the EJB 3.1 way:
{code:java}
@Startup
@Singleton
class MyInitialiser {
@PostConstruct
void initialiseMyApplication() {
...
}
}
{code}
-
2. Re: Jboss AS 7.1 application startup/stop service
ctomc Feb 21, 2012 7:58 AM (in response to sony2006)1 of 1 people found this helpfulHi,
since EE6 you can now have timers and lifecycle events as part of ee spec not something app server specific.
take a look at
@Singleton @Startup
annotations.
for some more ideas: https://blogs.oracle.com/enterprisetechtips/entry/a_sampling_of_ejb_3
--
tomaz
Stephen beat me to it :-)
-
3. Re: Jboss AS 7.1 application startup/stop service
sony2006 Feb 21, 2012 8:55 AM (in response to ctomc)I am using EJB 2.1. Any other ideas.
Thanks a lot!!!
-
4. Re: Jboss AS 7.1 application startup/stop service
sfcoy Feb 21, 2012 9:10 AM (in response to sony2006)Yep.
Change the opening xml in your ejb-jar.xml file to:
{code:xml}
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
...
</ejb-jar>
{code}
and do as we suggested above.
You should not need to change anything else...
-
5. Re: Jboss AS 7.1 application startup/stop service
sony2006 Feb 22, 2012 4:49 AM (in response to sfcoy)Thanks a lot Stephen. It worked
In the ejb-jar.xml
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
<enterprise-beans>
<session >
<display-name>ApplicationStarupService</display-name>
<ejb-name>ApplicationStarupServiceEJB</ejb-name>
<ejb-class>example.startup.ejb.ApplicationStarupServiceEJB</ejb-class>
<session-type>Singleton</session-type>
<init-on-startup>true</init-on-startup>
</session>
</enterprise-beans>
</ejb-jar>
And the EJB class
---------------------------
public class ApplicationStarupServiceEJB
{
@PostConstruct
protected void initialize()
{
}
}