summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.5.1
diff options
context:
space:
mode:
authorramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-09-02 11:57:20 +0000
committerramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-09-02 11:57:20 +0000
commitd8df6f699d7c5de11382b5f6dc5f148da523b19e (patch)
tree0a56f7d195f582c8375c650a7ca7da733bbbc3ab /branches/sca-java-1.5.1
parent90fae7c9948586c1080356a7b61b0196e2701448 (diff)
Fixes for TUSCANY-3249 - providing on/off feature for multiple application context support
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@810466 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java82
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java9
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java2
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java8
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java12
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java5
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java5
-rw-r--r--branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java25
8 files changed, 90 insertions, 58 deletions
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java b/branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
index d53edf2325..6e8f1e8df4 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
@@ -58,6 +58,7 @@ public class SpringContextTie {
private SpringImplementationStub implementation;
private boolean isAnnotationSupported;
private String versionSupported;
+ private boolean isMultipleContextSupport;
// TUSCANY-3128
// extension of the generic application context just to force the classloader
@@ -81,10 +82,11 @@ public class SpringContextTie {
}
}
- public SpringContextTie(SpringImplementationStub implementation, URL resource, boolean annotationSupport, String versionSupported) throws Exception {
+ public SpringContextTie(SpringImplementationStub implementation, URL resource, boolean annotationSupport, String versionSupported, boolean multipleContextSupport) throws Exception {
this.implementation = implementation;
this.isAnnotationSupported = annotationSupport;
this.versionSupported = versionSupported;
+ this.isMultipleContextSupport = multipleContextSupport;
if (! this.versionSupported.equals("ANY")) {
if ((SpringVersion.getVersion()!= null) && (! SpringVersion.getVersion().equals(versionSupported)))
throw new RuntimeException("Unsupported version: Use only Spring Framework Version " + versionSupported);
@@ -116,44 +118,46 @@ public class SpringContextTie {
beanFactory.setBeanClassLoader(implementation.getClassLoader());
AbstractApplicationContext appContext = null;
- for (String bean : beanFactory.getBeanDefinitionNames()) {
- 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[] configLocations = 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)
- configLocations = 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(implementation.getClassLoader().getResource(next.getValue()).toString());
- values.append("~");
- }
- }
- configLocations = (values.toString()).split("~");
- }
- }
-
- appContext = new ClassPathXmlApplicationContext(configLocations, true, scaParentContext);
- if (isAnnotationSupported)
- includeAnnotationProcessors(appContext.getBeanFactory());
- return appContext;
- }
+ if (isMultipleContextSupport) {
+ for (String bean : beanFactory.getBeanDefinitionNames()) {
+ 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[] configLocations = 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)
+ configLocations = 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(implementation.getClassLoader().getResource(next.getValue()).toString());
+ values.append("~");
+ }
+ }
+ configLocations = (values.toString()).split("~");
+ }
+ }
+
+ appContext = new ClassPathXmlApplicationContext(configLocations, true, scaParentContext);
+ if (isAnnotationSupported)
+ includeAnnotationProcessors(appContext.getBeanFactory());
+ return appContext;
+ }
+ }
}
// use the generic application context as default
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
index 4df4e8c964..39445d5c04 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
@@ -91,19 +91,22 @@ public class SpringXMLComponentTypeLoader {
private AssemblyFactory assemblyFactory;
private JavaInterfaceFactory javaFactory;
private PolicyFactory policyFactory;
+ private boolean isMultipleContextSupported;
private SpringBeanIntrospector beanIntrospector;
public SpringXMLComponentTypeLoader(ModelFactoryExtensionPoint factories,
AssemblyFactory assemblyFactory,
JavaInterfaceFactory javaFactory,
- PolicyFactory policyFactory) {
+ PolicyFactory policyFactory,
+ boolean multipleContextSupport) {
super();
this.assemblyFactory = assemblyFactory;
this.javaFactory = javaFactory;
this.policyFactory = policyFactory;
this.contributionFactory = factories.getFactory(ContributionFactory.class);
this.xmlInputFactory = factories.getFactory(XMLInputFactory.class);
+ this.isMultipleContextSupported = multipleContextSupport;
}
protected Class<SpringImplementation> getImplementationClass() {
@@ -338,7 +341,7 @@ public class SpringXMLComponentTypeLoader {
if (reader.getAttributeValue(null, "value") != null) {
String value = reader.getAttributeValue(null, "value");
constructorArg.addValue(value);
- if ((value.indexOf(".xml") != -1)) {
+ if ((isMultipleContextSupported) && (value.indexOf(".xml") != -1)) {
if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) {
XMLStreamReader creader = getApplicationContextReader(resolver, value);
// Read the context definition for the constructor-arg resources
@@ -359,7 +362,7 @@ public class SpringXMLComponentTypeLoader {
if (constructorArg != null) {
constructorArg.addValue(value);
// Identify the XML resource specified for the constructor-arg element
- if ((value.indexOf(".xml") != -1)) {
+ if ((isMultipleContextSupported) && (value.indexOf(".xml") != -1)) {
if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) {
XMLStreamReader creader = getApplicationContextReader(resolver, value);
// Read the context definition for the constructor-arg resources
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java
index 0464355565..4fdcb52241 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java
@@ -4,6 +4,8 @@ public interface ConfigurationPropertiesExtensionPoint {
boolean isAnnotationSupported();
+ boolean isMultipleContextSupported();
+
String getSupportedVersion();
}
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java
index a0e7186eab..94b8e0eb36 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java
@@ -8,11 +8,17 @@ public class DefaultConfigurationPropertiesExtensionPoint implements Configurati
}
// By default SCA annotations for implementation.spring
- // will be supproted.
+ // will be supproted for Tuscany.
public boolean isAnnotationSupported() {
return true;
}
+ // By default multiple application context implementation.spring
+ // will be supproted for Tuscany.
+ public boolean isMultipleContextSupported() {
+ return true;
+ }
+
// By defauly all the Spring version are supported for
// Tuscany.
public String getSupportedVersion() {
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
index 55dd1d6027..818bc4e102 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
@@ -47,9 +47,10 @@ public class SpringContextStub {
ProxyFactory proxyService,
JavaPropertyValueObjectFactory propertyValueObjectFactory,
boolean annotationSupport,
- String versionSupported) {
+ String versionSupported,
+ boolean multipleContextSupport) {
- initTie(component, implementation, propertyValueObjectFactory, annotationSupport, versionSupported);
+ initTie(component, implementation, propertyValueObjectFactory, annotationSupport, versionSupported, multipleContextSupport);
}
@@ -57,7 +58,8 @@ public class SpringContextStub {
SpringImplementation implementation,
JavaPropertyValueObjectFactory propertyValueObjectFactory,
boolean annotationSupport,
- String versionSupported) {
+ String versionSupported,
+ boolean multipleContextSupport) {
// TODO: what class loader to use?
ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -69,8 +71,8 @@ public class SpringContextStub {
Object stub = stubConstructor.newInstance(new SpringImplementationTie(implementation, component, propertyValueObjectFactory));
Class<?> tieClass = Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringContextTie", true, cl);
- Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[]{stubClass, URL.class, boolean.class, String.class});
- this.tie = tieConstructor.newInstance(stub, implementation.getResource(), annotationSupport, versionSupported);
+ Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[]{stubClass, URL.class, boolean.class, String.class, boolean.class});
+ this.tie = tieConstructor.newInstance(stub, implementation.getResource(), annotationSupport, versionSupported, multipleContextSupport);
this.startMethod = tieClass.getMethod("start");
this.closeMethod = tieClass.getMethod("close");
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
index 1fc01b2627..105bb4a553 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
@@ -52,13 +52,14 @@ public class SpringImplementationProvider implements ImplementationProvider {
ProxyFactory proxyService,
JavaPropertyValueObjectFactory propertyValueObjectFactory,
boolean annotationSupport,
- String versionSupported) {
+ String versionSupported,
+ boolean multipleContextSupport) {
super();
this.implementation = implementation;
this.component = component;
this.propertyValueObjectFactory = propertyValueObjectFactory;
- springContext = new SpringContextStub(component, implementation, proxyService, propertyValueObjectFactory, annotationSupport, versionSupported);
+ springContext = new SpringContextStub(component, implementation, proxyService, propertyValueObjectFactory, annotationSupport, versionSupported, multipleContextSupport);
} // end constructor
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
index 4796aa0de9..e0d31203bc 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
@@ -41,6 +41,7 @@ public class SpringImplementationProviderFactory implements ImplementationProvid
private ConfigurationPropertiesExtensionPoint configProperties;
private boolean annotationSupport;
private String versionSupported;
+ private boolean multipleContextSupport;
/**
* Simple constructor
@@ -58,6 +59,7 @@ public class SpringImplementationProviderFactory implements ImplementationProvid
}
annotationSupport = configProperties.isAnnotationSupported();
versionSupported = configProperties.getSupportedVersion();
+ multipleContextSupport = configProperties.isMultipleContextSupported();
// TODO: could the runtime have a default PropertyValueObjectFactory?
propertyFactory = new JavaPropertyValueObjectFactory(new MediatorImpl(extensionPoints));
@@ -77,7 +79,8 @@ public class SpringImplementationProviderFactory implements ImplementationProvid
proxyFactory,
propertyFactory,
annotationSupport,
- versionSupported);
+ versionSupported,
+ multipleContextSupport);
}
/**
diff --git a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
index 20bf2d0d94..29dc0a38a1 100644
--- a/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
+++ b/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
@@ -31,6 +31,7 @@ import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
@@ -38,6 +39,8 @@ import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
import org.apache.tuscany.sca.implementation.spring.introspect.SpringXMLComponentTypeLoader;
+import org.apache.tuscany.sca.implementation.spring.invocation.ConfigurationPropertiesExtensionPoint;
+import org.apache.tuscany.sca.implementation.spring.invocation.DefaultConfigurationPropertiesExtensionPoint;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
@@ -62,16 +65,24 @@ public class SpringImplementationProcessor implements StAXArtifactProcessor<Spri
private JavaInterfaceFactory javaFactory;
private PolicyFactory policyFactory;
private PolicyAttachPointProcessor policyProcessor;
+ private ConfigurationPropertiesExtensionPoint configProperties;
private Monitor monitor;
-
+
private ModelFactoryExtensionPoint factories;
+ private boolean multipleContextSupport;
- public SpringImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
- this.factories = modelFactories;
- this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
- this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ public SpringImplementationProcessor(ExtensionPointRegistry extensionPoints, Monitor monitor) {
+ this.factories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+
+ this.configProperties = extensionPoints.getExtensionPoint(ConfigurationPropertiesExtensionPoint.class);
+ if (configProperties == null) {
+ configProperties = new DefaultConfigurationPropertiesExtensionPoint();
+ }
+ this.multipleContextSupport = configProperties.isMultipleContextSupported();
this.monitor = monitor;
}
@@ -196,7 +207,7 @@ public class SpringImplementationProcessor implements StAXArtifactProcessor<Spri
/* Load the Spring component type by reading the Spring application context */
SpringXMLComponentTypeLoader springLoader =
- new SpringXMLComponentTypeLoader(factories, assemblyFactory, javaFactory, policyFactory);
+ new SpringXMLComponentTypeLoader(factories, assemblyFactory, javaFactory, policyFactory, multipleContextSupport);
try {
// Load the Spring Implementation information from its application context file...
springLoader.load(springImplementation, resolver);