1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can obtain
10 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12 * language governing permissions and limitations under the License.
13 *
14 * When distributing the software, include this License Header Notice in each
15 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
16 * Sun designates this particular file as subject to the "Classpath" exception
17 * as provided by Sun in the GPL Version 2 section of the License file that
18 * accompanied this code. If applicable, add the following below the License
19 * Header, with the fields enclosed by brackets [] replaced by your own
20 * identifying information: "Portions Copyrighted [year]
21 * [name of copyright owner]"
22 *
23 * Contributor(s):
24 *
25 * If you wish your version of this file to be governed by only the CDDL or
26 * only the GPL Version 2, indicate your decision by adding "[Contributor]
27 * elects to include this software in this distribution under the [CDDL or GPL
28 * Version 2] license." If you don't indicate a single choice of license, a
29 * recipient has the option to distribute your version of this file under
30 * either the CDDL, the GPL Version 2 or to extend the choice of license to
31 * its licensees as provided above. However, if you add GPL Version 2 code
32 * and therefore, elected the GPL Version 2 license, then the option applies
33 * only if the new code is made subject to such option by the copyright
34 * holder.
35 */
36
37 package javax.ejb.spi;
38
39 import java.io.IOException;
40 import java.io.ObjectOutputStream;
41 import java.io.ObjectInputStream;
42
43 import javax.ejb.EJBObject;
44 import javax.ejb.EJBHome;
45
46
47 /**
48 * The HandleDelegate interface is implemented by the EJB container.
49 * It is used by portable implementations of javax.ejb.Handle and
50 * javax.ejb.HomeHandle.
51 * It is not used by EJB components or by client components.
52 * It provides methods to serialize and deserialize EJBObject and
53 * EJBHome references to streams.
54 *
55 * <p> The HandleDelegate object is obtained by JNDI lookup at the
56 * reserved name "java:comp/HandleDelegate".
57 */
58
59 public interface HandleDelegate {
60 /**
61 * Serialize the EJBObject reference corresponding to a Handle.
62 *
63 * <p> This method is called from the writeObject method of
64 * portable Handle implementation classes. The ostream object is the
65 * same object that was passed in to the Handle class's writeObject.
66 *
67 * @param ejbObject The EJBObject reference to be serialized.
68 *
69 * @param ostream The output stream.
70 *
71 * @exception IOException The EJBObject could not be serialized
72 * because of a system-level failure.
73 */
74 public void writeEJBObject(EJBObject ejbObject, ObjectOutputStream ostream)
75 throws IOException;
76
77
78 /**
79 * Deserialize the EJBObject reference corresponding to a Handle.
80 *
81 * <p> readEJBObject is called from the readObject method of
82 * portable Handle implementation classes. The istream object is the
83 * same object that was passed in to the Handle class's readObject.
84 * When readEJBObject is called, istream must point to the location
85 * in the stream at which the EJBObject reference can be read.
86 * The container must ensure that the EJBObject reference is
87 * capable of performing invocations immediately after deserialization.
88 *
89 * @param istream The input stream.
90 *
91 * @return The deserialized EJBObject reference.
92 *
93 * @exception IOException The EJBObject could not be deserialized
94 * because of a system-level failure.
95 * @exception ClassNotFoundException The EJBObject could not be deserialized
96 * because some class could not be found.
97 */
98 public javax.ejb.EJBObject readEJBObject(ObjectInputStream istream)
99 throws IOException, ClassNotFoundException;
100
101 /**
102 * Serialize the EJBHome reference corresponding to a HomeHandle.
103 *
104 * <p> This method is called from the writeObject method of
105 * portable HomeHandle implementation classes. The ostream object is the
106 * same object that was passed in to the Handle class's writeObject.
107 *
108 * @param ejbHome The EJBHome reference to be serialized.
109 *
110 * @param ostream The output stream.
111 *
112 * @exception IOException The EJBObject could not be serialized
113 * because of a system-level failure.
114 */
115 public void writeEJBHome(EJBHome ejbHome, ObjectOutputStream ostream)
116 throws IOException;
117
118 /**
119 * Deserialize the EJBHome reference corresponding to a HomeHandle.
120 *
121 * <p> readEJBHome is called from the readObject method of
122 * portable HomeHandle implementation classes. The istream object is the
123 * same object that was passed in to the HomeHandle class's readObject.
124 * When readEJBHome is called, istream must point to the location
125 * in the stream at which the EJBHome reference can be read.
126 * The container must ensure that the EJBHome reference is
127 * capable of performing invocations immediately after deserialization.
128 *
129 * @param istream The input stream.
130 *
131 * @return The deserialized EJBHome reference.
132 *
133 * @exception IOException The EJBHome could not be deserialized
134 * because of a system-level failure.
135 * @exception ClassNotFoundException The EJBHome could not be deserialized
136 * because some class could not be found.
137 */
138 public javax.ejb.EJBHome readEJBHome(ObjectInputStream istream)
139 throws IOException, ClassNotFoundException;
140 }