[teiid-commits] teiid SVN: r3881 - branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Tue Feb 14 12:37:24 EST 2012
Author: van.halbert
Date: 2012-02-14 12:37:23 -0500 (Tue, 14 Feb 2012)
New Revision: 3881
Modified:
branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnection.java
branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnectionImpl.java
Log:
adding methods to support update
Modified: branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnection.java
===================================================================
--- branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnection.java 2012-02-14 17:22:52 UTC (rev 3880)
+++ branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnection.java 2012-02-14 17:37:23 UTC (rev 3881)
@@ -67,4 +67,13 @@
*/
public void remove(Object key) throws ResourceException;
+
+ /**
+ * Call to update the root object in the cache.
+ * @param key is the key to the object in the cache
+ * @param object is the root object to be updated
+ * @throws ResourceException
+ */
+ public void update(Object key, Object object) throws ResourceException;
+
}
Modified: branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnectionImpl.java
===================================================================
--- branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnectionImpl.java 2012-02-14 17:22:52 UTC (rev 3880)
+++ branches/7.7.x/connectors/sandbox/connector-coherence/src/main/java/org/teiid/resource/adapter/coherence/CoherenceConnectionImpl.java 2012-02-14 17:37:23 UTC (rev 3881)
@@ -137,6 +137,36 @@
}
+ public void update(Object key, Object object) throws ResourceException {
+ NamedCache sourceCache = getCache();
+ if (!sourceCache.containsKey(key)) {
+ throw new ResourceException("Unable to update object for key: " + key + " to cache " + this.cacheName + ", because it already exist");
+ }
+
+ TransactionMap tmap = CacheFactory.getLocalTransaction(sourceCache);
+
+ tmap.setTransactionIsolation(TransactionMap.TRANSACTION_REPEATABLE_GET);
+ tmap.setConcurrency(TransactionMap.CONCUR_PESSIMISTIC);
+
+ tmap.begin();
+ try
+ {
+ tmap.put(key, object);
+ tmap.prepare();
+ tmap.commit();
+ }
+ catch (Exception e) {
+ throw new ResourceException(e);
+ }
+
+ sourceCache = getCache();
+ if (!sourceCache.containsKey(key)) {
+ throw new ResourceException("Problem updating object for key: " + key + " to the cache " + this.cacheName +", object not found after add");
+ }
+
+
+ }
+
public void remove(Object key) throws ResourceException {
System.out.println("Remove: " + key);
NamedCache sourceCache = getCache();
More information about the teiid-commits
mailing list