|
Invocation API 1.1.0.Final | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.invocation.proxy.AbstractClassFactory<T>
org.jboss.invocation.proxy.AbstractSubclassFactory<T>
org.jboss.invocation.proxy.AbstractProxyFactory<T>
org.jboss.invocation.proxy.ProxyFactory<T>
T
- the superclass typepublic class ProxyFactory<T>
Proxy Factory that generates proxies that delegate all calls to an InvocationHandler
.
Typical usage looks like:
ProxyFactory<SimpleClass> proxyFactory = new ProxyFactory<SimpleClass>(SimpleClass.class); SimpleClass instance = proxyFactory.newInstance(new SimpleDispatcher());This will create a proxy for SimpleClass, and return a new instance that handles invocations using the InvocationDispatcher SimpleDispatcher.
Invocations on these proxies are very efficient, as no reflection is involved.
Nested Class Summary | |
---|---|
class |
ProxyFactory.ProxyConstructorBodyCreator
Generates a proxy constructor that delegates to super(), and then sets the constructed flag to true. |
class |
ProxyFactory.ProxyMethodBodyCreator
Overrides superclass methods and forwards calls to the dispatcher. |
class |
ProxyFactory.WriteReplaceBodyCreator
Generates the writeReplace method if advanced serialization is enabled. |
Field Summary | |
---|---|
static String |
CONSTRUCTED_GUARD
this field on the generated class stores if the constructor has been completed yet. |
static String |
INVOCATION_HANDLER_FIELD
Name of the field that holds the generated dispatcher on the generated proxy |
Fields inherited from class org.jboss.invocation.proxy.AbstractSubclassFactory |
---|
reflectionMetadataSource |
Fields inherited from class org.jboss.invocation.proxy.AbstractClassFactory |
---|
classFile |
Constructor Summary | |
---|---|
ProxyFactory(ProxyConfiguration<T> proxyConfiguration)
Construct a new instance. |
Method Summary | |
---|---|
protected void |
generateClass()
Generate the class. |
MethodBodyCreator |
getDefaultMethodOverride()
Returns the default MethodBodyCreator to use when creating overridden methods. |
InvocationHandler |
getInvocationHandler(Object proxy)
Returns the invocation handler for a proxy created from this factory. |
static InvocationHandler |
getInvocationHandlerStatic(Object proxy)
Gets the InvocationHandler for a given proxy instance. |
T |
newInstance(InvocationHandler handler)
Create a new proxy, initialising it with the given invocation handler. |
void |
setInvocationHandler(Object proxy,
InvocationHandler handler)
Sets the invocation handler for a proxy created from this factory. |
static void |
setInvocationHandlerStatic(Object proxy,
InvocationHandler handler)
Sets the invocation handler for a proxy. |
void |
setSerializableProxyClass(Class<? extends SerializableProxy> serializableProxyClass)
Sets the SerializableProxy class to emit from the proxies writeReplace method. |
Methods inherited from class org.jboss.invocation.proxy.AbstractProxyFactory |
---|
afterClassLoad, cleanup, finalizeStaticConstructor, getCachedMethods, loadMethodIdentifier |
Methods inherited from class org.jboss.invocation.proxy.AbstractSubclassFactory |
---|
addInterface, addInterface, createConstructorDelegates, createConstructorDelegates, getDefaultConstructorOverride, overrideAllMethods, overrideAllMethods, overrideEquals, overrideEquals, overrideFinalize, overrideFinalize, overrideHashcode, overrideHashcode, overrideMethod, overrideMethod, overridePublicMethods, overridePublicMethods, overrideToString, overrideToString |
Methods inherited from class org.jboss.invocation.proxy.AbstractClassFactory |
---|
buildClassDefinition, defineClass, getClassLoader, getClassName, getProtectionDomain, getSuperClass, getSuperClassName, isProxyClassDefined, isProxyClassDefined, newInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String INVOCATION_HANDLER_FIELD
public static final String CONSTRUCTED_GUARD
Constructor Detail |
---|
public ProxyFactory(ProxyConfiguration<T> proxyConfiguration)
proxyConfiguration
- The configuration to use to build the proxyMethod Detail |
---|
public T newInstance(InvocationHandler handler) throws InstantiationException, IllegalAccessException
handler
- the invocation handler to use
IllegalAccessException
- if the constructor is not accessible
InstantiationException
- if instantiation failed due to an exceptionprotected void generateClass()
generateClass
in class AbstractClassFactory<T>
public void setSerializableProxyClass(Class<? extends SerializableProxy> serializableProxyClass)
SerializableProxy
class to emit from the proxies writeReplace method. If this is set to null (the
default) then no writeReplace method will be generated. The proxy may still be serializable, providing that the
superclass and InvocationHandler
are both serializable.
serializableProxyClass
- the proxy class
IllegalStateException
- If the proxy class has already been generatedSerializableProxy
,
DefaultSerializableProxy
public MethodBodyCreator getDefaultMethodOverride()
AbstractSubclassFactory
MethodBodyCreator
to use when creating overridden methods.
getDefaultMethodOverride
in class AbstractSubclassFactory<T>
public void setInvocationHandler(Object proxy, InvocationHandler handler)
proxy
- the proxy to modifyhandler
- the handler to usepublic InvocationHandler getInvocationHandler(Object proxy)
proxy
- the proxy
public static void setInvocationHandlerStatic(Object proxy, InvocationHandler handler)
setInvocationHandler(Object, InvocationHandler)
, however it will work on any proxy, not just proxies from a
specific factory.
proxy
- the proxy to modifyhandler
- the handler to usepublic static InvocationHandler getInvocationHandlerStatic(Object proxy)
InvocationHandler
for a given proxy instance. This method is less efficient than
getInvocationHandler(Object)
, however it will work for any proxy, not just proxies from a specific factory
instance.
proxy
- the proxy
|
Invocation API 1.1.0.Final | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |