You are viewing a plain text version of this content. The canonical link for it is here.
Posted to nuvem-commits@incubator.apache.org by lr...@apache.org on 2010/09/22 01:53:49 UTC

svn commit: r999722 - in /incubator/nuvem/trunk/nuvem-google: pom.xml src/main/java/org/apache/nuvem/cloud/data/impl/DatastoreDocumentServiceImpl.java src/main/java/org/apache/nuvem/cloud/data/impl/MemcacheDocumentServiceImpl.java

Author: lresende
Date: Wed Sep 22 01:53:48 2010
New Revision: 999722

URL: http://svn.apache.org/viewvc?rev=999722&view=rev
Log:
Tidyng up GAE implementation for DocumentService

Modified:
    incubator/nuvem/trunk/nuvem-google/pom.xml
    incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/DatastoreDocumentServiceImpl.java
    incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/MemcacheDocumentServiceImpl.java

Modified: incubator/nuvem/trunk/nuvem-google/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-google/pom.xml?rev=999722&r1=999721&r2=999722&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-google/pom.xml (original)
+++ incubator/nuvem/trunk/nuvem-google/pom.xml Wed Sep 22 01:53:48 2010
@@ -51,6 +51,13 @@
 			<version>1.3.7</version>
 			<scope>provided</scope>
 		</dependency>
+        
+        <dependency>
+            <groupId>net.sf.jsr107cache</groupId>
+            <artifactId>jsr107cache</artifactId>
+            <version>1.1</version>
+        </dependency>
+        
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>

Modified: incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/DatastoreDocumentServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/DatastoreDocumentServiceImpl.java?rev=999722&r1=999721&r2=999722&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/DatastoreDocumentServiceImpl.java (original)
+++ incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/DatastoreDocumentServiceImpl.java Wed Sep 22 01:53:48 2010
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 package org.apache.nuvem.cloud.data.impl;
@@ -25,6 +25,7 @@ import org.apache.nuvem.cloud.data.Docum
 import org.apache.tuscany.sca.data.collection.Entry;
 import org.apache.tuscany.sca.data.collection.NotFoundException;
 import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Service;
 
 import com.google.appengine.api.datastore.DatastoreService;
 import com.google.appengine.api.datastore.DatastoreServiceFactory;
@@ -33,6 +34,7 @@ import com.google.appengine.api.datastor
 import com.google.appengine.api.datastore.Key;
 import com.google.appengine.api.datastore.KeyFactory;
 
+@Service(DocumentService.class)
 public class DatastoreDocumentServiceImpl implements DocumentService<Key, Entity> {
     private DatastoreService googleDataStoreService;
 
@@ -40,14 +42,14 @@ public class DatastoreDocumentServiceImp
     public void init() {
         googleDataStoreService = DatastoreServiceFactory.getDatastoreService();
     }
-    
+
     public Entry<Key, Entity>[] getAll() {
         throw new UnsupportedOperationException();
     }
 
     public Entity get(Key key) throws NotFoundException {
         Entity entity = null;
-        
+
         try {
             entity =  googleDataStoreService.get(key);
         } catch(EntityNotFoundException nf) {
@@ -63,7 +65,7 @@ public class DatastoreDocumentServiceImp
         if( key == null ) {
             key = KeyFactory.createKey("key", UUID.randomUUID().toString());
         }
-        
+
         return googleDataStoreService.put(entity);
     }
 
@@ -71,18 +73,18 @@ public class DatastoreDocumentServiceImp
         if( get(key) == null) {
             throw new NotFoundException("Could not find entity with key '" + key.toString() +"'");
         }
-        
+
         googleDataStoreService.put(entity);
     }
 
     public void delete(Key key) throws NotFoundException {
         googleDataStoreService.delete(key);
-        
+
     }
 
     public void delete(Key... keys) throws NotFoundException {
         googleDataStoreService.delete(keys);
-        
+
     }
 
     public Entry<Key, Entity>[] query(String query) {

Modified: incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/MemcacheDocumentServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/MemcacheDocumentServiceImpl.java?rev=999722&r1=999721&r2=999722&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/MemcacheDocumentServiceImpl.java (original)
+++ incubator/nuvem/trunk/nuvem-google/src/main/java/org/apache/nuvem/cloud/data/impl/MemcacheDocumentServiceImpl.java Wed Sep 22 01:53:48 2010
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 package org.apache.nuvem.cloud.data.impl;
@@ -26,31 +26,35 @@ import org.apache.tuscany.sca.data.colle
 import org.apache.tuscany.sca.data.collection.NotFoundException;
 import org.oasisopen.sca.annotation.Init;
 import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
 
 import com.google.appengine.api.memcache.Expiration;
 import com.google.appengine.api.memcache.MemcacheService;
 import com.google.appengine.api.memcache.MemcacheServiceFactory;
 
+@Service(DocumentService.class)
 public class MemcacheDocumentServiceImpl implements DocumentService<Object, Object> {
-    private MemcacheService googleMemecacheService;
-    
+	private MemcacheService googleMemecacheService;
+	private Expiration expiration;
+
     @Property(required=false)
-    protected Expiration defaultExpiration = Expiration.byDeltaSeconds(3600); // 1hr
+    protected int defaultExpiration = 3600;
 
     @Init
     public void init() {
+    	expiration = Expiration.byDeltaSeconds(defaultExpiration); // 1hr
         googleMemecacheService = MemcacheServiceFactory.getMemcacheService();
     }
-    
+
     public Entry<Object, Object>[] getAll() {
         throw new UnsupportedOperationException();
     }
 
     public Object get(Object key) throws NotFoundException {
         Object entity = null;
-        
+
         entity =  googleMemecacheService.get(key);
-        
+
         if(entity == null) {
             throw new NotFoundException("Could not find object with key '" + key.toString() + "'");
         }
@@ -62,9 +66,9 @@ public class MemcacheDocumentServiceImpl
         if( key == null ) {
             key = UUID.randomUUID().toString();
         }
-        
-        googleMemecacheService.put(key, entity, defaultExpiration);
-        
+
+        googleMemecacheService.put(key, entity, expiration);
+
         return entity;
     }
 
@@ -72,8 +76,8 @@ public class MemcacheDocumentServiceImpl
         if( get(key) == null) {
             throw new NotFoundException("Could not find entity with key '" + key.toString() +"'");
         }
-        
-        googleMemecacheService.put(key, entity, defaultExpiration);
+
+        googleMemecacheService.put(key, entity, expiration);
     }
 
     public void delete(Object key) throws NotFoundException {