T - the superclass typepublic abstract class AbstractSubclassFactory<T> extends AbstractClassFactory<T>
AbstractClassFactory by adding convenience methods to override methods on the superclass.| Modifier and Type | Field and Description |
|---|---|
protected ReflectionMetadataSource |
reflectionMetadataSource
The metadata source used to generate the proxy
|
classFile| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSubclassFactory(String className,
Class<T> superClass,
ClassLoader classLoader,
ProtectionDomain protectionDomain,
ReflectionMetadataSource reflectionMetadataSource)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
addInterface(Class<?> interfaceClass)
Adds an interface to the generated subclass, using the default
MethodBodyCreator to generate the method bodies. |
protected boolean |
addInterface(MethodBodyCreator override,
Class<?> interfaceClass)
Adds an interface to the generated subclass, using the given
MethodBodyCreator to generate the method bodies |
protected void |
cleanup()
Cleans up any resources left over from generating the class.
|
protected void |
createConstructorDelegates()
Adds a constructor for every non-private constructor present on the superclass.
|
protected void |
createConstructorDelegates(ConstructorBodyCreator creator)
Adds constructors that delegate the the superclass constructor for all non-private constructors present on the superclass
|
ConstructorBodyCreator |
getDefaultConstructorOverride()
Returns the default
ConstructorBodyCreator to use then creating overridden subclasses. |
MethodBodyCreator |
getDefaultMethodOverride()
Returns the default
MethodBodyCreator to use when creating overridden methods. |
protected void |
overrideAllMethods()
Calls
overrideAllMethods(MethodBodyCreator) with the default MethodBodyCreator. |
protected void |
overrideAllMethods(MethodBodyCreator override)
Overrides all methods on the superclass with the exception of
equals(Object), hashCode(),
toString() and finalize(). |
protected boolean |
overrideEquals()
Override the equals method using the default
MethodBodyCreator. |
protected boolean |
overrideEquals(MethodBodyCreator creator)
Override the equals method using the given
MethodBodyCreator. |
protected boolean |
overrideFinalize()
Override the finalize method using the default
MethodBodyCreator. |
protected boolean |
overrideFinalize(MethodBodyCreator creator)
Override the finalize method using the given
MethodBodyCreator. |
protected boolean |
overrideHashcode()
Override the hashCode method using the default
MethodBodyCreator. |
protected boolean |
overrideHashcode(MethodBodyCreator creator)
Override the hashCode method using the given
MethodBodyCreator. |
protected boolean |
overrideMethod(org.jboss.classfilewriter.ClassMethod method,
MethodIdentifier identifier,
MethodBodyCreator creator)
Creates a new method on the generated class that overrides the given methods, unless a method with the same signature has
already been overridden.
|
protected boolean |
overrideMethod(Method method,
MethodIdentifier identifier,
MethodBodyCreator creator)
Creates a new method on the generated class that overrides the given methods, unless a method with the same signature has
already been overridden.
|
protected void |
overridePublicMethods()
Overrides all public methods on the superclass.
|
protected void |
overridePublicMethods(MethodBodyCreator override)
Overrides all public methods on the superclass.
|
protected boolean |
overrideToString()
Override the toString method using the default
MethodBodyCreator |
protected boolean |
overrideToString(MethodBodyCreator creator)
Override the toString method using the given
MethodBodyCreator. |
afterClassLoad, buildClassDefinition, defineClass, generateClass, getClassLoader, getClassName, getProtectionDomain, getSuperClass, getSuperClassName, isProxyClassDefined, isProxyClassDefined, newInstanceprotected final ReflectionMetadataSource reflectionMetadataSource
protected AbstractSubclassFactory(String className, Class<T> superClass, ClassLoader classLoader, ProtectionDomain protectionDomain, ReflectionMetadataSource reflectionMetadataSource)
className - the class namesuperClass - the superclassclassLoader - the defining class loaderprotectionDomain - the protection domainprotected boolean overrideMethod(Method method, MethodIdentifier identifier, MethodBodyCreator creator)
method - The method to overrideidentifier - The identifier of the method to overridecreator - The MethodBodyCreator used to create the method bodytrue if the method was successfully overridden, false otherwiseprotected boolean overrideMethod(org.jboss.classfilewriter.ClassMethod method,
MethodIdentifier identifier,
MethodBodyCreator creator)
method - The method to overrideidentifier - The identifier of the method to overridecreator - The MethodBodyCreator used to create the method bodyfalse if the method has already been overriddenprotected void overridePublicMethods()
MethodBodyCreator is used to generate the class body.
NOTE: This will not override equals(Object), hashCode(), finalize() and
toString(), these should be overridden separately using overrideEquals(MethodBodyCreator)
overrideHashcode(MethodBodyCreator)overrideToString(MethodBodyCreator)
overrideFinalize(MethodBodyCreator)protected void cleanup()
cleanup in class AbstractClassFactory<T>protected void overridePublicMethods(MethodBodyCreator override)
MethodBodyCreator is used to generate the class body.
NOTE: This will not override equals(Object), hashCode(), finalize() and
toString(), these should be overridden separately using overrideEquals(MethodBodyCreator)
overrideHashcode(MethodBodyCreator),overrideToString(MethodBodyCreator) and
overrideFinalize(MethodBodyCreator)override - the method body creator to useprotected void overrideAllMethods()
overrideAllMethods(MethodBodyCreator) with the default MethodBodyCreator.protected void overrideAllMethods(MethodBodyCreator override)
equals(Object), hashCode(),
toString() and finalize(). The given MethodBodyCreator is used to generate the class
body.
Note that private methods are not actually overridden, and if the sub-class is loaded by a different ClassLoader to the
parent class then neither will package-private methods. These methods will still be present on the new class however, and
can be accessed via reflectionoverride - the method body creator to useprotected boolean overrideEquals()
MethodBodyCreator.protected boolean overrideEquals(MethodBodyCreator creator)
MethodBodyCreator.creator - the method body creator to useprotected boolean overrideHashcode()
MethodBodyCreator.protected boolean overrideHashcode(MethodBodyCreator creator)
MethodBodyCreator.creator - the method body creator to useprotected boolean overrideToString()
MethodBodyCreatorprotected boolean overrideToString(MethodBodyCreator creator)
MethodBodyCreator.creator - the method body creator to useprotected boolean overrideFinalize()
MethodBodyCreator.protected boolean overrideFinalize(MethodBodyCreator creator)
MethodBodyCreator.creator - the method body creator to useprotected boolean addInterface(Class<?> interfaceClass)
MethodBodyCreator to generate the method bodies.interfaceClass - the interface to addprotected boolean addInterface(MethodBodyCreator override, Class<?> interfaceClass)
MethodBodyCreator to generate the method bodiesoverride - the method body creator to useinterfaceClass - the interface to addprotected void createConstructorDelegates()
ConstructorBodyCreatorprotected void createConstructorDelegates(ConstructorBodyCreator creator)
creator - the constructor body creator to usepublic MethodBodyCreator getDefaultMethodOverride()
MethodBodyCreator to use when creating overridden methods.public ConstructorBodyCreator getDefaultConstructorOverride()
ConstructorBodyCreator to use then creating overridden subclasses.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.