public class WeavingAdaptor extends java.lang.Object implements IMessageContext
A weaving class loader should create a WeavingAdaptor
before any classes are defined, typically during construction.
The set of aspects passed to the adaptor is fixed for the lifetime of the adaptor although the classpath can be augmented. A
system property can be set to allow verbose weaving messages to be written to the console.
Modifier and Type | Class and Description |
---|---|
protected class |
WeavingAdaptor.WeavingAdaptorMessageHolder
Processes messages arising from weaver operations.
|
protected class |
WeavingAdaptor.WeavingAdaptorMessageWriter |
Modifier and Type | Field and Description |
---|---|
protected java.security.ProtectionDomain |
activeProtectionDomain |
protected BcelWorld |
bcelWorld |
protected WeavedClassCache |
cache |
BcelObjectType |
delegateForCurrentClass |
protected java.util.Map<java.lang.String,IUnwovenClassFile> |
generatedClasses |
protected GeneratedClassHandler |
generatedClassHandler |
static java.lang.String |
SHOW_WEAVE_INFO_PROPERTY |
static java.lang.String |
TRACE_MESSAGES_PROPERTY |
protected boolean |
verbose |
protected BcelWeaver |
weaver |
static java.lang.String |
WEAVING_ADAPTOR_VERBOSE
System property used to turn on verbose weaving messages
|
Modifier | Constructor and Description |
---|---|
protected |
WeavingAdaptor() |
|
WeavingAdaptor(GeneratedClassHandler handler,
java.net.URL[] classURLs,
java.net.URL[] aspectURLs)
Construct a WeavingAdaptor with a reference to a
GeneratedClassHandler , a full search path for resolving classes
and a complete set of aspects. |
|
WeavingAdaptor(WeavingClassLoader loader)
Construct a WeavingAdaptor with a reference to a weaving class loader.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(java.lang.String name,
byte[] bytes) |
void |
addURL(java.net.URL url)
Appends URL to path used by the WeavingAdptor to resolve classes
|
protected void |
createMessageHandler() |
protected boolean |
debug(java.lang.String message) |
protected void |
disable() |
protected void |
dump(java.lang.String name,
byte[] b,
boolean before)
Dump the given bytcode in _dump/...
|
protected void |
enable() |
protected void |
ensureDelegateInitialized(java.lang.String name,
byte[] bytes) |
protected boolean |
error(java.lang.String message) |
protected boolean |
error(java.lang.String message,
java.lang.Throwable th) |
java.lang.String |
getContextId() |
protected java.lang.String |
getDumpDir() |
protected java.util.List<java.lang.String> |
getFullClassPath(java.lang.ClassLoader loader) |
protected IMessageHandler |
getMessageHandler() |
IMessageHolder |
getMessageHolder() |
protected boolean |
info(java.lang.String message) |
protected void |
initializeCache(java.lang.ClassLoader loader,
java.util.List<java.lang.String> aspects,
GeneratedClassHandler existingClassHandler,
IMessageHandler myMessageHandler)
If the cache is enabled, initialize it and swap out the existing classhandler
for the caching one -
|
protected boolean |
isEnabled() |
void |
setActiveProtectionDomain(java.security.ProtectionDomain protectionDomain) |
protected void |
setMessageHandler(IMessageHandler mh) |
protected boolean |
shouldDump(java.lang.String name,
boolean before) |
protected boolean |
warn(java.lang.String message) |
protected boolean |
warn(java.lang.String message,
java.lang.Throwable th) |
byte[] |
weaveClass(java.lang.String name,
byte[] bytes)
Weave a class using aspects previously supplied to the adaptor.
|
byte[] |
weaveClass(java.lang.String name,
byte[] bytes,
boolean mustWeave)
Weave a class using aspects previously supplied to the adaptor.
|
public static final java.lang.String WEAVING_ADAPTOR_VERBOSE
public static final java.lang.String SHOW_WEAVE_INFO_PROPERTY
public static final java.lang.String TRACE_MESSAGES_PROPERTY
protected boolean verbose
protected BcelWorld bcelWorld
protected BcelWeaver weaver
protected GeneratedClassHandler generatedClassHandler
protected java.util.Map<java.lang.String,IUnwovenClassFile> generatedClasses
public BcelObjectType delegateForCurrentClass
protected java.security.ProtectionDomain activeProtectionDomain
protected WeavedClassCache cache
protected WeavingAdaptor()
public WeavingAdaptor(WeavingClassLoader loader)
loader
- instance of ClassLoader
public WeavingAdaptor(GeneratedClassHandler handler, java.net.URL[] classURLs, java.net.URL[] aspectURLs)
GeneratedClassHandler
, a full search path for resolving classes
and a complete set of aspects. The search path must include classes loaded by the class loader constructing the
WeavingAdaptor and all its parents in the hierarchy.handler
- GeneratedClassHandler
classURLs
- the URLs from which to resolve classesaspectURLs
- the aspects used to weave classes defined by this class loaderprotected java.util.List<java.lang.String> getFullClassPath(java.lang.ClassLoader loader)
protected void initializeCache(java.lang.ClassLoader loader, java.util.List<java.lang.String> aspects, GeneratedClassHandler existingClassHandler, IMessageHandler myMessageHandler)
loader
- classloader for this adapter, may be nullaspects
- List of strings representing aspects managed by the adapter; these could be urls or classnamesexistingClassHandler
- current class handlermyMessageHandler
- current message handlerprotected void createMessageHandler()
protected IMessageHandler getMessageHandler()
public IMessageHolder getMessageHolder()
protected void setMessageHandler(IMessageHandler mh)
protected void disable()
protected void enable()
protected boolean isEnabled()
public void addURL(java.net.URL url)
url
- to be appended to search pathpublic byte[] weaveClass(java.lang.String name, byte[] bytes) throws java.io.IOException
name
- the name of the classbytes
- the class bytesjava.io.IOException
- weave failedpublic byte[] weaveClass(java.lang.String name, byte[] bytes, boolean mustWeave) throws java.io.IOException
name
- the name of the classbytes
- the class bytesmustWeave
- if true then this class *must* get woven (used for concrete aspects generated from XML)java.io.IOException
- weave failedprotected boolean accept(java.lang.String name, byte[] bytes)
protected boolean shouldDump(java.lang.String name, boolean before)
protected void ensureDelegateInitialized(java.lang.String name, byte[] bytes)
protected boolean debug(java.lang.String message)
protected boolean info(java.lang.String message)
protected boolean warn(java.lang.String message)
protected boolean warn(java.lang.String message, java.lang.Throwable th)
protected boolean error(java.lang.String message)
protected boolean error(java.lang.String message, java.lang.Throwable th)
public java.lang.String getContextId()
getContextId
in interface IMessageContext
protected void dump(java.lang.String name, byte[] b, boolean before)
name
- b
- before
- whether we are dumping before weavingjava.lang.Throwable
protected java.lang.String getDumpDir()
public void setActiveProtectionDomain(java.security.ProtectionDomain protectionDomain)