Package: InstrumentableClassLoader

InstrumentableClassLoader

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.kernel.osgi.framework;
13:
14: import java.lang.instrument.ClassFileTransformer;
15:
16: /**
17: * Provides an interface onto <code>ClassLoaders</code> that support the use of {@link ClassFileTransformer
18: * ClassFileTransformers} for load-time weaving.<p/>
19: *
20: * <strong>Concurrent Semantics</strong><br />
21: *
22: * Implementations <strong>must</strong> be threadsafe.
23: *
24: */
25: public interface InstrumentableClassLoader {
26:
27: /**
28: * Adds the supplied {@link ClassFileTransformer} to the {@link ClassLoader}. All subsequent class loads will pass
29: * through the newly added <code>ClassFileTransformer</code>.
30: *
31: * @param transformer the <code>ClassFileTransformer</code>.
32: */
33: void addClassFileTransformer(ClassFileTransformer transformer);
34:
35: /**
36: * Creates a throw away {@link ClassLoader} that can be used to explore and introspect on types that will be loaded
37: * by this <code>ClassLoader</code>.
38: *
39: * @return the throw away <code>ClassLoader</code>.
40: */
41: ClassLoader createThrowAway();
42:
43: /**
44: * Queries whether this <code>ClassLoader</code> has been {@link #addClassFileTransformer(ClassFileTransformer)
45: * instrumented}.
46: *
47: * @return <code>true</code> if instrumented, otherwise <code>false</code>.
48: */
49: boolean isInstrumented();
50:
51: /**
52: * Gets the number of {@link ClassFileTransformer ClassFileTransformers} that have been added to this
53: * <code>ClassLoader</code>.
54: *
55: * @return the number of <code>ClassFileTransformers</code>.
56: */
57: int getClassFileTransformerCount();
58: }