KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > containers > ReadOnlyBeanHelper


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.containers;
25
26 import java.rmi.RemoteException JavaDoc;
27 import javax.naming.Context JavaDoc;
28 import javax.naming.InitialContext JavaDoc;
29 import javax.rmi.PortableRemoteObject JavaDoc;
30
31 import com.sun.ejb.containers.ReadOnlyEJBLocalHome;
32 import com.sun.ejb.containers.ReadOnlyEJBHome;
33
34 import java.util.logging.*;
35 import com.sun.logging.*;
36
37 import javax.ejb.EJBHome JavaDoc;
38
39 /**
40  * Class that is used to obtain ReadOnlyBeanNotifier
41  * and ReadOnlyBeanLocalNotifier.
42  *
43  * @deprecated New implementations must use com.sun.appserv.ejb.ReadOnlyBeanHelper
44  *
45  * @author Mahesh Kannan
46  */

47 public class ReadOnlyBeanHelper {
48
49     private static Logger _logger;
50     private static final boolean debug = false;
51
52     static {
53         _logger=LogDomains.getLogger(LogDomains.EJB_LOGGER);
54     }
55
56     /**
57      * Get a ReadOnlyBeanNotifier for a bean that can be "lookedup"
58      * using the ejbName
59      * @returns a ReadOnlyBeanNotifier or null if the lookup
60      * resulted in a NameNotFoundException
61      */

62     public static com.sun.ejb.ReadOnlyBeanNotifier
63         getReadOnlyBeanNotifier(String JavaDoc ejbName)
64     {
65         try {
66             Context JavaDoc ctx = new InitialContext JavaDoc();
67             Object JavaDoc obj = ctx.lookup(ejbName);
68             ReadOnlyEJBHome home = (ReadOnlyEJBHome)
69                 PortableRemoteObject.narrow(obj, ReadOnlyEJBHome.class);
70             return new ReadOnlyBeanNotifierImpl(home);
71         } catch (Exception JavaDoc ex) {
72             if(_logger.isLoggable(Level.SEVERE)) {
73                 _logger.log(Level.SEVERE,"ejb.remote_exception", ex);
74             }
75         }
76         return null;
77     }
78
79     /**
80      * Get a ReadOnlyBeanLocalNotifier for a bean that can be "lookedup"
81      * using the ejbName
82      * @returns a ReadOnlyBeanLocalNotifier or null if the lookup
83      * resulted in a NameNotFoundException
84      */

85     public static com.sun.ejb.ReadOnlyBeanLocalNotifier
86         getReadOnlyBeanLocalNotifier(String JavaDoc ejbName)
87     {
88         try {
89             Context JavaDoc ctx = new InitialContext JavaDoc();
90             ReadOnlyEJBLocalHome home =
91                 (ReadOnlyEJBLocalHome) ctx.lookup(ejbName);
92             return (com.sun.ejb.ReadOnlyBeanLocalNotifier)
93                 home.getReadOnlyBeanLocalNotifier();
94         } catch (Exception JavaDoc ex) {
95             if(_logger.isLoggable(Level.SEVERE)) {
96                 _logger.log(Level.SEVERE,"ejb.remote_exception",ex);
97             }
98         }
99         return null;
100     }
101
102 }
103
Popular Tags