summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-spring-runtime
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-08-18 18:26:30 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-08-18 18:26:30 +0000
commit1a51f9f3d1c3c4cd4cc0017288faf5e420b092c8 (patch)
treea2ff0ee70a5588054f992c8d95ac65e563291a1f /sca-java-2.x/trunk/modules/implementation-spring-runtime
parent55e979ac0d182a82b98684b5d65c77fbecbc1caa (diff)
Add impl spring stub/tie
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@986837 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring-runtime')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringBeanElement.java129
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringConstructorArgElement.java77
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringElementTie.java70
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringPropertyElement.java68
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAPropertyElement.java59
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAReferenceElement.java73
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAServiceElement.java73
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLLoaderTie.java57
8 files changed, 606 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringBeanElement.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringBeanElement.java
new file mode 100644
index 0000000000..d954195980
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringBeanElement.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <bean> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanElement {
+
+ private String id;
+ private String className = null;
+ private boolean innerBean = false;
+ private boolean abstractBean = false;
+ private boolean parentAttribute = false;
+ private boolean factoryBeanAttribute = false;
+ private boolean factoryMethodAttribute = false;
+
+ private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>();
+ private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>();
+
+ public SpringBeanElement(String id, String className) {
+ this.id = id;
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<SpringPropertyElement> getProperties() {
+ return properties;
+ }
+
+ public void addProperty(SpringPropertyElement property) {
+ properties.add(property);
+ }
+
+ public List<SpringConstructorArgElement> getCustructorArgs() {
+ return constructorargs;
+ }
+
+ public void addCustructorArgs(SpringConstructorArgElement args) {
+ constructorargs.add(args);
+ }
+
+ public boolean isInnerBean() {
+ return innerBean;
+ }
+
+ public void setInnerBean(boolean innerBean) {
+ this.innerBean = innerBean;
+ }
+
+ public boolean isAbstractBean() {
+ return abstractBean;
+ }
+
+ public void setAbstractBean(boolean abstractBean) {
+ this.abstractBean = abstractBean;
+ }
+
+ public boolean hasParentAttribute() {
+ return parentAttribute;
+ }
+
+ public void setParentAttribute(boolean parentAttribute) {
+ this.parentAttribute = parentAttribute;
+ }
+
+ public boolean hasFactoryBeanAttribute() {
+ return factoryBeanAttribute;
+ }
+
+ public void setFactoryBeanAttribute(boolean factoryBeanAttribute) {
+ this.factoryBeanAttribute = factoryBeanAttribute;
+ }
+
+ public boolean hasFactoryMethodAttribute() {
+ return factoryMethodAttribute;
+ }
+
+ public void setFactoryMethodAttribute(boolean factoryMethodAttribute) {
+ this.factoryMethodAttribute = factoryMethodAttribute;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringBeanElement [id=").append(id).append(", className=").append(className)
+ .append(", innerBean=").append(innerBean).append(", abstractBean=").append(abstractBean)
+ .append(", parentAttribute=").append(parentAttribute).append(", factoryBeanAttribute=")
+ .append(factoryBeanAttribute).append(", factoryMethodAttribute=").append(factoryMethodAttribute)
+ .append(", properties=").append(properties).append(", constructorargs=").append(constructorargs)
+ .append("]");
+ return builder.toString();
+ }
+
+} // end class SpringBeanElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringConstructorArgElement.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringConstructorArgElement.java
new file mode 100644
index 0000000000..5571029c61
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringConstructorArgElement.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <constructor-arg> element in a Spring application-context
+ * - this has ref attribute
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringConstructorArgElement {
+
+ private String type;
+ private int autoIndex = -1;
+ private int index = -1;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringConstructorArgElement(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getAutoIndex() {
+ return this.autoIndex;
+ }
+
+ public void setAutoIndex(int index) {
+ this.autoIndex = index;
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringElementTie.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringElementTie.java
new file mode 100644
index 0000000000..df4b077819
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringElementTie.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.spring.metadata;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A hacking utility to copy beans field by field between two class loaders
+ */
+public class SpringElementTie {
+ public static <T> T copy(Object source, Class<T> cls, Type genericType) {
+ if (source == null) {
+ return null;
+ }
+ if (cls.isPrimitive()) {
+ return (T)source;
+ }
+ if (Collection.class.isAssignableFrom(cls)) {
+ ParameterizedType pType = (ParameterizedType)genericType;
+ Type itemType = pType.getActualTypeArguments()[0];
+ Collection col = (Collection)source;
+ List target = new ArrayList();
+ for (Object item : col) {
+ target.add(copy(item, (Class<?>)itemType, itemType));
+ }
+ return (T)target;
+ }
+ if (cls.isInstance(source)) {
+ return cls.cast(source);
+ }
+ try {
+ Class<?> sourceClass = source.getClass();
+ T target = cls.newInstance();
+ for (Field sourceField : sourceClass.getDeclaredFields()) {
+ sourceField.setAccessible(true);
+ Field targetField = cls.getDeclaredField(sourceField.getName());
+ targetField.setAccessible(true);
+ Object sourceFieldValue = sourceField.get(source);
+ Object targetFieldValue = copy(sourceFieldValue, targetField.getType(), targetField.getGenericType());
+ targetField.set(target, targetFieldValue);
+ }
+ return target;
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringPropertyElement.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringPropertyElement.java
new file mode 100644
index 0000000000..585b3d3381
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringPropertyElement.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <property> element in a Spring application-context
+ * - this has name and ref attributes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringPropertyElement {
+
+ private String name;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringPropertyElement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringPropertyElement [name=").append(name).append(", refs=").append(refs).append(", values=")
+ .append(values).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAPropertyElement.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAPropertyElement.java
new file mode 100644
index 0000000000..f721b21042
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAPropertyElement.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.metadata;
+
+/**
+ * Represents an <sca:property> element in a Spring application-context
+ * - this has name and type attributes
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAPropertyElement {
+
+ private String name;
+ private String type;
+
+ public SpringSCAPropertyElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAPropertyElement [name=").append(name).append(", type=").append(type).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAReferenceElement.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAReferenceElement.java
new file mode 100644
index 0000000000..ffa91ad179
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAReferenceElement.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.metadata;
+
+
+/**
+ * Represents a <sca:reference> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAReferenceElement {
+
+ private String name;
+ private String type;
+ private String defaultBean;
+
+ public SpringSCAReferenceElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setDefaultBean(String defaultBean) {
+ this.defaultBean = defaultBean;
+ }
+
+ public String getDefaultBean() {
+ return defaultBean;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAReferenceElement [name=").append(name).append(", type=").append(type)
+ .append(", defaultBean=").append(defaultBean).append("]");
+ return builder.toString();
+ }
+
+
+} // end class SpringSCAReferenceElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAServiceElement.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAServiceElement.java
new file mode 100644
index 0000000000..6dee35f46e
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/metadata/SpringSCAServiceElement.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.metadata;
+
+
+/**
+ * Represents a <sca:service> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAServiceElement {
+
+ private String name;
+ private String type;
+ private String target;
+
+
+ public SpringSCAServiceElement(String name, String target) {
+ this.name = name;
+ this.target = target;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAServiceElement [name=").append(name).append(", type=").append(type)
+ .append(", target=").append(target).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAServiceElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLLoaderTie.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLLoaderTie.java
new file mode 100644
index 0000000000..b3f0a4a883
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLLoaderTie.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.spring.processor;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.runtime.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * A tie that allows Tuscany to call Spring library to load the application context for the purpose of introspection
+ */
+public class SpringXMLLoaderTie {
+
+ public static ApplicationContext createApplicationContext(Object scaParentContext,
+ ClassLoader classLoader,
+ List<URL> resources) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ SCAGenericApplicationContext appCtx =
+ new SCAGenericApplicationContext((ApplicationContext)scaParentContext, classLoader);
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+
+ return appCtx;
+
+ }
+
+}