org.jboss.cache.aop
Interface PojoCacheIfc

All Known Subinterfaces:
PojoCacheMBean, TreeCacheAopIfc, TreeCacheAopMBean
All Known Implementing Classes:
PojoCache, TreeCacheAop

public interface PojoCacheIfc

Interface for PojoCache. User should use this interface directly to access the public APIs.

PojoCache is an in-memory, transactional, fine-grained, and object-oriented cache system. It differs from the typical generic cache library by operating on the pojo level directly without requiring that object to be serializable (although it does require "aspectizing" the POJO). Further, it can preserve object graph during replication or persistency. It also track the replication via fine-grained maner, i.e., only changed fields are replicated.

Since:
1.4
Author:
Ben Wang

Method Summary
 java.util.Map findObjects(Fqn fqn)
          Query all managed pojo objects under the fqn recursively.
 java.util.Map findObjects(java.lang.String fqn)
          Query all managed pojo objects under the fqn recursively.
 CachedType getCachedType(java.lang.Class clazz)
          Obtain a cache aop type for user to traverse the defined "primitive" types in aop.
 java.lang.Object getObject(Fqn fqn)
          Retrieve pojo object from the cache.
 java.lang.Object getObject(java.lang.String fqn)
          Retrieve pojo from the cache.
 boolean isMarshallNonSerializable()
          Indicate whether the flag is set or not.
 java.lang.Object putObject(Fqn fqn, java.lang.Object obj)
          Insert a pojo into the cache.
 java.lang.Object putObject(java.lang.String fqn, java.lang.Object obj)
          Insert a pojo into the cache.
 java.lang.Object removeObject(Fqn fqn)
          Remove pojo object from the cache.
 java.lang.Object removeObject(java.lang.String fqn)
          Remove pojo object from the cache.
 void setMarshallNonSerializable(boolean marshall)
          If the flag is set, then POJO which is not instrumented under AOP and which is not implementing the Serializable interface will still be marshalled and make serializable.
 

Method Detail

getObject

java.lang.Object getObject(java.lang.String fqn)
                           throws CacheException
Retrieve pojo from the cache. Return null if object does not exist in the cache. Note that this operation is fast if there is already an POJO instance attached to the cache.

Parameters:
fqn - Instance that associates with this node.
Returns:
Current content value. Null if does not exist.
Throws:
CacheException - Throws if there is an error related to the cache operation, e.g., TimeoutException.

getObject

java.lang.Object getObject(Fqn fqn)
                           throws CacheException
Retrieve pojo object from the cache. Return null if object does not exist in the cache. Note that this operation is fast if there is already an POJO instance attached to the cache.

Parameters:
fqn - Instance that associates with this node.
Returns:
Current content value. Null if does not exist.
Throws:
CacheException - Throws if there is an error related to the cache operation, e.g., TimeoutException.

putObject

java.lang.Object putObject(java.lang.String fqn,
                           java.lang.Object obj)
                           throws CacheException
Insert a pojo into the cache. It will also recursively put the any sub-object that is declared as aop-capable (i.e., in jboss-aop.xml). Note that List, Map, Set attributes are aop-enabled, by default, as well.

Parameters:
fqn - The fqn instance to associate with the object in the cache.
obj - aop-enabled object to be inerted into the cache. If null, it will nullify the fqn node.
obj - Return the previous content under fqn.
Returns:
Existing POJO or null if there is not.
Throws:
CacheException - Throws if there is an error related to the cache operation, e.g., TimeoutException.

putObject

java.lang.Object putObject(Fqn fqn,
                           java.lang.Object obj)
                           throws CacheException
Insert a pojo into the cache. It will also recursively put the any sub-object that is declared as aop-capable (i.e., in jboss-aop.xml). Note that List, Map, Set attributes are aop-enabled, by default, as well.

Parameters:
fqn - The fqn instance to associate with the object in the cache.
obj - aop-enabled object to be inerted into the cache. If null, it will nullify the fqn node.
obj - Return the previous content under fqn.
Returns:
Existing POJO or null if there is not.
Throws:
CacheException - Throws if there is an error related to the cache operation, e.g., TimeoutException.

removeObject

java.lang.Object removeObject(java.lang.String fqn)
                              throws CacheException
Remove pojo object from the cache.

Parameters:
fqn - Instance that associates with this node.
Returns:
Original value object from this node.
Throws:
CacheException - Throws if there is an error related to the cache operation, e.g., TimeoutException.

removeObject

java.lang.Object removeObject(Fqn fqn)
                              throws CacheException
Remove pojo object from the cache.

Parameters:
fqn - Instance that associates with this node.
Returns:
Original value object from this node.
Throws:
CacheException - Throws if there is an error related to the cache operation, e.g., TimeoutException.

findObjects

java.util.Map findObjects(java.lang.String fqn)
                          throws CacheException
Query all managed pojo objects under the fqn 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. Note also that this operation is not thread-safe now. In addition, it assumes that once a pojo is found with a fqn, no more pojo is stored under the children of the fqn. That is, we don't mixed the fqn with different pojos.

Parameters:
fqn - The starting place to find all pojos.
Returns:
Map of all pojos found with (fqn, pojo) pair. Return size of 0, if not found.
Throws:
CacheException - Throws if there is an error related to the cache operation, e.g., TimeoutException.

findObjects

java.util.Map findObjects(Fqn fqn)
                          throws CacheException
Query all managed pojo objects under the fqn 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. Note also that this operation is not thread-safe now. In addition, it assumes that once a pojo is found with a fqn, no more pojo is stored under the children of the fqn. That is, we don't mixed the fqn with different pojos.

Parameters:
fqn - The starting place to find all pojos.
Returns:
Map of all pojos found with (fqn, pojo) pair. Return size of 0, if not found.
Throws:
CacheException

setMarshallNonSerializable

void setMarshallNonSerializable(boolean marshall)
If the flag is set, then POJO which is not instrumented under AOP and which is not implementing the Serializable interface will still be marshalled and make serializable.


isMarshallNonSerializable

boolean isMarshallNonSerializable()
Indicate whether the flag is set or not.


getCachedType

CachedType getCachedType(java.lang.Class clazz)
Obtain a cache aop type for user to traverse the defined "primitive" types in aop.

Parameters:
clazz - The original pojo class
Returns:
CachedType


Copyright 1998-2005 JBoss Inc . All Rights Reserved.