Class JMapBaseNetworkConnection

java.lang.Object
com.kheops.jmap.net.JMapConnection
com.kheops.jmap.net.JMapBaseNetworkConnection
All Implemented Interfaces:
KSchedulerClient
Direct Known Subclasses:
JMapNetworkConnection, JMapSrvConnection

public abstract class JMapBaseNetworkConnection extends JMapConnection implements KSchedulerClient
Abstract superclass over JMapConnection. Encapsulates common instructions and functionalities between JMapNetworkConnection and JMapSrvConnection.
Since:
7.0
  • Field Details

    • DEFAULT_DIRECT_CONNECTION_TIMEOUT

      public static final int DEFAULT_DIRECT_CONNECTION_TIMEOUT
      See Also:
    • DEFAULT_PROXY_CONNECTION_TIMEOUT

      public static final int DEFAULT_PROXY_CONNECTION_TIMEOUT
      See Also:
    • DEFAULT_READ_TIMEOUT

      public static final int DEFAULT_READ_TIMEOUT
      See Also:
    • READ_TIMEOUT

      @Deprecated public static final int READ_TIMEOUT
      Deprecated.
      Use JMapBaseNetworkConnection.DEFAULT_READ_TIMEOUT
      See Also:
    • JMAP_PROXY_SERVLET_PATH

      public static final String JMAP_PROXY_SERVLET_PATH
      See Also:
    • CONN_PROXY_ALWAYS

      @Deprecated public static final int CONN_PROXY_ALWAYS
      Deprecated.
      since JMap 3.1. Use CONN_PROXY instead.
      Connection mode constant. Specifies that the proxy should always be used.
      See Also:
    • CONN_DIRECT_ALWAYS

      @Deprecated public static final int CONN_DIRECT_ALWAYS
      Deprecated.
      since JMap 3.1. This connection type is no longer supported. The default behavior for the direct connection is to switch for the proxy mode if the connection can't be made. Use CONN_DIRECT instead.
      Connection mode constant. Specifies that a direct socket connection should always be used.
      See Also:
    • CONN_PROXY_IFNEEDED

      @Deprecated public static final int CONN_PROXY_IFNEEDED
      Deprecated.
      since JMap 3.1. Use CONN_DIRECT instead.
      Connection mode constant. Specifies that a direct socket connection should tried first but if it fails, proxy should be used.
      See Also:
    • CONNECTION_DIRECT

      public static final int CONNECTION_DIRECT
      Connection mode constant. Specifies that a direct socket connection should tried first but if it fails, proxy should be used.
      See Also:
    • CONNECTION_PROXY

      public static final int CONNECTION_PROXY
      Connection mode constant. Specifies that the proxy should always be used.
      See Also:
    • protocol

      protected String protocol
    • host

      protected String host
    • proxyPath

      protected String proxyPath
    • serverId

      protected String serverId
    • port

      protected int port
    • httpPort

      protected int httpPort
    • directConnectionTimeout

      protected int directConnectionTimeout
    • proxyConnectionTimeout

      protected int proxyConnectionTimeout
    • connectionMode

      protected int connectionMode
    • useProxy

      protected boolean useProxy
    • workingOffline

      protected boolean workingOffline
    • autoReconnect

      protected boolean autoReconnect
    • autoSendPendingRequests

      protected boolean autoSendPendingRequests
    • connectionListeners

      protected List<JMapConnectionListener> connectionListeners
    • verbose

      protected boolean verbose
  • Constructor Details

    • JMapBaseNetworkConnection

      public JMapBaseNetworkConnection()
  • Method Details

    • open

      public abstract void open(String host, int port) throws Exception
      Throws:
      Exception
    • open

      public abstract void open(String host, int port, String proxyPath, String serverId) throws Exception
      Throws:
      Exception
    • open

      public abstract void open(String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) throws Exception
      Throws:
      Exception
    • open

      public abstract void open(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) throws Exception
      Throws:
      Exception
    • isOpen

      public boolean isOpen()
    • setVerbose

      public void setVerbose(boolean verbose)
      Parameters:
      verbose - The verbose mode
    • getVerbose

      public boolean getVerbose()
      Returns:
      Returns the verbose mode
    • addConnectionListener

      public void addConnectionListener(JMapConnectionListener listener)
      Parameters:
      listener -
    • removeConnectionListener

      public void removeConnectionListener(JMapConnectionListener listener)
    • fireConnectionEvent

      protected void fireConnectionEvent(JMapRequest lastRequest, boolean wasOffline)
    • fireDisconnectionEvent

      protected void fireDisconnectionEvent(JMapRequest lastRequest)
    • fireConnectionActivity

      protected void fireConnectionActivity(JMapConnectionRequestEvent event, boolean active)
    • goOffline

      public abstract boolean goOffline()
    • goOnline

      public abstract boolean goOnline()
    • isWorkingOffline

      public boolean isWorkingOffline()
      Returns the connection state.
      Returns:
      true if offline; false if online
    • isAutoReconnect

      public boolean isAutoReconnect()
      Returns the state of the auto reconnect. Note : false will be returned if offline mode is not allowed.
      Returns:
      current state
    • setAutoReconnect

      public void setAutoReconnect(boolean autoReconnect)
      Sets the state of the auto reconnect. Is the connection will try to reconnect each time a request is asked? Note : Setting this flag at true has no effects if the offline mode is not allowed.
      Parameters:
      autoReconnect -
    • isAutoSendPendingRequests

      public boolean isAutoSendPendingRequests()
      Returns the state of the auto send pending requests.
      Returns:
      current state
    • setAutoSendPendingRequests

      public void setAutoSendPendingRequests(boolean autoSendPendingRequests)
      Sets the state of the auto send pending requests. If true, all pending requests will be executed at next reconnection.
      Parameters:
      autoSendPendingRequests -
    • schCallback

      public void schCallback(int jobId)
      Called by the scheduler to ping the server periodically.
      Specified by:
      schCallback in interface KSchedulerClient
      Parameters:
      jobId - the jobId of the job that has been called back
    • destroy

      public void destroy()
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable