Class AbstractConnection

java.lang.Object
org.processmining.framework.connections.impl.AbstractConnection
All Implemented Interfaces:
Connection
Direct Known Subclasses:
AbstractStrongReferencingConnection, GraphLayoutConnection

public abstract class AbstractConnection extends Object implements Connection
Note that for all implementations of Connection, it is essential to consider memory consumption. Connections are kept in the framework for as long as the isRemoved() method returns false, hence this method should return true at the earliest occasion. The AbstractConnection keeps weak references to the objects added through the put methods. As soon as one of these objects is collected by the garbage collector, then this connection becomes removed. Therefore, it is essential that subclasses of the AbstractConnection do not keep pointers to these objects, or at least only keep weak references. This class is annotated with @ConnectionAnnotation. Therefore, none of the implementing classes have to do so explicitly.
Author:
bfvdonge
  • Field Details

  • Constructor Details

    • AbstractConnection

      protected AbstractConnection(String label)
  • Method Details

    • setManager

      public void setManager(ConnectionManager manager)
      Description copied from interface: Connection
      Sets the manager for the connection. This method is called by the connection manager as soon as this connection is added to that manager. A connection should keep a reference to the manager only in a transient field.
      Specified by:
      setManager in interface Connection
    • getLabel

      public String getLabel()
      Description copied from interface: Connection
      Return the label of the connection
      Specified by:
      getLabel in interface Connection
      Returns:
    • containsObjects

      public boolean containsObjects(Object... objects)
      Description copied from interface: Connection
      Return true if all objects given as parameter are contained in the connection. Multiplicities are taken into account, however order is abstracted from
      Specified by:
      containsObjects in interface Connection
      Parameters:
      objects - the objects to check for
      Returns:
    • containsObjects

      public boolean containsObjects(Collection<?> objects)
      Description copied from interface: Connection
      Return true if all objects given as parameter are contained in the connection. Multiplicities are taken into account, i.e. each object should occur as often as it is returned by the iterator of the given collection however order is abstracted from
      Specified by:
      containsObjects in interface Connection
      Parameters:
      objects - the objects as a collection
      Returns:
    • isRemoved

      public boolean isRemoved()
      Description copied from interface: Connection
      Return true if one of the objects connected by this connection no longer exists, i.e. it is collected by the garbage collector.
      Specified by:
      isRemoved in interface Connection
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getObjects

      public MultiSet<Object> getObjects()
      Description copied from interface: Connection
      Return all objects contained in this connection, without their labels. By contract, this method should always return the same set of objects after the connections was created, i.e. connections may only be changed by changing the contents of the objects, but not by changing the pointers.
      Specified by:
      getObjects in interface Connection
      Returns:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getID

      public ConnectionID getID()
      Description copied from interface: Connection
      Return the ID of the connection.
      Specified by:
      getID in interface Connection
      Returns:
    • getObjectWithRole

      public <T> T getObjectWithRole(String role)
      Description copied from interface: Connection
      Return the object with the given role in this connection The type of the returned object is T. However, no checks have to be performed to see if the cast can be made. It is up to the calling method to ensure this cast is safe.
      Specified by:
      getObjectWithRole in interface Connection
      Type Parameters:
      T - The type of object that should be returned.
      Parameters:
      role - the role the returned object has to have
      Returns:
      the object attached to this role (not null).
    • getRoles

      public Set<String> getRoles()
      Description copied from interface: Connection
      Return the roles of all objects in this connection
      Specified by:
      getRoles in interface Connection
      Returns:
    • put

      protected <T> WeakReference<T> put(String role, T o)
    • remove

      protected void remove(String role)
    • get

      protected Object get(String role)
    • getMapping

      protected Map<String,WeakReference<?>> getMapping()
    • remove

      public void remove()
      Removes the connection. After calling this method, isRemoved()returns true;
      Specified by:
      remove in interface Connection
    • setLabel

      public void setLabel(String name)
      sets the label of the connection to the new name
      Specified by:
      setLabel in interface Connection
      Parameters:
      name -
    • updated

      public void updated()
      Description copied from interface: Connection
      This method should be called as soon as the connection is changed, for example if the label changed, or if the contents of one of the connected objects changes. By calling this method, the connection manager should be notified.
      Specified by:
      updated in interface Connection