summaryrefslogtreecommitdiffstats
path: root/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding')
-rw-r--r--sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java77
-rw-r--r--sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java35
-rw-r--r--sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java100
-rw-r--r--sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java36
-rw-r--r--sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java137
5 files changed, 385 insertions, 0 deletions
diff --git a/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java b/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java
new file mode 100644
index 0000000000..c1868f05dc
--- /dev/null
+++ b/sandbox/event/modules/binding-gdata/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/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java b/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java
new file mode 100644
index 0000000000..ec2f179fdb
--- /dev/null
+++ b/sandbox/event/modules/binding-gdata/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/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java b/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java
new file mode 100644
index 0000000000..5797629bed
--- /dev/null
+++ b/sandbox/event/modules/binding-gdata/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/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java b/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java
new file mode 100644
index 0000000000..e0c3bfbe78
--- /dev/null
+++ b/sandbox/event/modules/binding-gdata/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/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java b/sandbox/event/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java
new file mode 100644
index 0000000000..baba882c4c
--- /dev/null
+++ b/sandbox/event/modules/binding-gdata/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;
+ }
+}