|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.run.jca.CacheAdapter
public class CacheAdapter
CacheAdapter encapsulates the operations neccessary to communicate
with Coherence™ resource adapter (coherence-tx.rar).
The Coherence resource adapter, in turn, is a gateway into the Coherence
clustered services, so some methods closely resemble methods at
CacheFactory
class.
In a simplest form a client code would look like:
Context ctx = new InitialContext();
CacheAdapter adapter = new CacheAdapter(ctx, "tangosol.coherenceTx",
CacheAdapter.CONCUR_OPTIMISTIC, CacheAdapter.TRANSACTION_REPEATABLE_GET, 0);
try
{
NamedCache map = adapter.getNamedCache("MyCache", getClass().getClassLoader(),
new SimpleValidator(), false);
// perform operations on the map
}
finally
{
adapter.close();
}
Note: the CacheAdapter is intended to be used by one and only one thread
at the time and is not thread safe.
Nested Class Summary | |
---|---|
static class |
CacheAdapter.CacheConnectionSpec
CacheConnectionSpec is an implementation of ConnectionSpec
interface used to pass the connection info to the adapter. |
Field Summary | |
---|---|
static int |
CONCUR_EXTERNAL
Same as TransactionMap.CONCUR_EXTERNAL |
static int |
CONCUR_OPTIMISTIC
Same as TransactionMap.CONCUR_OPTIMISTIC |
static int |
CONCUR_PESSIMISTIC
Same as TransactionMap.CONCUR_PESSIMISTIC |
static int |
TRANSACTION_GET_COMMITTED
Same as TransactionMap.TRANSACTION_GET_COMMITTED |
static int |
TRANSACTION_REPEATABLE_GET
Same as TransactionMap.TRANSACTION_REPEATABLE_GET |
static int |
TRANSACTION_SERIALIZABLE
Same as TransactionMap.TRANSACTION_SERIALIZABLE |
Constructor Summary | |
---|---|
CacheAdapter()
Construct the adapter using a default InitialContext, standard JNDI name, "optimistic" concurrency, "committed" isolation level an no timeout. |
|
CacheAdapter(Context ctx,
String sJndiName,
int nConcur,
int nIsolation,
int nTimeout)
Construct the adapter using the specified Context and JNDI name |
Method Summary | |
---|---|
void |
close()
Close the connection assosiated with this adapter. |
void |
connect(String sServiceName,
String sUserName,
String sPassword)
Connect the adapter to the specified clustered service. |
void |
connect(String sServiceName,
String sServiceType,
String sUserName,
String sPassword)
Connect the adapter to the specified clustered service. |
protected void |
finalize()
Perform cleanup during garbage collection. |
NamedCache |
getDistributedCache(String sName,
ClassLoader loader)
Deprecated. use getNamedCache(java.lang.String, java.lang.ClassLoader) instead. |
NamedCache |
getNamedCache(String sName,
ClassLoader loader)
Obtain an instance of a NamedCache. |
NamedCache |
getNamedCache(String sName,
ClassLoader loader,
TransactionMap.Validator validator,
boolean fImmutable)
Obtain an instance of a NamedCache. |
NamedCache |
getReplicatedCache(String sName,
ClassLoader loader)
Deprecated. use getNamedCache(java.lang.String, java.lang.ClassLoader) instead. |
protected boolean |
isConnected()
Return the connection status. |
String |
toString()
Return a human readable description of the CacheAdapter. |
Field Detail |
---|
public static final int TRANSACTION_GET_COMMITTED
TransactionMap.TRANSACTION_GET_COMMITTED
public static final int TRANSACTION_REPEATABLE_GET
TransactionMap.TRANSACTION_REPEATABLE_GET
public static final int TRANSACTION_SERIALIZABLE
TransactionMap.TRANSACTION_SERIALIZABLE
public static final int CONCUR_PESSIMISTIC
TransactionMap.CONCUR_PESSIMISTIC
public static final int CONCUR_OPTIMISTIC
TransactionMap.CONCUR_OPTIMISTIC
public static final int CONCUR_EXTERNAL
TransactionMap.CONCUR_EXTERNAL
Constructor Detail |
---|
public CacheAdapter()
public CacheAdapter(Context ctx, String sJndiName, int nConcur, int nIsolation, int nTimeout)
ctx
- the Context object to use for lookup operation;
if null, the default InitialiContext is usedsJndiName
- the JNDI name of the Coherence resource adapter;
if null, the default name ("tangosol.coherenceTx")
is usednConcur
- the default concurrency valuenIsolation
- the default transaction isolation valuenTimeout
- the default transaction timeout value (in seconds)Method Detail |
---|
public NamedCache getReplicatedCache(String sName, ClassLoader loader)
getNamedCache(java.lang.String, java.lang.ClassLoader)
instead.
When called within a transaction, the returned cache will be transactional, controlled by the container's transaction coordinator. When called outside of a transaction, the returned cache will be non-transactional, which is equivalent to obtaining the instance directly from CacheFactory.
sName
- cache name (unique across the cluster). If the NamedCache
with the specified name already exists, a reference to
the same object will be returned in the same transactional
contextloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the cluster
IllegalStateException
- if the adapter is already connected to a
different servicepublic NamedCache getDistributedCache(String sName, ClassLoader loader)
getNamedCache(java.lang.String, java.lang.ClassLoader)
instead.
When called within a transaction, the returned cache will be transactional, controlled by the container's transaction coordinator. When called outside of a transaction, the returned cache will be non-transactional, which is equivalent to obtaining the instance directly from CacheFactory.
sName
- cache name (unique across the cluster). If the NamedCache
with the specified name already exists, a reference to
the same object will be returned in the same transactional
contextloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the cluster
IllegalStateException
- if the adapter is already connected to a
different servicepublic void connect(String sServiceName, String sUserName, String sPassword)
sServiceName
- service name (unique across the cluster)sUserName
- name of the user establishing a connection (optional)sPassword
- password for the user establishing a connection (optional)
IllegalArgumentException
- if the specified service is not running
IllegalStateException
- if the adapter is already connected orpublic void connect(String sServiceName, String sServiceType, String sUserName, String sPassword)
sServiceName
- service name (unique across the cluster)sServiceType
- service type (i.e. CacheService.TYPE_REPLICATED or
CacheService.TYPE_DISTRIBUTED)sUserName
- name of the user establishing a connection (optional)sPassword
- password for the user establishing a connection (optional)
IllegalArgumentException
- if the specified service cannot be found
IllegalStateException
- if the adapter is already connectedpublic NamedCache getNamedCache(String sName, ClassLoader loader)
CacheFactory.getCache(sName, loader)
unless the adapter is already
connected to a specific cache service, in which case the
corresponding NamedCache will be retrieved using
service.ensureCache(sName, loader)
.
When called within a transaction, the returned cache will be transactional, controlled by the container's transaction coordinator. When called outside of a transaction, the returned cache will be non-transactional, which is equivalent to obtaining the instance directly from CacheFactory.
sName
- cache name (unique across the cluster).
If the NamedCache with the specified name already
exists, a reference to the same object will be
returned in the same transactional contextloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the cluster
public NamedCache getNamedCache(String sName, ClassLoader loader, TransactionMap.Validator validator, boolean fImmutable)
CacheFactory.getCache(sName, loader)
unless the adapter is already
connected to a specific cache service, in which case the
corresponding NamedCache will be retrieved using
service.ensureCache(sName, loader)
.
When called within a transaction, the returned cache will be transactional, controlled by the container's transaction coordinator. When called outside of a transaction, the returned cache will be non-transactional, which is equivalent to obtaining the instance directly from CacheFactory.
sName
- cache name (unique across the cluster).
If the NamedCache with the specified name already
exists, a reference to the same object will be
returned in the same transactional contextloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the clustervalidator
- the Validator object to be used to enlist and validate
transactional resources; this parameter is only used
within transactional context and only for optimistic
concurrencyfImmutable
- specifies whether or not the values kept in this cache
are known to be immutable; this parameter is only used
within transactional context
TransactionMap.setValidator()
,
TransactionMap.setValuesImmutable()
public void close()
protected boolean isConnected()
public String toString()
protected void finalize()
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |