Top Description Fields Constructors Methods
org.eclipse.persistence.internal.indirection

public Class ProxyIndirectionHandler<T>

extends Object
implements InvocationHandler, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.reflect.InvocationHandler
Imports
java.io.Serializable, java.lang.reflect.InvocationHandler, .InvocationTargetException, .Method, .Proxy, org.eclipse.persistence.exceptions.QueryException, .ValidationException, org.eclipse.persistence.indirection.ValueHolderInterface, org.eclipse.persistence.internal.security.PrivilegedAccessHelper

ProxyIndirectionHandler

Transparently handles EclipseLink indirection for 1:1 relationships through use of the Java Proxy framework in JDK 1.3. This class intercepts messages sent to the proxy object, and instantiates its internal ValueHolder when necessary.
Author
Rick Barkhouse
Since
TopLink 3.0
See Also
org.eclipse.persistence.internal.indirection.ProxyIndirectionPolicy

Field Summary

Modifier and TypeField and Description
private ValueHolderInterface<T>

Constructor Summary

AccessConstructor and Description
public
ProxyIndirectionHandler()

INTERNAL: Just in here to allow for Serialization.

private
ProxyIndirectionHandler(ValueHolderInterface<T> valueHolder)

INTERNAL: Store the value holder.

Method Summary

Modifier and TypeMethod and Description
public ValueHolderInterface<T>
getValueHolder()

INTERNAL: Get the ValueHolder associated with this handler.

public Object
invoke(final Object
the proxy instance that the method was invoked on
proxy
,
final Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
m
,
final Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

INTERNAL: Handle the method calls on the proxy object.
public static <T> Object
newProxyInstance(final Class<?> anInterface, final Class<?>[] interfaces, final ValueHolderInterface<T> valueHolder)

INTERNAL: Utility method to create a new proxy object.

public void
setValueHolder(ValueHolderInterface<T> value)

INTERNAL: Set the ValueHolder associated with this handler.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueHolderback to summary
private ValueHolderInterface<T> valueHolder

Constructor Detail

ProxyIndirectionHandlerback to summary
public ProxyIndirectionHandler()

INTERNAL: Just in here to allow for Serialization.

ProxyIndirectionHandlerback to summary
private ProxyIndirectionHandler(ValueHolderInterface<T> valueHolder)

INTERNAL: Store the value holder.

Method Detail

getValueHolderback to summary
public ValueHolderInterface<T> getValueHolder()

INTERNAL: Get the ValueHolder associated with this handler.

invokeback to summary
public Object invoke(final Object proxy, final Method m, final Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

INTERNAL: Handle the method calls on the proxy object.

Parameters
proxy:Object

Doc from java.lang.reflect.InvocationHandler.invoke.

the proxy instance that the method was invoked on

m:Method

Doc from java.lang.reflect.InvocationHandler.invoke.

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

Doc from java.lang.reflect.InvocationHandler.invoke.

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

Doc from java.lang.reflect.InvocationHandler.invoke.

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
Exceptions
Throwable:

Doc from java.lang.reflect.InvocationHandler.invoke.

the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.

newProxyInstanceback to summary
public static <T> Object newProxyInstance(final Class<?> anInterface, final Class<?>[] interfaces, final ValueHolderInterface<T> valueHolder)

INTERNAL: Utility method to create a new proxy object.

setValueHolderback to summary
public void setValueHolder(ValueHolderInterface<T> value)

INTERNAL: Set the ValueHolder associated with this handler.