Author: ramkumar
Date: Tue Oct 13 09:24:58 2009
New Revision: 824651

URL: http://svn.apache.org/viewvc?rev=824651&view=rev
Log:
For implementation.spring module on unix path fixes and policy processor for 
service and references

Modified:
    
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
    
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
    
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java

Modified: 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java?rev=824651&r1=824650&r2=824651&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
 Tue Oct 13 09:24:58 2009
@@ -18,6 +18,11 @@
  */
 package org.apache.tuscany.sca.implementation.spring;
 
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
 /**
  * Represents a <sca:reference> element in a Spring application-context
  * - this has id and className attributes
@@ -30,8 +35,8 @@
     private String name;
     private String type;
     private String defaultBean;
-    private String requiredIntents;
-    private String policySets;
+    private List<Intent> intents = new ArrayList<Intent>();
+    private List<PolicySet> policySets = new ArrayList<PolicySet>();
 
     public SpringSCAReferenceElement(String name, String type) {
         this.name = name;
@@ -62,19 +67,11 @@
         return defaultBean;
     }
     
-    public void setRequiredIntents(String requiredIntents) {           
-       this.requiredIntents = requiredIntents;
-    }
-    
-    public String getRequiredIntents() {       
-       return requiredIntents;
-    }
-    
-    public void setPolicySets(String policySets) {     
-       this.policySets = policySets;
+    public List<Intent> getRequiredIntents() {
+        return intents;
     }
     
-    public String getPolicySets() {    
+    public List<PolicySet> getPolicySets() {           
        return policySets;
     }
 

Modified: 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java?rev=824651&r1=824650&r2=824651&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
 Tue Oct 13 09:24:58 2009
@@ -18,6 +18,11 @@
  */
 package org.apache.tuscany.sca.implementation.spring;
 
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
 /**
  * Represents a <sca:service> element in a Spring application-context
  * - this has id and className attributes
@@ -30,8 +35,8 @@
     private String name;
     private String type;
     private String target;
-    private String requiredIntents;
-    private String policySets;
+    private List<Intent> intents = new ArrayList<Intent>();
+    private List<PolicySet> policySets = new ArrayList<PolicySet>();
 
     public SpringSCAServiceElement(String name, String target) {
         this.name = name;
@@ -62,19 +67,11 @@
         return target;
     }
     
-    public void setRequiredIntents(String requiredIntents) {           
-       this.requiredIntents = requiredIntents;
-    }
-    
-    public String getRequiredIntents() {       
-       return requiredIntents;
-    }
-    
-    public void setPolicySets(String policySets) {     
-       this.policySets = policySets;
+    public List<Intent> getRequiredIntents() {
+        return intents;
     }
     
-    public String getPolicySets() {    
+    public List<PolicySet> getPolicySets() {           
        return policySets;
     }
 

Modified: 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java?rev=824651&r1=824650&r2=824651&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
 Tue Oct 13 09:24:58 2009
@@ -51,6 +51,7 @@
 import org.apache.tuscany.sca.assembly.Property;
 import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
 import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.ContributionFactory;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
@@ -93,6 +94,7 @@
     private AssemblyFactory assemblyFactory;
     private JavaInterfaceFactory javaFactory;
     private PolicyFactory policyFactory;
+    private PolicySubjectProcessor policyProcessor;
     private Monitor monitor;
     private SpringBeanIntrospector beanIntrospector;
 
@@ -105,6 +107,7 @@
         this.assemblyFactory = assemblyFactory;
         this.javaFactory = javaFactory;
         this.policyFactory = policyFactory;
+        this.policyProcessor = new PolicySubjectProcessor(policyFactory);
         this.contributionFactory = 
factories.getFactory(ContributionFactory.class);
         this.xmlInputFactory = factories.getFactory(XMLInputFactory.class);
         this.monitor = monitor;
@@ -311,10 +314,7 @@
                                                                                
        reader.getAttributeValue(null, "target"));
                             if (reader.getAttributeValue(null, "type") != null)
                                service.setType(reader.getAttributeValue(null, 
"type"));
-                            if (reader.getAttributeValue(null, "requires") != 
null)
-                               
service.setRequiredIntents(reader.getAttributeValue(null, "requires"));
-                            if (reader.getAttributeValue(null, "policySets") 
!= null)
-                               
service.setPolicySets(reader.getAttributeValue(null, "policySets"));
+                            policyProcessor.readPolicies(service, reader);
                             services.add(service);
                         } else if 
(SpringImplementationConstants.SCA_REFERENCE_ELEMENT.equals(qname)) {
                                // The value of the @name attribute of an 
<sca:reference/> subelement of a <beans/> 
@@ -328,10 +328,7 @@
                                                                                
          reader.getAttributeValue(null, "type"));
                             if (reader.getAttributeValue(null, "default") != 
null)
                                
reference.setDefaultBean(reader.getAttributeValue(null, "default"));
-                            if (reader.getAttributeValue(null, "requires") != 
null)
-                               
reference.setRequiredIntents(reader.getAttributeValue(null, "requires"));
-                            if (reader.getAttributeValue(null, "policySets") 
!= null)
-                               
reference.setPolicySets(reader.getAttributeValue(null, "policySets"));
+                            policyProcessor.readPolicies(reference, reader);
                             references.add(reference);                         
   
                         } else if 
(SpringImplementationConstants.SCA_PROPERTY_ELEMENT.equals(qname)) {
                                // The value of the @name attribute of an 
<sca:property/> subelement of a <beans/> 
@@ -560,7 +557,7 @@
             // Deal with the services first....
             Iterator<SpringSCAServiceElement> its = services.iterator();
             while (its.hasNext()) {
-                SpringSCAServiceElement serviceElement = its.next();
+                SpringSCAServiceElement serviceElement = its.next();           
     
                 Class<?> interfaze = resolveClass(resolver, 
serviceElement.getType());
                 Service theService = createService(interfaze, 
serviceElement.getName());
                 // Spring allows duplication of bean definitions in multiple 
context scenario,
@@ -581,11 +578,9 @@
                     if (beanName.equals(beanElement.getId())) {
                        if (isvalidBeanForService(beanElement)) {
                                // add the required intents and policySets for 
the service
-                            
//theService.getRequiredIntents().addAll(collection);
-                            //theService.getPolicySets().addAll(collection);
+                            
theService.getRequiredIntents().addAll(serviceElement.getRequiredIntents());
+                            
theService.getPolicySets().addAll(serviceElement.getPolicySets());
                             implementation.setBeanForService(theService, 
beanElement);
-                       } else {
-                               // Do we need a warning message here.
                        }
                     }
                 } // end for
@@ -608,8 +603,8 @@
                        componentType.getReferences().remove(duplicate);
                 
                 // add the required intents and policySets for this reference
-                //theReference.getRequiredIntents().addAll(collection);
-                //theReference.getPolicySets().addAll(collection);
+                
theReference.getRequiredIntents().addAll(referenceElement.getRequiredIntents());
+                
theReference.getPolicySets().addAll(referenceElement.getPolicySets());
                 componentType.getReferences().add(theReference);
             } // end while
 
@@ -1006,7 +1001,7 @@
                         }
                     }
                     // No MANIFEST.MF file OR no manifest-specified Spring 
context , then read all the 
-                    // xml files available in the META-INF/spring folder.
+                    // .xml files available in the META-INF/spring folder.
                     Enumeration<JarEntry> entries = jf.entries();
                     while (entries.hasMoreElements()) {
                        je = entries.nextElement();
@@ -1030,7 +1025,7 @@
                                // Deal with the directory inside a jar file, 
in case the contribution itself is a JAR file.
                                try {
                                        if 
(locationFile.getPath().indexOf(".jar") > 0) {
-                                               String jarPath = 
url.getPath().substring(6, url.getPath().indexOf("!"));
+                                               String jarPath = 
url.getPath().substring(5, url.getPath().indexOf("!"));
                                                JarFile jf = new 
JarFile(jarPath);
                                                JarEntry je = 
jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/")+2)
                                                                                
                                + "/" + "META-INF" + "/" + "MANIFEST.MF");
@@ -1050,7 +1045,7 @@
                                    }
                                                }                               
            
                                            // No MANIFEST.MF file OR no 
manifest-specified Spring context , then read all the 
-                               // xml files available in the META-INF/spring 
folder.
+                               // .xml files available in the META-INF/spring 
folder.
                                            Enumeration<JarEntry> entries = 
jf.entries();
                                while (entries.hasMoreElements()) {
                                        je = entries.nextElement();


Reply via email to