You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2010/08/18 00:54:13 UTC

svn commit: r986516 [2/4] - in /tuscany/sca-java-2.x/trunk/contrib/modules: implementation-spring-runtime/ implementation-spring-runtime/META-INF/ implementation-spring-runtime/src/ implementation-spring-runtime/src/main/ implementation-spring-runtime/...

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.invocation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringInvocationException extends Exception {
+
+    private static final long serialVersionUID = -1157790036638157513L;
+
+    public SpringInvocationException(String msg) {
+        super(msg);
+    }
+
+    public SpringInvocationException(Throwable e) {
+        super(e);
+    }
+
+    public SpringInvocationException(String msg, Throwable e) {
+        super(msg, e);
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,126 @@
+/*
+ * 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.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.context.SpringContextWrapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Initial implementation of a Spring bean invoker
+ * @version $Rev$ $Date$ 
+ */
+public class SpringInvoker implements Invoker {
+
+    private Method theMethod = null;
+    private Object bean;
+    private SpringBeanElement beanElement;
+    private boolean badInvoker = false;
+
+    private SpringContextWrapper springContext;
+    private Operation operation;
+
+    /**
+     * SpringInvoker constructor
+     * @param component - the Spring component to invoke
+     * @param service - the service to invoke
+     * @param operation - the operation to invoke
+     */
+    public SpringInvoker(RuntimeComponent component,
+                         SpringContextWrapper springContext,
+                         RuntimeComponentService service,
+                         Operation operation) {
+
+        this.springContext = springContext;
+        this.operation = operation;
+
+        // From the component and the service, identify the Spring Bean which is the target
+        SpringImplementation theImplementation = (SpringImplementation)component.getImplementation();
+        beanElement = theImplementation.getBeanFromService(service.getService());
+
+        if (beanElement == null) {
+            badInvoker = true;
+            return;
+        }
+
+    } // end constructor SpringInvoker
+
+    // Lazy-load the method to avoid timing problems with the Spring Context
+    private void setupMethod() throws SpringInvocationException {
+        try {
+            bean = springContext.getBean(beanElement.getId());
+            Class<?> beanClass = bean.getClass();
+            theMethod = JavaInterfaceUtil.findMethod(beanClass, operation);
+            //System.out.println("SpringInvoker - found method " + theMethod.getName() );
+        } catch (NoSuchMethodException e) {
+            throw new SpringInvocationException(e);
+        }
+    }
+
+    private Object doInvoke(Object payload) throws SpringInvocationException {
+        if (theMethod == null)
+            setupMethod();
+
+        if (badInvoker)
+            throw new SpringInvocationException("Spring invoker incorrectly configured");
+        // Invoke the method on the Spring bean using the payload, returning the results
+        try {
+            Object ret;
+
+            if (payload != null && !payload.getClass().isArray()) {
+                ret = theMethod.invoke(bean, payload);
+            } else {
+                ret = theMethod.invoke(bean, (Object[])payload);
+            }
+            return ret;
+        } catch (InvocationTargetException e) {
+            throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.",
+                                                e.getCause());
+        } catch (Exception e) {
+            throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.", e);
+        }
+
+    } // end method doInvoke
+
+    /**
+     * @param msg the message to invoke on the target bean
+     */
+    public Message invoke(Message msg) {
+        try {
+            Object resp = doInvoke(msg.getBody());
+            msg.setBody(resp);
+        } catch (SpringInvocationException e) {
+            msg.setFaultBody(e.getCause());
+        } catch (Throwable e) {
+            msg.setFaultBody(e);
+        }
+        //System.out.println("Spring Invoker - invoke called");
+        return msg;
+    } // end method invoke
+
+} // end class SpringInvoker

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.namespace;
+
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandler;
+
+/**
+ * Overrides the default Spring namespace resolver to automatically register
+ * {@link ScaNamespaceHandler} instead of requiring a value to be supplied in a
+ * Spring configuration
+ * 
+ * @version $Rev$ $Date$
+ */
+public class SCANamespaceHandlerResolver extends DefaultNamespaceHandlerResolver {
+    private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca";
+
+    private ScaNamespaceHandler handler;
+
+    public SCANamespaceHandlerResolver(ClassLoader classLoader) {
+        super(classLoader);
+        handler = new ScaNamespaceHandler(/*componentType*/);
+    }
+
+    public SCANamespaceHandlerResolver(String handlerMappingsLocation, ClassLoader classLoader) {
+        super(classLoader, handlerMappingsLocation);
+        handler = new ScaNamespaceHandler(/*componentType*/);
+    }
+
+    @Override
+    public NamespaceHandler resolve(String namespaceUri) {
+        if (SCA_NAMESPACE.equals(namespaceUri)) {
+            return handler;
+        }
+        return super.resolve(namespaceUri);
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed 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.namespace;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Handler for the &lt;sca:&gt; namespace in an application context
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+    public ScaNamespaceHandler() {
+        init();
+    }
+
+    public final void init() {
+        registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+        registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+        registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.namespace;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ * @version $Rev$ $Date$
+ */
+public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser {
+
+    public BeanDefinition parse(Element element, ParserContext parserContext) {
+        BeanDefinitionRegistry registry = parserContext.getRegistry();
+        if (registry instanceof SCAGenericApplicationContext) {
+            SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+            SpringSCAPropertyElement propertyElement =
+                new SpringSCAPropertyElement(element.getAttributeNS(null, "name"), element.getAttributeNS(null, "type"));
+            context.addSCAPropertyElement(propertyElement);
+        }
+        // do nothing, this is handled by Tuscany
+        return null;
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.namespace;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser {
+
+    public BeanDefinition parse(Element element, ParserContext parserContext) {
+        BeanDefinitionRegistry registry = parserContext.getRegistry();
+        if (registry instanceof SCAGenericApplicationContext) {
+            SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+            SpringSCAReferenceElement referenceElement =
+                new SpringSCAReferenceElement(element.getAttributeNS(null, "name"),
+                                              element.getAttributeNS(null, "type"));
+            referenceElement.setDefaultBean(element.getAttributeNS(null, "default"));
+            context.addSCAReferenceElement(referenceElement);
+        }
+
+        // do nothing, this is handled by Tuscany
+        return null;
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.namespace;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:service/&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser {
+
+    public BeanDefinition parse(Element element, ParserContext parserContext) {
+        BeanDefinitionRegistry registry = parserContext.getRegistry();
+        if (registry instanceof SCAGenericApplicationContext) {
+            SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+            SpringSCAServiceElement serviceElement =
+                new SpringSCAServiceElement(element.getAttributeNS(null, "name"),
+                                            element.getAttributeNS(null, "target"));
+            serviceElement.setType(element.getAttributeNS(null, "type"));
+            context.addSCAServiceElement(serviceElement);
+        }
+        // do nothing, handled by Tuscany
+        return null;
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,151 @@
+/*
+ * 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.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.ref.Reference;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
+
+    private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+
+    private String componentName;
+
+    public ComponentNameAnnotationProcessor(String componentName) {
+        this.componentName = componentName;
+    }
+
+    /**
+     * Gets componentName annotation type.
+     */
+    protected Class<? extends Annotation> getComponentNameAnnotationType() {
+        return this.componentNameAnnotationType;
+    }
+
+    /**
+     * Sets componentName annotation type.
+     */
+    public void setComponentNameAnnotationType(Class<? extends Annotation> componentNameAnnotationType) {
+        Assert.notNull(componentNameAnnotationType, "'componentNameAnnotationType' type must not be null.");
+        this.componentNameAnnotationType = componentNameAnnotationType;
+    }
+
+    /**
+     * This method is used to execute before a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+        processAnnotation(bean);
+        return bean;
+    }
+
+    /**
+     * This method is used to execute after a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+        return bean;
+    }
+
+    /**
+     * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+     */
+    protected void processAnnotation(final Object bean) {
+
+        final Class<?> clazz = bean.getClass();
+
+        ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+            public void doWith(Field field) {
+                Annotation annotation = field.getAnnotation(getComponentNameAnnotationType());
+
+                if (annotation != null) {
+                    if (Modifier.isStatic(field.getModifiers())) {
+                        throw new IllegalStateException("ComponentName annotation is not supported on static fields");
+                    }
+
+                    if (Modifier.isPrivate(field.getModifiers())) {
+                        throw new IllegalStateException("ComponentName annotation is not supported on private fields");
+                    }
+
+                    ReflectionUtils.makeAccessible(field);
+
+                    if (field.getType().getName().equals("java.lang.String")) {
+                        Object nameObj = componentName;
+                        if (nameObj != null)
+                            ReflectionUtils.setField(field, bean, nameObj);
+                    } else {
+                        throw new IllegalStateException(
+                                                        "ComponentName annotation is supported only on java.lang.String field type.");
+                    }
+                }
+            }
+        });
+
+        ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+            public void doWith(Method method) {
+                Annotation annotation = method.getAnnotation(getComponentNameAnnotationType());
+
+                if (annotation != null) {
+                    if (Modifier.isStatic(method.getModifiers())) {
+                        throw new IllegalStateException("ComponentName annotation is not supported on static methods");
+                    }
+
+                    if (Modifier.isPrivate(method.getModifiers())) {
+                        throw new IllegalStateException("ComponentName annotation is not supported on private methods");
+                    }
+
+                    if (method.getParameterTypes().length == 0) {
+                        throw new IllegalStateException(
+                                                        "ComponentName annotation requires at least one argument: " + method);
+                    }
+
+                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+
+                    if (pd.getPropertyType().getName().equals("java.lang.String")) {
+                        Object nameObj = componentName;
+                        if (nameObj != null) {
+                            try {
+                                pd.getWriteMethod().invoke(bean, new Object[] {nameObj});
+                            } catch (Throwable e) {
+                                throw new FatalBeanException("Problem injecting reference:  " + e.getMessage(), e);
+                            }
+                        }
+                    } else {
+                        throw new IllegalStateException(
+                                                        "ComponentName annotation is supported only on java.lang.String field type.");
+                    }
+                }
+            }
+        });
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,112 @@
+/*
+ * 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.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.util.Assert;
+
+public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostProcessorAdapter {
+
+    private Class<? extends Annotation> constructorAnnotationType = org.oasisopen.sca.annotation.Constructor.class;
+
+    private Class<? extends Annotation> autowiredAnnotationType = Autowired.class;
+
+    public ConstructorAnnotationProcessor() {
+        // Default constructor.
+    }
+
+    /**
+     * Set the 'autowired' annotation type, to be used on constructors, fields,
+     * setter methods and arbitrary config methods.
+     */
+    public void setAutowiredAnnotationType(Class<? extends Annotation> autowiredAnnotationType) {
+        Assert.notNull(autowiredAnnotationType, "'autowiredAnnotationType' must not be null");
+        this.autowiredAnnotationType = autowiredAnnotationType;
+    }
+
+    /**
+     * Return the 'autowired' annotation type.
+     */
+    protected Class<? extends Annotation> getAutowiredAnnotationType() {
+        return this.autowiredAnnotationType;
+    }
+
+    /**
+     * Return the 'constructor' annotation type.
+     */
+    protected Class<? extends Annotation> getConstructorAnnotationType() {
+        return this.constructorAnnotationType;
+    }
+
+    /**
+     * Sets the 'constructor' annotation type.
+     */
+    public void setConstructorAnnotationType(Class<? extends Annotation> constructorAnnotationType) {
+        Assert.notNull(constructorAnnotationType, "'constructorAnnotationType' type must not be null.");
+        this.constructorAnnotationType = constructorAnnotationType;
+    }
+
+    /**
+     * This method is used to execute before a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+        return bean;
+    }
+
+    /**
+     * This method is used to execute after a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+        return bean;
+    }
+
+    public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
+        /*Constructor[] declaredConstructors = beanClass.getDeclaredConstructors();                
+        Method[] declaredMethods = beanClass.getDeclaredMethods();
+        List candidates = new ArrayList(declaredConstructors.length);
+
+        for (int i = 0; i < declaredMethods.length; i++) {
+            Method method = declaredMethods[i];
+            Annotation annotation = method.getAnnotation(getConstructorAnnotationType());
+            if (annotation != null) {
+                if (Modifier.isStatic(method.getModifiers())) {
+                    throw new IllegalStateException("Constructor annotation is not supported on static methods");
+                }
+                
+                if (candidates.size() == 1) {
+                    throw new IllegalStateException("Only one method is allowed to have constructor annotation in a bean: " + method);
+                }
+                
+                candidates.add(method);
+            }
+        }
+
+        return (Constructor[]) candidates.toArray(new Constructor[candidates.size()]);*/
+        return null;
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,75 @@
+/*
+ * 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.lang.annotation.Annotation;
+
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
+
+public class InitDestroyAnnotationProcessor extends InitDestroyAnnotationBeanPostProcessor {
+
+    private static final long serialVersionUID = 0;
+
+    private Class<? extends Annotation> initAnnotationType = Init.class;
+    private Class<? extends Annotation> destroyAnnotationType = Destroy.class;
+
+    /**
+     * Gets init annotation type.
+     */
+    protected Class<? extends Annotation> getInitAnnotationType() {
+        return this.initAnnotationType;
+    }
+
+    /**
+     * Sets init annotation type.
+     */
+    /*
+     * public void setInitAnnotationType(Class<? extends Annotation>
+     * initAnnotationType) { Assert.notNull(initAnnotationType,
+     * "Init annotation type must not be null."); this.initAnnotationType =
+     * initAnnotationType; }
+     */
+
+    /**
+     * Gets destroy annotation type.
+     */
+    protected Class<? extends Annotation> getDestroyAnnotationType() {
+        return this.destroyAnnotationType;
+    }
+
+    /**
+     * Sets destroy annotation type.
+     */
+    /*
+     * public void setDestroyAnnotationType(Class<? extends Annotation>
+     * destroyAnnotationType) { Assert.notNull(destroyAnnotationType,
+     * "Destroy annotation type must not be null."); this.destroyAnnotationType
+     * = destroyAnnotationType; }
+     */
+
+    public InitDestroyAnnotationProcessor() {
+        // Set the @Init annotation type
+        setInitAnnotationType(initAnnotationType);
+
+        // Set the @Destroy annotation type
+        setDestroyAnnotationType(destroyAnnotationType);
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,164 @@
+/*
+ * 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.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.implementation.spring.invocation.PropertyValueWrapper;
+import org.oasisopen.sca.annotation.Property;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class PropertyAnnotationProcessor implements BeanPostProcessor {
+
+    private Class<? extends Annotation> propertyAnnotationType = Property.class;
+
+    private PropertyValueWrapper propertyValue;
+
+    public PropertyAnnotationProcessor(PropertyValueWrapper propertyValue) {
+        this.propertyValue = propertyValue;
+    }
+
+    /**
+     * Gets property annotation type.
+     */
+    protected Class<? extends Annotation> getPropertyAnnotationType() {
+        return this.propertyAnnotationType;
+    }
+
+    /**
+     * Sets property annotation type.
+     */
+    public void setPropertyAnnotationType(Class<? extends Annotation> propertyAnnotationType) {
+        Assert.notNull(propertyAnnotationType, "'propertyAnnotationType' type must not be null.");
+        this.propertyAnnotationType = propertyAnnotationType;
+    }
+
+    /**
+     * This method is used to execute before a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+        processAnnotation(bean);
+        return bean;
+    }
+
+    /**
+     * This method is used to execute after a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+        return bean;
+    }
+
+    /**
+     * <p>Processes a beans fields for injection if it has a {@link Property} annotation.</p>
+     */
+    protected void processAnnotation(final Object bean) {
+
+        final Class<?> clazz = bean.getClass();
+
+        ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+            public void doWith(Method method) {
+
+                Property annotation = (Property)method.getAnnotation(getPropertyAnnotationType());
+
+                if (annotation != null) {
+                    if (Modifier.isStatic(method.getModifiers())) {
+                        throw new IllegalStateException("Property annotation is not supported on static methods");
+                    }
+
+                    /*
+                    if (Modifier.isPrivate(method.getModifiers())) {
+                        throw new IllegalStateException("Property annotation is not supported on private methods");
+                    }
+                    */
+
+                    if (method.getParameterTypes().length == 0) {
+                        throw new IllegalStateException("Property annotation requires at least one argument: " + method);
+                    }
+
+                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+                    if (pd != null) {
+                        String propName = annotation.name();
+                        if ("".equals(propName)) {
+                            injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), pd.getName()));
+                        } else {
+                            injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), propName));
+                        }
+                    }
+                }
+            }
+        });
+
+        ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+            public void doWith(Field field) {
+
+                Property annotation = (Property)field.getAnnotation(getPropertyAnnotationType());
+
+                if (annotation != null) {
+                    if (Modifier.isStatic(field.getModifiers())) {
+                        throw new IllegalStateException("Property annotation is not supported on static fields");
+                    }
+
+                    /*
+                    if (Modifier.isPrivate(field.getModifiers())) {
+                        throw new IllegalStateException("Property annotation is not supported on private fields");
+                    }
+                    */
+
+                    ReflectionUtils.makeAccessible(field);
+
+                    Object propertyObj = null;
+                    String propName = annotation.name();
+                    if ("".equals(propName)) {
+                        propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());
+                    } else {
+                        propertyObj = propertyValue.getPropertyObj(field.getType(), propName);
+                    }
+
+                    if (propertyObj != null)
+                        ReflectionUtils.setField(field, bean, propertyObj);
+                }
+            }
+        });
+    }
+
+    public void injectProperty(Object bean, PropertyDescriptor pd, Object propertyObj) {
+
+        if (propertyObj != null) {
+            try {
+                pd.getWriteMethod().invoke(bean, new Object[] {propertyObj});
+            } catch (Throwable e) {
+                throw new FatalBeanException("Problem injecting property:  " + e.getMessage(), e);
+            }
+        }
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,168 @@
+/*
+ * 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.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.implementation.spring.invocation.ComponentWrapper;
+import org.oasisopen.sca.annotation.Reference;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ReferenceAnnotationProcessor implements BeanPostProcessor {
+
+    private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+    private ComponentWrapper component;
+
+    public ReferenceAnnotationProcessor(ComponentWrapper component) {
+        this.component = component;
+    }
+
+    /**
+     * Gets referece annotation type.
+     */
+    protected Class<? extends Annotation> getReferenceAnnotationType() {
+        return this.referenceAnnotationType;
+    }
+
+    /**
+     * Sets referece annotation type.
+     */
+    public void setReferenceAnnotationType(Class<? extends Annotation> referenceAnnotationType) {
+        Assert.notNull(referenceAnnotationType, "'referenceAnnotationType' type must not be null.");
+        this.referenceAnnotationType = referenceAnnotationType;
+    }
+
+    /**
+     * This method is used to execute before a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+        processAnnotation(bean);
+        return bean;
+    }
+
+    /**
+     * This method is used to execute after a bean's initialization callback.
+     * 
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+     */
+    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+        return bean;
+    }
+
+    /**
+     * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+     */
+    protected void processAnnotation(final Object bean) {
+
+        final Class<?> clazz = bean.getClass();
+
+        ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+            public void doWith(Method method) {
+
+                Reference annotation = (Reference)method.getAnnotation(getReferenceAnnotationType());
+
+                if (annotation != null) {
+                    if (Modifier.isStatic(method.getModifiers())) {
+                        throw new IllegalStateException("Reference annotation is not supported on static methods");
+                    }
+
+                    /*
+                    if (Modifier.isPrivate(method.getModifiers())) {
+                        throw new IllegalStateException("Reference annotation is not supported on private methods");
+                    }
+                    */
+
+                    if (method.getParameterTypes().length == 0) {
+                        throw new IllegalStateException(
+                                                        "Reference annotation requires at least one argument: " + method);
+                    }
+
+                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+                    if (pd != null) {
+                        String refName = annotation.name();
+                        if ("".equals(refName)) {
+                            injectReference(bean, pd, pd.getName());
+                        } else {
+                            injectReference(bean, pd, refName);
+                        }
+                    }
+                }
+            }
+        });
+
+        ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+            public void doWith(Field field) {
+
+                Reference annotation = (Reference)field.getAnnotation(getReferenceAnnotationType());
+
+                if (annotation != null) {
+                    if (Modifier.isStatic(field.getModifiers())) {
+                        throw new IllegalStateException("Reference annotation is not supported on static fields");
+                    }
+
+                    /*
+                    if (Modifier.isPrivate(field.getModifiers())) {
+                        throw new IllegalStateException("Reference annotation is not supported on private fields");
+                    }
+                    */
+
+                    ReflectionUtils.makeAccessible(field);
+
+                    Object referenceObj = null;
+                    String refName = annotation.name();
+                    if ("".equals(refName)) {
+                        referenceObj = component.getService(field.getType(), field.getName());
+                    } else {
+                        referenceObj = component.getService(field.getType(), refName);
+                    }
+
+                    if (referenceObj != null)
+                        ReflectionUtils.setField(field, bean, referenceObj);
+                }
+            }
+        });
+    }
+
+    /**
+     * Processes a property descriptor to inject a service.
+     */
+    public void injectReference(Object bean, PropertyDescriptor pd, String name) {
+
+        Object referenceObj = component.getService(pd.getPropertyType(), name);
+
+        if (referenceObj != null) {
+            try {
+                pd.getWriteMethod().invoke(bean, new Object[] {referenceObj});
+            } catch (Throwable e) {
+                throw new FatalBeanException("Problem injecting reference:  " + e.getMessage(), e);
+            }
+        }
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java Tue Aug 17 22:54:09 2010
@@ -0,0 +1,78 @@
+/*
+ * 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.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
+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 SpringXMLBeanDefinitionLoaderImpl implements SpringXMLBeanDefinitionLoader {
+
+    private static SCAGenericApplicationContext 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;
+
+    }
+
+    @Override
+    public Object load(List<URL> resources,
+                       List<SpringSCAServiceElement> serviceElements,
+                       List<SpringSCAReferenceElement> referenceElements,
+                       List<SpringSCAPropertyElement> propertyElements,
+                       List<SpringBeanElement> beanElements,
+                       ProcessorContext context) {
+        SCAGenericApplicationContext applicationContext = createApplicationContext(null, null, resources);
+        serviceElements.addAll(applicationContext.getServiceElements());
+        referenceElements.addAll(applicationContext.getReferenceElements());
+        propertyElements.addAll(applicationContext.getPropertyElements());
+        beanElements.addAll(applicationContext.getBeanElements());
+        return applicationContext;
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader Tue Aug 17 22:54:09 2010
@@ -0,0 +1,17 @@
+# 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. 
+org.apache.tuscany.sca.implementation.spring.processor.SpringXMLBeanDefinitionLoaderImpl;ranking=100
\ No newline at end of file

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory Tue Aug 17 22:54:09 2010
@@ -0,0 +1,20 @@
+# 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. 
+
+# Implementation class for the implementation extension
+org.apache.tuscany.sca.implementation.spring.invocation.SpringImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.spring.SpringImplementation
+

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers Tue Aug 17 22:54:09 2010
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/sca=org.apache.tuscany.sca.implementation.spring.namespace.ScaNamespaceHandler

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas Tue Aug 17 22:54:09 2010
@@ -0,0 +1 @@
+http\://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd=org/springframework/sca/xml/spring-sca.xsd

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd Tue Aug 17 22:54:09 2010
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<xsd:schema xmlns="http://www.springframework.org/schema/sca" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    attributeFormDefault="unqualified" elementFormDefault="qualified"
+    targetNamespace="http://www.springframework.org/schema/sca">
+
+    <xsd:element name="reference">
+        <xsd:complexType>
+            <xsd:attribute name="name" use="required">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+            <xsd:attribute name="type" use="required">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+            <xsd:attribute name="default" use="optional">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:element name="property">
+        <xsd:complexType>
+            <xsd:attribute name="id" use="optional">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+            <xsd:attribute name="name" use="required">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+            <xsd:attribute name="type" use="required">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:element name="service">
+        <xsd:complexType>
+            <xsd:attribute name="name" use="required">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+            <xsd:attribute name="type" use="required">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+            <xsd:attribute name="target" use="required">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string" />
+                </xsd:simpleType>
+            </xsd:attribute>
+        </xsd:complexType>
+    </xsd:element>
+
+</xsd:schema>

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/test/java/org/apache/tuscany/sca/implementation/spring/runtime/context/BeanLoadTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/test/java/org/apache/tuscany/sca/implementation/spring/runtime/context/BeanLoadTestCase.java?rev=986516&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/test/java/org/apache/tuscany/sca/implementation/spring/runtime/context/BeanLoadTestCase.java (added)
+++ tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/test/java/org/apache/tuscany/sca/implementation/spring/runtime/context/BeanLoadTestCase.java Tue Aug 17 22:54:09 2010
@@ -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.runtime.context;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * 
+ */
+public class BeanLoadTestCase {
+
+    private SCAGenericApplicationContext context;
+    private XmlBeanDefinitionReader reader;
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        context = new SCAGenericApplicationContext(null, getClass().getClassLoader());
+        reader = new XmlBeanDefinitionReader(context);
+    }
+
+    @Test
+    public void testLoad() throws Exception {
+        File file =
+            new File(
+                     "/Users/rfeng/Perforce/perforce.internal.shutterfly.com_1666/rfeng_Raymond-Feng/SSP/giza/services/ecom/src/test/resources/com/shutterfly/services/ecom/ep.xml");
+        UrlResource resource = new UrlResource(file.toURI().toURL());
+        reader.loadBeanDefinitions(resource);
+        for (SpringBeanElement beanElement : context.getBeanElements()) {
+            System.out.println(beanElement);
+        }
+
+        System.out.println(context.getPropertyElements());
+        System.out.println(context.getReferenceElements());
+        System.out.println(context.getServiceElements());
+
+    }
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @After
+    public void tearDown() throws Exception {
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/test/java/org/apache/tuscany/sca/implementation/spring/runtime/context/BeanLoadTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/contrib/modules/implementation-spring-runtime/src/test/java/org/apache/tuscany/sca/implementation/spring/runtime/context/BeanLoadTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date