|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.ws.jaxme.js.pattern.ProxyGenerator
public class ProxyGenerator
This class is a generator for the proxy object pattern. A proxy
object performs the same task as an object created by the
Proxy
class: It delegates its method
calls to an internal instance.
In the case of Proxy
this works by
invoking a so-called InvocationHandler
.
The InvocationHandler calls the actual object via Java reflection.
In our case, the proxy object is an instance of a generated class. The main advantage of the generated approach is that you can customize the proxy class quite easily by overwriting it. Compared to the creation of an InvocationHandler, this saves a lot of hazzle.
Constructor Summary | |
---|---|
ProxyGenerator()
|
Method Summary | |
---|---|
JavaSource |
generate(JavaSourceFactory pFactory,
JavaQName pTargetName,
InterfaceDescription[] pInterfaces)
Generates a class implementing the given interfaces. |
protected void |
generateInterfaceMethods(JavaSource pJs,
java.util.Map pGeneratedMethods,
JavaSource pInterface)
Generates the methods for a given interface. |
protected JavaField |
getBackingObjectField(JavaSource pJs,
InterfaceDescription[] pInterfaces)
Generates the backingObject field. |
protected JavaConstructor |
getConstructor(JavaSource pJs,
InterfaceDescription[] pInterfaces)
Creates a constructor with protected access and a single argument, the backing object. |
JavaQName |
getExtendedClass()
Returns the class extended by the generated proxy class. |
protected JavaMethod |
getInterfaceMethod(JavaSource pJs,
JavaMethod pMethod)
Generated an instance of JavaMethod for the given
JavaMethod . |
protected JavaSource |
getJavaSource(JavaSourceFactory pFactory,
JavaQName pTargetName)
Creates the class. |
void |
setExtendedClass(JavaQName pExtendedClass)
Sets the class extended by the generated proxy class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProxyGenerator()
Method Detail |
---|
public JavaQName getExtendedClass()
Returns the class extended by the generated proxy class.
Defaults to Object
.
public void setExtendedClass(JavaQName pExtendedClass)
Sets the class extended by the generated proxy class.
Defaults to Object
.
protected JavaMethod getInterfaceMethod(JavaSource pJs, JavaMethod pMethod)
Generated an instance of JavaMethod
for the given
JavaMethod
.
protected void generateInterfaceMethods(JavaSource pJs, java.util.Map pGeneratedMethods, JavaSource pInterface) throws java.lang.ClassNotFoundException
Generates the methods for a given interface.
pJs
- The Java class being generatedpGeneratedMethods
- A set of already generated methods; each entry in the
set is an instance of MethodKey
. The method creates a new instance
of MethodKey
and adds it to the set. A warning is written to
System.err
, if the method isn't unique.
java.lang.ClassNotFoundException
protected JavaConstructor getConstructor(JavaSource pJs, InterfaceDescription[] pInterfaces) throws java.lang.Exception
Creates a constructor with protected access and a single argument, the backing object.
java.lang.Exception
protected JavaSource getJavaSource(JavaSourceFactory pFactory, JavaQName pTargetName)
Creates the class.
protected JavaField getBackingObjectField(JavaSource pJs, InterfaceDescription[] pInterfaces)
Generates the backingObject
field.
public JavaSource generate(JavaSourceFactory pFactory, JavaQName pTargetName, InterfaceDescription[] pInterfaces) throws java.lang.Exception
Generates a class implementing the given interfaces.
pFactory
- The ProxyGenerator will use this factory for creating
instances of JavaSource.pTargetName
- Name of the generated classpInterfaces
- The interfaces being implemented by the generated class.
java.lang.ClassNotFoundException
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |