summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules/binding-gdata-gsoc/src/main
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-09-12 21:54:50 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-09-12 21:54:50 +0000
commitd232b6a46e4225ff35a0123a5f5597da7592fc38 (patch)
tree0c607d86a472ccbdd5587eb3ae53f535b6aa36f2 /branches/sca-equinox/modules/binding-gdata-gsoc/src/main
parent2e48ecc0ea43d7b859c578080c72e4c739717487 (diff)
Creating a branch for the equinox work.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@694816 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/modules/binding-gdata-gsoc/src/main')
-rw-r--r--branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java49
-rw-r--r--branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java34
-rw-r--r--branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.java35
-rw-r--r--branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java142
-rw-r--r--branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java158
-rw-r--r--branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GdataBindingFactory18
-rw-r--r--branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
7 files changed, 455 insertions, 0 deletions
diff --git a/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java
new file mode 100644
index 0000000000..ab2acef234
--- /dev/null
+++ b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java
@@ -0,0 +1,49 @@
+/*
+ * 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 GData collection.
+ * @return
+ */
+ String getTitle();
+
+ /**
+ * Sets the title of the GData collection.
+ * @param title
+ */
+ void setTitle(String title);
+
+ String getUsername();
+ String getPassword();
+ String getServiceType();
+ void setUsername(String username);
+ void setPassword(String password);
+ void setServiceType(String serviceType);
+}
diff --git a/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java
new file mode 100644
index 0000000000..847bb6956b
--- /dev/null
+++ b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java
@@ -0,0 +1,34 @@
+/*
+ * 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
+ *
+ */
+public interface GdataBindingFactory {
+
+ /**
+ * Creates a new GData binding.
+ * @return the new GData binding
+ */
+ GdataBinding createGdataBinding();
+
+}
diff --git a/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.java b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.java
new file mode 100644
index 0000000000..656776c358
--- /dev/null
+++ b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.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.impl;
+
+import org.apache.tuscany.sca.binding.gdata.GdataBinding;
+import org.apache.tuscany.sca.binding.gdata.GdataBindingFactory;
+
+/**
+ * Factory for the GData binding model.
+ *
+ */
+public class GdataBindingFactoryImpl implements GdataBindingFactory {
+
+ public GdataBinding createGdataBinding() {
+ return new GdataBindingImpl();
+ }
+
+}
diff --git a/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java
new file mode 100644
index 0000000000..c389bacdc9
--- /dev/null
+++ b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java
@@ -0,0 +1,142 @@
+/*
+ * 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.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+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.
+ *
+ */
+class GdataBindingImpl implements GdataBinding, PolicySetAttachPoint {
+
+ private String name;
+ private String uri;
+ private String title;
+ private String username;
+ private String password;
+ private String serviceType;
+ 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 String getUsername(){
+ return username;
+ }
+
+ public String getPassword(){
+ return password;
+ }
+
+ public String getServiceType(){
+ return serviceType;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+
+ 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;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java
new file mode 100644
index 0000000000..1cd0f72a93
--- /dev/null
+++ b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java
@@ -0,0 +1,158 @@
+/*
+ * 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 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.PolicyAttachPointProcessor;
+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.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl;
+
+import org.apache.tuscany.sca.binding.gdata.GdataBinding;
+import org.apache.tuscany.sca.binding.gdata.GdataBindingFactory;
+
+/**
+ * A processor for <binding.gdata> elements.
+ */
+public class GdataBindingProcessor implements StAXArtifactProcessor<GdataBinding> {
+
+ private QName BINDING_GDATA = new QName("http://tuscany.apache.org/xmlns/sca/1.0", "binding.gdata");
+
+ private final GdataBindingFactory factory;
+
+ //private PolicyAttachPointProcessor policyProcessor;
+
+ public GdataBindingProcessor(ModelFactoryExtensionPoint modelFactories) {
+ this.factory = modelFactories.getFactory(GdataBindingFactory.class);
+ System.out.println("[Debug Info]GdataBindingProcessor reached");
+ //this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+ }
+
+ public QName getArtifactType() {
+ return BINDING_GDATA;
+ }
+
+ public Class<GdataBinding> getModelType() {
+ return GdataBinding.class;
+ }
+
+ public GdataBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ GdataBinding gdataBinding = factory.createGdataBinding();
+ IntentAttachPointType bindingType = new IntentAttachPointTypeFactoryImpl().createBindingType();
+ bindingType.setName(getArtifactType());
+ bindingType.setUnresolved(true);
+ ((PolicySetAttachPoint)gdataBinding).setType(bindingType);
+
+ String name = reader.getAttributeValue(null, "name");
+ if (name != null) {
+ gdataBinding.setName(name);
+ }
+
+ String uri = reader.getAttributeValue(null, "uri");
+ if (uri != null) {
+ gdataBinding.setURI(uri);
+ }
+
+ String serviceType = reader.getAttributeValue(null, "serviceType");
+ if (serviceType != null) {
+ gdataBinding.setServiceType(serviceType);
+ }
+
+ String username = reader.getAttributeValue(null, "username");
+ if (username != null) {
+ gdataBinding.setUsername(username);
+ }
+
+ String password = reader.getAttributeValue(null, "password");
+ if (password != null) {
+ gdataBinding.setPassword(password);
+ }
+
+ //policyProcessor.readPolicies(echoBinding, reader);
+
+ return gdataBinding;
+ }
+
+ public void write(GdataBinding gdataBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ //policyProcessor.writePolicyPrefixes(gdataBinding, writer);
+ writer.writeStartElement(BINDING_GDATA.getNamespaceURI(), BINDING_GDATA.getLocalPart());
+ //policyProcessor.writePolicyAttributes(gdataBinding, writer);
+
+ if (gdataBinding.getName() != null) {
+ writer.writeAttribute("name", gdataBinding.getName());
+ }
+
+ 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();
+ }
+
+
+ //FIXME: Resolve the attached policySet, might not needed (the echo binding implementation example)
+ public void resolve(GdataBinding gdataBinding, ModelResolver resolver) throws ContributionResolveException {
+ PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)gdataBinding;
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ Intent resolvedIntent = null;
+ for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) {
+ resolvedIntent = resolver.resolveModel(Intent.class, intent);
+ requiredIntents.add(resolvedIntent);
+ }
+ policySetAttachPoint.getRequiredIntents().clear();
+ policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);
+
+ List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
+ PolicySet resolvedPolicySet = null;
+ for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
+ resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
+ resolvedPolicySets.add(resolvedPolicySet);
+ }
+ policySetAttachPoint.getPolicySets().clear();
+ policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
+ }
+}
diff --git a/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GdataBindingFactory b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GdataBindingFactory
new file mode 100644
index 0000000000..21688a62a6
--- /dev/null
+++ b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GdataBindingFactory
@@ -0,0 +1,18 @@
+# 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/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..4e71818f7b
--- /dev/null
+++ b/branches/sca-equinox/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.binding.gdata.impl.GdataBindingProcessor;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