Package spin

Class ProxyFactory

  • Direct Known Subclasses:
    CGLibProxyFactory, JDKProxyFactory

    public abstract class ProxyFactory
    extends java.lang.Object
    A factory of proxies which intercept invocations, using Evaluators to evaluate them.
    See Also:
    Evaluator
    • Constructor Summary

      Constructors 
      Constructor Description
      ProxyFactory()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract boolean areProxyEqual​(java.lang.Object proxy1, java.lang.Object proxy2)
      Test if the given proxies of this factory are intercepting the same object.
      abstract java.lang.Object createProxy​(java.lang.Object object, Evaluator evaluator)
      Create a proxy for the given object that evaluates invocations with the given evaluator.
      protected java.lang.Object evaluteInvocation​(Evaluator evaluator, java.lang.Object proxy, Invocation invocation)
      Evaluate the given invocation with the given evaluator.
      abstract boolean isProxy​(java.lang.Object object)
      Test if the given object is a proxy created by this factory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProxyFactory

        public ProxyFactory()
    • Method Detail

      • createProxy

        public abstract java.lang.Object createProxy​(java.lang.Object object,
                                                     Evaluator evaluator)
        Create a proxy for the given object that evaluates invocations with the given evaluator.
        Parameters:
        object - object to create proxy for
        evaluator - evaluator to evaluate invocations with
        Returns:
        new proxy
      • isProxy

        public abstract boolean isProxy​(java.lang.Object object)
        Test if the given object is a proxy created by this factory.
        Parameters:
        object - object to test
        Returns:
        true if given object is a Spin proxy, false otherwise
      • areProxyEqual

        protected abstract boolean areProxyEqual​(java.lang.Object proxy1,
                                                 java.lang.Object proxy2)
        Test if the given proxies of this factory are intercepting the same object.
        Parameters:
        proxy1 - first proxy
        proxy2 - second proxy
        Returns:
        true if both proxies are intercepting the same object
      • evaluteInvocation

        protected java.lang.Object evaluteInvocation​(Evaluator evaluator,
                                                     java.lang.Object proxy,
                                                     Invocation invocation)
                                              throws java.lang.Throwable
        Evaluate the given invocation with the given evaluator.
        Parameters:
        evaluator - evaluator to evaluate with
        proxy - proxy that intcepted the invocation
        invocation - the invocation to evaluate
        Returns:
        result of evaluation
        Throws:
        java.lang.Throwable