1 5 package ve.luz.ica.jackass.daemon.proxy; 6 7 import org.apache.commons.logging.Log; 8 import org.apache.commons.logging.LogFactory; 9 import org.apache.commons.pool.ObjectPool; 10 11 import org.omg.CORBA.CompletionStatus ; 12 import org.omg.CORBA.INTERNAL ; 13 import org.omg.PortableServer.ForwardRequest ; 14 import org.omg.PortableServer.POA ; 15 import org.omg.PortableServer.Servant ; 16 import org.omg.PortableServer.ServantLocatorPackage.CookieHolder ; 17 18 import ve.luz.ica.jackass.component.ComponentInfo; 19 import ve.luz.ica.jackass.component.ComponentInfoManager; 20 21 30 public class ProxyServantLocator 31 extends org.omg.CORBA.LocalObject 32 implements org.omg.PortableServer.ServantLocator 33 { 34 private static final int ERR_MINOR_CODE = 0; 35 private static final Log LOG = LogFactory.getLog(ProxyServantLocator.class); 36 37 private ComponentInfoManager manager; 38 39 45 public ProxyServantLocator(ComponentInfoManager manager) throws NullPointerException 46 { 47 if (manager == null) 48 { 49 throw new NullPointerException ("manager == null"); 50 } 51 52 this.manager = manager; 53 } 54 55 62 public Servant preinvoke(byte[] oid, POA adapter, String operation, CookieHolder theCookie) throws ForwardRequest 63 { 64 Servant servant; 65 try 66 { 67 ComponentInfo info = manager.getComponentInfo(oid); 68 ObjectPool servantPool = info.getProxyServantPool(); 69 servant = (Servant ) servantPool.borrowObject(); 70 } 71 catch (Exception e) 72 { 73 if (LOG.isErrorEnabled()) 74 { 75 LOG.error(e.getMessage(), e); 76 } 77 78 throw new INTERNAL (e.getMessage(), ERR_MINOR_CODE, CompletionStatus.COMPLETED_NO); 79 } 80 return servant; 81 } 82 83 89 public void postinvoke(byte[] oid, POA adapter, String operation, Object theCookie, Servant theServant) 90 { 91 try 92 { 93 ComponentInfo info = manager.getComponentInfo(oid); 94 ObjectPool servantPool = info.getProxyServantPool(); 95 servantPool.returnObject(theServant); 96 } 97 catch (Exception e) 98 { 99 if (LOG.isErrorEnabled()) 100 { 101 LOG.error(e.getMessage(), e); 102 } 103 104 throw new INTERNAL (e.getMessage(), ERR_MINOR_CODE, CompletionStatus.COMPLETED_MAYBE); 105 } 106 } 107 } 108 | Popular Tags |