net.sf.jga.swing
Class FunctorProxy

java.lang.Object
  extended by net.sf.jga.swing.FunctorProxy

public class FunctorProxy
extends java.lang.Object

Factory that builds Proxy objects that map Functors to event notification methods. Using this proxy is a two step process: first build the proxy instance calling makeListenerFor or newProxyInstance; second, register the desired functors with the various registration methods.

Copyright © 2005 David A. Hall


Nested Class Summary
static class FunctorProxy.FunctorInvocationHandler
          The InvocationHandler for FunctorProxy instances.
 
Constructor Summary
FunctorProxy()
           
 
Method Summary
static java.lang.reflect.Proxy makeListenerFor(java.lang.Object obj)
          Manufactures a Proxy that can listen to any/all events that the given object may fire.
static java.lang.reflect.Proxy newProxyInstance(java.lang.ClassLoader loader, java.lang.Class<?>[] interfaces)
          Returns an instance of a proxy class for the specified interfaces that dispatches method invocations to functors registed via a FunctorInvocationHandler.
static void register(java.lang.reflect.Proxy proxy, java.lang.Class<?> listenerClass, java.lang.Class<?> eventClass, java.lang.String methodName, UnaryFunctor<?,?> functor)
          Registers a functor to be evaluated when the given method is invoked.
static void register(java.lang.reflect.Proxy proxy, java.lang.reflect.Method method, UnaryFunctor<?,?> functor)
          Registers the given functor to be invoked by the proxy when the given method is called.
static void register(java.lang.reflect.Proxy proxy, java.lang.String methodName, java.lang.String expression)
          Registers the functor described by the given expression, to be invoked by the proxy when a method with the given method is called.
static void register(java.lang.reflect.Proxy proxy, java.lang.String methodName, UnaryFunctor<?,?> functor)
          Registers the given functor to be invoked by the proxy when a method with the given method is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctorProxy

public FunctorProxy()
Method Detail

makeListenerFor

public static java.lang.reflect.Proxy makeListenerFor(java.lang.Object obj)
Manufactures a Proxy that can listen to any/all events that the given object may fire. The generated Proxy's invocation handler will be an instance FunctorInvocationHandler.


newProxyInstance

public static java.lang.reflect.Proxy newProxyInstance(java.lang.ClassLoader loader,
                                                       java.lang.Class<?>[] interfaces)
Returns an instance of a proxy class for the specified interfaces that dispatches method invocations to functors registed via a FunctorInvocationHandler.


register

public static void register(java.lang.reflect.Proxy proxy,
                            java.lang.String methodName,
                            java.lang.String expression)
                     throws ParseException,
                            java.lang.NoSuchMethodException
Registers the functor described by the given expression, to be invoked by the proxy when a method with the given method is called. If the proxy supports more than one method with this name, then which one will be invoked is undefined.

Throws:
java.lang.NoSuchMethodException - if no method with the given name is found
ParseException - if the expression cannot be parsed
java.lang.ClassCastException - if the given proxy's handler is not a FunctorInvocationHandler

register

public static void register(java.lang.reflect.Proxy proxy,
                            java.lang.String methodName,
                            UnaryFunctor<?,?> functor)
                     throws java.lang.NoSuchMethodException
Registers the given functor to be invoked by the proxy when a method with the given method is called. If the proxy supports more than one method with this name, then which one will be invoked is undefined.

Throws:
java.lang.NoSuchMethodException - if no method with the given name is found
java.lang.ClassCastException - if the given proxy's handler is not a FunctorInvocationHandler

register

public static void register(java.lang.reflect.Proxy proxy,
                            java.lang.reflect.Method method,
                            UnaryFunctor<?,?> functor)
Registers the given functor to be invoked by the proxy when the given method is called.

Throws:
java.lang.ClassCastException - if the given proxy's handler is not a FunctorInvocationHandler

register

public static void register(java.lang.reflect.Proxy proxy,
                            java.lang.Class<?> listenerClass,
                            java.lang.Class<?> eventClass,
                            java.lang.String methodName,
                            UnaryFunctor<?,?> functor)
                     throws java.lang.NoSuchMethodException,
                            java.lang.IllegalArgumentException
Registers a functor to be evaluated when the given method is invoked.

Throws:
java.lang.IllegalArgumentException - if the proxy does not implement the listenerClass
java.lang.NoSuchMethodException - if the proxy does not have a method with the given name that takes an argument of class eventClass
java.lang.ClassCastException - if the given proxy's handler is not a FunctorInvocationHandler


Copyright © 2002-2006 David A. Hall. All Rights Reserved.