summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-01-29 01:02:16 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-01-29 01:02:16 +0000
commit2e79dc9247a5ffb78b420eed43280467ce35e99b (patch)
treedc02949563bc95ff026ee063b1dc0f68587984db /branches/sca-java-1.x/modules
parent192325d5aedd6a5268c673d7b88638847ec6a3bc (diff)
Adding support for extended attributes to java implementation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@738689 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules')
-rw-r--r--branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java9
-rw-r--r--branches/sca-java-1.x/modules/implementation-java-xml/pom.xml2
-rw-r--r--branches/sca-java-1.x/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java41
3 files changed, 43 insertions, 9 deletions
diff --git a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
index 9796621747..366d85429b 100644
--- a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
+++ b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
@@ -86,7 +86,7 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
private StAXAttributeProcessor<Object> extensionAttributeProcessor;
private Monitor monitor;
- public WebServiceBindingProcessor(ExtensionPointRegistry extensionPoints) {
+ public WebServiceBindingProcessor(ExtensionPointRegistry extensionPoints, Monitor monitor) {
this.extensionPoints = extensionPoints;
ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
@@ -96,11 +96,7 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class);
this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
- UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
- if (monitorFactory != null) {
- this.monitor = monitorFactory.createMonitor();
- }
+ this.monitor = monitor;
this.configuredOperationProcessor = new ConfiguredOperationProcessor(modelFactories, this.monitor);
this.extensionAttributeProcessor = extensionPoints.getExtensionPoint(ExtensibleStAXAttributeProcessor.class);
}
@@ -351,6 +347,7 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsBinding.getLocation());
}
+ // Write extended attributes
for(Extension extension : wsBinding.getAttributeExtensions()) {
if(extension.isAttribute()) {
extensionAttributeProcessor.write(extension, writer);
diff --git a/branches/sca-java-1.x/modules/implementation-java-xml/pom.xml b/branches/sca-java-1.x/modules/implementation-java-xml/pom.xml
index cf46df6722..e471ad4639 100644
--- a/branches/sca-java-1.x/modules/implementation-java-xml/pom.xml
+++ b/branches/sca-java-1.x/modules/implementation-java-xml/pom.xml
@@ -33,7 +33,7 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly-xml</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>${version}</version>
</dependency>
<dependency>
diff --git a/branches/sca-java-1.x/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java b/branches/sca-java-1.x/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
index 11934ec6bb..e89fd13877 100644
--- a/branches/sca-java-1.x/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
+++ b/branches/sca-java-1.x/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
@@ -36,6 +36,8 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.ExtensionFactory;
import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
@@ -46,6 +48,7 @@ import org.apache.tuscany.sca.assembly.xml.Constants;
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.processor.StAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.resolver.ClassReference;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
@@ -71,22 +74,29 @@ import org.apache.tuscany.sca.policy.PolicyFactory;
public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaImplementation>,
JavaImplementationConstants {
- private JavaImplementationFactory javaFactory;
private AssemblyFactory assemblyFactory;
private PolicyFactory policyFactory;
+ private ExtensionFactory extensionFactory;
+ private JavaImplementationFactory javaFactory;
private PolicyAttachPointProcessor policyProcessor;
private IntentAttachPointTypeFactory intentAttachPointTypeFactory;
private ConfiguredOperationProcessor configuredOperationProcessor;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
private Monitor monitor;
- public JavaImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+ public JavaImplementationProcessor(ModelFactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ Monitor monitor) {
this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class);
this.javaFactory = modelFactories.getFactory(JavaImplementationFactory.class);
this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
this.monitor = monitor;
this.configuredOperationProcessor = new ConfiguredOperationProcessor(modelFactories, this.monitor);
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
}
/**
@@ -134,6 +144,26 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm
// Read policies
policyProcessor.readPolicies(javaImplementation, reader);
+
+ // Handle extended attributes
+ for (int a = 0; a < reader.getAttributeCount(); a++) {
+ QName attributeName = reader.getAttributeName(a);
+ if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
+ if( (! Constants.SCA10_NS.equals(attributeName.getNamespaceURI()) &&
+ (! Constants.SCA10_TUSCANY_NS.equals(attributeName.getNamespaceURI()) ))) {
+ Object attributeValue = extensionAttributeProcessor.read(attributeName, reader);
+ Extension attributeExtension;
+ if (attributeValue instanceof Extension) {
+ attributeExtension = (Extension) attributeValue;
+ } else {
+ attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true);
+ }
+ javaImplementation.getAttributeExtensions().add(attributeExtension);
+ }
+ }
+ }
+
+
// read operation elements if exists or skip unto end element
int event;
@@ -171,6 +201,13 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm
writer.writeAttribute(CLASS, javaImplementation.getName());
}
+ // Write extended attributes
+ for(Extension extension : javaImplementation.getAttributeExtensions()) {
+ if(extension.isAttribute()) {
+ extensionAttributeProcessor.write(extension, writer);
+ }
+ }
+
writer.writeEndElement();
}