tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r572267 [6/6] - in /incubator/tuscany/java/sca: itest/ modules/ modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ modules/binding-jms/src/main/jav...
Date Mon, 03 Sep 2007 09:46:47 GMT
Modified: incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java
(original)
+++ incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java
Mon Sep  3 02:46:41 2007
@@ -21,23 +21,21 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.StringTokenizer;
 
 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.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.interfacedef.Operation;
 import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
 import org.apache.tuscany.sca.policy.PolicyFactory;
 import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
 
 import echo.EchoBinding;
 import echo.EchoBindingFactory;
@@ -50,11 +48,11 @@
     private QName BINDING_ECHO = new QName("http://echo", "binding.echo");
     
     private final EchoBindingFactory factory;
-    private PolicyFactory policyFactory;
+    private PolicyAttachPointProcessor policyProcessor;
 
-    public EchoBindingProcessor(EchoBindingFactory factory, PolicyFactory pFactory) {
+    public EchoBindingProcessor(EchoBindingFactory factory, PolicyFactory policyFactory)
{
         this.factory = factory;
-        this.policyFactory = pFactory;
+        this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
     }
 
     public QName getArtifactType() {
@@ -65,72 +63,39 @@
         return EchoBinding.class;
     }
 
-    public EchoBinding read(XMLStreamReader reader) throws ContributionReadException {
+    public EchoBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException
{
         EchoBinding echoBinding = factory.createEchoBinding();
 
         String name = reader.getAttributeValue(null, "name");
         if (name != null) {
             echoBinding.setName(name);
         }
+
         String uri = reader.getAttributeValue(null, "uri");
         if (uri != null) {
             echoBinding.setURI(uri);
         }
         
-        readPolicies(echoBinding, null, reader);
+        policyProcessor.readPolicies(echoBinding, reader);
+
         return echoBinding;
     }
     
-    protected QName getQNameValue(XMLStreamReader reader, String value) {
-        if (value != null) {
-            int index = value.indexOf(':');
-            String prefix = index == -1 ? "" : value.substring(0, index);
-            String localName = index == -1 ? value : value.substring(index + 1);
-            String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
-            if (ns == null) {
-                ns = "";
-            }
-            return new QName(ns, localName, prefix);
-        } else {
-            return null;
-        }
-    }
-    
-    protected void readIntents(IntentAttachPoint attachPoint, Operation operation, XMLStreamReader
reader) {
-        String value = reader.getAttributeValue(null, "requires");
-        if (value != null) {
-            List<Intent> requiredIntents = attachPoint.getRequiredIntents();
-            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();)
{
-                QName qname = getQNameValue(reader, tokens.nextToken());
-                Intent intent = policyFactory.createIntent();
-                intent.setName(qname);
-                if (operation != null) {
-                    //intent.getOperations().add(operation);
-                }
-                requiredIntents.add(intent);
-            }
-        }
-    }
-    
-    protected void readPolicies(PolicySetAttachPoint attachPoint, Operation operation, XMLStreamReader
reader) {
-        readIntents(attachPoint, operation, reader);
+    public void write(EchoBinding echoBinding, XMLStreamWriter writer) throws ContributionWriteException,
XMLStreamException {
 
-        String value = reader.getAttributeValue(null, "policySets");
-        if (value != null) {
-            List<PolicySet> policySets = attachPoint.getPolicySets();
-            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();)
{
-                QName qname = getQNameValue(reader, tokens.nextToken());
-                PolicySet policySet = policyFactory.createPolicySet();
-                policySet.setName(qname);
-                if (operation != null) {
-                    //policySet.getOperations().add(operation);
-                }
-                policySets.add(policySet);
-            }
+        policyProcessor.writePolicyPrefixes(echoBinding, writer);
+        writer.writeStartElement(BINDING_ECHO.getNamespaceURI(), BINDING_ECHO.getLocalPart());
+        policyProcessor.writePolicyAttributes(echoBinding, writer);
+        
+        if (echoBinding.getName() != null) {
+            writer.writeAttribute("name", echoBinding.getName());
         }
-    }
-
-    public void write(EchoBinding echoBinding, XMLStreamWriter writer) throws ContributionWriteException
{
+        
+        if (echoBinding.getURI() != null) {
+            writer.writeAttribute("uri", echoBinding.getURI());
+        }
+        
+        writer.writeEndElement();
     }
 
     public void resolve(EchoBinding echoBinding, ModelResolver resolver) throws ContributionResolveException
{

Modified: incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java
(original)
+++ incubator/tuscany/java/sca/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java
Mon Sep  3 02:46:41 2007
@@ -40,21 +40,20 @@
         return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
     }
 
-    public WSPolicy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException
{
+    public WSPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException
{
+        //FIXME Implement this method
         return new WSPolicy();
     }
 
-    public void write(WSPolicy arg0, XMLStreamWriter arg1) throws ContributionWriteException,
-                                                        XMLStreamException {
-
+    public void write(WSPolicy wsPolicy, XMLStreamWriter writer) throws ContributionWriteException,
XMLStreamException {
+        //FIXME Implement this method
     }
 
     public Class<WSPolicy> getModelType() {
-        // TODO Auto-generated method stub
         return WSPolicy.class;
     }
 
-    public void resolve(WSPolicy arg0, ModelResolver arg1) throws ContributionResolveException
{
+    public void resolve(WSPolicy wsPolicy, ModelResolver modelResolver) throws ContributionResolveException
{
 
     }
 }

Modified: incubator/tuscany/java/sca/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java
(original)
+++ incubator/tuscany/java/sca/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java
Mon Sep  3 02:46:41 2007
@@ -28,6 +28,7 @@
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.ComponentType;
 import org.apache.tuscany.sca.assembly.Service;
+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.ClassReference;
@@ -39,6 +40,7 @@
 import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
 
 import pojo.POJOImplementation;
 import pojo.POJOImplementationFactory;
@@ -57,6 +59,8 @@
     private AssemblyFactory assemblyFactory;
     private JavaInterfaceFactory javaFactory;
     private POJOImplementationFactory pojoImplementationFactory;
+    private PolicyFactory policyFactory;
+    private PolicyAttachPointProcessor policyProcessor;
     
     public POJOImplementationProcessor(ModelFactoryExtensionPoint modelFactories) {
         
@@ -64,7 +68,9 @@
         // create model objects 
         assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
         javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+        policyFactory = modelFactories.getFactory(PolicyFactory.class);
         pojoImplementationFactory = modelFactories.getFactory(POJOImplementationFactory.class);
+        policyProcessor = new PolicyAttachPointProcessor(policyFactory);
     }
 
     public QName getArtifactType() {
@@ -80,12 +86,13 @@
     public POJOImplementation read(XMLStreamReader reader) throws ContributionReadException,
XMLStreamException {
     
         // Read an <implementation.pojo> element
+        POJOImplementation implementation = pojoImplementationFactory.createPOJOImplementation();
+        
+        // Read policies
+        policyProcessor.readPolicies(implementation, reader);
         
         // Read the POJO class attribute.
         String className = reader.getAttributeValue(null, "class");
-
-        // Create the POJO implementation model
-        POJOImplementation implementation = pojoImplementationFactory.createPOJOImplementation();
         implementation.setPOJOName(className);
         
         // Mark the POJO model unresolved to track the fact that it's not
@@ -150,6 +157,17 @@
         implementation.setUnresolved(false);
     }
 
-    public void write(POJOImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException
{
+    public void write(POJOImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException,
XMLStreamException {
+        
+        // Write <implementation.pojo> element
+        policyProcessor.writePolicyPrefixes(implementation, writer);
+        writer.writeStartElement(IMPLEMENTATION_POJO.getNamespaceURI(), IMPLEMENTATION_POJO.getLocalPart());
+        policyProcessor.writePolicyAttributes(implementation, writer);
+        
+        if (implementation.getPOJOName() != null) {
+            writer.writeAttribute("class", implementation.getPOJOName());
+        }
+        
+        writer.writeEndElement();
     }
 }

Modified: incubator/tuscany/java/sca/samples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/pom.xml?rev=572267&r1=572266&r2=572267&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/pom.xml (original)
+++ incubator/tuscany/java/sca/samples/pom.xml Mon Sep  3 02:46:41 2007
@@ -67,10 +67,10 @@
                 <module>implementation-notification</module>
                 <module>implementation-pojo-extension</module>
                 <module>loanapplication</module>
+                <!--
                 <module>osgi-supplychain</module>
-<!--
                 <module>quote-xquery</module>
--->
+                -->
                 <module>simple-bigbank</module>
                 <module>simple-bigbank-spring</module>
                 <module>simple-callback</module>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message