Author: ramkumar
Date: Wed Apr 29 11:16:54 2009
New Revision: 769749

URL: http://svn.apache.org/viewvc?rev=769749&view=rev
Log:
Fixes for Spring Refactoring

Modified:
    tuscany/java/sca/modules/implementation-spring/META-INF/MANIFEST.MF
    
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
    
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
    
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java

Modified: tuscany/java/sca/modules/implementation-spring/META-INF/MANIFEST.MF
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/META-INF/MANIFEST.MF?rev=769749&r1=769748&r2=769749&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring/META-INF/MANIFEST.MF 
(original)
+++ tuscany/java/sca/modules/implementation-spring/META-INF/MANIFEST.MF Wed Apr 
29 11:16:54 2009
@@ -11,6 +11,7 @@
 Import-Package: javax.xml.namespace,
  javax.xml.stream,
  org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
  org.apache.tuscany.sca.assembly.impl;version="2.0.0",
  org.apache.tuscany.sca.assembly.xml;version="2.0.0",
  org.apache.tuscany.sca.contribution.processor;version="2.0.0",

Modified: 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java?rev=769749&r1=769748&r2=769749&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
 Wed Apr 29 11:16:54 2009
@@ -20,6 +20,7 @@
 
 import java.util.Hashtable;
 import java.util.List;
+import java.net.URL;
 
 import org.apache.tuscany.sca.assembly.Component;
 import org.apache.tuscany.sca.assembly.ComponentType;
@@ -31,19 +32,19 @@
 import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.springframework.core.io.Resource;
+import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
 
 /**
  * Represents a Spring implementation. 
  * 
  * @version $Rev: 511195 $ $Date: 2007-02-24 02:29:46 +0000 (Sat, 24 Feb 2007) 
$ 
  */
-public class SpringImplementation extends ImplementationImpl implements 
Implementation, Extensible {
+public class SpringImplementation extends ImplementationImpl implements 
Implementation, ComponentPreProcessor, Extensible {
 
     // The location attribute which points to the Spring application-context 
XML file
     private String location;
     // The application-context file as a Spring Resource
-    private Resource resource;
+    private URL resource;
     private ComponentType componentType;
     // Mapping of Services to Beans
     private Hashtable<String, SpringBeanElement> serviceMap;
@@ -75,11 +76,11 @@
         return;
     }
 
-    public void setResource(Resource resource) {
+    public void setResource(URL resource) {
         this.resource = resource;
     }
 
-    public Resource getResource() {
+    public URL getResource() {
         return resource;
     }
 

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=769749&r1=769748&r2=769749&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
 Wed Apr 29 11:16:54 2009
@@ -65,8 +65,6 @@
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
 import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
 import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
 
 /**
  * Introspects a Spring XML application-context configuration file to create 
<implementation-spring../>
@@ -133,7 +131,7 @@
         List<SpringSCAReferenceElement> references = new 
ArrayList<SpringSCAReferenceElement>();
         List<SpringSCAPropertyElement> scaproperties = new 
ArrayList<SpringSCAPropertyElement>();        
 
-        Resource resource;
+        URL resource;
 
         contextPath = implementation.getLocation();
 
@@ -144,10 +142,10 @@
             resource = getApplicationContextResource(contextPath, cl);
             implementation.setResource(resource);
             // The URI is used to uniquely identify the Implementation
-            implementation.setURI(resource.getURL().toString());            
+            implementation.setURI(resource.toString());            
             // FIXME - need a better way to handle the XMLInputFactory than 
allocating a new one every time
             XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
-            reader = 
xmlFactory.createXMLStreamReader(resource.getInputStream());
+            reader = xmlFactory.createXMLStreamReader(new 
FileInputStream(resource.toString()));
 
             // System.out.println("Spring TypeLoader - starting to read 
context file");            
             readContextDefinition(reader, beans, services, references, 
scaproperties);
@@ -175,10 +173,11 @@
         try {
             // FIXME - is the ContextClassLoader the right place to start the 
search?
             cl = Thread.currentThread().getContextClassLoader();
-            Resource resource = getApplicationContextResource(location, cl);   
         
+            URL resource = getApplicationContextResource(location, cl);        
    
             // FIXME - need a better way to handle the XMLInputFactory than 
allocating a new one every time
             XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
-            XMLStreamReader reader = 
xmlFactory.createXMLStreamReader(resource.getInputStream());
+            XMLStreamReader reader = 
+               xmlFactory.createXMLStreamReader(new 
FileInputStream(resource.toString()));
             return reader;
         } catch (IOException e) {
             throw new ContributionReadException(e);
@@ -596,7 +595,7 @@
      * @param locationAttr - the location attribute from the 
<implementation.spring../> element
      * @param cl - the ClassLoader for the Spring implementation
      */
-    protected Resource getApplicationContextResource(String locationAttr, 
ClassLoader cl)
+    protected URL getApplicationContextResource(String locationAttr, 
ClassLoader cl)
         throws ContributionReadException {
         File manifestFile = null;
         File appXmlFile;
@@ -622,7 +621,7 @@
                     if (appCtxPath != null) {
                         appXmlFile = new File(locationFile, appCtxPath);
                         if (appXmlFile.exists()) {
-                            return new UrlResource(appXmlFile.toURL());
+                            return appXmlFile.toURL();
                         }
                     }
                 }
@@ -630,7 +629,7 @@
                 appXmlFile = new File(locationFile, "META-INF" + 
File.separator + "spring" 
                                                         + File.separator + 
SpringImplementationConstants.APPLICATION_CONTEXT);
                 if (appXmlFile.exists()) {
-                    return new UrlResource(appXmlFile.toURL());
+                    return appXmlFile.toURL();
                 }
             } catch (IOException e) {
                 throw new ContributionReadException("Error reading manifest " 
+ manifestFile);
@@ -648,13 +647,13 @@
                             je = jf.getJarEntry(appCtxPath);
                             if (je != null) {
                                 // TODO return a Spring specific Resource type 
for jars
-                                return new UrlResource(new URL("jar:" + 
locationFile.toURI().toURL() + "!/" + appCtxPath));
+                                return new URL("jar:" + 
locationFile.toURI().toURL() + "!/" + appCtxPath);
                             }
                         }
                     }
                     je = jf.getJarEntry("META-INF" + "/" + "spring" + "/" + 
SpringImplementationConstants.APPLICATION_CONTEXT);
                     if (je != null) {
-                        return new UrlResource(new URL("jar:" + 
locationFile.toURI().toURL() + "!/" + 
SpringImplementationConstants.APPLICATION_CONTEXT));
+                        return new URL("jar:" + locationFile.toURI().toURL() + 
"!/" + SpringImplementationConstants.APPLICATION_CONTEXT);
                     }
                 } catch (IOException e) {
                     // bad archive
@@ -665,7 +664,7 @@
                }
                else {
                        if (locationFile.getName().endsWith(".xml")) {
-                               return new UrlResource(url);
+                               return url;
                        } 
                        else {
                                // Deal with the directory inside a jar file, 
in case the contribution itself is a JAR file.
@@ -682,7 +681,7 @@
                                    if (appCtxPath != null) {
                                        je = 
jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/")+2) + "/" + 
appCtxPath);
                                        if (je != null) {
-                                           return new UrlResource(new 
URL("jar:" + url.getPath() + "/" + appCtxPath));
+                                           return new URL("jar:" + 
url.getPath() + "/" + appCtxPath);
                                        }
                                    }
                                                }

Modified: 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java?rev=769749&r1=769748&r2=769749&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
 Wed Apr 29 11:16:54 2009
@@ -45,6 +45,7 @@
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
+import org.springframework.core.io.UrlResource;
 
 /**
  * A provider class for runtime Spring implementation instances
@@ -79,7 +80,7 @@
             new SCAParentApplicationContext(component, implementation, 
proxyService, propertyValueObjectFactory);
         //springContext = new SCAApplicationContext(scaParentContext, 
implementation.getResource());        
         
-        XmlBeanFactory beanFactory = new 
XmlBeanFactory(implementation.getResource());
+        XmlBeanFactory beanFactory = new XmlBeanFactory(new 
UrlResource(implementation.getResource()));
         springContext = createApplicationContext(beanFactory, 
scaParentContext);        
         
     } // end constructor


Reply via email to