Class ProviderWrapper

  • All Implemented Interfaces:
    InvocationHandler

    public class ProviderWrapper
    extends Object
    implements InvocationHandler
    This class wraps an EJB which is decorated with ServiceProvider and has a valid service interface specified (that is it extends JoynrProvider). When the bean is discovered in JoynrIntegrationBean.initialise() an instance of this class is registered as the provider with the joynr runtime. When joynr wants to call a method of the specified service interface, then this instance will obtain a reference to the bean via the JoynrIntegrationBean.beanManager and will delegate to the corresponding method on that bean (i.e. with the same name and parameters). The result is then wrapped in a deferred / promise and returned.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProviderWrapper​(javax.enterprise.inject.spi.Bean<?> bean, javax.enterprise.inject.spi.BeanManager beanManager, com.google.inject.Injector injector)
      Initialises the instance with the service interface which will be exposed and the bean reference it is meant to wrap.
    • Constructor Detail

      • ProviderWrapper

        public ProviderWrapper​(javax.enterprise.inject.spi.Bean<?> bean,
                               javax.enterprise.inject.spi.BeanManager beanManager,
                               com.google.inject.Injector injector)
        Initialises the instance with the service interface which will be exposed and the bean reference it is meant to wrap.
        Parameters:
        bean - the bean reference to which calls will be delegated.
        beanManager - the bean manager.
        injector - the Guice injector.
    • Method Detail

      • invoke

        public Object invoke​(Object proxy,
                             Method method,
                             Object[] args)
                      throws Throwable
        When a method is invoked via a joynr call, then it is delegated to an instance of the bean with which this instance was initialised, if the method is part of the business interface and to this instance if it was part of the JoynrProvider interface or the Object class.
        Specified by:
        invoke in interface InvocationHandler
        Parameters:
        proxy - the proxy object on which the method was called.
        method - the specific method which was called.
        args - the arguments with which the method was called.
        Returns:
        the result of the delegate method call on the EJB, but wrapped in a promise, as all the provider methods in joynr are declared that way.
        Throws:
        Throwable