1 5 package ve.luz.ica.jackass.instantiator; 6 7 import org.apache.commons.logging.Log; 8 import org.apache.commons.logging.LogFactory; 9 import org.apache.commons.pool.BasePoolableObjectFactory; 10 import org.omg.CORBA.CompletionStatus ; 11 import org.omg.CORBA.INTERNAL ; 12 13 import ve.luz.ica.jackass.component.ApplicationContext; 14 import ve.luz.ica.jackass.component.StatelessContext; 15 import ve.luz.ica.jackass.component.StatelessHook; 16 17 21 public class StatelessServantFactory extends BasePoolableObjectFactory 22 { 23 private static final Log LOG = LogFactory.getLog(StatelessServantFactory.class); 24 25 private static final int ERR_MINOR_CODE = 0; 26 27 private ApplicationContext appContext; 28 private StatelessContext compContext; 29 private Class servantClass; 30 31 37 public StatelessServantFactory(ApplicationContext appContext, StatelessContext compContext, Class servantClass) 38 { 39 this.appContext = appContext; 40 this.compContext = compContext; 41 this.servantClass = servantClass; 42 } 43 44 45 51 public Object makeObject() throws Exception 52 { 53 try 54 { 55 if (LOG.isDebugEnabled()) LOG.debug("Creating object for class " + servantClass); 56 StatelessHook hook = (StatelessHook) servantClass.newInstance(); 57 hook.jackassSetContexts(appContext, compContext); 58 hook.jackassCreate(); 59 60 if (LOG.isDebugEnabled()) LOG.debug("Object created "); 61 62 return hook; 63 } 64 catch (Exception e) 65 { 66 String errorMsg = "Error while creating proxy servant"; 67 68 if (LOG.isErrorEnabled()) 69 { 70 errorMsg += " for class " + servantClass; 71 LOG.error(errorMsg, e); 72 } 73 74 throw new INTERNAL (errorMsg, ERR_MINOR_CODE, CompletionStatus.COMPLETED_NO); 75 } 76 } 77 } 78 | Popular Tags |