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: ContinuationsTransformer.java 3811 2007-06-25 15:06:16Z gbevin $
07: */
08: package com.uwyn.rife.continuations.instrument;
09:
10: import com.uwyn.rife.continuations.ContinuationConfigInstrument;
11: import com.uwyn.rife.continuations.instrument.ContinuationsBytecodeTransformer;
12: import com.uwyn.rife.instrument.RifeTransformer;
13: import java.lang.instrument.IllegalClassFormatException;
14: import java.security.ProtectionDomain;
15:
16: /**
17: * A bytecode transformer that will modify classes so that they
18: * receive the functionalities that are required to support the continuations
19: * functionalities as they are provided by RIFE's web engine.
20: * <p>This transformer is internally used by the {@link ContinuationsAgent}.
21: *
22: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
23: * @version $Revision: 3811 $
24: * @since 1.6
25: */
26: public class ContinuationsTransformer extends RifeTransformer {
27: private ContinuationConfigInstrument mConfigInstrument;
28:
29: /**
30: * Creates a new transformer.
31: *
32: * @param configInstrument the instance of the instrumentation
33: * configuration that will be used for the transformation
34: * @since 1.6
35: */
36: public ContinuationsTransformer(
37: ContinuationConfigInstrument configInstrument) {
38: mConfigInstrument = configInstrument;
39: }
40:
41: protected byte[] transformRife(ClassLoader loader,
42: String className, Class<?> classBeingRedefined,
43: ProtectionDomain protectionDomain, byte[] classfileBuffer)
44: throws IllegalClassFormatException {
45: try {
46: byte[] result = ContinuationsBytecodeTransformer
47: .transformIntoResumableBytes(mConfigInstrument,
48: classfileBuffer, className
49: .replace('/', '.'));
50: if (result != null) {
51: return result;
52: }
53: } catch (ClassNotFoundException e) {
54: return classfileBuffer;
55: }
56:
57: return classfileBuffer;
58: }
59: }
|