001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.timer.ejb;
023:
024: import javax.ejb.SessionBean;
025: import javax.ejb.SessionContext;
026: import javax.ejb.TimedObject;
027: import javax.ejb.Timer;
028:
029: import org.apache.log4j.Logger;
030:
031: /**
032: * Stateful Session Bean Timer Test
033: * @author Thomas Diesler
034: * @author Scott.Stark@jboss.org
035: * @version $Revision: 57211 $
036: * @ejb:bean name="test/timer/TimerSFSB" display-name="Timer in Stateful Session
037: * Bean" type="Stateful" transaction-type="Container" view-type="remote"
038: * jndi-name="ejb/test/timer/TimerSFSB"
039: * @ejb:transaction type="Required"
040: */
041: public class TimerSFSBean implements SessionBean, TimedObject {
042: // -------------------------------------------------------------------------
043: // Static
044: // -------------------------------------------------------------------------
045: private static Logger log = Logger.getLogger(TimerSFSBean.class);
046:
047: // -------------------------------------------------------------------------
048: // Members
049: // -------------------------------------------------------------------------
050:
051: private SessionContext mContext;
052:
053: // -------------------------------------------------------------------------
054: // Methods
055: // -------------------------------------------------------------------------
056:
057: /**
058: * @ejb:interface-method view-type="both"
059: */
060: public void checkTimerService() {
061: log
062: .info("TimerSFSBean.checkTimerService(), try to get a Timer Service from the Session Context");
063: mContext.getTimerService();
064: }
065:
066: /**
067: * Create the Session Bean
068: * @ejb:create-method view-type="both"
069: */
070: public void ejbCreate() {
071: log.info("TimerSFSBean.ejbCreate()");
072: }
073:
074: public void ejbTimeout(Timer pTimer) {
075: log.info("ejbTimeout(), timer: " + pTimer);
076: }
077:
078: /**
079: * Describes the instance and its content for debugging purpose
080: * @return Debugging information about the instance and its content
081: */
082: public String toString() {
083: return "TimerSFSBean [ " + " ]";
084: }
085:
086: // -------------------------------------------------------------------------
087: // Framework Callbacks
088: // -------------------------------------------------------------------------
089:
090: public void setSessionContext(SessionContext aContext) {
091: mContext = aContext;
092: }
093:
094: public void ejbActivate() {
095: }
096:
097: public void ejbPassivate() {
098: }
099:
100: public void ejbRemove() {
101: }
102: }
|