Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.remoting.callback
Class CallbackStore

    java.lang.Object
      org.jboss.remoting.callback.CallbackStore

All Implemented Interfaces:
  CallbackStoreMBean, SerializableStore

    public class CallbackStore

extends java.lang.Object
implements CallbackStoreMBean

Acts as a persistent list which writes Serializable objects to disk and will retrieve them in same order in which they were added (FIFO). Each file will be named according to the current time (using System.currentTimeMillis() with the file suffix specified (see below). When the object is read and returned by calling the getNext() method, the file on disk for that object will be deleted. If for some reason the store VM crashes, the objects will still be available upon next startup.

The attributes to make sure to configure are:

file path - this determins which directory to write the objects. The default value is the property value of 'jboss.server.data.dir' and if this is not set, then will be 'data'. For example, might be /jboss/server/default/data.

file suffix - the file suffix to use for the file written for each object stored.

This is also a service mbean, so can be run as a service within JBoss AS or stand alone.

Author:
  Tom Elrod

Nested Class Summary
`class` | `CallbackStore.StoreFileFilter`

Field Summary
`static java.lang.String` | `FILE_PATH_KEY` Key for setting which directory to write the callback objects.
`static java.lang.String` | `FILE_SUFFIX_KEY` Key for setting the file suffix to use for the callback objects written to disk.

Constructor Summary
`CallbackStore()` Default store constructor.
`CallbackStore(boolean purgeOnDestroy)` Store constructor.

Method Summary
`void` | `add(java.io.Serializable object)` Persists the serializable object passed to the directory specified.
`void` | `create()` This is a no op method, but needed in order to be used as a service within JBoss AS.
`void` | `destroy()` If purgeOnDestroy is true, will remove files upon shutdown.
`java.lang.Object` | `getNext()` Will look through the files in the store directory for the oldest object serialized to disk, load it, delete the file, and return the deserialized object.
`boolean` | `getPurgeOnShutdown()` Returns if store will clean up persisted files when shutdown (destroy()).
`java.lang.String` | `getStoreFilePath()` Gets the file path for the directory where the objects will be stored.
`java.lang.String` | `getStoreFileSuffix()` Gets the file suffix for each of the files that objects will be persisted to.
`void` | `purgeFiles()`
`void` | `setConfig(java.util.Map config)` Will use the values in the map to set configuration.
`void` | `setPurgeOnShutdown(boolean purgeOnShutdown)` Sets if store should clean up persisted files when shutdown (destroy()).
`void` | `setStoreFilePath(java.lang.String filePath)` Sets teh file path for the directory where the objects will be stored.
`void` | `setStoreFileSuffix(java.lang.String fileSuffix)` Sets the file suffix for each of the files that objects will be persisted to.
`int` | `size()` Getst the number of objects stored and available.
`void` | `start()` Will get the file path value (if not already set will just use the default setting) and will create the directory specified by the file path if it does not already exist.
`void` | `stop()` This will allow for change of file suffix and file path and then may start again using these new values.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FILE_PATH_KEY

    public static final java.lang.String FILE_PATH_KEY

  Key for setting which directory to write the callback objects. The default value is the property value of 'jboss.server.data.dir' and if this is not set, then will be 'data'. Will then append 'remoting' and the callback client's session id. An example would be 'data\remoting\5c4o05l-9jijyx-e5b6xyph-1-e5b6xyph-2'.

  See Also:
    Constant Field Values

### FILE_SUFFIX_KEY

    public static final java.lang.String FILE_SUFFIX_KEY

  Key for setting the file suffix to use for the callback objects written to disk. The default value is ?ser?.

  See Also:
    Constant Field Values

Constructor Detail

### CallbackStore

    public CallbackStore()

  Default store constructor.

### CallbackStore

    public CallbackStore(boolean purgeOnDestroy)

  Store constructor.

  Parameters:
    `purgeOnDestroy` - if true, will remove all persisted objects from disk on when destroy() is called, else will leave the files (which is the default behaviour).

Method Detail

### start

    public void start()
               throws java.lang.Exception

  Will get the file path value (if not already set will just use the default setting) and will create the directory specified by the file path if it does not already exist.

  Specified by:
    `start` in interface `SerializableStore`
  Throws:
    `java.lang.Exception`

### setPurgeOnShutdown

    public void setPurgeOnShutdown(boolean purgeOnShutdown)

  Sets if store should clean up persisted files when shutdown (destroy()).

  Specified by:
    `setPurgeOnShutdown` in interface `SerializableStore`
  Parameters:
    `purgeOnShutdown` -

### getPurgeOnShutdown

    public boolean getPurgeOnShutdown()

  Returns if store will clean up persisted files when shutdown (destroy()).

  Specified by:
    `getPurgeOnShutdown` in interface `SerializableStore`
  Returns:

### create

    public void create()
                throws java.lang.Exception

  This is a no op method, but needed in order to be used as a service within JBoss AS.

  Specified by:
    `create` in interface `SerializableStore`
  Throws:
    `java.lang.Exception`

### stop

    public void stop()

  This will allow for change of file suffix and file path and then may start again using these new values. However, any object already written out using the old values will be lost as will not longer be accessible if these attributes are changed while stopped.

  Specified by:
    `stop` in interface `SerializableStore`

### destroy

    public void destroy()

  If purgeOnDestroy is true, will remove files upon shutdown.

  Specified by:
    `destroy` in interface `SerializableStore`

### purgeFiles

    public void purgeFiles()

  Specified by:
    `purgeFiles` in interface `SerializableStore`

### setConfig

    public void setConfig(java.util.Map config)

  Will use the values in the map to set configuration. This will not change behaviour of store until has been stopped and then started (if has not been started, will take effect upon start). The keys for the map are FILE_PATH_KEY and FILE_SUFFIX_KEY.

  Specified by:
    `setConfig` in interface `SerializableStore`
  Parameters:
    `config` -

### getStoreFilePath

    public java.lang.String getStoreFilePath()

  Gets the file path for the directory where the objects will be stored.

  Specified by:
    `getStoreFilePath` in interface `CallbackStoreMBean`
  Returns:

### setStoreFilePath

    public void setStoreFilePath(java.lang.String filePath)

  Sets teh file path for the directory where the objects will be stored.

  Specified by:
    `setStoreFilePath` in interface `CallbackStoreMBean`
  Parameters:
    `filePath` -

### getStoreFileSuffix

    public java.lang.String getStoreFileSuffix()

  Gets the file suffix for each of the files that objects will be persisted to.

  Specified by:
    `getStoreFileSuffix` in interface `CallbackStoreMBean`
  Returns:

### setStoreFileSuffix

    public void setStoreFileSuffix(java.lang.String fileSuffix)

  Sets the file suffix for each of the files that objects will be persisted to.

  Specified by:
    `setStoreFileSuffix` in interface `CallbackStoreMBean`
  Parameters:
    `fileSuffix` -

### size

    public int size()

  Getst the number of objects stored and available.

  Specified by:
    `size` in interface `SerializableStore`
  Returns:

### getNext

    public java.lang.Object getNext()
                             throws java.io.IOException

  Will look through the files in the store directory for the oldest object serialized to disk, load it, delete the file, and return the deserialized object. Important to note that once this object is returned from this method, it is gone forever from this store and will not be able to retrieve it again without adding it back.

  Specified by:
    `getNext` in interface `SerializableStore`
  Returns:
  Throws:
    `java.io.IOException`

### add

    public void add(java.io.Serializable object)
             throws java.io.IOException

  Persists the serializable object passed to the directory specified. The file name will be the current time in milliseconds (vis System.currentTimeMillis()) with the specified suffix. This object can later be retrieved using the getNext() method, but objects will be returned in the order that they were added (FIFO).

  Specified by:
    `add` in interface `SerializableStore`
  Parameters:
    `object` -
  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ? 1998-2005 JBoss Inc . All Rights Reserved.