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.cache.pojo.impl
Class PojoCacheImpl

    java.lang.Object
      org.jboss.cache.pojo.impl.PojoCacheImpl

All Implemented Interfaces:
  PojoCache

    public class PojoCacheImpl

extends Object
implements PojoCache

Implementation class for PojoCache interface

Version:
  $Id: PojoCacheImpl.java 6991 2008-10-21 21:03:54Z jason.greene@jboss.com $
Author:
  Ben Wang

Field Summary
`protected org.apache.commons.logging.Log` | `log_`

Constructor Summary
`PojoCacheImpl(Configuration config, boolean toStart)`
`PojoCacheImpl(String configStr, boolean toStart)`

Method Summary
`void` | `addListener(Object listener)` Add a PojoCache listener.
`void` | `addListener(Object listener, Pattern pattern)` Add a PojoCache listener that will only monitor a specific ID(FQN) pattern.
`Object` | `attach(Fqn<?> id, Object pojo)` Attach a POJO into PojoCache.
`Object` | `attach(Fqn<?> id, Object pojo, String field, Object source)`
`Object` | `attach(String id, Object pojo)` Attach a POJO into PojoCache.
`void` | `create()` Lifecycle method to start PojoCache.
`void` | `destroy()` Lifecycle method to destroy PojoCache.
`Object` | `detach(Fqn<?> id)` Remove POJO object from the cache.
`Object` | `detach(Fqn<?> id, String field, Object source)`
`Object` | `detach(String id)` Remove POJO object from the cache.
`boolean` | `exists(Fqn<?> id)` Determines if an object is attached at a particular location.
`Object` | `find(Fqn<?> id)` Retrieve POJO from the cache system.
`Object` | `find(Fqn<?> id, String field, Object source)`
`Object` | `find(String id)` Retrieve POJO from the cache system.
`Map<Fqn<?>,Object>` | `findAll(Fqn<?> id)` Query all managed POJO objects under the id recursively.
`Map<Fqn<?>,Object>` | `findAll(String id)` Query all managed POJO objects under the id recursively.
`Cache<Object,Object>` | `getCache()` Obtain the underlying generic cache system.
`CachedType` | `getCachedType(Class clazz)` Obtain a cache aop type for user to traverse the defined "primitive" types in aop.
`CacheSPI<Object,Object>` | `getCacheSPI()`
`Fqn<?>` | `getInternalFqn(Object object)` Return the `Fqn` of the internal node containing the data of this attached object.
`Collection<Object>` | `getListeners()` Retrieve a read-only list of listeners.
`Collection<Reference>` | `getReferences(Object object)` Return a list of the references from attached objects to this object.
`PojoCacheThreadContext` | `getThreadContext()` Get's the thread context for all POJO Cache operations.
`String` | `getVersion()`
`void` | `removeListener(Object listener)` Remove the specific listener.
`void` | `start()` Lifecycle method to start PojoCache.
`void` | `stop()` Lifecycle method to stop PojoCache.
`String` | `toString()`

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

Field Detail

### log_

    protected final org.apache.commons.logging.Log log_

Constructor Detail

### PojoCacheImpl

    public PojoCacheImpl(String configStr,
                         boolean toStart)

### PojoCacheImpl

    public PojoCacheImpl(Configuration config,
                         boolean toStart)

Method Detail

### getCacheSPI

    public CacheSPI<Object,Object> getCacheSPI()

### attach

    public Object attach(String id,
                         Object pojo)
                  throws PojoCacheException

  Description copied from interface: `PojoCache`

  Attach a POJO into PojoCache. It will also recursively put any sub-POJO into the cache system. A POJO can be the following and have the consqeuences when attached:

  - it is Replicable, that is, it has been annotated with `Replicable` annotation (or via XML), and has been "instrumented" either compile- or load-time. The POJO will be mapped recursively to the system and fine-grained replication will be performed.
  - It is Serializable. The POJO will still be stored in the cache system. However, it is treated as an "opaque" object per se. That is, the POJO will neither be intercepted (for fine-grained operation) or object relantionship will be maintained.
  - Neither of above. In this case, a user can specify whether it wants this POJO to be stored (e.g., replicated or persistent). If not, a PojoCacheException will be thrown.

  Specified by:
    `attach` in interface `PojoCache`
  Parameters:
    `id` - An id String to identify the object in the cache. To promote concurrency, we recommend the use of hierarchical String separating by a designated separator. Default is "/" but it can be set differently via a System property, jbosscache.separator in the future release. E.g., "/ben", or "/student/joe", etc.
    `pojo` - object to be inerted into the cache. If null, it will nullify the fqn node.
  Returns:
    Existing POJO or null if there is none.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### attach

    public Object attach(Fqn<?> id,
                         Object pojo)
                  throws PojoCacheException

  Description copied from interface: `PojoCache`

  Attach a POJO into PojoCache. It will also recursively put any sub-POJO into the cache system. A POJO can be the following and have the consequences when attached:

  - it is Replicable, that is, it has been annotated with `Replicable` annotation (or via XML), and has been "instrumented" either compile- or load-time. The POJO will be mapped recursively to the system and fine-grained replication will be performed.
  - It is Serializable. The POJO will still be stored in the cache system. However, it is treated as an "opaque" object per se. That is, the POJO will neither be intercepted (for fine-grained operation) or object relationship will be maintained.
  - Neither of above. In this case, a user can specify whether it wants this POJO to be stored (e.g., replicated or persistent). If not, a PojoCacheException will be thrown.

  Specified by:
    `attach` in interface `PojoCache`
  Parameters:
    `id` - the Fqn that specifies the location in the cache to attach the object
    `pojo` - object to be inserted into the cache. If null, it will nullify the fqn node.
  Returns:
    Existing POJO or null if there is none.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### attach

    public Object attach(Fqn<?> id,
                         Object pojo,
                         String field,
                         Object source)
                  throws PojoCacheException

  Throws:
    `PojoCacheException`

### detach

    public Object detach(Fqn<?> id,
                         String field,
                         Object source)
                  throws PojoCacheException

  Throws:
    `PojoCacheException`

### detach

    public Object detach(String id)
                  throws PojoCacheException

  Description copied from interface: `PojoCache`
  Remove POJO object from the cache.

  Specified by:
    `detach` in interface `PojoCache`
  Parameters:
    `id` - Is string that associates with this node.
  Returns:
    Original value object from this node.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### detach

    public Object detach(Fqn<?> id)
                  throws PojoCacheException

  Description copied from interface: `PojoCache`
  Remove POJO object from the cache.

  Specified by:
    `detach` in interface `PojoCache`
  Parameters:
    `id` - location of the object to remove
  Returns:
    Original value object from this node.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### getInternalFqn

    public Fqn<?> getInternalFqn(Object object)

  Description copied from interface: `PojoCache`
  Return the `Fqn` of the internal node containing the data of this attached object.

  Note that if the object is not attached to the cache system, this method will simply return null. Same for any object of an immediate type (primitive wrapper types, String, or Class) or of any `Serializable` types.

  Specified by:
    `getInternalFqn` in interface `PojoCache`
  Parameters:
    `object` - Any object.
  Returns:
    `Fqn` of the internal data node. `null` if the object is immediate, serializable, or not in the cache.

### getReferences

    public Collection<Reference> getReferences(Object object)

  Description copied from interface: `PojoCache`
  Return a list of the references from attached objects to this object. For each reference it returns a `Reference` object containing the `Fqn` of the referrer object and the name of the field that contains the reference.

  If the node is not attached to the cache, this method will return an empty list. Same for any object of an immediate type (primitive wrapper types, String, or Class) or of any `Serializable` types.

  For external references (i.e. when the object was directly attached to the cache by user code) the `Reference.fieldName` property is `null`. Otherwise it is the name of the field that contains the reference to this object.

  Specified by:
    `getReferences` in interface `PojoCache`
  Parameters:
    `object` - Any object.
  Returns:
    Collection of internal references to the given object. Empty collection if the object is immediate, serializable, or not in the cache.

### exists

    public boolean exists(Fqn<?> id)

  Description copied from interface: `PojoCache`
  Determines if an object is attached at a particular location. This is somewhat less expensive than find() because an object is not created, and internal reference links are not traversed.

  Specified by:
    `exists` in interface `PojoCache`
  Parameters:
    `id` - the location in the cache to examine
  Returns:
    true if an attached object exists, false if not

### find

    public Object find(String id)
                throws PojoCacheException

  Description copied from interface: `PojoCache`
  Retrieve POJO from the cache system. Return null if object does not exist in the cache. Note that this operation is fast if there is already a POJO instance attached to the cache.

  Specified by:
    `find` in interface `PojoCache`
  Parameters:
    `id` - that associates with this node.
  Returns:
    Current content value. Null if does not exist.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### find

    public Object find(Fqn<?> id)
                throws PojoCacheException

  Description copied from interface: `PojoCache`
  Retrieve POJO from the cache system. Return null if object does not exist in the cache. Note that this operation is fast if there is already a POJO instance attached to the cache.

  Specified by:
    `find` in interface `PojoCache`
  Parameters:
    `id` - that associates with this node.
  Returns:
    Current content value. Null if does not exist.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### find

    public Object find(Fqn<?> id,
                       String field,
                       Object source)
                throws CacheException

  Throws:
    `CacheException`

### findAll

    public Map<Fqn<?>,Object> findAll(String id)
                               throws PojoCacheException

  Description copied from interface: `PojoCache`
  Query all managed POJO objects under the id recursively. Note that this will not return the sub-object POJOs, e.g., if Person has a sub-object of Address, it won't return Address pojo. Also note also that this operation is not thread-safe now. In addition, it assumes that once a POJO is found with a id, no more POJO is stored under the children of the id. That is, we don't mix the id with different POJOs.

  Specified by:
    `findAll` in interface `PojoCache`
  Parameters:
    `id` - The starting place to find all POJOs.
  Returns:
    Map of all POJOs found with (id, POJO) pair. Return size of 0, if not found.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### findAll

    public Map<Fqn<?>,Object> findAll(Fqn<?> id)
                               throws PojoCacheException

  Description copied from interface: `PojoCache`
  Query all managed POJO objects under the id recursively. Note that this will not return the sub-object POJOs, e.g., if Person has a sub-object of Address, it won't return Address pojo. Also note also that this operation is not thread-safe now. In addition, it assumes that once a POJO is found with a id, no more POJO is stored under the children of the id. That is, we don't mix the id with different POJOs.

  Specified by:
    `findAll` in interface `PojoCache`
  Parameters:
    `id` - The starting place to find all POJOs.
  Returns:
    Map of all POJOs found with (id, POJO) pair. Return size of 0, if not found.
  Throws:
    `PojoCacheException` - Throws if there is an error related to the cache operation.

### getVersion

    public String getVersion()

### create

    public void create()
                throws PojoCacheException

  Description copied from interface: `PojoCache`
  Lifecycle method to start PojoCache.

  Specified by:
    `create` in interface `PojoCache`
  Throws:
    `PojoCacheException`

### start

    public void start()
               throws PojoCacheException

  Description copied from interface: `PojoCache`
  Lifecycle method to start PojoCache.

  Specified by:
    `start` in interface `PojoCache`
  Throws:
    `PojoCacheException`

### stop

    public void stop()
              throws PojoCacheException

  Description copied from interface: `PojoCache`
  Lifecycle method to stop PojoCache. Note that PojoCache can be stopped and started repeatedly.

  Specified by:
    `stop` in interface `PojoCache`
  Throws:
    `PojoCacheException`

### destroy

    public void destroy()
                 throws PojoCacheException

  Description copied from interface: `PojoCache`
  Lifecycle method to destroy PojoCache.

  Specified by:
    `destroy` in interface `PojoCache`
  Throws:
    `PojoCacheException`

### getListeners

    public Collection<Object> getListeners()

  Description copied from interface: `PojoCache`
  Retrieve a read-only list of listeners.

  Specified by:
    `getListeners` in interface `PojoCache`

### addListener

    public void addListener(Object listener)

  Description copied from interface: `PojoCache`

  Add a PojoCache listener. A given listener instance can only be added once. To have a duplicate listener simply create a new instance.

  The listener must be annotated with the `PojoCacheListener` annotation, and all callback methods need to be annotated with the respective event annotations. Otherwise, an exception will be thrown.

  Specified by:
    `addListener` in interface `PojoCache`
  Parameters:
    `listener` - the listener instance to register
  See Also:
    `for examples`

### addListener

    public void addListener(Object listener,
                            Pattern pattern)

  Description copied from interface: `PojoCache`

  Add a PojoCache listener that will only monitor a specific ID(FQN) pattern. A given listener instance can only be added once, whether or not there is a pattern. To have a duplicate listener simply create a new instance.

  The listener must be annotated with the `PojoCacheListener` annotation, and all callback methods need to be annotated with the respective event annotations. Otherwise, an exception will be thrown.

  Specified by:
    `addListener` in interface `PojoCache`
  Parameters:
    `listener` - the listener instance to register
    `pattern` - the ID pattern for notifications of interest
  See Also:
    `for examples`

### removeListener

    public void removeListener(Object listener)

  Description copied from interface: `PojoCache`
  Remove the specific listener.

  Specified by:
    `removeListener` in interface `PojoCache`
  Parameters:
    `listener` - the listener to remove

### getThreadContext

    public PojoCacheThreadContext getThreadContext()

  Description copied from interface: `PojoCache`
  Get's the thread context for all POJO Cache operations.

  Specified by:
    `getThreadContext` in interface `PojoCache`
  Returns:
    the current thread's context

### getCache

    public Cache<Object,Object> getCache()

  Description copied from interface: `PojoCache`
  Obtain the underlying generic cache system. Use this for non-POJO cache operation, e.g.

  Specified by:
    `getCache` in interface `PojoCache`

### getCachedType

    public CachedType getCachedType(Class clazz)

  Obtain a cache aop type for user to traverse the defined "primitive" types in aop. Note that this is not a synchronized call now for speed optimization.

  Parameters:
    `clazz` - The original pojo class
  Returns:
    CachedType

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

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 © 2008 JBoss, a division of Red Hat. All Rights Reserved.