jodd.proxetta
Class Proxetta

java.lang.Object
  extended by jodd.proxetta.Proxetta

public class Proxetta
extends java.lang.Object

Proxetta creates dynamic proxy classes in the run-time.

To wrap a class with proxy Proxetta needs a target class (or its name or InputStream) and one or more proxy aspects that will be applied to target. Proxetta will examine target class and check if there are any methods to wrap, as defined by aspects pointcut. If there is at least one matched method, new proxy class will be created that extends target class.

If no matching method founded, Proxetta may or may not create an empty proxy class. This behaviour is defined by forced mode during creation.


Field Summary
protected  ProxyAspect[] aspects
           
protected  java.lang.ClassLoader classLoader
           
protected  boolean forced
           
protected  boolean variableClassName
           
 
Constructor Summary
Proxetta(ProxyAspect... aspects)
           
 
Method Summary
 Proxetta constantClassName()
          Sets constant proxy class name so each time created proxy class will have the same name.
protected  ProxettaCreator createProxettaCreator()
          Creates ProxettaCreator with current options.
 byte[] createProxy(java.lang.Class target)
          Generates proxy bytecode for provided class.
 byte[] createProxy(java.io.InputStream in)
          Generates proxy bytecode for class provided as InputStream.
protected  byte[] createProxy(ProxettaCreator pc)
          Returns byte array of invoked proxetta creator.
 byte[] createProxy(java.lang.String targetName)
          Generates proxy bytecode for provided class.
<T> T
createProxyInstance(java.lang.Class<T> target)
           
 java.lang.Object createProxyInstance(java.lang.String targetName)
           
 java.lang.Class defineProxy(java.lang.Class target)
          Defines new proxy class.
 java.lang.Class defineProxy(java.lang.String targetName)
          Defines new proxy class.
 Proxetta forced(boolean forced)
          Specifies 'forced' mode.
 Proxetta loadsWith(java.lang.ClassLoader classLoader)
          Specifies classloaders for use.
 Proxetta variableClassName()
          Sets variable proxy class name so every time when new proxy class is created its name will be different, so one classloader may load it without a problem.
static Proxetta withAspects(ProxyAspect... aspects)
          Specifies aspects for the target and creates Proxetta instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aspects

protected final ProxyAspect[] aspects

forced

protected boolean forced

classLoader

protected java.lang.ClassLoader classLoader

variableClassName

protected boolean variableClassName
Constructor Detail

Proxetta

public Proxetta(ProxyAspect... aspects)
Method Detail

withAspects

public static Proxetta withAspects(ProxyAspect... aspects)
Specifies aspects for the target and creates Proxetta instance.


forced

public Proxetta forced(boolean forced)
Specifies 'forced' mode. If true, new proxy class will be created even if there are no matching pointcuts. If false, new proxy class will be created only if there is at least one matching pointcut - otherwise, original class will be returned.


loadsWith

public Proxetta loadsWith(java.lang.ClassLoader classLoader)
Specifies classloaders for use.


variableClassName

public Proxetta variableClassName()
Sets variable proxy class name so every time when new proxy class is created its name will be different, so one classloader may load it without a problem.


constantClassName

public Proxetta constantClassName()
Sets constant proxy class name so each time created proxy class will have the same name. Such class can be loaded only once by a classloader.


createProxettaCreator

protected ProxettaCreator createProxettaCreator()
Creates ProxettaCreator with current options.


createProxy

public byte[] createProxy(java.lang.Class target)
Generates proxy bytecode for provided class. Returns null if there was no matching pointcuts and forced mode is off.


createProxy

public byte[] createProxy(java.lang.String targetName)
Generates proxy bytecode for provided class. Returns null if there was no matching pointcuts and forced mode is off.


createProxy

public byte[] createProxy(java.io.InputStream in)
Generates proxy bytecode for class provided as InputStream. Returns null if there was no matching pointcuts and forced mode is off.


createProxy

protected byte[] createProxy(ProxettaCreator pc)
Returns byte array of invoked proxetta creator.


defineProxy

public java.lang.Class defineProxy(java.lang.Class target)
Defines new proxy class.


defineProxy

public java.lang.Class defineProxy(java.lang.String targetName)
Defines new proxy class.


createProxyInstance

public <T> T createProxyInstance(java.lang.Class<T> target)

createProxyInstance

public java.lang.Object createProxyInstance(java.lang.String targetName)


Copyright ©2008 Jodd Team