1 19 package org.apache.cayenne.instrument; 20 21 import java.lang.instrument.Instrumentation ; 22 23 29 public class InstrumentUtil { 30 31 35 public static final String INSTRUMENTATION_FACTORY_PROPERTY = "org.apache.cayenne.instrument.factory"; 36 37 41 public static Instrumentation getInstrumentation() { 42 43 InstrumentationFactory factory; 44 45 String factoryName = System.getProperty(INSTRUMENTATION_FACTORY_PROPERTY); 46 if (factoryName != null) { 47 try { 48 factory = (InstrumentationFactory) Class.forName( 49 factoryName, 50 true, 51 Thread.currentThread().getContextClassLoader()).newInstance(); 52 } 53 catch (Throwable th) { 54 throw new IllegalStateException ("Invalid instrumentation factory: " 55 + factoryName, th); 56 } 57 } 58 else { 59 factory = new CayenneInstrumentationFactory(); 60 } 61 62 return factory.getInstrumentation(); 63 } 64 } 65 | Popular Tags |