You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2006/10/10 16:01:18 UTC
svn commit: r454745 -
/incubator/cayenne/main/trunk/core/cayenne-jpa-agent/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java
Author: aadamchik
Date: Tue Oct 10 07:01:17 2006
New Revision: 454745
URL: http://svn.apache.org/viewvc?view=rev&rev=454745
Log:
CAY-684 - removing JPA-specific properties from CayenneAgent
Modified:
incubator/cayenne/main/trunk/core/cayenne-jpa-agent/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java
Modified: incubator/cayenne/main/trunk/core/cayenne-jpa-agent/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa-agent/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java?view=diff&rev=454745&r1=454744&r2=454745
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa-agent/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa-agent/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java Tue Oct 10 07:01:17 2006
@@ -22,63 +22,25 @@
import java.lang.instrument.Instrumentation;
/**
- * An instrumentation agent that configures a
- * {@link org.apache.cayenne.jpa.spi.JpaUnitFactory} that will load JPA class
- * enhancers in the main Instrumentation instance.
+ * An agent that provides access to {@link Instrumentation} instance
* <p>
- * To enable CayenneAgent (and hence class enhancers in the Java SE
- * environment), start the JVM with the "-javaagent:" option. E.g.:
+ * To enable CayenneAgent (and hence class enhancers in the Java SE environment), start
+ * the JVM with the "-javaagent:" option. E.g.:
*
- * <pre>
- * java -javaagent:/path/to/cayenne-jpa-agent-xxxx.jar org.example.Main
- * </pre>
+ * <pre>java -javaagent:/path/to/cayenne-agent-xxxx.jar org.example.Main</pre>
*
* @author Andrus Adamchik
*/
public class CayenneAgent {
- // do not use the actual Java class to prevent dependencies from loading too
- // early..;
- // using a unit test to ensure that the factory name is valid.
- static final String FACTORY_CLASS = "org.apache.cayenne.jpa.instrument.InstrumentingUnitFactory";
+ static Instrumentation instrumentation;
- // duplicating JpaPersistenceProvider property constant to avoid premature
- // loading of
- // JPA classes.
- static final String UNIT_FACTORY_PROPERTY = "org.apache.cayenne.jpa.jpaUnitFactory";
-
- static Instrumentation instrumentation;
-
- public static void premain(String agentArgs, Instrumentation instrumentation) {
- System.out.println("*** CayenneAgent starting...");
- CayenneAgent.instrumentation = instrumentation;
-
- // TODO: andrus, 5/1/2006 - add explicit debugging option to the agent
-
- // This can be used to debug enhancer:
- // instrumentation.addTransformer(new ClassFileTransformer() {
- //
- // public byte[] transform(
- // ClassLoader loader,
- // String className,
- // Class<?> classBeingRedefined,
- // ProtectionDomain protectionDomain,
- // byte[] classfileBuffer) throws IllegalClassFormatException {
- //
- // if (className.indexOf("jpa") > 0) {
- // System.out.println("*** className..."
- // + className
- // + ", loader: "
- // + loader);
- // }
- // return null;
- // }
- // });
-
- System.setProperty(UNIT_FACTORY_PROPERTY, FACTORY_CLASS);
- }
-
- public static Instrumentation getInstrumentation() {
- return instrumentation;
- }
+ public static void premain(String agentArgs, Instrumentation instrumentation) {
+ System.out.println("*** CayenneAgent starting...");
+ CayenneAgent.instrumentation = instrumentation;
+ }
+
+ public static Instrumentation getInstrumentation() {
+ return instrumentation;
+ }
}