de.esprit.netsuite.netdata

## Class AbstractServerModel<S extends ServerContext>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<S>
    - - de.esprit.netsuite.server.AbstractServerObject<S>
      - - de.esprit.netsuite.netdata.AbstractServerModel<S>

- All Implemented Interfaces:
    ApplicationObject<S>, CloseableComponent, Initializable, SimpleLogSupport, Dumpable, LastAccessed, ServerObject<S>, java.lang.AutoCloseable
  Direct Known Subclasses:
    AbstractSessionServerModel

      public abstract class AbstractServerModel<S extends ServerContext>
      extends AbstractServerObject<S>
      implements LastAccessed, CloseableComponent, Initializable

  This is a base implementation for a server side model which provides simple support for client access tracking.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractServerModel(S serverCtx)`
    `AbstractServerModel(S serverCtx, java.lang.String modelName)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkInitialized()` Checks whether initialization has yet been done and throws an `NotInitializedException` if not.
    `void` | `close()` Is called on model when the `ServerContext` is closed.
    `java.sql.Timestamp` | `getCreatedTs()`
    `java.sql.Timestamp` | `getLastAccessedTs()` Returns the timestamp of last client access
    `SessionId` | `getLastAccessorId()` Tells which client has last accessed the model
    `java.lang.String` | `getModelName()` Returns a name for identification
    `void` | `init()` Is called on model after the `ServerContext` has been constructed successfully.
    `boolean` | `isInitialized()` Tells whether initialization has yet been done.
    `protected void` | `sendChangeEvent(NetEvent event)` This method should be called for any change on the model in order to notify all clients.
    `protected void` | `setInitialized()`
    `void` | `setLastAccessorId(SessionId sessId)` Sets the sessionId of the client who has last accessed the model

    - ### Methods inherited from class de.esprit.netsuite.server.AbstractServerObject

      `checkPermission, getServerConfig, getServerContext, getStatisticManager, toString`

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

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

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

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

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

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

- - ### Constructor Detail

    - #### AbstractServerModel

          public AbstractServerModel(S serverCtx)

    - #### AbstractServerModel

          public AbstractServerModel(S serverCtx,
                             java.lang.String modelName)

  - ### Method Detail

    - #### getModelName

          public final java.lang.String getModelName()

      Returns a name for identification

    - #### init

          public void init()
                    throws java.lang.Exception

      Is called on model after the `ServerContext` has been constructed successfully. This default implementation just logs that the model has been initialized.
      Specified by:
        `init` in interface `Initializable`
      Throws:
        `java.lang.Exception`

    - #### setInitialized

          protected final void setInitialized()

    - #### isInitialized

          public final boolean isInitialized()

      Description copied from interface: `Initializable`
      Tells whether initialization has yet been done.
      Specified by:
        `isInitialized` in interface `Initializable`

    - #### checkInitialized

          public final void checkInitialized()
                                      throws NotInitializedException

      Description copied from interface: `Initializable`
      Checks whether initialization has yet been done and throws an `NotInitializedException` if not.
      Specified by:
        `checkInitialized` in interface `Initializable`
      Throws:
        `NotInitializedException`

    - #### close

          public void close()

      Is called on model when the `ServerContext` is closed. This default implementation just logs that the model has been destroyed.
      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### getCreatedTs

          public final java.sql.Timestamp getCreatedTs()

    - #### getLastAccessedTs

          public final java.sql.Timestamp getLastAccessedTs()

      Description copied from interface: `LastAccessed`
      Returns the timestamp of last client access
      Specified by:
        `getLastAccessedTs` in interface `LastAccessed`

    - #### getLastAccessorId

          public final SessionId getLastAccessorId()

      Description copied from interface: `LastAccessed`
      Tells which client has last accessed the model
      Specified by:
        `getLastAccessorId` in interface `LastAccessed`

    - #### setLastAccessorId

          public final void setLastAccessorId(SessionId sessId)

      Description copied from interface: `LastAccessed`
      Sets the sessionId of the client who has last accessed the model
      Specified by:
        `setLastAccessorId` in interface `LastAccessed`

    - #### sendChangeEvent

          protected void sendChangeEvent(NetEvent event)

      This method should be called for any change on the model in order to notify all clients. It also ensures the last accessor to be stored in the model.

Copyright © 2014 EsprIT-Systems. All Rights Reserved.