summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-gdata2/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/binding-gdata2/src/main')
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java77
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java35
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java100
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java36
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java137
-rw-r--r--java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory19
-rw-r--r--java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor21
7 files changed, 425 insertions, 0 deletions
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java
new file mode 100644
index 0000000000..c1868f05dc
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java
@@ -0,0 +1,77 @@
+/*
+ * 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.binding.gdata;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * GData binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GDataBinding extends Binding {
+
+ /**
+ * Returns the title of the Atom collection.
+ * @return
+ */
+ String getTitle();
+
+ /**
+ * Sets the title of the Atom collection.
+ * @param title
+ */
+ void setTitle(String title);
+
+ /*
+ * Returns the username of a Google account
+ * @return
+ */
+ String getUsername();
+
+ /*
+ * Sets the username of a Google account
+ * @param username
+ */
+ void setUsername(String username);
+
+ /*
+ * Returns the password of a Google account
+ * @return
+ */
+ String getPassword();
+
+ /*
+ * Sets the password of a Google account
+ * @param password
+ */
+ void setPassword(String password);
+
+ /*
+ * Retruns the name of the Google service to which we are connecting. Sample names of services might include "cl" (Calendar), "mail" (GMail), or "blogger" (Blogger)
+ * @return
+ */
+ String getServiceType();
+
+ /*
+ * Sets the name of the Google service to which we are connecting. Sample names of services might include "cl" (Calendar), "mail" (GMail), or "blogger" (Blogger)
+ * @param serviceType
+ */
+ void setServiceType(String serviceType);
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java
new file mode 100644
index 0000000000..ec2f179fdb
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java
@@ -0,0 +1,35 @@
+/*
+ * 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.binding.gdata;
+
+/**
+ * Factory for the GData binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GDataBindingFactory {
+
+ /**
+ * Creates a new Atom binding.
+ * @return the new Atom binding
+ */
+ GDataBinding createAtomBinding();
+
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java
new file mode 100644
index 0000000000..5797629bed
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java
@@ -0,0 +1,100 @@
+/*
+ * 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.binding.gdata;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+public class GDataImplementationProcessor implements StAXArtifactProcessor<GDataBinding> {
+
+ private GDataBindingFactory gdataFactory;
+ protected static final QName BINDING_GDATA = new QName(Constants.SCA10_TUSCANY_NS, "binding.gdata");
+
+ public GDataImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+
+ this.gdataFactory = (GDataBindingFactory) modelFactories.getFactory(GDataBindingFactory.class);
+ }
+
+ public GDataBinding read(XMLStreamReader reader) {
+
+ assert BINDING_GDATA.equals(reader.getName());
+
+ GDataBinding gdataBinding = gdataFactory.createAtomBinding();
+
+ /*
+ * <tuscany:binding.gdata uri="..."
+ * login="..."
+ * password="..."/>
+ */
+
+ String uri = reader.getAttributeValue(null, "uri");
+ String serviceType = reader.getAttributeValue(null, "serviceType");
+ String login = reader.getAttributeValue(null, "username");
+ String password = reader.getAttributeValue(null, "password");
+
+ gdataBinding.setURI(uri);
+ gdataBinding.setServiceType(serviceType);
+ gdataBinding.setUsername(login);
+ gdataBinding.setPassword(password);
+
+ return gdataBinding;
+ }
+
+ public void write(GDataBinding gdataBinding, XMLStreamWriter writer) throws XMLStreamException {
+ if (gdataBinding != null) {
+ writer.writeStartElement(BINDING_GDATA.getNamespaceURI(), BINDING_GDATA.getLocalPart());
+
+ if (gdataBinding.getURI() != null) {
+ writer.writeAttribute("uri", gdataBinding.getURI());
+ }
+
+ if (gdataBinding.getServiceType() != null) {
+ writer.writeAttribute("serviceType", gdataBinding.getServiceType());
+ }
+ if (gdataBinding.getUsername() != null) {
+ writer.writeAttribute("username", gdataBinding.getUsername());
+ }
+ if (gdataBinding.getPassword() != null) {
+ writer.writeAttribute("password", gdataBinding.getPassword());
+ }
+
+ writer.writeEndElement();
+ }
+ }
+
+ public QName getArtifactType() {
+ return BINDING_GDATA;
+ }
+
+ public void resolve(GDataBinding arg0, ModelResolver arg1) throws ContributionResolveException {
+ }
+
+ public Class<GDataBinding> getModelType() {
+ return GDataBinding.class;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java
new file mode 100644
index 0000000000..e0c3bfbe78
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java
@@ -0,0 +1,36 @@
+/*
+ * 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.binding.gdata.impl;
+
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+import org.apache.tuscany.sca.binding.gdata.GDataBindingFactory;
+
+/**
+ * Factory for the GData binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GDataBindingFactoryImpl implements GDataBindingFactory {
+
+ public GDataBinding createAtomBinding() {
+ return new GDataBindingImpl();
+ }
+
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java
new file mode 100644
index 0000000000..baba882c4c
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java
@@ -0,0 +1,137 @@
+/*
+ * 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.binding.gdata.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Implementation of the GData binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class GDataBindingImpl implements GDataBinding, PolicySetAttachPoint {
+
+ private String password;
+ private String username;
+ private String name;
+ private String serviceType;
+ private String uri;
+ private String title;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private IntentAttachPointType intentAttachPointType;
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public boolean isUnresolved() {
+ // The binding is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public IntentAttachPointType getType() {
+ return intentAttachPointType;
+ }
+
+ public void setType(IntentAttachPointType intentAttachPointType) {
+ this.intentAttachPointType = intentAttachPointType;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getServiceType() {
+ return this.serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory
new file mode 100644
index 0000000000..48be99b507
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory
@@ -0,0 +1,19 @@
+# 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.
+
+# Implementation class for the model factory
+org.apache.tuscany.sca.binding.gdata.impl.GDataBindingFactoryImpl \ No newline at end of file
diff --git a/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..92aad3d44d
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,21 @@
+# 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.
+
+# Implementation class for the artifact processor extension
+
+#org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.gdata,model=org.apache.tuscany.sca.binding.gdata.GDataBinding,factory=org.apache.tuscany.sca.binding.gdata.GDataBindingFactory
+org.apache.tuscany.sca.binding.gdata.GDataImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.gdata,model=org.apache.tuscany.sca.binding.gdata.GDataBinding,factory=org.apache.tuscany.sca.binding.gdata.GDataBindingFactory \ No newline at end of file