Class UnicastWrapper

  • Direct Known Subclasses:
    SpringRemotingWrapper

    public class UnicastWrapper
    extends RemoteObjectWrapper
    The UnicastWrapper class extends RemoteObjectWrapper and is used for wrapping UnicastRef.
    Author:
    Tobias Neitzel (@qtc_de)
    • Field Detail

      • objID

        public final ObjID objID
        associated ObjID
      • endpoint

        public final sun.rmi.transport.tcp.TCPEndpoint endpoint
        associated TCPEndpoint
      • unicastRef

        public final sun.rmi.server.UnicastRef unicastRef
        associated UnicastRef
      • duplicates

        public List<UnicastWrapper> duplicates
        list of bound names implementing the same interface
    • Constructor Detail

      • UnicastWrapper

        public UnicastWrapper​(Remote remoteObject,
                              String boundName,
                              sun.rmi.server.UnicastRef ref)
                       throws IllegalArgumentException,
                              IllegalAccessException,
                              NoSuchFieldException,
                              SecurityException
        Create a new UnicastWrapper from a RemoteObject. The third argument seems superfluous, as the UnicastRef is already contained within the remote object. However, UnicastWrappers should be created by using the getInstance method of RemoteObjectWrapper. This one extracts the reference from the remote object anyway to check whether it is a UnicastRef or ActivatableRef. Therefore, we can reuse this extracted ref instead of performing another extraction.
        Parameters:
        remoteObject - Incoming RemoteObject, usually obtained by an RMI lookup call
        boundName - The bound name that the remoteObject uses inside the RMI registry
        ref - UnicastRef to build the wrapper around
        Throws:
        IllegalArgumentException - if reflective access fails
        IllegalAccessException - if reflective access fails
        NoSuchFieldException - if reflective access fails
        SecurityException - if reflective access fails
    • Method Detail

      • getHost

        public String getHost()
        Returns the host name associated with the UnicastWrapper.
        Returns:
        host name the Wrapper is pointing to
      • getPort

        public int getPort()
        Returns the port number associated with the UnicastWrapper.
        Returns:
        port number the Wrapper is pointing to
      • getTarget

        public String getTarget()
        Returns a string that combines the host name and port in the 'host:port' notation.
        Returns:
        host:port the Wrapper is pointing to
      • hasDuplicates

        public boolean hasDuplicates()
        Checks whether the Wrapper has any duplicates (other remote objects that implement the same remote interface).
        Returns:
        true if duplicates are present
      • addDuplicate

        public void addDuplicate​(UnicastWrapper o)
        Add a duplicate to the UnicastWrapper. This should be a wrapper that implements the same remote interface as the original wrapper.
        Parameters:
        o - duplicate UnicastWrapper that implements the same remote interface
      • getDuplicateBoundNames

        public String[] getDuplicateBoundNames()
        Iterates over the list of registered duplicates and returns the associated bound names as an array.
        Returns:
        array of String that contains duplicate bound names
      • handleDuplicates

        public static UnicastWrapper[] handleDuplicates​(UnicastWrapper[] list)
        Takes a list of UnicastWrapper and looks for duplicates within it. The return value is a list of unique UnicastWrapper that have the corresponding duplicates assigned.
        Parameters:
        list - UnicastWrapper to search for duplicates
        Returns:
        Unique UnicastWrapper with duplicates assigned
      • hasDuplicates

        public static boolean hasDuplicates​(UnicastWrapper[] list)
        Takes a list of UnicastWrapper and checks whether one of them contains duplicates.
        Parameters:
        list - UnicastWrapper to check for duplicates
        Returns:
        true if at least one UnicastWrapper contains a duplicate