KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > container > JRemote


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  * --------------------------------------------------------------------------
23  * $Id: JRemote.java,v 1.11 2005/04/28 16:52:59 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas_ejb.container;
28
29 import java.rmi.NoSuchObjectException JavaDoc;
30 import java.rmi.RemoteException JavaDoc;
31
32 import javax.ejb.EJBObject JavaDoc;
33 import javax.rmi.PortableRemoteObject JavaDoc;
34
35 import org.objectweb.util.monolog.api.BasicLevel;
36
37 /**
38  * This class is the common part of the EJBObject implementation class. Here
39  * goes the code common for Entity beans and Session beans
40  * @author Philippe Durieux
41  */

42 public abstract class JRemote extends PortableRemoteObject JavaDoc implements EJBObject JavaDoc {
43
44     protected JFactory bf;
45
46     /**
47      * constructor
48      * @param bf The Bean Factory
49      */

50     public JRemote(JFactory bf) throws RemoteException JavaDoc {
51         if (TraceEjb.isDebugIc()) {
52             TraceEjb.interp.log(BasicLevel.DEBUG, "");
53         }
54         this.bf = bf;
55     }
56
57     // --------------------------------------------------------------------------
58
// EJBObject implementation
59
// --------------------------------------------------------------------------
60

61     // --------------------------------------------------------------------------
62
// Export / UnExport Object
63
// Due to the fact that this object extends RemoteObject, it is
64
// automatically
65
// exported when built. We just need to unexport it when unused, and to re
66
// export
67
// it if we reuse it again.
68
// --------------------------------------------------------------------------
69

70     /**
71      * Make this object accessible again thru the Orb.
72      * @return True if export is OK.
73      */

74     public boolean exportObject() {
75         if (TraceEjb.isDebugIc()) {
76             TraceEjb.interp.log(BasicLevel.DEBUG, "");
77         }
78         try {
79             exportObject(this);
80         } catch (Exception JavaDoc e) {
81             TraceEjb.logger.log(BasicLevel.ERROR, "cannot export", e);
82             return false;
83         }
84         return true;
85     }
86
87     /**
88      * Make this object unaccessible thru the Orb.
89      */

90     public void unexportObject() throws NoSuchObjectException JavaDoc {
91         if (TraceEjb.isDebugIc()) {
92             TraceEjb.interp.log(BasicLevel.DEBUG, "");
93         }
94         unexportObject(this);
95     }
96
97     /**
98      * @return the bean factory
99      */

100     public JFactory getBf() {
101         return bf;
102     }
103 }
Popular Tags