de.esprit.netsuite.server.coserver

## Class CoClientContext

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.log.LogSupportAdapter
    - - de.esprit.appsuite.launch.ApplicationContext
      - - de.esprit.netsuite.client.ClientContext
        - - de.esprit.netsuite.server.coserver.CoClientContext

- All Implemented Interfaces:
    ErrorHandler, Initializable, Exitable, LogSupport, Dumpable, RequestHandler, ServerObject, java.io.Closeable, java.lang.AutoCloseable

      public class CoClientContext
      extends ClientContext
      implements RequestHandler

  This class encapsulates a connection to a co-server.
  Author:
    Rainer Buesch

- - ### Field Summary

    - ### Fields inherited from class de.esprit.appsuite.launch.ApplicationContext

      `isExitOnClose`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CoClientContext(ServerContext serverCtx, ServerHost coSrvHost)` This constructor is used for temporary CoServers connections
    `CoClientContext(ServerContext serverCtx, ServerHost coSrvHost, boolean isReconnectMode)` This constructor is used for permanent fail-safe CoServer connections

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Overridden to disconnect only!!!
    `protected ErrorHandler` | `createErrorHandler()` Creates the `ConsoleErrorHandler` instance used to hande errors of Agents and ClientCommands
    `protected License` | `createLicense()`
    `protected ServerNotificationHandler` | `createServerNotificationHandler()` Creates the `ServerNotificationHandler` instance used to handle received ServerMessages
    `boolean` | `exit()` Exits the VM by default.
    `java.lang.String` | `getCoClientName()`
    `java.lang.String` | `getCoServerName()`
    `ServerContext` | `getServerContext()` Returns the ServerContext of the server this client is running in.
    `CoSessionId` | `getSessionId()` Return a never null `CoSessionId`.
    `NetResponse` | `handleRequest(NetRequest request, NetResponse response)`
    `void` | `init()` Performs the initialization of this class.
    `protected boolean` | `isDefaultContext()` If there are several contexts within the same VM then only one of them can be the default-context.
    `boolean` | `isGuiClient()` Tells whether this client has a GUI
    `void` | `setMainFrame(ApplicationMainFrame mainFrame)` Sets the MainFrame for this application.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.

    - ### Methods inherited from class de.esprit.netsuite.client.ClientContext

      `cancelTask, cancelTask, createClientConnector, createClientInfo, createTaskManager, getABOManager, getAdminActionValidator, getAgentParamsCache, getClientCache, getClientConfig, getClientConnector, getMainFrame, getNetActionValidator, getServerMessageHandler, getTaskManager, getUserActionValidator, getUserCache, isCoClient, loadTranslations, readClientInfo, toDumpString`

    - ### Methods inherited from class de.esprit.appsuite.launch.ApplicationContext

      `checkInitialized, confirmCancelAllAsyncActivity, createUncaughtExceptionHandler, getApplicationConfig, getApplicationName, getCustomVersion, getDatabase, getErrorHandler, getEspritVersion, getJavaVersionManager, getLicense, getSupportedLanguages, getTextEditor, hasMainFrame, isClosed, isInitialized, registerForClose, setDatabase, setExitOnClose, showError, showError, showError, showInfo, showInfo, showWarning, showWarning`

    - ### Methods inherited from class de.esprit.common.log.LogSupportAdapter

      `getLogChannel, getLogLevel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel, setLogLevel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CoClientContext

          public CoClientContext(ServerContext serverCtx,
                         ServerHost coSrvHost)

      This constructor is used for temporary CoServers connections

    - #### CoClientContext

          public CoClientContext(ServerContext serverCtx,
                         ServerHost coSrvHost,
                         boolean isReconnectMode)

      This constructor is used for permanent fail-safe CoServer connections

  - ### Method Detail

    - #### init

          public void init()
                    throws java.lang.Exception

      Description copied from interface: `Initializable`
      Performs the initialization of this class. Note that the implementation should maintain an isInitialized flag which must be set when initialization has completed.
      Specified by:
        `init` in interface `Initializable`
      Overrides:
        `init` in class `ClientContext`
      Throws:
        `java.lang.Exception`

    - #### createServerNotificationHandler

          protected final ServerNotificationHandler createServerNotificationHandler()

      Creates the `ServerNotificationHandler` instance used to handle received ServerMessages
      Specified by:
        `createServerNotificationHandler` in class `ClientContext`

    - #### createErrorHandler

          protected final ErrorHandler createErrorHandler()

      Creates the `ConsoleErrorHandler` instance used to hande errors of Agents and ClientCommands
      Overrides:
        `createErrorHandler` in class `ApplicationContext`

    - #### isDefaultContext

          protected final boolean isDefaultContext()

      Description copied from class: `ApplicationContext`
      If there are several contexts within the same VM then only one of them can be the default-context. All logging output of Util.log* methods will be passed to the default-context.
      Overrides:
        `isDefaultContext` in class `ApplicationContext`
      See Also:
        `AppUtil.getDefaultContext()`

    - #### createLicense

          protected final License createLicense()
                                         throws java.lang.Exception

      Overrides:
        `createLicense` in class `ApplicationContext`
      Throws:
        `java.lang.Exception`

    - #### isGuiClient

          public final boolean isGuiClient()

      Description copied from class: `ApplicationContext`
      Tells whether this client has a GUI
      Overrides:
        `isGuiClient` in class `ApplicationContext`

    - #### setMainFrame

          public final void setMainFrame(ApplicationMainFrame mainFrame)

      Description copied from class: `ClientContext`
      Sets the MainFrame for this application.
      Overrides:
        `setMainFrame` in class `ClientContext`

    - #### handleRequest

          public NetResponse handleRequest(NetRequest request,
                                  NetResponse response)

      Specified by:
        `handleRequest` in interface `RequestHandler`

    - #### getCoServerName

          public final java.lang.String getCoServerName()

    - #### getCoClientName

          public final java.lang.String getCoClientName()

    - #### getSessionId

          public final CoSessionId getSessionId()

      Return a never null `CoSessionId`. Note that `CoSessionId` MUST exist even if the co-server is not connected but just configured!

    - #### getServerContext

          public ServerContext getServerContext()

      Returns the ServerContext of the server this client is running in.
      Specified by:
        `getServerContext` in interface `ServerObject`

    - #### close

          public void close()

      Overridden to disconnect only!!! Note that close() is called when a coServer was cleanly shut down. In this case the `CoClientReconnectorTask` will try to reconnect!
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `ApplicationContext`

    - #### exit

          public final boolean exit()

      Description copied from class: `ApplicationContext`
      Exits the VM by default. Should return false if the exit was anyhow prevented.
      Specified by:
        `exit` in interface `Exitable`
      Overrides:
        `exit` in class `ApplicationContext`
      Returns:
        false if the exit was actually prevented by any check

    - #### toString

          public ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `ClientContext`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.