1 23 24 package com.sun.appserv.ejb; 25 26 import java.rmi.RemoteException ; 27 import javax.naming.Context ; 28 import javax.naming.InitialContext ; 29 import javax.rmi.PortableRemoteObject ; 30 31 import com.sun.ejb.containers.ReadOnlyEJBLocalHome; 32 import com.sun.ejb.containers.ReadOnlyEJBHome; 33 34 import com.sun.ejb.containers.ReadOnlyBeanNotifierImpl; 35 36 import java.util.logging.*; 37 import com.sun.logging.*; 38 39 45 public class ReadOnlyBeanHelper { 46 47 protected static Logger _logger; 48 49 static { 50 _logger=LogDomains.getLogger(LogDomains.EJB_LOGGER); 51 } 52 53 public static ReadOnlyBeanNotifier getReadOnlyBeanNotifier(String ejbName) { 54 try { 55 Context ctx = new InitialContext (); 56 Object obj = ctx.lookup(ejbName); 57 ReadOnlyEJBHome home = (ReadOnlyEJBHome) 58 PortableRemoteObject.narrow(obj, ReadOnlyEJBHome.class); 59 return new ReadOnlyBeanNotifierImpl(home); 60 } catch (Exception ex) { 61 if(_logger.isLoggable(Level.SEVERE)) { 62 _logger.log(Level.SEVERE, "ejb.remote_exception", ex); 63 } 64 } 65 return null; 66 } 67 68 public static ReadOnlyBeanLocalNotifier getReadOnlyBeanLocalNotifier( 69 String ejbName) 70 { 71 try { 72 Context ctx = new InitialContext (); 73 ReadOnlyEJBLocalHome home = 74 (ReadOnlyEJBLocalHome) ctx.lookup(ejbName); 75 return home.getReadOnlyBeanLocalNotifier(); 76 } catch (Exception ex) { 77 if(_logger.isLoggable(Level.SEVERE)) { 78 _logger.log(Level.SEVERE, "ejb.remote_exception",ex); 79 } 80 } 81 return null; 82 } 83 84 } 85 86 | Popular Tags |