Class AnnotationProxy
- java.lang.Object
-
- org.eclipse.persistence.jaxb.javamodel.AnnotationProxy
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
public class AnnotationProxy extends java.lang.Object implements java.lang.reflect.InvocationHandler
Purpose:The purpose of this class is to act as a dynamic proxy that allows JDK Annotation method calls to be made on a non Annotation object.
Responsibilities:
- Create and return a dynamic proxy instance based on an Annotation class
and a
Map
of components (method name to value pairs) - Allow JDK Annotation method calls to be invoked on the proxy object
This class provides a means to invoke JDK Annotation method calls on a non Annotation instance.
- See Also:
Proxy
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
getComponents()
Return theMap
of method name/value pairs for this proxy instance.static <A extends java.lang.annotation.Annotation>
AgetProxy(java.util.Map<java.lang.String,java.lang.Object> components, java.lang.Class<A> annoClass, java.lang.ClassLoader cl, org.eclipse.persistence.internal.helper.ConversionManager conversionMgr)
This is the preferred way to obtain an instance of a dynamic proxy.java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
Invoke a givenMethod
on this proxy.
-
-
-
Method Detail
-
getProxy
public static <A extends java.lang.annotation.Annotation> A getProxy(java.util.Map<java.lang.String,java.lang.Object> components, java.lang.Class<A> annoClass, java.lang.ClassLoader cl, org.eclipse.persistence.internal.helper.ConversionManager conversionMgr)
This is the preferred way to obtain an instance of a dynamic proxy. The method takes aClassLoader
(which is used to load the targetAnnotation
), aClass
(which indicates the targetAnnotation
, i.e.javax.xml.bind.annotation.XmlElement.class)
, and aMap
of method name to value pairs, which represent the method names on theAnnotation
and the values that are to be returned from each method call. For example, if this proxy is to be used for an@XmlElement
, theMap
should contain the following keys:- defaultValue
- name
- namespace
- nillable
- required
- type
- "defaultValue", "##default"
- "name", "employee"
- "namespace", "www.example.org"
- "nillable", false
- "required", false
- "type", javax.xml.bind.annotation.XmlElement.DEFAULT.class
- Parameters:
components
-Map
of method name/value pairs for this proxy instanceannoClass
- The interface for the proxy class to implementcl
- TheClassLoader
to define the proxy classconversionMgr
-ConversionManager
instance for converting to the correct return type in theinvoke
method- Returns:
- A dynamic proxy instance based on a Java model JavaAnnotation
-
getComponents
public java.util.Map<java.lang.String,java.lang.Object> getComponents()
Return theMap
of method name/value pairs for this proxy instance.- Returns:
Map
of method name/value pairs for this proxy instance
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
Invoke a givenMethod
on this proxy. The componentMap
will be accessed using the givenMethod
's name, and if an entry exists, the associated value is returned.- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Parameters:
proxy
- Satisfy theInvocationHandler
interface - not usedmethod
- TheMethod
instance corresponding to the interface method invoked on the proxy instanceargs
- Satisfy theInvocationHandler
interface - not used- Returns:
- The value from the method invocation on the proxy instance
- Throws:
java.lang.Throwable
-
-