001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: WoSesSL.java 6612 2005-04-22 07:43:55Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.beans.sequence;
027:
028: import java.rmi.RemoteException;
029:
030: import javax.ejb.CreateException;
031: import javax.ejb.EJBException;
032: import javax.ejb.SessionBean;
033: import javax.ejb.SessionContext;
034: import javax.naming.InitialContext;
035: import javax.naming.NamingException;
036:
037: /**
038: * This class is WoSesSL seesion bean.
039: *
040: * This bean is stateless.
041: *
042: */
043: public class WoSesSL implements SessionBean {
044:
045: private String className = "WoSesSL";
046: private WoHomeLocal woHome;
047: private SequenceSesHome sequenceSesHome;
048:
049: /**
050: * Method ejbCreate
051: *
052: *
053: * @throws CreateException
054: *
055: */
056: public void ejbCreate() throws CreateException {
057: }
058:
059: /**
060: * Method schedule
061: * @param assId
062: * @param qty
063: * @return Woid
064: * @exception EJBException if there is a system failure
065: */
066: public Integer schedule(String assId, int qty) {
067:
068: WoLocal wo;
069: Integer woId = null;
070:
071: try {
072: wo = woHome.create(assId, qty);
073: woId = wo.getId();
074:
075: } catch (CreateException e) {
076: throw new EJBException("Unable to create " + e);
077: } catch (EJBException e) {
078: e.printStackTrace();
079: throw new EJBException(e);
080: }
081: return woId;
082: }
083:
084: /**
085: * Constructor WoSesSL
086: *
087: *
088: */
089: public WoSesSL() {
090: }
091:
092: /**
093: * Method ejbRemove
094: *
095: *
096: */
097: public void ejbRemove() {
098: }
099:
100: /**
101: * Method ejbActivate
102: *
103: *
104: */
105: public void ejbActivate() {
106: }
107:
108: /**
109: * Method ejbPassivate
110: *
111: *
112: */
113: public void ejbPassivate() {
114: }
115:
116: /**
117: * Method setSessionContext
118: *
119: *
120: * @param sc
121: *
122: */
123: public void setSessionContext(SessionContext sc) {
124:
125: InitialContext initCtx;
126:
127: try {
128: initCtx = new InitialContext();
129: woHome = (WoHomeLocal) initCtx
130: .lookup("java:comp/env/ejb/WoLocalHome");
131: sequenceSesHome = (SequenceSesHome) javax.rmi.PortableRemoteObject
132: .narrow(initCtx.lookup("SequencesHome"),
133: SequenceSesHome.class);
134: } catch (NamingException e) {
135: e.printStackTrace();
136:
137: throw new EJBException(e);
138: }
139:
140: }
141: }
|