diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-09 15:11:06 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-09 15:11:06 +0000 |
commit | 65622dd13e196361e2ba8774e5dbbcda8ab51f7c (patch) | |
tree | b09a0a03e189ebe11033a8417662465cc2d4a549 /java/sca/modules | |
parent | 173e0992b2a76c5712958ffa94f395ef99eb471e (diff) |
TUSCANY-2467 - Adding GDataImplementationProcessor
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@675221 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
5 files changed, 144 insertions, 23 deletions
diff --git a/java/sca/modules/binding-gdata/pom.xml b/java/sca/modules/binding-gdata/pom.xml index 5aa5d212b2..58525f32ec 100644 --- a/java/sca/modules/binding-gdata/pom.xml +++ b/java/sca/modules/binding-gdata/pom.xml @@ -36,6 +36,12 @@ <version>1.4-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> diff --git a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java index 3cec1cd203..2c4022b166 100644 --- a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.tuscany.sca.binding.gdata; import org.apache.tuscany.sca.assembly.Binding; @@ -27,17 +26,24 @@ import org.apache.tuscany.sca.assembly.Binding; * @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); + + String getLogin(); + + void setLogin(String login); + + String getPassword(); + void setPassword(String password); } diff --git a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java new file mode 100644 index 0000000000..39bbf110ed --- /dev/null +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java @@ -0,0 +1,92 @@ +/* + * Copyright 2008 douglas. + * + * Licensed 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. + * 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 = 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 login = reader.getAttributeValue(null, "login"); + String password = reader.getAttributeValue(null, "password"); + + gdataBinding.setURI(uri); + gdataBinding.setLogin(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.getLogin() != null) { + writer.writeAttribute("login", gdataBinding.getLogin()); + } + 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-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java index 58bca95c19..b2282419c0 100644 --- a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.tuscany.sca.binding.gdata.impl; import java.util.ArrayList; @@ -39,6 +38,8 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint; */ class GDataBindingImpl implements GDataBinding, OptimizableBinding, PolicySetAttachPoint { + private String password; + private String login; private String name; private String uri; private String title; @@ -70,7 +71,7 @@ class GDataBindingImpl implements GDataBinding, OptimizableBinding, PolicySetAtt public String getTitle() { return title; } - + public void setTitle(String title) { this.title = title; } @@ -87,7 +88,7 @@ class GDataBindingImpl implements GDataBinding, OptimizableBinding, PolicySetAtt public List<PolicySet> getPolicySets() { return policySets; } - + public List<Intent> getRequiredIntents() { return requiredIntents; } @@ -95,51 +96,65 @@ class GDataBindingImpl implements GDataBinding, OptimizableBinding, PolicySetAtt public IntentAttachPointType getType() { return intentAttachPointType; } - + public void setType(IntentAttachPointType intentAttachPointType) { this.intentAttachPointType = intentAttachPointType; - } - - //FIXME Temporary to get access to the target binding information + } //FIXME Temporary to get access to the target binding information // To be removed when the distributed domain supports wiring of other // bindings than the SCA binding - private Binding targetBinding; - private Component targetComponent; - private ComponentService targetComponentService; - + private Binding targetBinding; + private Component targetComponent; + private ComponentService targetComponentService; + public Object clone() throws CloneNotSupportedException { return super.clone(); } - + public Binding getTargetBinding() { return targetBinding; } - + public void setTargetBinding(Binding binding) { this.targetBinding = binding; } - + public Component getTargetComponent() { return targetComponent; } - + public void setTargetComponent(Component component) { this.targetComponent = component; } - + public ComponentService getTargetComponentService() { return targetComponentService; } - + public void setTargetComponentService(ComponentService service) { - this.targetComponentService = service; + this.targetComponentService = service; } public void setPolicySets(List<PolicySet> policySets) { - this.policySets = policySets; + this.policySets = policySets; } public void setRequiredIntents(List<Intent> intents) { this.requiredIntents = intents; } + + public String getLogin() { + return this.login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } } diff --git a/java/sca/modules/binding-gdata/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/binding-gdata/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index 1e2cff2b1e..92aad3d44d 100644 --- a/java/sca/modules/binding-gdata/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ b/java/sca/modules/binding-gdata/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -16,4 +16,6 @@ # 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
\ No newline at end of file + +#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 |