Package jodd.proxetta
Class ProxettaFactory<T extends ProxettaFactory,P extends Proxetta>
- java.lang.Object
-
- jodd.proxetta.ProxettaFactory<T,P>
-
- Direct Known Subclasses:
InvokeProxettaFactory
,ProxyProxettaFactory
,WrapperProxettaFactory
public abstract class ProxettaFactory<T extends ProxettaFactory,P extends Proxetta> extends java.lang.Object
Proxetta builder. WhileProxetta
only holds aspects and configuration,ProxettaBuilder
deals with the actually building proxies and wrappers over provided target.
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassWriter
destClassWriter
protected P
proxetta
protected boolean
proxyApplied
protected java.lang.String
proxyClassName
protected java.lang.String
requestedProxyClassName
Requested proxy class name (or class name template).protected static int
suffixCounter
Number appended to proxy class name, incremented on each use to make classnames unique in the system (e.g.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ProxettaFactory(P proxetta)
Creates new builder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected T
_this()
protected void
assertProxyIsCreated()
Checks if proxy is created and throws an exception if not.byte[]
create()
Returns byte array of created class.java.lang.Class
define()
Defines class.protected void
dumpClassInDebugFolder(byte[] bytes)
Writes created class content to output folder for debugging purposes.java.lang.String
getProxyClassName()
Returns proxy class name.boolean
isProxyApplied()
Returnstrue
if at least one method was wrapped.java.lang.Object
newInstance()
Creates new instance of created class.protected void
process()
Reads the target and creates destination class.protected abstract WorkData
process(ClassReader cr, TargetClassInfoReader targetClassInfoReader)
Creates custom class builder and process the target class with it.protected java.lang.String
resolveClassNameSuffix()
Returns new suffix ornull
if suffix is not in use.protected T
setTarget(java.io.InputStream target)
Defines class input stream as a target.T
setTarget(java.lang.Class target)
Defines class as a target.protected T
setTarget(java.lang.String targetName)
Defines class name as a target.T
setTargetProxyClassName(java.lang.String targetProxyClassName)
Sets requested proxy class name.protected byte[]
toByteArray()
Returns raw bytecode.
-
-
-
Field Detail
-
requestedProxyClassName
protected java.lang.String requestedProxyClassName
Requested proxy class name (or class name template).
-
suffixCounter
protected static int suffixCounter
Number appended to proxy class name, incremented on each use to make classnames unique in the system (e.g. classloader).- See Also:
Proxetta.setVariableClassName(boolean)
-
destClassWriter
protected ClassWriter destClassWriter
-
proxyApplied
protected boolean proxyApplied
-
proxyClassName
protected java.lang.String proxyClassName
-
-
Constructor Detail
-
ProxettaFactory
protected ProxettaFactory(P proxetta)
Creates new builder.
-
-
Method Detail
-
_this
protected T _this()
-
setTargetProxyClassName
public T setTargetProxyClassName(java.lang.String targetProxyClassName)
Sets requested proxy class name.
-
setTarget
protected T setTarget(java.io.InputStream target)
Defines class input stream as a target.
-
setTarget
protected T setTarget(java.lang.String targetName)
Defines class name as a target. Class will not be loaded by classloader!
-
setTarget
public T setTarget(java.lang.Class target)
Defines class as a target.
-
resolveClassNameSuffix
protected java.lang.String resolveClassNameSuffix()
Returns new suffix ornull
if suffix is not in use.
-
process
protected abstract WorkData process(ClassReader cr, TargetClassInfoReader targetClassInfoReader)
Creates custom class builder and process the target class with it.
-
process
protected void process()
Reads the target and creates destination class.
-
create
public byte[] create()
Returns byte array of created class.
-
define
public java.lang.Class define()
Defines class.
-
newInstance
public java.lang.Object newInstance()
Creates new instance of created class. Assumes default no-arg constructor.
-
dumpClassInDebugFolder
protected void dumpClassInDebugFolder(byte[] bytes)
Writes created class content to output folder for debugging purposes.
-
assertProxyIsCreated
protected void assertProxyIsCreated()
Checks if proxy is created and throws an exception if not.
-
toByteArray
protected byte[] toByteArray()
Returns raw bytecode.
-
isProxyApplied
public boolean isProxyApplied()
Returnstrue
if at least one method was wrapped.
-
getProxyClassName
public java.lang.String getProxyClassName()
Returns proxy class name.
-
-