Author: svkrish
Date: Thu Mar 20 00:47:04 2008
New Revision: 639189

URL: http://svn.apache.org/viewvc?rev=639189&view=rev
Log:
syncing up with r638840 in trunk : fixing resolution of intentattachpointtypes 
and fixing composite preprocessing for applicablepolicySets for the case of 
multiple contributions with their own definitions.xml

Modified:
    
incubator/tuscany/branches/sca-java-1.2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
    
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
    
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
    
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java

Modified: 
incubator/tuscany/branches/sca-java-1.2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java?rev=639189&r1=639188&r2=639189&view=diff
==============================================================================
--- 
incubator/tuscany/branches/sca-java-1.2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
 (original)
+++ 
incubator/tuscany/branches/sca-java-1.2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
 Thu Mar 20 00:47:04 2008
@@ -24,6 +24,7 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.Collection;
 import java.util.Hashtable;
 import java.util.List;
@@ -69,18 +70,26 @@
     public Composite read(URL contributionURL, URI uri, URL url) throws 
ContributionReadException {
         InputStream scdlStream = null;
         try {
-            if ( domainPolicySets == null ) {
+               if (scaDefnSink != null ) {
                 fillDomainPolicySets(scaDefnSink);
             }
+
             
             byte[] transformedArtifactContent = null;
             try {
-                transformedArtifactContent =
-                    PolicyComputationUtils.addApplicablePolicySets(url, 
domainPolicySets);
+                if ( domainPolicySets != null ) {
+                    transformedArtifactContent =
+                        PolicyComputationUtils.addApplicablePolicySets(url, 
domainPolicySets);
+                    scdlStream = new 
ByteArrayInputStream(transformedArtifactContent);
+                } else {
+                    URLConnection connection = url.openConnection();
+                    connection.setUseCaches(false);
+                    scdlStream = connection.getInputStream();
+                }
             } catch ( Exception e ) {
                 throw new ContributionReadException(e);
             }
-            scdlStream = new ByteArrayInputStream(transformedArtifactContent);
+            
             XMLStreamReader reader = 
inputFactory.createXMLStreamReader(scdlStream);
             
             reader.nextTag();
@@ -138,8 +147,16 @@
     }
     
     private void fillDomainPolicySets(List scaDefnsSink) {
-        Map<QName, PolicySet> domainPolicySetMap = new Hashtable<QName, 
PolicySet>();
-        if ( scaDefnsSink != null ) {
+        Map<QName, PolicySet> domainPolicySetMap = null;
+        if ( !scaDefnsSink.isEmpty() ) {
+            domainPolicySetMap = new Hashtable<QName, PolicySet>();
+            
+            if ( domainPolicySets != null ) {
+                for ( PolicySet policySet : domainPolicySets ) {
+                    domainPolicySetMap.put(policySet.getName(), policySet);
+                } 
+            }
+            
             for ( Object object : scaDefnsSink ) {
                 if ( object instanceof SCADefinitions ) {
                     for ( PolicySet policySet : 
((SCADefinitions)object).getPolicySets() ) {
@@ -147,7 +164,8 @@
                     }
                 }
             }
+            domainPolicySets =  domainPolicySetMap.values();
+            scaDefnsSink.clear();
         }
-        domainPolicySets =  domainPolicySetMap.values();
     }
 }

Modified: 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java?rev=639189&r1=639188&r2=639189&view=diff
==============================================================================
--- 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
 (original)
+++ 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
 Thu Mar 20 00:47:04 2008
@@ -42,15 +42,4 @@
     public QName getArtifactType() {
         return BINDING_TYPE_QNAME;
     }
-
-    @Override
-    public IntentAttachPointType resolveExtensionType(IntentAttachPointType 
extnType, ModelResolver resolver) throws ContributionResolveException {
-        if ( extnType instanceof BindingTypeImpl ) {
-            BindingTypeImpl bindingType = (BindingTypeImpl)extnType;
-            return resolver.resolveModel(BindingTypeImpl.class, bindingType);
-        } else {
-            return extnType;
-        }
-        
-    }
 }

Modified: 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java?rev=639189&r1=639188&r2=639189&view=diff
==============================================================================
--- 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
 (original)
+++ 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
 Thu Mar 20 00:47:04 2008
@@ -43,15 +43,4 @@
     public QName getArtifactType() {
         return IMPLEMENTATION_TYPE_QNAME;
     }
-    
-    @Override
-    public IntentAttachPointType resolveExtensionType(IntentAttachPointType 
extnType, ModelResolver resolver) throws ContributionResolveException {
-        if ( extnType instanceof ImplementationTypeImpl ) {
-            ImplementationTypeImpl implType = (ImplementationTypeImpl)extnType;
-            return resolver.resolveModel(ImplementationTypeImpl.class, 
implType);
-        } else {
-            return extnType;
-        }
-        
-    }
 }

Modified: 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java?rev=639189&r1=639188&r2=639189&view=diff
==============================================================================
--- 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
 (original)
+++ 
incubator/tuscany/branches/sca-java-1.2/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
 Thu Mar 20 00:47:04 2008
@@ -50,8 +50,6 @@
     private IntentAttachPointTypeFactory attachPointTypeFactory;
     private PolicyFactory policyFactory; 
     
-    public abstract IntentAttachPointType 
resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver) 
throws ContributionResolveException;
-
     public IntentAttachPointTypeProcessor(PolicyFactory policyFactory, 
IntentAttachPointTypeFactory attachPointTypeFactory, 
StAXArtifactProcessor<Object> extensionProcessor) {
         this.policyFactory = policyFactory;
         this.attachPointTypeFactory = attachPointTypeFactory;
@@ -64,7 +62,7 @@
             if ( type.getLocalPart().startsWith(BINDING) ) {
                 IntentAttachPointType bindingType = 
attachPointTypeFactory.createBindingType();
                 bindingType.setName(type);
-                bindingType.setUnresolved(false);
+                bindingType.setUnresolved(true);
                 
                 readAlwaysProvidedIntents(bindingType, reader);
                 readMayProvideIntents(bindingType, reader);
@@ -72,7 +70,7 @@
             } else if ( type.getLocalPart().startsWith(IMPLEMENTATION) ) {
                 IntentAttachPointType implType = 
attachPointTypeFactory.createImplementationType();
                 implType.setName(type);
-                implType.setUnresolved(false);
+                implType.setUnresolved(true);
                 
                 readAlwaysProvidedIntents(implType, reader);
                 readMayProvideIntents(implType, reader);
@@ -157,64 +155,61 @@
     public void resolve(IntentAttachPointType extnType, ModelResolver 
resolver) throws ContributionResolveException {
         resolveAlwaysProvidedIntents(extnType, resolver);
         resolveMayProvideIntents(extnType, resolver);
-        resolveExtensionType(extnType, resolver);
-        
-/*        if ( !extnType.isUnresolved() ) {
-             resolver.addModel(extnType);
-        }*/
+        extnType.setUnresolved(false);
     }
 
-    private void resolveAlwaysProvidedIntents(IntentAttachPointType 
extensionType,
-                                              ModelResolver resolver) throws 
ContributionResolveException {
-        if (extensionType != null) {
-            // resolve all provided intents
-            List<Intent> alwaysProvided = new ArrayList<Intent>();
-            for (Intent providedIntent : 
extensionType.getAlwaysProvidedIntents()) {
-                if (providedIntent.isUnresolved()) {
-                    Intent resolvedProvidedIntent = 
resolver.resolveModel(Intent.class, providedIntent);
-                    if (resolvedProvidedIntent != null) {
-                        alwaysProvided.add(resolvedProvidedIntent);
-                    } else {
-                        throw new ContributionResolveException(
-                                                                 "Always 
Provided Intent - " + providedIntent
-                                                                     + " not 
found for ExtensionType "
-                                                                     + 
extensionType);
-
-                    }
-                } else {
-                    alwaysProvided.add(providedIntent);
-                }
-            }
-            extensionType.getAlwaysProvidedIntents().clear();
-            extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
-        }
-    }
+    private void resolveAlwaysProvidedIntents(
+                       IntentAttachPointType extensionType, ModelResolver 
resolver)
+                       throws ContributionResolveException {
+               if (extensionType != null) {
+                       // resolve all provided intents
+                       List<Intent> alwaysProvided = new ArrayList<Intent>();
+                       for (Intent providedIntent : 
extensionType.getAlwaysProvidedIntents()) {
+                               if (providedIntent.isUnresolved()) {
+                                       providedIntent = 
resolver.resolveModel(Intent.class, providedIntent);
+                                       if (!providedIntent.isUnresolved()) {
+                                               
alwaysProvided.add(providedIntent);
+                                       } else {
+                                               throw new 
ContributionResolveException(
+                                                               "Always 
Provided Intent - " + providedIntent
+                                                                               
+ " not found for ExtensionType "
+                                                                               
+ extensionType);
+
+                                       }
+                               } else {
+                                       alwaysProvided.add(providedIntent);
+                               }
+                       }
+                       extensionType.getAlwaysProvidedIntents().clear();
+                       
extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+               }
+       }
     
     private void resolveMayProvideIntents(IntentAttachPointType extensionType,
-                                            ModelResolver resolver) throws 
ContributionResolveException {
-        if (extensionType != null) {
-            // resolve all provided intents
-            List<Intent> mayProvide = new ArrayList<Intent>();
-            for (Intent providedIntent : extensionType.getMayProvideIntents()) 
{
-                if (providedIntent.isUnresolved()) {
-                    Intent resolvedProvidedIntent = 
resolver.resolveModel(Intent.class, providedIntent);
-                    if (resolvedProvidedIntent != null) {
-                        mayProvide.add(resolvedProvidedIntent);
-                    } else {
-                        throw new ContributionResolveException(
-                                                                 "May Provide 
Intent - " + providedIntent
-                                                                     + " not 
found for ExtensionType "
-                                                                     + 
extensionType);
-
-                    }
-                } else {
-                    mayProvide.add(providedIntent);
-                }
-            }
-            extensionType.getMayProvideIntents().clear();
-            extensionType.getMayProvideIntents().addAll(mayProvide);
-        }
-    }
+                       ModelResolver resolver) throws 
ContributionResolveException {
+               if (extensionType != null) {
+                       // resolve all provided intents
+                       List<Intent> mayProvide = new ArrayList<Intent>();
+                       for (Intent providedIntent : 
extensionType.getMayProvideIntents()) {
+                               if (providedIntent.isUnresolved()) {
+                                       providedIntent = 
resolver.resolveModel(Intent.class, providedIntent);
+                                       if (!providedIntent.isUnresolved()) {
+                                               mayProvide.add(providedIntent);
+                                       } else {
+                                               throw new 
ContributionResolveException(
+                                                               "May Provide 
Intent - " + providedIntent
+                                                                               
+ " not found for ExtensionType "
+                                                                               
+ extensionType);
+
+                                       }
+                               } else {
+                                       mayProvide.add(providedIntent);
+                               }
+                       }
+                       extensionType.getMayProvideIntents().clear();
+                       extensionType.getMayProvideIntents().addAll(mayProvide);
+               }
+       }
     
     public Class<IntentAttachPointType> getModelType() {
         return IntentAttachPointType.class;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to