KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > container > jorm > JEntityContext


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  * Initial developer(s): Sebastien Chassande
22  * Contributor(s):
23  *
24  * --------------------------------------------------------------------------
25  * $Id: JEntityContext.java,v 1.4 2004/03/19 14:31:52 sauthieg Exp $
26  * --------------------------------------------------------------------------
27  */

28
29
30 package org.objectweb.jonas_ejb.container.jorm;
31
32 import javax.ejb.EntityBean JavaDoc;
33
34 import org.objectweb.jonas_ejb.container.JEntityFactory;
35 import org.objectweb.jorm.naming.api.PName;
36
37 /**
38  * This class extends the JEntityContext of the JOnAS container in order to take
39  * in consideration the fact that the container manages PName instances and not
40  * primary keys. This is the reason why the getPrimaryKey method is overriden.
41  *
42  * @author Sebastien Chassande-Barrioz
43  */

44 public class JEntityContext
45     extends org.objectweb.jonas_ejb.container.JEntityContext {
46
47     public JEntityContext(JEntityFactory bf, EntityBean JavaDoc eb) {
48         super(bf, eb);
49     }
50
51     /**
52      * Obtains the primary key of the EJB object that is currently associated
53      * with this instance.
54      * @return The EJB object currently associated with the instance.
55      * @exception IllegalStateException Thrown if the instance invokes this
56      * method while the instance is in a state that does not allow
57      * the instance to invoke this method.
58      */

59     public Object JavaDoc getPrimaryKey() throws IllegalStateException JavaDoc {
60         PName pn = (PName) super.getPrimaryKey();
61         Coder c = (Coder) bf.getLocalHome();
62         if (c==null) {
63             c = (Coder) bf.getHome();
64         }
65         try {
66             return c.encode(pn);
67         }
68         catch (Exception JavaDoc e) {
69             throw new IllegalStateException JavaDoc("Inner: Encoding error:"
70                                             + e.getMessage());
71         }
72     }
73 }
74
Popular Tags