1 23 24 package com.sun.enterprise.iiop; 25 26 import org.omg.CORBA.INITIALIZE ; 27 import org.omg.CORBA.CompletionStatus ; 28 import org.omg.CORBA.TSIdentification; 29 import java.lang.reflect.Method ; 30 import java.lang.reflect.InvocationTargetException ; 31 import java.util.Properties ; 32 import com.sun.corba.ee.impl.logging.POASystemException; 33 import com.sun.corba.ee.impl.txpoa.TSIdentificationImpl; 34 import com.sun.corba.ee.spi.costransactions.TransactionService; 35 import com.sun.corba.ee.spi.orb.ORB ; 36 import com.sun.corba.ee.spi.orb.ORBConfigurator; 37 import com.sun.corba.ee.spi.orb.ParserImplBase; 38 import com.sun.corba.ee.spi.orb.PropertyParser; 39 import com.sun.corba.ee.spi.orb.DataCollector; 40 import com.sun.corba.ee.spi.orb.OperationFactory; 41 import com.sun.corba.ee.spi.copyobject.ObjectCopierFactory ; 42 import com.sun.corba.ee.spi.copyobject.CopierManager; 43 import com.sun.corba.ee.spi.copyobject.CopyobjectDefaults; 44 import com.sun.corba.ee.impl.orbutil.ORBConstants; 45 import com.sun.corba.ee.impl.orbutil.closure.Constant; 46 import com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager; 47 import com.sun.enterprise.util.ORBManager; 48 import com.sun.enterprise.util.S1ASThreadPoolManager; 49 50 import com.sun.enterprise.Switch; 51 import com.sun.enterprise.admin.monitor.callflow.Agent; 52 import com.sun.enterprise.admin.monitor.callflow.ContainerTypeOrApplicationType; 53 import com.sun.corba.ee.spi.presentation.rmi.InvocationInterceptor; 54 import com.sun.corba.ee.impl.oa.poa.BadServerIdHandler ; 55 import com.sun.corba.ee.spi.ior.ObjectKey ; 56 57 import com.sun.jts.pi.InterceptorImpl; 59 60 import java.util.logging.*; 61 import com.sun.logging.*; 62 63 public class PEORBConfigurator implements ORBConfigurator { 64 65 private static final java.util.logging.Logger logger = 66 java.util.logging.Logger.getLogger(LogDomains.CORBA_LOGGER); 67 68 private static final String OPT_COPIER_CLASS = 69 "com.sun.corba.ee.spi.copyobject.OptimizedCopyobjectDefaults"; 70 71 private static com.sun.jts.pi.InterceptorImpl jtsInterceptor; 72 private static TSIdentification tsIdent; 73 private static ORB theORB; 74 private static ThreadPoolManager threadpoolMgr = null; 75 76 static { 77 tsIdent = new TSIdentificationImpl(); 78 } 79 80 public void configure( DataCollector dc, ORB orb ) { 81 orb.setBadServerIdHandler( 85 new BadServerIdHandler() { 86 public void handle( ObjectKey objectkey ) { 87 } 89 } 90 ) ; 91 if (threadpoolMgr != null) { 93 orb.setThreadPoolManager(threadpoolMgr); 97 } 98 99 configureCopiers(orb); 100 configureCallflowInvocationInterceptor(orb); 101 } 102 103 private static void configureCopiers(ORB orb) { 104 ObjectCopierFactory stream; 105 CopierManager cpm = orb.getCopierManager(); 106 107 stream = CopyobjectDefaults.makeORBStreamObjectCopierFactory(orb); 109 cpm.registerObjectCopierFactory(stream, 110 POARemoteReferenceFactory.PASS_BY_VALUE_ID); 111 cpm.setDefaultId(POARemoteReferenceFactory.PASS_BY_VALUE_ID); 112 113 try { 116 Class cls = Class.forName(OPT_COPIER_CLASS); 117 configureOptCopier(orb, cls, stream); 118 } catch (ClassNotFoundException cnfe) { 119 } 122 } 123 124 private static void configureOptCopier(ORB orb, Class cls, 125 ObjectCopierFactory stream) { 126 CopierManager cpm = orb.getCopierManager(); 127 128 ObjectCopierFactory reference = CopyobjectDefaults. 130 getReferenceObjectCopierFactory(); 131 132 try { 133 Method m = cls.getMethod("makeReflectObjectCopierFactory", 134 new Class [] {com.sun.corba.ee.spi.orb.ORB.class}); 135 ObjectCopierFactory reflect = 136 (ObjectCopierFactory)m.invoke(cls, new Object [] {orb}); 137 ObjectCopierFactory fallback = 138 CopyobjectDefaults.makeFallbackObjectCopierFactory(reflect, stream); 139 cpm.registerObjectCopierFactory(fallback, 140 POARemoteReferenceFactory.PASS_BY_VALUE_ID); 141 cpm.registerObjectCopierFactory(reference, 142 POARemoteReferenceFactory.PASS_BY_REFERENCE_ID); 143 cpm.setDefaultId(POARemoteReferenceFactory.PASS_BY_VALUE_ID); 144 } catch (NoSuchMethodException e) { 145 logger.log(Level.FINE,"Caught NoSuchMethodException - " + e.getMessage()); 146 logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier"); 147 } catch (IllegalAccessException e) { 148 logger.log(Level.FINE,"Caught IllegalAccessException - " + e.getMessage()); 149 logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier"); 150 } catch (IllegalArgumentException e) { 151 logger.log(Level.FINE,"Caught IllegalArgumentException - " + e.getMessage()); 152 logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier"); 153 } catch (InvocationTargetException e) { 154 logger.log(Level.FINE,"Caught InvocationTargetException - " + e.getMessage()); 155 logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier"); 156 } catch (NullPointerException e) { 157 logger.log(Level.FINE,"Caught NullPointerException - " + e.getMessage()); 158 logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier"); 159 } catch (ExceptionInInitializerError e) { 160 logger.log(Level.FINE,"Caught ExceptionInInitializerError - " + e.getMessage()); 161 logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier"); 162 } 163 } 164 165 static void setJTSInterceptor(InterceptorImpl intr, ORB orb) 167 { 168 theORB = orb; 169 jtsInterceptor = intr; 170 171 jtsInterceptor.setOrb(theORB); 174 } 175 176 public static void setThreadPoolManager() { 178 threadpoolMgr = S1ASThreadPoolManager.getThreadPoolManager(); 179 } 180 181 public static void initTransactionService(String jtsClassName, Properties 182 jtsProperties ) 183 { 184 String clsName = (jtsClassName == null) ? 185 "com.sun.jts.CosTransactions.DefaultTransactionService" : jtsClassName; 186 try { 187 Class theJTSClass = Class.forName(clsName); 188 189 if (theJTSClass != null) { 190 try { 191 TransactionService jts = (TransactionService)theJTSClass.newInstance(); 192 jts.identify_ORB(theORB, tsIdent, jtsProperties ) ; 193 jtsInterceptor.setTSIdentification(tsIdent); 194 org.omg.CosTransactions.Current transactionCurrent = 197 jts.get_current(); 198 199 theORB.getLocalResolver().register( 200 ORBConstants.TRANSACTION_CURRENT_NAME, 201 new Constant(transactionCurrent)); 202 203 theORB.getLocalResolver().register( 205 "TSIdentification", new Constant(tsIdent)); 206 207 } catch (Exception ex) { 208 throw new org.omg.CORBA.INITIALIZE ( 209 "JTS Exception: "+ex, POASystemException.JTS_INIT_ERROR , 210 CompletionStatus.COMPLETED_MAYBE); 211 } 212 } 213 } catch (ClassNotFoundException cnfe) { 214 logger.log(Level.SEVERE,"iiop.inittransactionservice_exception",cnfe); 215 } 216 217 } 218 219 private static void configureCallflowInvocationInterceptor(ORB orb) { 220 orb.setInvocationInterceptor( 221 new InvocationInterceptor() { 222 public void preInvoke() { 223 Agent agent = Switch.getSwitch().getCallFlowAgent(); 224 if (agent != null) { 225 agent.startTime( 226 ContainerTypeOrApplicationType.ORB_CONTAINER); 227 } 228 } 229 public void postInvoke() { 230 Agent agent = Switch.getSwitch().getCallFlowAgent(); 231 if (agent != null) { 232 agent.endTime(); 233 } 234 } 235 } 236 ); 237 } 238 } 239 | Popular Tags |