de.esprit.netsuite.server.abo

## Class ABOServerCache

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<S>
    - - de.esprit.netsuite.server.AbstractServerObject<ServerContext>
      - - de.esprit.netsuite.server.abo.ABOServerCache

- All Implemented Interfaces:
    ApplicationObject<ServerContext>, CloseableComponent, SimpleLogSupport, Dumpable, ServerObject<ServerContext>, java.lang.AutoCloseable

      public class ABOServerCache
      extends AbstractServerObject<ServerContext>
      implements CloseableComponent

  This is a cache for all accessed `AliveBusinessObject` instances. An internal `ABOAccessList` maintains the `SessionId`s currently accessing ABOs. Only such clients currently accessing an ABO will get change notifications.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ABOServerCache(ServerContext serverCtx)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkPermission(SessionId sessionId, PermissionControlled obj, EspritPermission action)` Checks whether the current user has permission on the given object for the given action.
    `void` | `clear()` Removes all ABOs from the cache sending according client notifications.
    `void` | `close()`
    `protected int` | `configureDumpHeadlineLength()`
    `<A extends AliveBusinessObject> A` | `createABO(SessionId sessionId, A abo)` Creates the ABO and sends a client notification.
    `boolean` | `deleteABO(SessionId sessionId, AliveBusinessObject abo)` Deletes the ABO from the cache and sends a client notification.
    `void` | `dropABO(SessionId sessionId, PrimaryKey pk)` Drops the given `SessionId` from the ABOs access list.
    `int` | `dumpCacheContent(DumpString s)`
    `<A extends AliveBusinessObject> A` | `fetchABO(SessionId sessionId, PrimaryKey pk)` Feches the ABO from the cache.
    `<T extends AbstractSingletonABO> T` | `findCachedABO(java.lang.Class<? extends AbstractABO> aboClass)` Finds the according SingletonABO in the cache
    `<T extends AliveBusinessObject> T` | `findCachedABO(PrimaryKey pk)` Returns the cached ABO matching the `PrimaryKey`.
    `AliveBusinessObject` | `findCachedABO(SessionId sessionId, PrimaryKey pk)` Returns the cached ABO matching the `PrimaryKey`.
    `<A extends AliveBusinessObject> java.util.List<A>` | `findCachedABOs(SessionId sessionId, java.lang.Class<A> aboClass, ABOFilter filter)` Returns a list of ABOs matching the given type and condition.
    `ABOAccessList` | `getABOAccessList()` Returns a snapshot copy of the current access list.
    `int` | `getABOInstanceCount(PrimaryKey pk)` Counts the number of cached instances of the ABO-type given in the primary key.
    `java.util.Collection<AliveBusinessObject>` | `getAllCachedABOs()` Returns a snapshot collection of all ABOs currently in the cache.
    `int` | `getCachedABOCount()` Returns the number of ABOs currently in the cache.
    `java.util.Collection<AliveBusinessObject>` | `getCachedABOs(SessionId sessionId)` Returns all ABOs currently accessed by the given `SessionId`
    `void` | `putABO(AliveBusinessObject abo)` Puts the given ABO into the cache and sends a client notification.
    `void` | `updateABO(SessionId sessionId, AliveBusinessObject abo)` Updates the given ABO and sends a client notification.

    - ### 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

      `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

    - #### ABOServerCache

          public ABOServerCache(ServerContext serverCtx)

  - ### Method Detail

    - #### getCachedABOCount

          public int getCachedABOCount()

      Returns the number of ABOs currently in the cache.

    - #### getCachedABOs

          public java.util.Collection<AliveBusinessObject> getCachedABOs(SessionId sessionId)

      Returns all ABOs currently accessed by the given `SessionId`

    - #### getAllCachedABOs

          public java.util.Collection<AliveBusinessObject> getAllCachedABOs()

      Returns a snapshot collection of all ABOs currently in the cache.

    - #### getABOInstanceCount

          public int getABOInstanceCount(PrimaryKey pk)
                                  throws java.lang.ClassNotFoundException

      Counts the number of cached instances of the ABO-type given in the primary key.
      Throws:
        `java.lang.ClassNotFoundException`

    - #### getABOAccessList

          public ABOAccessList getABOAccessList()

      Returns a snapshot copy of the current access list.

    - #### putABO

          public void putABO(AliveBusinessObject abo)

      Puts the given ABO into the cache and sends a client notification. If the ABO existed already in the cache it will be replaced and notified as an ABO MODIFY, otherwise as an ABO CREATE.

    - #### findCachedABO

          public <T extends AbstractSingletonABO> T findCachedABO(java.lang.Class<? extends AbstractABO> aboClass)

      Finds the according SingletonABO in the cache

    - #### findCachedABO

          public <T extends AliveBusinessObject> T findCachedABO(PrimaryKey pk)

      Returns the cached ABO matching the `PrimaryKey`. This is an informative fetch only, it does NOT affect the accesslist.

    - #### findCachedABO

          public AliveBusinessObject findCachedABO(SessionId sessionId,
                                          PrimaryKey pk)

      Returns the cached ABO matching the `PrimaryKey`. The given `SessionId` is registered in the accesslist, making the ABO online.

    - #### fetchABO

          public <A extends AliveBusinessObject> A fetchABO(SessionId sessionId,
                                                   PrimaryKey pk)
                                                 throws java.lang.Exception

      Feches the ABO from the cache. If the ABO does not exist it is being instantiated on the server. The given `SessionId` is registered in the access-list, making the ABO online.
      Throws:
        `java.lang.Exception`

    - #### createABO

          public <A extends AliveBusinessObject> A createABO(SessionId sessionId,
                                                    A abo)
                                                  throws java.lang.Exception

      Creates the ABO and sends a client notification. A persistent ABO will perform a database INSERT. The given `SessionId` is registered in the access-list, making the ABO online.
      Throws:
        `java.lang.Exception`

    - #### updateABO

          public void updateABO(SessionId sessionId,
                       AliveBusinessObject abo)
                         throws java.lang.Exception

      Updates the given ABO and sends a client notification. A persistent ABO will perform a database MODIFY. The given `SessionId` is registered in the access-list, making the ABO online.
      Throws:
        `java.lang.Exception`

    - #### dropABO

          public void dropABO(SessionId sessionId,
                     PrimaryKey pk)

      Drops the given `SessionId` from the ABOs access list. If the ABO remains without any accessing sessions and is not declared cache-resident, it will be removed from the cache without client notification.

    - #### deleteABO

          public boolean deleteABO(SessionId sessionId,
                          AliveBusinessObject abo)
                            throws java.lang.Exception

      Deletes the ABO from the cache and sends a client notification. A persistent ABO will perform a database DELETE.
      Returns:
        true if the ABO was found in the cache and deletion was successful.
      Throws:
        `java.lang.Exception`

    - #### clear

          public void clear()

      Removes all ABOs from the cache sending according client notifications.

    - #### close

          public void close()

      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### checkPermission

          protected final void checkPermission(SessionId sessionId,
                             PermissionControlled obj,
                             EspritPermission action)
                                        throws PermissionException

      Checks whether the current user has permission on the given object for the given action.
      Throws:
        `PermissionException`

    - #### findCachedABOs

          public <A extends AliveBusinessObject> java.util.List<A> findCachedABOs(SessionId sessionId,
                                                                         java.lang.Class<A> aboClass,
                                                                         ABOFilter filter)

      Returns a list of ABOs matching the given type and condition.

    - #### configureDumpHeadlineLength

          protected int configureDumpHeadlineLength()

      Overrides:
        `configureDumpHeadlineLength` in class `DumpableObject`

    - #### dumpCacheContent

          public int dumpCacheContent(DumpString s)

Copyright © 2014 EsprIT-Systems. All Rights Reserved.