summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreranda <eranda@13f79535-47bb-0310-9956-ffa450edef68>2011-08-19 19:42:16 +0000
committereranda <eranda@13f79535-47bb-0310-9956-ffa450edef68>2011-08-19 19:42:16 +0000
commit26a29763aa23bf394dbb36a35a09937660168dc2 (patch)
tree4f9f45f716300d2fb83d81c43ff39c8996e9bee6
parentb2a97423304c9b5ef3c0a042ae134e857c2d25a5 (diff)
Making REST services from the datastores(Apache Cassandra, Apacha CouchDB and Apache Hadoop/hbase)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1159757 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/pom.xml29
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java67
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java71
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/META-INF/sca-contribution.xml7
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/datastore.composite16
-rw-r--r--collaboration/GSoC-2011-Eranda/couchdb/pom.xml16
-rw-r--r--collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java67
-rw-r--r--collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java71
-rw-r--r--collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/META-INF/sca-contribution.xml7
-rw-r--r--collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/datastore.composite16
-rw-r--r--collaboration/GSoC-2011-Eranda/hbase/pom.xml18
-rw-r--r--collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java67
-rw-r--r--collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java71
-rw-r--r--collaboration/GSoC-2011-Eranda/hbase/src/main/resources/META-INF/sca-contribution.xml7
-rw-r--r--collaboration/GSoC-2011-Eranda/hbase/src/main/resources/datastore.composite16
15 files changed, 534 insertions, 12 deletions
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/pom.xml b/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
index 1194cdfd26..bc74631d4e 100644
--- a/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
+++ b/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
@@ -22,39 +22,52 @@ under the License.
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.tuscany</groupId>
- <artifactId>nosql-datastore</artifactId>
+ <artifactId>nosql-datastore-cassandra</artifactId>
<version>0.0.1</version>
-
<packaging>jar</packaging>
<name>tuscany</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <cassandra.version>0.7.1</cassandra.version>
+ <hector.version>0.7.0-29</hector.version>
+ <tuscany.version>2.0-M5</tuscany.version>
</properties>
-
<dependencies>
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector-core</artifactId>
- <version>0.7.0-29</version>
+ <version>${hector.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-javautils</artifactId>
- <version>0.7.1</version>
+ <version>${cassandra.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
- <version>0.7.4</version>
+ <version>${cassandra.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
+ <version>4.8.1</version>
+ <scope>test</scope>
</dependency>
</dependencies>
-
<build>
<plugins>
<plugin>
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java
new file mode 100644
index 0000000000..e63fb16bf5
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.*;
+import org.oasisopen.sca.annotation.Remotable;
+
+import javax.ws.rs.*;
+
+@Remotable
+public interface DatastoreService {
+
+ @GET
+ @Path("echoTest")
+ String echoTest(@QueryParam("database") String database);
+
+ @POST
+ @Path("addEntry")
+ void addEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key,
+ @QueryParam("value") String value) throws DuplicateEntryException, SessionException;
+
+ @POST
+ @Path("updateEntry")
+ void updateEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key,
+ @QueryParam("value") String value) throws EntryNotFoundException, SessionException;
+
+ @POST
+ @Path("deleteEntry")
+ void deleteEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key) throws EntryNotFoundException, SessionException;
+
+ @GET
+ @Path("getEntry")
+ String getEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key) throws EntryNotFoundException, SessionException;
+
+ @DELETE
+ @Path("deleteGroup")
+ void deleteGroup(@QueryParam("database") String database,
+ @QueryParam("group") String group) throws GroupNotFoundException, SessionException;
+
+ @DELETE
+ @Path("deleteDatabase")
+ void deleteDatabase(@QueryParam("database") String database) throws DatabaseNotFoundException, SessionException;
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java
new file mode 100644
index 0000000000..6c63f74cef
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.*;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class DatastoreServiceImpl implements DatastoreService{
+
+ private Session session;
+
+ @Init
+ public void init(){
+ session = (new SessionFactory()).getCassandraSession();
+ }
+
+ public String echoTest(String database){
+ return "Database "+database;
+ }
+
+ public void addEntry(String database, String group, String key, String value) throws DuplicateEntryException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.addEntry(key, value);
+ }
+
+ public void updateEntry(String database, String group, String key, String value) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.updateEntry(key, value);
+ }
+
+ public void deleteEntry(String database, String group, String key) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.deleteEntry(key);
+ }
+
+ public String getEntry(String database, String group, String key) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ return grp.getEntry(key);
+ }
+
+ public void deleteGroup(String database, String group) throws GroupNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ db.deleteGroup(group);
+ }
+
+ public void deleteDatabase(String database) throws DatabaseNotFoundException, SessionException {
+ session.deleteDatabase(database);
+ }
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/META-INF/sca-contribution.xml b/collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b9960d1bac
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:datastore="http://datastore">
+
+ <deployable composite="datastore:datastore-contribution" />
+
+</contribution>
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/datastore.composite b/collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/datastore.composite
new file mode 100644
index 0000000000..bf67ad5eee
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/resources/datastore.composite
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://datastore"
+ name="datastore-contribution">
+ <component name="DatastoreComponent">
+ <implementation.java class="org.apache.tuscany.nosqldatastore.DatastoreServiceImpl"/>
+ <service name="DatastoreService">
+ <interface.java interface="org.apache.tuscany.nosqldatastore.DatastoreService"/>
+ <tuscany:binding.rest uri="http://localhost:8085/DatastoreService">
+ <tuscany:wireFormat.json/>
+ <tuscany:operationSelector.jaxrs/>
+ </tuscany:binding.rest>
+ </service>
+ </component>
+</composite>
diff --git a/collaboration/GSoC-2011-Eranda/couchdb/pom.xml b/collaboration/GSoC-2011-Eranda/couchdb/pom.xml
index 32c17907ad..4e3aff6542 100644
--- a/collaboration/GSoC-2011-Eranda/couchdb/pom.xml
+++ b/collaboration/GSoC-2011-Eranda/couchdb/pom.xml
@@ -30,13 +30,27 @@ under the License.
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <jcouchdb.version>0.10.0-1</jcouchdb.version>
+ <tuscany.version>2.0-M5</tuscany.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.jcouchdb</groupId>
<artifactId>jcouchdb</artifactId>
- <version>0.10.0-1</version>
+ <version>${jcouchdb.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java b/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java
new file mode 100644
index 0000000000..e63fb16bf5
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.*;
+import org.oasisopen.sca.annotation.Remotable;
+
+import javax.ws.rs.*;
+
+@Remotable
+public interface DatastoreService {
+
+ @GET
+ @Path("echoTest")
+ String echoTest(@QueryParam("database") String database);
+
+ @POST
+ @Path("addEntry")
+ void addEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key,
+ @QueryParam("value") String value) throws DuplicateEntryException, SessionException;
+
+ @POST
+ @Path("updateEntry")
+ void updateEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key,
+ @QueryParam("value") String value) throws EntryNotFoundException, SessionException;
+
+ @POST
+ @Path("deleteEntry")
+ void deleteEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key) throws EntryNotFoundException, SessionException;
+
+ @GET
+ @Path("getEntry")
+ String getEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key) throws EntryNotFoundException, SessionException;
+
+ @DELETE
+ @Path("deleteGroup")
+ void deleteGroup(@QueryParam("database") String database,
+ @QueryParam("group") String group) throws GroupNotFoundException, SessionException;
+
+ @DELETE
+ @Path("deleteDatabase")
+ void deleteDatabase(@QueryParam("database") String database) throws DatabaseNotFoundException, SessionException;
+}
diff --git a/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java b/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java
new file mode 100644
index 0000000000..a153f0ce0f
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.*;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class DatastoreServiceImpl implements DatastoreService{
+
+ private Session session;
+
+ @Init
+ public void init(){
+ session = (new SessionFactory()).getCouchDBSession();
+ }
+
+ public String echoTest(String database){
+ return "Database "+database;
+ }
+
+ public void addEntry(String database, String group, String key, String value) throws DuplicateEntryException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.addEntry(key, value);
+ }
+
+ public void updateEntry(String database, String group, String key, String value) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.updateEntry(key, value);
+ }
+
+ public void deleteEntry(String database, String group, String key) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.deleteEntry(key);
+ }
+
+ public String getEntry(String database, String group, String key) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ return grp.getEntry(key);
+ }
+
+ public void deleteGroup(String database, String group) throws GroupNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ db.deleteGroup(group);
+ }
+
+ public void deleteDatabase(String database) throws DatabaseNotFoundException, SessionException {
+ session.deleteDatabase(database);
+ }
+}
diff --git a/collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/META-INF/sca-contribution.xml b/collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b9960d1bac
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:datastore="http://datastore">
+
+ <deployable composite="datastore:datastore-contribution" />
+
+</contribution>
diff --git a/collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/datastore.composite b/collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/datastore.composite
new file mode 100644
index 0000000000..bf67ad5eee
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/couchdb/src/main/resources/datastore.composite
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://datastore"
+ name="datastore-contribution">
+ <component name="DatastoreComponent">
+ <implementation.java class="org.apache.tuscany.nosqldatastore.DatastoreServiceImpl"/>
+ <service name="DatastoreService">
+ <interface.java interface="org.apache.tuscany.nosqldatastore.DatastoreService"/>
+ <tuscany:binding.rest uri="http://localhost:8085/DatastoreService">
+ <tuscany:wireFormat.json/>
+ <tuscany:operationSelector.jaxrs/>
+ </tuscany:binding.rest>
+ </service>
+ </component>
+</composite>
diff --git a/collaboration/GSoC-2011-Eranda/hbase/pom.xml b/collaboration/GSoC-2011-Eranda/hbase/pom.xml
index a726ce23fb..518ccf7114 100644
--- a/collaboration/GSoC-2011-Eranda/hbase/pom.xml
+++ b/collaboration/GSoC-2011-Eranda/hbase/pom.xml
@@ -30,21 +30,33 @@ under the License.
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <hbase.version>0.90.3</hbase.version>
+ <tuscany.version>2.0-M5</tuscany.version>
</properties>
-
<dependencies>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
- <version>0.90.3</version>
+ <version>${hbase.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
-
<build>
<plugins>
<plugin>
diff --git a/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java b/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java
new file mode 100644
index 0000000000..e63fb16bf5
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreService.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.*;
+import org.oasisopen.sca.annotation.Remotable;
+
+import javax.ws.rs.*;
+
+@Remotable
+public interface DatastoreService {
+
+ @GET
+ @Path("echoTest")
+ String echoTest(@QueryParam("database") String database);
+
+ @POST
+ @Path("addEntry")
+ void addEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key,
+ @QueryParam("value") String value) throws DuplicateEntryException, SessionException;
+
+ @POST
+ @Path("updateEntry")
+ void updateEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key,
+ @QueryParam("value") String value) throws EntryNotFoundException, SessionException;
+
+ @POST
+ @Path("deleteEntry")
+ void deleteEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key) throws EntryNotFoundException, SessionException;
+
+ @GET
+ @Path("getEntry")
+ String getEntry(@QueryParam("database") String database,
+ @QueryParam("group") String group,
+ @QueryParam("key") String key) throws EntryNotFoundException, SessionException;
+
+ @DELETE
+ @Path("deleteGroup")
+ void deleteGroup(@QueryParam("database") String database,
+ @QueryParam("group") String group) throws GroupNotFoundException, SessionException;
+
+ @DELETE
+ @Path("deleteDatabase")
+ void deleteDatabase(@QueryParam("database") String database) throws DatabaseNotFoundException, SessionException;
+}
diff --git a/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java b/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java
new file mode 100644
index 0000000000..7049129046
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/DatastoreServiceImpl.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.*;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class DatastoreServiceImpl implements DatastoreService{
+
+ private Session session;
+
+ @Init
+ public void init(){
+ session = (new SessionFactory()).getHBaseSession();
+ }
+
+ public String echoTest(String database){
+ return "Database "+database;
+ }
+
+ public void addEntry(String database, String group, String key, String value) throws DuplicateEntryException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.addEntry(key, value);
+ }
+
+ public void updateEntry(String database, String group, String key, String value) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.updateEntry(key, value);
+ }
+
+ public void deleteEntry(String database, String group, String key) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ grp.deleteEntry(key);
+ }
+
+ public String getEntry(String database, String group, String key) throws EntryNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ Group grp = db.getGroup(group);
+ return grp.getEntry(key);
+ }
+
+ public void deleteGroup(String database, String group) throws GroupNotFoundException, SessionException {
+ Database db = session.getDatabase(database);
+ db.deleteGroup(group);
+ }
+
+ public void deleteDatabase(String database) throws DatabaseNotFoundException, SessionException {
+ session.deleteDatabase(database);
+ }
+}
diff --git a/collaboration/GSoC-2011-Eranda/hbase/src/main/resources/META-INF/sca-contribution.xml b/collaboration/GSoC-2011-Eranda/hbase/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b9960d1bac
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/hbase/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:datastore="http://datastore">
+
+ <deployable composite="datastore:datastore-contribution" />
+
+</contribution>
diff --git a/collaboration/GSoC-2011-Eranda/hbase/src/main/resources/datastore.composite b/collaboration/GSoC-2011-Eranda/hbase/src/main/resources/datastore.composite
new file mode 100644
index 0000000000..bf67ad5eee
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/hbase/src/main/resources/datastore.composite
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://datastore"
+ name="datastore-contribution">
+ <component name="DatastoreComponent">
+ <implementation.java class="org.apache.tuscany.nosqldatastore.DatastoreServiceImpl"/>
+ <service name="DatastoreService">
+ <interface.java interface="org.apache.tuscany.nosqldatastore.DatastoreService"/>
+ <tuscany:binding.rest uri="http://localhost:8085/DatastoreService">
+ <tuscany:wireFormat.json/>
+ <tuscany:operationSelector.jaxrs/>
+ </tuscany:binding.rest>
+ </service>
+ </component>
+</composite>