diff options
Diffstat (limited to 'java/sca/modules/implementation-spring/src')
5 files changed, 85 insertions, 9 deletions
diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java index f098e2d78e..60af3e2ad5 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java @@ -33,6 +33,9 @@ public class SpringBeanElement { private String id; private String className; private boolean innerBean = false; + private boolean abstractBean = false; + private boolean refParentBean = false; + private boolean reffactoryBean = false; private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>(); private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>(); @@ -72,5 +75,13 @@ public class SpringBeanElement { public void setInnerBean(boolean innerBean) { this.innerBean = innerBean; } + + public boolean isAbstractBean() { + return abstractBean; + } + + public void setAbstractBean(boolean abstractBean) { + this.abstractBean = abstractBean; + } } // end class SpringBeanElement diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java index 0df04457fb..9a8fac6a61 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java @@ -55,6 +55,7 @@ public class SpringImplementation extends ImplementationImpl implements Implemen private Hashtable<String, Class<?>> propertyMap; // List of unresolved bean property references private Hashtable<String, Reference> unresolvedBeanRef; + private ClassLoader classLoader; public SpringImplementation() { super(TYPE); @@ -217,4 +218,12 @@ public class SpringImplementation extends ImplementationImpl implements Implemen } return newProperty; } -} + + public ClassLoader getClassLoader() { + return classLoader; + } + + public void setClassLoader(ClassLoader classLoader) { + this.classLoader = classLoader; + } +}
\ No newline at end of file diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java index efc4b309e0..720a56e0ad 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java @@ -27,7 +27,11 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; +import java.util.Arrays; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -77,7 +81,6 @@ import org.apache.tuscany.sca.policy.PolicyFactory; * Introspects a Spring XML application-context configuration file to create <implementation-spring../> * component type information. * - * * @version $Rev$ $Date$ */ public class SpringXMLComponentTypeLoader { @@ -158,6 +161,8 @@ public class SpringXMLComponentTypeLoader { try { resource = resolveLocation(resolver, contextPath); resource = getApplicationContextResource(resource); + + implementation.setClassLoader(new ContextClassLoader(resolver)); implementation.setResource(resource); // The URI is used to uniquely identify the Implementation implementation.setURI(resource.toString()); @@ -687,12 +692,13 @@ public class SpringXMLComponentTypeLoader { } } } + // Look for the default applicaiton-context.xml file, when MANIFEST.MF is absent. je = jf.getJarEntry("META-INF" + "/" + "spring" + "/" + SpringImplementationConstants.APPLICATION_CONTEXT); if (je != null) { - return new URL("jar:" + locationFile.toURI().toURL() + "!/" + SpringImplementationConstants.APPLICATION_CONTEXT); + return new URL("jar:" + locationFile.toURI().toURL() + "!/" + + "META-INF" + "/" + "spring" + "/" + SpringImplementationConstants.APPLICATION_CONTEXT); } } catch (IOException e) { - // bad archive // TODO: create a more appropriate exception type throw new ContributionReadException("SpringXMLLoader getApplicationContextResource: " + " IO exception reading context file.", e); @@ -706,8 +712,8 @@ public class SpringXMLComponentTypeLoader { // 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 jarEntry = url.getPath().substring(6, url.getPath().indexOf("!")); - JarFile jf = new JarFile(jarEntry); + String jarPath = url.getPath().substring(6, url.getPath().indexOf("!")); + JarFile jf = new JarFile(jarPath); JarEntry je = jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/")+2) + "/" + "META-INF" + "/" + "MANIFEST.MF"); if (je != null) { @@ -721,6 +727,13 @@ public class SpringXMLComponentTypeLoader { } } } + // Look for the default applicaiton-context.xml file, when MANIFEST.MF is absent. + je = jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/")+2) + "/" + + "META-INF" + "/" + "spring" + "/" + SpringImplementationConstants.APPLICATION_CONTEXT); + if (je != null) { + return new URL("jar:" + url.getPath() + "/" + + "META-INF" + "/" + "spring" + "/" + SpringImplementationConstants.APPLICATION_CONTEXT); + } } } catch (IOException e) { throw new ContributionReadException("Error reading manifest " + manifestFile); @@ -778,4 +791,38 @@ public class SpringXMLComponentTypeLoader { return reference; } -} // end class SpringXMLComponentTypeLoader + + private class ContextClassLoader extends ClassLoader { + public ContextClassLoader(ModelResolver resolver) { + super(); + this.resolver = resolver; + } + + private ModelResolver resolver; + + @Override + protected Class<?> findClass(String name) throws ClassNotFoundException { + return SpringXMLComponentTypeLoader.this.resolveClass(resolver, name); + } + + @Override + protected URL findResource(String name) { + try { + return resolveLocation(resolver, name); + } catch (Exception e) { + return null; + } + } + + @Override + protected Enumeration<URL> findResources(String name) throws IOException { + URL url = findResource(name); + if (url != null) { + return Collections.enumeration(Arrays.asList(url)); + } else { + Collection<URL> urls = Collections.emptyList(); + return Collections.enumeration(urls); + } + } + } +} // end class SpringXMLComponentTypeLoader
\ No newline at end of file diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java index 6a7eb2e024..5ca8c128f4 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java @@ -85,6 +85,7 @@ public class SpringContextStub { } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { + e.printStackTrace(); throw new RuntimeException(e); } } @@ -97,6 +98,7 @@ public class SpringContextStub { } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { + e.printStackTrace(); throw new RuntimeException(e); } } @@ -109,6 +111,7 @@ public class SpringContextStub { } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { + e.printStackTrace(); throw new RuntimeException(e); } } @@ -123,8 +126,9 @@ public class SpringContextStub { } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { + e.printStackTrace(); throw new RuntimeException(e); } } -} +}
\ No newline at end of file diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java index 590b278e4c..6ff573f4be 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java @@ -140,4 +140,9 @@ public class SpringImplementationTie { public Object getPropertyValueTie() { return new PropertyValueTie(component, propertyFactory); } -} + + public ClassLoader getClassLoader() { + return implementation.getClassLoader(); + } + +}
\ No newline at end of file |