KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 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: JHandleDelegate.java,v 1.4 2005/04/28 16:52:59 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_ejb.container;
27
28 import java.io.IOException JavaDoc;
29 import java.io.ObjectInputStream JavaDoc;
30 import java.io.ObjectOutputStream JavaDoc;
31
32 import javax.ejb.EJBHome JavaDoc;
33 import javax.ejb.EJBObject JavaDoc;
34 import javax.ejb.spi.HandleDelegate JavaDoc;
35 import javax.rmi.PortableRemoteObject JavaDoc;
36
37 import org.objectweb.carol.rmi.util.RmiMultiUtility;
38 import org.objectweb.util.monolog.api.BasicLevel;
39
40 /**
41  * Implementation for HandleDelegate SPI.
42  * @author durieuxp
43  */

44 public class JHandleDelegate implements HandleDelegate JavaDoc {
45
46     // -----------------------------------------------------------------------
47
// HandleDelegate implementation
48
// ------------------------------------------------------------------------
49

50     /**
51      * Serialize the EJBObject reference corresponding to a Handle. This method
52      * is called from the writeObject method of portable Handle implementation
53      * classes. The ostream object is the same object that was passed in to the
54      * Handle class's writeObject.
55      * @param ejb The EJBObject reference to be serialized.
56      * @param out The output stream.
57      * @throws IOException The EJBObject could not be serialized because of a
58      * system-level failure.
59      */

60     public void writeEJBObject(EJBObject JavaDoc ejb, ObjectOutputStream JavaDoc out) throws IOException JavaDoc {
61         if (TraceEjb.isDebugIc()) {
62             TraceEjb.interp.log(BasicLevel.DEBUG, "");
63         }
64         out.writeObject(ejb);
65     }
66
67     /**
68      * Deserialize the EJBObject reference corresponding to a Handle.
69      * readEJBObject is called from the readObject method of portable Handle
70      * implementation classes. The istream object is the same object that was
71      * passed in to the Handle class's readObject. When readEJBObject is called,
72      * istream must point to the location in the stream at which the EJBObject
73      * reference can be read. The container must ensure that the EJBObject
74      * reference is capable of performing invocations immediately after
75      * deserialization.
76      * @param in The input stream.
77      * @return The deserialized EJBObject reference.
78      * @throws IOException The EJBObject could not be deserialized because of a
79      * system-level failure.
80      * @throws ClassNotFoundException The EJBObject could not be deserialized
81      * because some class could not be found.
82      */

83     public EJBObject JavaDoc readEJBObject(ObjectInputStream JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
84         if (TraceEjb.isDebugIc()) {
85             TraceEjb.interp.log(BasicLevel.DEBUG, "");
86         }
87         Object JavaDoc ejb = in.readObject();
88         RmiMultiUtility.reconnectStub2Orb(ejb);
89         return (EJBObject JavaDoc) PortableRemoteObject.narrow(ejb, EJBObject JavaDoc.class);
90     }
91
92     /**
93      * Serialize the EJBHome reference corresponding to a HomeHandle. This
94      * method is called from the writeObject method of portable HomeHandle
95      * implementation classes. The ostream object is the same object that was
96      * passed in to the Handle class's writeObject.
97      * @param home The EJBHome reference to be serialized.
98      * @param out The output stream.
99      * @throws IOException The EJBObject could not be deserialized because of a
100      * system-level failure.
101      */

102     public void writeEJBHome(EJBHome JavaDoc home, ObjectOutputStream JavaDoc out) throws IOException JavaDoc {
103         if (TraceEjb.isDebugIc()) {
104             TraceEjb.interp.log(BasicLevel.DEBUG, "");
105         }
106         out.writeObject(home);
107     }
108
109     /**
110      * Deserialize the EJBHome reference corresponding to a HomeHandle.
111      * readEJBHome is called from the readObject method of portable HomeHandle
112      * implementation classes. The istream object is the same object that was
113      * passed in to the HomeHandle class's readObject. When readEJBHome is
114      * called, istream must point to the location in the stream at which the
115      * EJBHome reference can be read. The container must ensure that the EJBHome
116      * reference is capable of performing invocations immediately after
117      * deserialization.
118      * @param in The input stream.
119      * @return The deserialized EJBHome reference.
120      * @throws IOException The EJBHome could not be deserialized because of a
121      * system-level failure.
122      * @throws ClassNotFoundException The EJBHome could not be deserialized
123      * because some class could not be found.
124      */

125     public EJBHome JavaDoc readEJBHome(ObjectInputStream JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
126         if (TraceEjb.isDebugIc()) {
127             TraceEjb.interp.log(BasicLevel.DEBUG, "");
128         }
129         Object JavaDoc home = in.readObject();
130         RmiMultiUtility.reconnectStub2Orb(home);
131         return (EJBHome JavaDoc) PortableRemoteObject.narrow(home, EJBHome JavaDoc.class);
132     }
133 }
Popular Tags