Class AbstractConnector.DefaultConnectionCache

java.lang.Object
org.scictrl.csshell.AbstractConnector.DefaultConnectionCache
All Implemented Interfaces:
ConnectionCache<C>
Enclosing class:
AbstractConnector<C extends Connection<?,?,?>>

public class AbstractConnector.DefaultConnectionCache extends Object implements ConnectionCache<C>
Default implementation of connection cache interface. Uses weak references.
Author:
igor@scictrl.com
  • Constructor Details

    • DefaultConnectionCache

      public DefaultConnectionCache()
      Constructor.
  • Method Details

    • add

      public C add(C ch)
      Description copied from interface: ConnectionCache
      Adds connection to the cache by it's name. If any connection by same name already exists, it is released and returned.
      Specified by:
      add in interface ConnectionCache<C extends Connection<?,?,?>>
      Parameters:
      ch - the connection to be placed in cache
      Returns:
      previous connection with this name, if it was any, otherwise null
    • remove

      public C remove(String name)
      Description copied from interface: ConnectionCache
      Removes connection from cache.
      Specified by:
      remove in interface ConnectionCache<C extends Connection<?,?,?>>
      Parameters:
      name - the name of connection to be removed from cache
      Returns:
      the removed connection, is exists, otherwise null
    • get

      public C get(String name)
      Description copied from interface: ConnectionCache
      Returns connection, which has provided name. Or null if no such connection.
      Specified by:
      get in interface ConnectionCache<C extends Connection<?,?,?>>
      Parameters:
      name - the connection name
      Returns:
      the connection, or null
    • cleanup

      public void cleanup()
      Description copied from interface: ConnectionCache
      Removes all dead references and deleted connections.
      Specified by:
      cleanup in interface ConnectionCache<C extends Connection<?,?,?>>