01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: RifeAgent.java 3811 2007-06-25 15:06:16Z gbevin $
07: */
08: package com.uwyn.rife.instrument;
09:
10: import java.lang.instrument.Instrumentation;
11:
12: /**
13: * The RIFE instrumentation agent will modify the bytecode of the classes
14: * that are loaded to provide new capabilities that are otherwise provided by
15: * the class-loader.
16: * <p>To activate the agent you need to execute the Java application with the
17: * proper argument, for example:
18: * <pre>java -javaagent:/path/to/rife-agent-1.6-jdk15.jar com.your.mainClass</pre>
19: * <p>When the agent is active the class-loader will automatically be disabled
20: * to ensure that they are not conflicting with each other. The agent is
21: * packaged in its own jar file which should correspond to the RIFE version
22: * that you are using in your application.
23: * <p>Note that this agent doesn't entirely replace the functionality of the
24: * class-loader, during development mode you might want to make use of the
25: * automatic re-compilation of classes that is only provided by the
26: * class-loader. However, during production the agent is the recommended
27: * choice.
28: *
29: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
30: * @version $Revision: 3811 $
31: * @since 1.6
32: */
33: public class RifeAgent {
34: public final static String AGENT_ACTIVE_PROPERTY = "rife.agent.active";
35:
36: public static void premain(String agentArguments,
37: Instrumentation instrumentation) {
38: System.getProperties().setProperty(AGENT_ACTIVE_PROPERTY,
39: String.valueOf(true));
40:
41: instrumentation.addTransformer(new InitialTransformer());
42: instrumentation
43: .addTransformer(new EngineContinuationsTransformer());
44: instrumentation.addTransformer(new MetaDataTransformer());
45: instrumentation.addTransformer(new LazyLoadTransformer());
46: instrumentation.addTransformer(new FinalTransformer());
47: }
48: }
|