de.esprit.netsuite.netdata.command

## Class ClientCommand<C extends ClientContext>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.util.TransferableObject
    - - de.esprit.netsuite.netdata.command.ClientCommand<C>

- All Implemented Interfaces:
    CancellableTask, Renderable, SimpleLogSupport, DeepCloneable, Dumpable, ClientObject<C>, DeliverableMessage, java.io.Serializable, java.lang.Cloneable
  Direct Known Subclasses:
    CancelClientCommand, CancelRemoteTaskCommand, CancelTransferCommand, ClientInfoCommand, ClientMessageCommand, ClientResetCommand, ClientShutdownCommand, ExAsyncClientCommand, LockReleaseCommand

      public abstract class ClientCommand<C extends ClientContext>
      extends TransferableObject
      implements ClientObject<C>, DeliverableMessage, CancellableTask, Renderable, SimpleLogSupport

  This is the base class for commands that can be sent to a client for execution
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientCommand(ServerContext serverCtx, SessionId toSessId, java.lang.Object argument)` Used if the server itself sends the command.
    `ClientCommand(SessionId fromSessId)`
    `ClientCommand(SessionId fromSessId, SessionId toSessId)`
    `ClientCommand(SessionId fromSessId, SessionId toSessId, java.lang.Object argument)` Used if the the command was caused by another client.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel()`
    `protected void` | `checkCancelled()` Checks whether the task was cancelled and throws a `CancellationException` just in case.
    `void` | `executeAsync()` This method is called by the clients `ClientCommandTask`.
    `void` | `executeSyncFinally()` This method is called after `executeAsync()` only if the async execution was successful.
    `java.lang.Object` | `getArgument()`
    `C` | `getClientContext()` Returns the the client runtime environment
    `java.lang.String` | `getCommandId()`
    `SessionId` | `getFromSession()`
    `LogChannel` | `getLogChannel()`
    `java.lang.String` | `getName()`
    `java.awt.Color` | `getRenderColor()`
    `javax.swing.Icon` | `getRenderIcon()`
    `java.lang.String` | `getRenderText()`
    `ServerContext` | `getServerContext()` Returns the ServerContext of the server in which this client is running as a co-client, or null if this client is not a co-client.
    `SessionId` | `getTargetSession()`
    `java.lang.String[]` | `getTargetUsers()`
    `boolean` | `hasFromSession()`
    `boolean` | `hasTargetSession()`
    `boolean` | `hasTargetUser()`
    `boolean` | `isCoClient()`
    `boolean` | `isGuiClient()`
    `boolean` | `isLogDebug()`
    `boolean` | `isLogVerbose()`
    `boolean` | `isSkipSender()` If this flag is set, then the message is sent to all sessions except the session of the sender himself.
    `void` | `logDebug(java.lang.String message)`
    `void` | `logDump(java.lang.String message)`
    `void` | `logError(java.lang.String message)`
    `void` | `logError(java.lang.String message, java.lang.Exception e)`
    `void` | `logFatal(java.lang.String message, java.lang.Exception e)`
    `void` | `logInfo(java.lang.String message)`
    `void` | `logVerbose(java.lang.String message)`
    `void` | `logWarning(java.lang.String message)`
    `void` | `setArgument(java.lang.Object argument)`
    `void` | `setcancelled()`
    `void` | `setClientContext(C clientCtx)`
    `void` | `setFromSession(SessionId sessId)`
    `void` | `setLogChannel(LogChannel logCh)`
    `void` | `setName(java.lang.String cmdName)`
    `void` | `setSkipSender(boolean notToSender)`
    `void` | `setTargetSession(SessionId sessId)`
    `void` | `setTargetUser(java.lang.String userName)`
    `void` | `setTargetUsers(java.lang.String[] userNames)`
    `void` | `sleepChecked(long millis)`
    `DumpString` | `toDumpString(DumpString s)` This method allows subclasses to add values to the existing DumpString of the superclass.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.
    `boolean` | `wasCancelled()` Tells whether ever an attempt has been made to cancel this task.

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

      `clone, deepClone`

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

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

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

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

- - ### Constructor Detail

    - #### ClientCommand

          public ClientCommand(SessionId fromSessId)

    - #### ClientCommand

          public ClientCommand(SessionId fromSessId,
                       SessionId toSessId)

    - #### ClientCommand

          public ClientCommand(ServerContext serverCtx,
                       SessionId toSessId,
                       java.lang.Object argument)

      Used if the server itself sends the command. Thus we have got no fromSession.

    - #### ClientCommand

          public ClientCommand(SessionId fromSessId,
                       SessionId toSessId,
                       java.lang.Object argument)

      Used if the the command was caused by another client.

  - ### Method Detail

    - #### isGuiClient

          public boolean isGuiClient()

    - #### isCoClient

          public boolean isCoClient()

    - #### setClientContext

          public void setClientContext(C clientCtx)

    - #### getClientContext

          public final C getClientContext()

      Description copied from interface: `ClientObject`
      Returns the the client runtime environment
      Specified by:
        `getClientContext` in interface `ClientObject<C extends ClientContext>`

    - #### getCommandId

          public java.lang.String getCommandId()

    - #### getName

          public java.lang.String getName()

    - #### setName

          public void setName(java.lang.String cmdName)

    - #### cancel

          public void cancel()

    - #### setcancelled

          public void setcancelled()

    - #### wasCancelled

          public boolean wasCancelled()

      Description copied from interface: `CancellableTask`
      Tells whether ever an attempt has been made to cancel this task.
      Specified by:
        `wasCancelled` in interface `CancellableTask`

    - #### sleepChecked

          public void sleepChecked(long millis)

    - #### checkCancelled

          protected final void checkCancelled()

      Checks whether the task was cancelled and throws a `CancellationException` just in case. This methods should be called within loops in order to react promptly on cancellation.

    - #### isSkipSender

          public boolean isSkipSender()

      Description copied from interface: `DeliverableMessage`
      If this flag is set, then the message is sent to all sessions except the session of the sender himself.
      Specified by:
        `isSkipSender` in interface `DeliverableMessage`

    - #### setSkipSender

          public void setSkipSender(boolean notToSender)

      Specified by:
        `setSkipSender` in interface `DeliverableMessage`

    - #### getServerContext

          public ServerContext getServerContext()

      Returns the ServerContext of the server in which this client is running as a co-client, or null if this client is not a co-client.

    - #### getTargetSession

          public SessionId getTargetSession()

      Specified by:
        `getTargetSession` in interface `DeliverableMessage`

    - #### setTargetSession

          public void setTargetSession(SessionId sessId)

      Specified by:
        `setTargetSession` in interface `DeliverableMessage`

    - #### hasTargetSession

          public boolean hasTargetSession()

      Specified by:
        `hasTargetSession` in interface `DeliverableMessage`

    - #### getFromSession

          public SessionId getFromSession()

      Specified by:
        `getFromSession` in interface `DeliverableMessage`

    - #### setFromSession

          public void setFromSession(SessionId sessId)

      Specified by:
        `setFromSession` in interface `DeliverableMessage`

    - #### hasFromSession

          public boolean hasFromSession()

      Specified by:
        `hasFromSession` in interface `DeliverableMessage`

    - #### getTargetUsers

          public java.lang.String[] getTargetUsers()

      Specified by:
        `getTargetUsers` in interface `DeliverableMessage`

    - #### setTargetUsers

          public void setTargetUsers(java.lang.String[] userNames)

      Specified by:
        `setTargetUsers` in interface `DeliverableMessage`

    - #### setTargetUser

          public void setTargetUser(java.lang.String userName)

      Specified by:
        `setTargetUser` in interface `DeliverableMessage`

    - #### hasTargetUser

          public boolean hasTargetUser()

      Specified by:
        `hasTargetUser` in interface `DeliverableMessage`

    - #### setArgument

          public void setArgument(java.lang.Object argument)

    - #### getArgument

          public java.lang.Object getArgument()

    - #### executeAsync

          public void executeAsync()
                            throws java.lang.Exception

      This method is called by the clients `ClientCommandTask`. You must NOT perform any GUI updates within this method. The default implementation is empty.
      Throws:
        `java.lang.Exception`

    - #### executeSyncFinally

          public void executeSyncFinally()
                                  throws java.lang.Exception

      This method is called after `executeAsync()` only if the async execution was successful. If the client has a GUI it runs in the EventDispatcher thread and thus may perform GUI updates. The default implementation is empty.
      Throws:
        `java.lang.Exception`

    - #### getRenderIcon

          public javax.swing.Icon getRenderIcon()

      Specified by:
        `getRenderIcon` in interface `Renderable`

    - #### getRenderText

          public java.lang.String getRenderText()

      Specified by:
        `getRenderText` in interface `Renderable`

    - #### getRenderColor

          public java.awt.Color getRenderColor()

      Specified by:
        `getRenderColor` in interface `Renderable`

    - #### getLogChannel

          public LogChannel getLogChannel()

      Specified by:
        `getLogChannel` in interface `SimpleLogSupport`

    - #### isLogDebug

          public boolean isLogDebug()

      Specified by:
        `isLogDebug` in interface `SimpleLogSupport`

    - #### isLogVerbose

          public boolean isLogVerbose()

      Specified by:
        `isLogVerbose` in interface `SimpleLogSupport`

    - #### logDebug

          public void logDebug(java.lang.String message)

      Specified by:
        `logDebug` in interface `SimpleLogSupport`

    - #### logDump

          public void logDump(java.lang.String message)

      Specified by:
        `logDump` in interface `SimpleLogSupport`

    - #### logError

          public void logError(java.lang.String message,
                      java.lang.Exception e)

      Specified by:
        `logError` in interface `SimpleLogSupport`

    - #### logError

          public void logError(java.lang.String message)

      Specified by:
        `logError` in interface `SimpleLogSupport`

    - #### logFatal

          public void logFatal(java.lang.String message,
                      java.lang.Exception e)

      Specified by:
        `logFatal` in interface `SimpleLogSupport`

    - #### logInfo

          public void logInfo(java.lang.String message)

      Specified by:
        `logInfo` in interface `SimpleLogSupport`

    - #### logVerbose

          public void logVerbose(java.lang.String message)

      Specified by:
        `logVerbose` in interface `SimpleLogSupport`

    - #### logWarning

          public void logWarning(java.lang.String message)

      Specified by:
        `logWarning` in interface `SimpleLogSupport`

    - #### setLogChannel

          public void setLogChannel(LogChannel logCh)

      Specified by:
        `setLogChannel` in interface `SimpleLogSupport`

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

    - #### toDumpString

          public DumpString toDumpString(DumpString s)

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

Copyright © 2014 EsprIT-Systems. All Rights Reserved.