Class JavassistProxyService

    • Constructor Detail

      • JavassistProxyService

        public JavassistProxyService()
    • Method Detail

      • supportsFeature

        public boolean supportsFeature​(ProxyService.Feature feature)
        Description copied from interface: ProxyService
        If the concrete service supports specified feature.
        Specified by:
        supportsFeature in interface ProxyService
        Parameters:
        feature - feature to test
        Returns:
        if service supports feature
      • instantiate

        public <I> I instantiate​(ClassLoader classLoader,
                                 Class<?> baseClass,
                                 List<? extends Class<?>> interfaces,
                                 InvocationHandler<? super MethodInvocation<I>> handler)
                          throws ProxyService.UnsupportedFeatureException
        Description copied from interface: ProxyService
        Creates proxy instance.

        This method either creates new proxy class, or reuses one that matches. This proxy class extends baseClass and implements interfaces, and is created in classLoader. After creating this class, its object is instantiated. The object will delegate every call that it receives to specified InvocationHandler. The only exception is Object.finalize(), which must be ignored.

        This method assumes that the arguments were correctly prepared:

        • baseClass is not final
        • baseClass is actually a class (not an interface)
        • baseClass and each element of interfaces has classloader exactly classLoader
        • Each element in interfaces is an interface (not a class)
        Specified by:
        instantiate in interface ProxyService
        Type Parameters:
        I - type of proxy
        Parameters:
        classLoader - classloader used to create proxy class
        baseClass - proxy superclass, cannot be final, must be a class
        interfaces - additional interfaces that proxy class should implement
        handler - invocation handler to pass method execution for this proxy instance
        Returns:
        proxy instance
        Throws:
        ProxyService.UnsupportedFeatureException - when this service cannot create proxy with requested parameters, because it doesn't support some feature required to do so