summaryrefslogtreecommitdiffstats
path: root/sandbox/sebastien/java/dynamic/modules/data-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/sebastien/java/dynamic/modules/data-api/src')
-rw-r--r--sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java79
-rw-r--r--sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java86
-rw-r--r--sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java159
-rw-r--r--sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java30
-rw-r--r--sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java28
-rw-r--r--sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java45
6 files changed, 427 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java
new file mode 100644
index 0000000000..fa4da391a5
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java
@@ -0,0 +1,79 @@
+/*
+ * 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.sca.data.collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+@Remotable
+public interface Collection <K, D> {
+
+ /**
+ * Get the whole collection.
+ *
+ * @return the whole collection.
+ */
+ Entry<K, D>[] getAll();
+
+ /**
+ * Returns a collection resulting from a query.
+ *
+ * @return the collection.
+ */
+ Entry<K, D>[] query(String queryString);
+
+ /**
+ * Creates a new item.
+ *
+ * @param key
+ * @param item
+ * @return
+ */
+ K post(K key, D item);
+
+ /**
+ * Retrieves an item.
+ *
+ * @param key
+ * @return
+ */
+ D get(K key) throws NotFoundException;
+
+ /**
+ * Updates an item.
+ *
+ * @param key
+ * @param item
+ * @return
+ */
+ void put(K key, D item) throws NotFoundException;
+
+ /**
+ * Delete an item.
+ *
+ * @param key
+ */
+ void delete(K key) throws NotFoundException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java
new file mode 100644
index 0000000000..f9ecd6c641
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java
@@ -0,0 +1,86 @@
+/*
+ * 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.sca.data.collection;
+
+
+/**
+ * Represents a key/data pair in a data collection.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class Entry <K, D> {
+
+ private K key;
+ private D data;
+
+ /**
+ * Constructs a new entry.
+ */
+ public Entry() {
+ }
+
+ /**
+ * Constructs a new entry.
+ * @param key the entry key
+ * @param data the entry data
+ */
+ public Entry(K key, D data) {
+ this.key = key;
+ this.data = data;
+ }
+
+ /**
+ * Returns the entry key.
+ * @return the key
+ */
+ public K getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the entry key.
+ * @param key the key
+ */
+ public void setKey(K key) {
+ this.key = key;
+ }
+
+ /**
+ * Returns the entry data.
+ * @return the entry data
+ */
+ public D getData() {
+ return data;
+ }
+
+ /**
+ * Sets the entry data
+ * @param data the entry data
+ */
+ public void setData(D data) {
+ this.data = data;
+ }
+
+ //FIXME Temporary methods to make JAXB register the Item
+ // class when the Entry class is registered in a JAXB context
+ public void setDummy(Item item) {}
+ public Item getDummy() { return null; }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java
new file mode 100644
index 0000000000..37042c0895
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java
@@ -0,0 +1,159 @@
+/*
+ * 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.sca.data.collection;
+
+import java.util.Date;
+
+
+/**
+ * Represents a data item.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Item {
+
+ private String title;
+ private String contents;
+ private String link;
+ private String related;
+ private String alternate;
+ private Date date;
+
+ /**
+ * Constructs a new item.
+ */
+ public Item() {
+ }
+
+ /**
+ * Constructs a new item.
+ * @param title the item title
+ * @param contents the item contents
+ * @param link the item link to a web resource
+ * @param related the item link to a related web resource
+ * @param date the item date
+ */
+ public Item(String title, String contents, String link, String related, Date date) {
+ this.title = title;
+ this.contents = contents;
+ this.link = link;
+ this.related = related;
+ this.date = date;
+ }
+
+ /**
+ * Returns the item title.
+ * @return the item title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the item title.
+ * @param title the item title
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Returns the item contents
+ * @return the item contents
+ */
+ public String getContents() {
+ return contents;
+ }
+
+ /**
+ * Sets the item contents
+ * @param contents the item contents
+ */
+ public void setContents(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Returns the item link to a web resource
+ * @return the item link to a web resource
+ */
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * Sets the item link to a web resource
+ * @param link the item link to a web resource
+ */
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ /**
+ * Returns the item link to a related web resource
+ * @return the item link to a related web resource
+ */
+ public String getRelated() {
+ return related;
+ }
+
+ /**
+ * Sets the item link to a related web resource.
+ *
+ * @param related the item link to a related web resource
+ */
+ public void setRelated(String related) {
+ this.related = related;
+ }
+
+ /**
+ * Returns the item link to an alternate web resource
+ * @return the item link to an alternate web resource
+ */
+ public String getAlternate() {
+ return alternate;
+ }
+
+ /**
+ * Sets the item link to an alternate web resource.
+ *
+ * @param alternate the item link to an alternate web resource
+ */
+ public void setAlternate(String alternate) {
+ this.alternate = alternate;
+ }
+
+ /**
+ * Returns the item date
+ * @return the item date
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * Sets the item date
+ * @param date the item date
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java
new file mode 100644
index 0000000000..229b29f5cd
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sca.data.collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface ItemCollection extends Collection<String, Item> {
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java
new file mode 100644
index 0000000000..69512058b7
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java
@@ -0,0 +1,28 @@
+/*
+ * 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.sca.data.collection;
+
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LocalItemCollection extends Collection<String, Item> {
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java
new file mode 100644
index 0000000000..7f13db5228
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java
@@ -0,0 +1,45 @@
+/*
+ * 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.sca.data.collection;
+
+/**
+ * Indicates that an item could not be found in a collection.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotFoundException extends Exception {
+ private static final long serialVersionUID = 6792367409396084646L;
+
+ public NotFoundException() {
+ }
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}