diff options
author | ramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-29 08:57:12 +0000 |
---|---|---|
committer | ramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-29 08:57:12 +0000 |
commit | bd7f93a11ed3da2db0e17f2e5c725b8d9acb3e67 (patch) | |
tree | 6e381149a20e1495893e5201b9c705518239dbf0 /branches/sca-java-1.x/modules | |
parent | 8d7bfe07035515556840fa330504f07c38b86267 (diff) |
Fixes for TUSCANY-3104
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@789263 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules')
2 files changed, 38 insertions, 47 deletions
diff --git a/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java b/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java index 9e56eac6cd..2cd60d201f 100644 --- a/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java +++ b/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java @@ -40,7 +40,6 @@ import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.UrlResource;
import org.springframework.core.SpringVersion;
@@ -84,58 +83,52 @@ public class SpringContextTie { }
/**
- * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ * Create appropriate ApplicationContext by reading the bean definitions.
*/
-// private Object createApplicationContext(SCAParentApplicationContext scaParentContext) {
-
private AbstractApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext, URL resource) {
XmlBeanFactory beanFactory = new XmlBeanFactory(new UrlResource(resource));
AbstractApplicationContext appContext = null;
for (String bean : beanFactory.getBeanDefinitionNames()) {
- String beanClassName = (beanFactory.getType(bean)).getName();
- if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1 ||
- beanClassName.indexOf(".FileSystemXmlApplicationContext") != -1)
- {
- BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);
- String[] listValues = null;
- List<ConstructorArgumentValues.ValueHolder> conArgs =
- beanDef.getConstructorArgumentValues().getGenericArgumentValues();
- for (ConstructorArgumentValues.ValueHolder conArg : conArgs) {
- if (conArg.getValue() instanceof TypedStringValue) {
- TypedStringValue value = (TypedStringValue) conArg.getValue();
- if (value.getValue().indexOf(".xml") != -1)
- listValues = new String[]{value.getValue()};
- }
- if (conArg.getValue() instanceof ManagedList) {
- Iterator itml = ((ManagedList)conArg.getValue()).iterator();
- StringBuffer values = new StringBuffer();
- while (itml.hasNext()) {
- TypedStringValue next = (TypedStringValue)itml.next();
- if (next.getValue().indexOf(".xml") != -1) {
- values.append(next.getValue());
- values.append("~");
- }
+ String beanClassName = (beanFactory.getType(bean)).getName();
+ // Using FileSystemXmlApplicationContext is not supported, as the
+ // SCA runtime does not support paths relative to current VM working directory.
+ if (beanClassName.indexOf(".FileSystemXmlApplicationContext") != -1) {
+ throw new RuntimeException("Usage of FileSystemXmlApplicationContext Bean is not supported");
+ }
+
+ if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1) {
+ BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);
+ String[] listValues = null;
+ List<ConstructorArgumentValues.ValueHolder> conArgs =
+ beanDef.getConstructorArgumentValues().getGenericArgumentValues();
+ for (ConstructorArgumentValues.ValueHolder conArg : conArgs) {
+ if (conArg.getValue() instanceof TypedStringValue) {
+ TypedStringValue value = (TypedStringValue) conArg.getValue();
+ if (value.getValue().indexOf(".xml") != -1)
+ listValues = new String[]{value.getValue()};
+ }
+ if (conArg.getValue() instanceof ManagedList) {
+ Iterator itml = ((ManagedList)conArg.getValue()).iterator();
+ StringBuffer values = new StringBuffer();
+ while (itml.hasNext()) {
+ TypedStringValue next = (TypedStringValue)itml.next();
+ if (next.getValue().indexOf(".xml") != -1) {
+ values.append(next.getValue());
+ values.append("~");
}
- listValues = (values.toString()).split("~");
}
+ listValues = (values.toString()).split("~");
}
-
- if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1) {
- appContext = new ClassPathXmlApplicationContext(listValues, false, scaParentContext);
- appContext.refresh();
- if (isAnnotationSupported)
- includeAnnotationProcessors(appContext.getBeanFactory());
- return appContext;
- } else {
- appContext = new FileSystemXmlApplicationContext(listValues, false, scaParentContext);
- appContext.refresh();
- if (isAnnotationSupported)
- includeAnnotationProcessors(appContext.getBeanFactory());
- return appContext;
- }
- }
+ }
+
+ appContext = new ClassPathXmlApplicationContext(listValues, false, scaParentContext);
+ appContext.refresh();
+ if (isAnnotationSupported)
+ includeAnnotationProcessors(appContext.getBeanFactory());
+ return appContext;
+ }
}
// use the generic application context as default
diff --git a/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java index 50aad250ea..3ed3060d8f 100644 --- a/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java +++ b/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java @@ -294,8 +294,7 @@ public class SpringXMLComponentTypeLoader { String value = reader.getAttributeValue(null, "value");
constructorArg.addValue(value);
if ((value.indexOf(".xml") != -1)) {
- if ((bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) ||
- (bean.getClassName().indexOf(".FileSystemXmlApplicationContext") != -1)) {
+ if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) {
XMLStreamReader creader = getApplicationContextReader(value);
// Read the context definition for the constructor-arg resources
readContextDefinition(creader, beans, services, references, scaproperties);
@@ -316,8 +315,7 @@ public class SpringXMLComponentTypeLoader { constructorArg.addValue(value);
// Identify the XML resource specified for the constructor-arg element
if ((value.indexOf(".xml") != -1)) {
- if ((bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) ||
- (bean.getClassName().indexOf(".FileSystemXmlApplicationContext") != -1)) {
+ if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) {
XMLStreamReader creader = getApplicationContextReader(value);
// Read the context definition for the constructor-arg resources
readContextDefinition(creader, beans, services, references, scaproperties);
|