Interface ProxyService

    • Method Detail

      • supportsFeature

        boolean supportsFeature​(ProxyService.Feature feature)
        If the concrete service supports specified feature.
        Parameters:
        feature - feature to test
        Returns:
        if service supports feature
      • supportsAllFeatures

        default boolean supportsAllFeatures​(ProxyService.Feature... features)
        If the concrete service supports all of specified features.
        Parameters:
        features - feature set to test
        Returns:
        if service supports features
      • instantiate

        <I> I instantiate​(ClassLoader classLoader,
                          Class<?> baseClass,
                          List<? extends Class<?>> interfaces,
                          InvocationHandler<? super MethodInvocation<I>> handler)
                   throws ProxyService.UnsupportedFeatureException
        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)
        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