KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > sequence > WoEC2


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: WoEC2.java,v 1.2 2005/04/22 07:43:55 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.beans.sequence;
27
28 import java.rmi.RemoteException JavaDoc;
29
30 import javax.ejb.CreateException JavaDoc;
31 import javax.ejb.EJBException JavaDoc;
32 import javax.ejb.EntityBean JavaDoc;
33 import javax.ejb.EntityContext JavaDoc;
34 import javax.ejb.FinderException JavaDoc;
35 import javax.ejb.RemoveException JavaDoc;
36 import javax.naming.Context JavaDoc;
37 import javax.naming.InitialContext JavaDoc;
38 import javax.naming.NamingException JavaDoc;
39 import javax.rmi.PortableRemoteObject JavaDoc;
40
41
42 public abstract class WoEC2 implements EntityBean JavaDoc {
43
44     protected EntityContext JavaDoc entityContext;
45     private SequenceSesHome sequenceHome;
46
47     /**
48      * Constructs the WorkOrder object
49      * @param assId
50      * @param qty Original qty
51      */

52     public Integer JavaDoc ejbCreate(String JavaDoc assId, int qty) throws CreateException JavaDoc {
53         setQty(qty);
54         setAssId(assId);
55         try {
56             SequenceSes sequence = sequenceHome.create();
57             setId(new Integer JavaDoc(sequence.nextKey("workorder")));
58         } catch (RemoteException JavaDoc e) {
59             throw new CreateException JavaDoc("Error on sequence:" + e);
60         } catch (FinderException JavaDoc e) {
61             throw new CreateException JavaDoc("Error on sequence:" + e);
62         }
63         return null;
64     }
65
66     public void ejbPostCreate(String JavaDoc assemblyId, int origQty) throws CreateException JavaDoc {
67     }
68
69     public void ejbRemove() throws RemoveException JavaDoc {}
70
71     public void ejbActivate() {
72     }
73
74     public void ejbPassivate() {
75     }
76
77     public void ejbLoad() {
78     }
79
80     public void ejbStore() {
81     }
82
83     public void unsetEntityContext() {
84         entityContext = null;
85     }
86
87     public void setEntityContext(EntityContext JavaDoc entityContext) {
88
89         Context JavaDoc context = null;
90
91         try {
92             context = new InitialContext JavaDoc();
93         } catch( Exception JavaDoc e ) {
94             e.printStackTrace(System.err);
95
96             throw new EJBException JavaDoc(e);
97         }
98         this.entityContext = entityContext;
99
100         try {
101             sequenceHome =
102             (SequenceSesHome) PortableRemoteObject.narrow( context.lookup("java:comp/env/ejb/SequenceSes"),
103                SequenceSesHome.class);
104         } catch( NamingException JavaDoc e ) {
105             e.printStackTrace();
106             throw new EJBException JavaDoc("Failure looking up home " + e);
107         }
108     }
109
110     public abstract Integer JavaDoc getId() ;
111
112     public abstract void setId(Integer JavaDoc id) ;
113
114     public abstract int getQty() ;
115
116     public abstract void setQty(int qty) ;
117
118     public abstract String JavaDoc getAssId() ;
119
120     public abstract void setAssId(String JavaDoc assId) ;
121
122 }
123
124
125
126
Popular Tags