Enterprise java bean help
-
I need to know if there is anyone that can help with this ejb's. I'm just trying to set up a simple timer. I want to set it up in intervals plus I need to know what all does the ejb needs. And its ejb3.0 and ejb is Enterprise Java Beans. The code is below: Client: -> did have something but wasn't working correctly. <pre>package ejb30.STClient; import ejb30.STBean.*; import javax.ejb.EJB; import javax.ejb.TimerService; import javax.naming.*; public class Client { }</pre> Remote: <pre>package ejb30.STBean; import javax.ejb.Remote; import javax.naming.NamingException; @Remote public interface STBeanRemote { public void Timer(); } </pre> Bean: <pre>package ejb30.STBean; import javax.annotation.Resource; import javax.ejb.Stateless; import javax.ejb.TimedObject; import javax.ejb.TimerService; import sun.misc.Timer; /** * Session Bean implementation class STBean */ @Stateless public class STBean implements STBeanRemote, TimedObject { @Resource private TimerService gog; /** * Default constructor. */ public void setSessionContext() { } public void Timer() { Timer ts = (Timer) gog.createTimer(0, 15000, null); } @Override public void ejbTimeout(javax.ejb.Timer timer) { // TODO Auto-generated method stub System.out.println("I'm working"); } } </pre> XML: <pre><?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar\_3\_0-0.dtd"> <ejb-jar xmlns ="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://ww.w3.org/2001/XMLSchema-instance" metadata-complete="true" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/nx/javaee/ejb-jar\_3\_0.xsd"> <enterprise-beans> <session> <display-name>STBean</display-name> <ejb-name>STBean</ejb-name> <business-remote>ejb30.STBean.STBeanRemote</business-remote> <ejb-class>ejb30.STBean.STBean</ejb-class> <session-type>Stateless</session-type> <transaction>Container</transaction> <security-identity> <use-caller-identity /> <
-
I need to know if there is anyone that can help with this ejb's. I'm just trying to set up a simple timer. I want to set it up in intervals plus I need to know what all does the ejb needs. And its ejb3.0 and ejb is Enterprise Java Beans. The code is below: Client: -> did have something but wasn't working correctly. <pre>package ejb30.STClient; import ejb30.STBean.*; import javax.ejb.EJB; import javax.ejb.TimerService; import javax.naming.*; public class Client { }</pre> Remote: <pre>package ejb30.STBean; import javax.ejb.Remote; import javax.naming.NamingException; @Remote public interface STBeanRemote { public void Timer(); } </pre> Bean: <pre>package ejb30.STBean; import javax.annotation.Resource; import javax.ejb.Stateless; import javax.ejb.TimedObject; import javax.ejb.TimerService; import sun.misc.Timer; /** * Session Bean implementation class STBean */ @Stateless public class STBean implements STBeanRemote, TimedObject { @Resource private TimerService gog; /** * Default constructor. */ public void setSessionContext() { } public void Timer() { Timer ts = (Timer) gog.createTimer(0, 15000, null); } @Override public void ejbTimeout(javax.ejb.Timer timer) { // TODO Auto-generated method stub System.out.println("I'm working"); } } </pre> XML: <pre><?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar\_3\_0-0.dtd"> <ejb-jar xmlns ="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://ww.w3.org/2001/XMLSchema-instance" metadata-complete="true" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/nx/javaee/ejb-jar\_3\_0.xsd"> <enterprise-beans> <session> <display-name>STBean</display-name> <ejb-name>STBean</ejb-name> <business-remote>ejb30.STBean.STBeanRemote</business-remote> <ejb-class>ejb30.STBean.STBean</ejb-class> <session-type>Stateless</session-type> <transaction>Container</transaction> <security-identity> <use-caller-identity /> <
You should fine all the info in the Java EE Tutorial in the "Using the Timer Service" section. http://java.sun.com/javaee/5/docs/tutorial/doc/bnboy.html[^]