KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
32
33
34 /**
35  * A portable implementation of HomeHandle 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  */

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