KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > portable > HandleImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.ejb.portable;
25
26 import java.io.*;
27 import java.rmi.RemoteException JavaDoc;
28
29 import javax.ejb.*;
30 import javax.ejb.spi.HandleDelegate JavaDoc;
31 import javax.naming.NamingException JavaDoc;
32
33
34 /**
35  * A portable implementation of Handle using the
36  * HandleDelegate SPI.
37  * This class can potentially be instantiated in another vendor's container
38  * so it must not refer to any non-portable RI-specific classes.
39  *
40  * @author Kenneth Saks
41  */

42
43 public final class HandleImpl implements Handle, Serializable
44 {
45     private EJBObject ejbObject;
46
47     // This constructor will only be used by the EJB container in the RI.
48
public HandleImpl(EJBObject ejbObject)
49     {
50     this.ejbObject = ejbObject;
51     }
52
53     // This is the public API from javax.ejb.Handle
54
public EJBObject getEJBObject() throws RemoteException JavaDoc
55     {
56     return ejbObject;
57     }
58
59     private void writeObject(ObjectOutputStream ostream)
60     throws IOException
61     {
62     HandleDelegate JavaDoc handleDelegate;
63     try {
64         handleDelegate = HandleDelegateUtil.getHandleDelegate();
65         } catch ( NamingException JavaDoc ne ) {
66             throw new EJBException("Unable to lookup HandleDelegate", ne);
67         }
68         handleDelegate.writeEJBObject(ejbObject, ostream);
69     }
70
71     private void readObject(ObjectInputStream istream)
72     throws IOException, ClassNotFoundException JavaDoc
73     {
74     HandleDelegate JavaDoc handleDelegate;
75     try {
76         handleDelegate = HandleDelegateUtil.getHandleDelegate();
77     } catch ( NamingException JavaDoc ne ) {
78             throw new EJBException("Unable to lookup HandleDelegate", ne);
79         }
80         ejbObject = handleDelegate.readEJBObject(istream);
81     }
82 }
83
Popular Tags