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 4496 2007-09-21 03:15:01Z jason.greene@jboss.com $
Author:
  Ben Wang

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

Constructor Summary
`PojoCacheImpl(org.jboss.cache.config.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(org.jboss.cache.Fqn<?> id, Object pojo)` Attach a POJO into PojoCache.
`Object` | `attach(org.jboss.cache.Fqn<?> id, Object pojo, String field)`
`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(org.jboss.cache.Fqn<?> id)` Remove POJO object from the cache.
`Object` | `detach(org.jboss.cache.Fqn<?> id, String field)`
`Object` | `detach(String id)` Remove POJO object from the cache.
`boolean` | `exists(org.jboss.cache.Fqn<?> id)` Determines if an object is attached at a particular location.
`Object` | `find(org.jboss.cache.Fqn<?> id)` Retrieve POJO from the cache system.
`Object` | `find(String id)` Retrieve POJO from the cache system.
`Map<org.jboss.cache.Fqn<?>,Object>` | `findAll(org.jboss.cache.Fqn<?> id)` Query all managed POJO objects under the id recursively.
`Map<org.jboss.cache.Fqn<?>,Object>` | `findAll(String id)` Query all managed POJO objects under the id recursively.
`org.jboss.cache.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.
`org.jboss.cache.CacheSPI<Object,Object>` | `getCacheSPI()`
`Collection<Object>` | `getListeners()` Retrieve a read-only list of listeners.
`Object` | `getObject(org.jboss.cache.Fqn<?> id)`
`Object` | `getObject(org.jboss.cache.Fqn<?> id, String field)`
`String` | `getPojoID(Object pojo)` Return the POJO id that is associated with PojoCache.
`String` | `getVersion()`
`Object` | `putObject(org.jboss.cache.Fqn<?> id, Object pojo, String field)` This public API is called from internal package only.
`void` | `removeListener(Object listener)` Remove the specific listener.
`Object` | `removeObject(org.jboss.cache.Fqn<?> id, String field)`
`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(org.jboss.cache.config.Configuration config,
                         boolean toStart)

Method Detail

### getCacheSPI

    public org.jboss.cache.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 `@org.jboss.cache.pojo.annotation.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(org.jboss.cache.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 consqeuences when attached:

  - it is Replicable, that is, it has been annotated with `@org.jboss.cache.pojo.annotation.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(org.jboss.cache.Fqn<?> id,
                         Object pojo,
                         String field)
                  throws PojoCacheException

  Throws:
    `PojoCacheException`

### putObject

    public Object putObject(org.jboss.cache.Fqn<?> id,
                            Object pojo,
                            String field)
                     throws org.jboss.cache.CacheException

  This public API is called from internal package only.

  Throws:
    `org.jboss.cache.CacheException`

### 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(org.jboss.cache.Fqn<?> id,
                         String field)
                  throws PojoCacheException

  Throws:
    `PojoCacheException`

### detach

    public Object detach(org.jboss.cache.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.

### removeObject

    public Object removeObject(org.jboss.cache.Fqn<?> id,
                               String field)
                        throws org.jboss.cache.CacheException

  Throws:
    `org.jboss.cache.CacheException`

### getPojoID

    public String getPojoID(Object pojo)

  Description copied from interface: `PojoCache`
  Return the POJO id that is associated with PojoCache. Note that if a POJO has not yet attached to the cache system, it will simply return null.

  Specified by:
    `getPojoID` in interface `PojoCache`
  Parameters:
    `pojo` - The POJO that is attached to PojoCache.
  Returns:
    String ID. Null if not existed.

### exists

    public boolean exists(org.jboss.cache.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(org.jboss.cache.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.

### getObject

    public Object getObject(org.jboss.cache.Fqn<?> id)
                     throws org.jboss.cache.CacheException

  Throws:
    `org.jboss.cache.CacheException`

### getObject

    public Object getObject(org.jboss.cache.Fqn<?> id,
                            String field)
                     throws org.jboss.cache.CacheException

  Throws:
    `org.jboss.cache.CacheException`

### findAll

    public Map<org.jboss.cache.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<org.jboss.cache.Fqn<?>,Object> findAll(org.jboss.cache.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

### getCache

    public org.jboss.cache.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.