1 5 package ve.luz.ica.jackass.daemon.proxy; 6 7 import java.lang.reflect.Constructor ; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 import org.apache.commons.pool.BasePoolableObjectFactory; 12 13 import org.omg.CORBA.CompletionStatus ; 14 import org.omg.CORBA.INTERNAL ; 15 import org.omg.CORBA.Object ; 16 import org.omg.PortableServer.Servant ; 17 18 23 public class ProxyServantFactory extends BasePoolableObjectFactory 24 { 25 private static final Log LOG = LogFactory.getLog(ProxyServantFactory.class); 26 27 private org.omg.CORBA.Object objectRef; 28 private Class proxyClass; 29 30 35 public ProxyServantFactory(Object objectRef, Class proxyClass) 36 { 37 this.objectRef = objectRef; 38 this.proxyClass = proxyClass; 39 } 40 41 46 public java.lang.Object makeObject() throws Exception 47 { 48 try 50 { 51 Class [] params = {org.omg.CORBA.Object .class}; 52 if (LOG.isDebugEnabled()) 53 { 54 LOG.debug("proxyClass " + proxyClass.getName()); 55 } 56 Constructor constructor = proxyClass.getDeclaredConstructor(params); 57 Servant servant = (Servant ) constructor.newInstance(new Object [] {objectRef}); 58 return servant; 59 } 60 catch (Exception e) 61 { 62 String errorMsg = "Error while creating proxy servant "; 63 64 if (LOG.isErrorEnabled()) 65 { 66 errorMsg += " for class " + proxyClass; 67 68 LOG.error(errorMsg, e); 69 } 70 71 throw new INTERNAL (errorMsg, 0, CompletionStatus.COMPLETED_NO); 72 } 73 } 74 } | Popular Tags |