public class ProxyFactory
extends java.lang.Object
| Modifier and Type | Method and Description | 
|---|---|
static <P> P | 
newProxy(java.lang.Class<P> type, P delegate)
Create a new  
 of the given type. | 
static <P> P | 
newSoftProxy(java.lang.Class<P> type, P delegate)
Create a new  
 of the given type. | 
static <P> P | 
newSoftProxy(java.lang.Class<P> type, P delegate, Operator runWhenNull)
Create a new  
 of the given type. | 
static <P> P | 
newSoftProxy(java.lang.Class<P> type, P delegate, java.lang.Runnable runWhenNull)
Deprecated. 
 
use  
#newSoftProxy(Class
  | 
static <P> P | 
newWeakProxy(java.lang.Class<P> type, P delegate)
Create a new  
 of the given type. | 
static <P> P | 
newWeakProxy(java.lang.Class<P> type, P delegate, Operator runWhenNull)
Create a new  
 of the given type. | 
static <P> P | 
newWeakProxy(java.lang.Class<P> type, P delegate, java.lang.Runnable runWhenNull)
Deprecated. 
 
Use  
#newWeakProxy(Class
  | 
public static <P> P newProxy(java.lang.Class<P> type,
             P delegate)
Proxy of the given type. Method invocations will be forwarded to the given delegate.P - the parameterized typetype - the type to be implemented by the returned proxy (must be an interface type)delegate - the implementation to which method invocations will be forwardedProxy of the given type
public static <P> P newWeakProxy(java.lang.Class<P> type,
                 P delegate)
Proxy of the given type. Method invocations will be forwarded to the given delegate. Only a weak reference to the delegate will be held by the proxy, such that the proxy will not keep the delegate from being garbage collected.
This may be useful for providing a proxy to an event listener, so that the object to which the listener proxy is added won't hold a hard reference to the delegate itself thereby reducing potential memory issues and freeing the programmer from the job of determining the best opportunity to remove the listener.
P - the parameterized typetype - the type to be implemented by the returned proxy (must be an interface type)delegate - the implementation to which method invocations will be forwardedProxy of the given type
@Deprecated
public static <P> P newWeakProxy(java.lang.Class<P> type,
                            P delegate,
                            java.lang.Runnable runWhenNull)
#newWeakProxy(Class
, P, Operator)
Proxy of the given type. Method invocations will be forwarded to the given delegate. Only a weak reference to the delegate will be held by the proxy, such that the proxy will not keep the delegate from being garbage collected. The optional Runnable will be executed in the case that the proxy is invoked after its reference to the delegate has been cleared (usually due to garbage collection).
This may be useful for providing a proxy to an event listener, so that the object to which the listener proxy is added won't hold a hard reference to the delegate itself thereby reducing potential memory issues and freeing the programmer from the job of determining the best opportunity to remove the listener.
P - the parameterized typetype - the type to be implemented by the returned proxy (must be an interface type)delegate - the implementation to which method invocations will be forwardedrunWhenNull - will be executed when the reference to the delegate has been clearedProxy of the given type
public static <P> P newWeakProxy(java.lang.Class<P> type,
                 P delegate,
                 Operator runWhenNull)
Proxy of the given type. Method invocations will be forwarded to the given delegate. Only a weak reference to the delegate will be held by the proxy, such that the proxy will not keep the delegate from being garbage collected. The optional Runnable will be executed in the case that the proxy is invoked after its reference to the delegate has been cleared (usually due to garbage collection).
This may be useful for providing a proxy to an event listener, so that the object to which the listener proxy is added won't hold a hard reference to the delegate itself thereby reducing potential memory issues and freeing the programmer from the job of determining the best opportunity to remove the listener.
P - the parameterized typetype - the type to be implemented by the returned proxy (must be an interface type)delegate - the implementation to which method invocations will be forwardedrunWhenNull - will be invoked with the created proxy instance when the reference to the delegate has been clearedProxy of the given type
public static <P> P newSoftProxy(java.lang.Class<P> type,
                 P delegate)
Proxy of the given type. Method invocations will be forwarded to the given delegate. Only a soft reference to the delegate will be held by the proxy, such that the proxy will not keep the delegate from being garbage collected. Usually the delegate will not be collected until the VM is low on memory.
This may be useful for providing a proxy to an event listener, so that the object to which the listener proxy is added won't hold a hard reference to the delegate itself thereby reducing potential memory issues and freeing the programmer from the job of determining the best opportunity to remove the listener.
P - the parameterized typetype - the type to be implemented by the returned proxy (must be an interface type)delegate - the implementation to which method invocations will be forwardedProxy of the given type
@Deprecated
public static <P> P newSoftProxy(java.lang.Class<P> type,
                            P delegate,
                            java.lang.Runnable runWhenNull)
#newSoftProxy(Class
, P, Operator)
Proxy of the given type. Method invocations will be forwarded to the given delegate. Only a weak reference to the delegate will be held by the proxy, such that the proxy will not keep the delegate from being garbage collected. Usually the delegate will not be collected until the VM is low on memory. The optional Runnable will be executed in the case that the proxy is invoked after its reference to the delegate has been cleared (usually due to garbage collection).
This may be useful for providing a proxy to an event listener, so that the object to which the listener proxy is added won't hold a hard reference to the delegate itself thereby reducing potential memory issues and freeing the programmer from the job of determining the best opportunity to remove the listener.
P - the parameterized typetype - the type to be implemented by the returned proxy (must be an interface type)delegate - the implementation to which method invocations will be forwardedrunWhenNull - will be executed when the reference to the delegate has been clearedProxy of the given type
public static <P> P newSoftProxy(java.lang.Class<P> type,
                 P delegate,
                 Operator runWhenNull)
Proxy of the given type. Method invocations will be forwarded to the given delegate. Only a weak reference to the delegate will be held by the proxy, such that the proxy will not keep the delegate from being garbage collected. Usually the delegate will not be collected until the VM is low on memory. The optional Runnable will be executed in the case that the proxy is invoked after its reference to the delegate has been cleared (usually due to garbage collection).
This may be useful for providing a proxy to an event listener, so that the object to which the listener proxy is added won't hold a hard reference to the delegate itself thereby reducing potential memory issues and freeing the programmer from the job of determining the best opportunity to remove the listener.
P - the parameterized typetype - the type to be implemented by the returned proxy (must be an interface type)delegate - the implementation to which method invocations will be forwardedrunWhenNull - will be invoked with the created proxy instance when the reference to the delegate has been clearedProxy of the given type