Interface WrappingProxy

  • All Known Implementing Classes:
    de.aristaflow.adept2.model.common.defaultimplementation.DefaultWrappingProxy, LocalisationResolver

    public interface WrappingProxy
    This interface resembles Wrapper. It is usually used for InvocationHandler to allow for unwrapping their wrapped object instance. Unwrapping is required within the communication (a proxy may itself not be serialisable) but also allows to unwrap localised objects and access the fields directly.

    Subclasses which implement InvocationHandler.invoke(Object, java.lang.reflect.Method, Object[]) have to make sure that the methods of this interface are handled as normal method calls instead of the interception logic for which the proxy exists.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean isWrapperFor​(Class<?> iface)
      Gets whether this WrappingProxy wraps an object instance that is an instance of the designated class.
      Object unwrap()
      Gets the object instance that is wrapped by this proxy.
      <T> T unwrap​(Class<T> iface)
      Gets an object instance that is an instance of the designated class.
    • Method Detail

      • unwrap

        Object unwrap()
        Gets the object instance that is wrapped by this proxy. This simply unwraps, so there are no type checks. In case of a cascaded proxy, this may even be an instance of WrappingProxy again.
        Returns:
        The object that is wrapped by a proxy. Since this object has to exist, null will never be returned.
      • isWrapperFor

        boolean isWrapperFor​(Class<?> iface)
        Gets whether this WrappingProxy wraps an object instance that is an instance of the designated class. This also applies transitively, that is, the wrapped object instance may be a WrappingProxy that wraps an instance of the designated class.
        Parameters:
        iface - The interface which to check for whether this proxy wraps an object instance of.
        Returns:
        Whether the object instance wrapped by this WrappingProxy is an instance (or a WrappingProxy) of the designated class/interface.
      • unwrap

        <T> T unwrap​(Class<T> iface)
        Gets an object instance that is an instance of the designated class. This will be the first (transitively) wrapped object instance that is an instance of the designated class. In this case this unwraps. However, if there is no such wrapped object but this (WrappingProxy) instance itself is an instance of this class, this will be returned, thus not unwrapping. If neither this object instance nor the wrapped object instance nor the possibly further wrapped object instances are instances of the designated class, null will be returned.
        Parameters:
        iface - The interface for which to get an unwrapped object instance of.
        Returns:
        The first directly or indirectly wrapped object instance that implements the designated class. If this object instance implements it, this will be returned. If no object instance of the designated class is (transitively) found, null will be returned.