You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ra...@apache.org on 2009/04/28 12:21:36 UTC

svn commit: r769322 - in /tuscany/java/sca/modules/implementation-spring-runtime: ./ META-INF/ src/main/java/org/apache/tuscany/sca/implementation/spring/ src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ src/main/java/org/apache/tu...

Author: ramkumar
Date: Tue Apr 28 10:21:35 2009
New Revision: 769322

URL: http://svn.apache.org/viewvc?rev=769322&view=rev
Log:
Refactoring Spring Modules

Added:
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java   (contents, props changed)
      - copied, changed from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java   (contents, props changed)
      - copied, changed from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java   (contents, props changed)
      - copied, changed from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java   (contents, props changed)
      - copied, changed from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java   (contents, props changed)
      - copied, changed from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
Removed:
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java
Modified:
    tuscany/java/sca/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
    tuscany/java/sca/modules/implementation-spring-runtime/pom.xml
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers

Modified: tuscany/java/sca/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/META-INF/MANIFEST.MF?rev=769322&r1=769321&r2=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/META-INF/MANIFEST.MF (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/META-INF/MANIFEST.MF Tue Apr 28 10:21:35 2009
@@ -11,5 +11,11 @@
 Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.runtime
 Bundle-DocURL: http://www.apache.org/
 Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
-Import-Package: org.springframework.beans.factory.config;version="2.5.5",
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.injection;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.springframework.beans.factory.config;version="2.5.5",
  org.springframework.beans.factory.xml;version="2.5.5"
+Export-Package: org.apache.tuscany.sca.implementation.spring.processor;version="2.0.0";uses:="org.apache.tuscany.sca.implementation.java.injection,org.apache.tuscany.sca.runtime"

Modified: tuscany/java/sca/modules/implementation-spring-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/pom.xml?rev=769322&r1=769321&r2=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/pom.xml (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/pom.xml Tue Apr 28 10:21:35 2009
@@ -31,15 +31,35 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-spring</artifactId>
+            <artifactId>tuscany-assembly</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-interface</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xml</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-sca-api</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>
-
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-spring-xml</artifactId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>
+               
         <!-- Spring dependencies... -->    
         <dependency>
             <groupId>org.springframework</groupId>

Copied: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java (from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java)
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java?p2=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java&p1=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java&r1=769264&r2=769322&rev=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java Tue Apr 28 10:21:35 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.    
  */
-package org.apache.tuscany.sca.implementation.spring;
+package org.apache.tuscany.sca.implementation.spring.namespace;
 
 import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
 import org.springframework.beans.factory.xml.NamespaceHandler;

Propchange: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 28 10:21:35 2009
@@ -0,0 +1,3 @@
+/tuscany/branches/sca-java-1.3/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java:671193
+/tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java:713805-714043
+/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/SCANamespaceHandlerResolver.java:694816-713804

Copied: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java (from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java)
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java?p2=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java&p1=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java&r1=769264&r2=769322&rev=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java Tue Apr 28 10:21:35 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  */
-package org.apache.tuscany.sca.implementation.spring;
+package org.apache.tuscany.sca.implementation.spring.namespace;
 
 import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
 

Propchange: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 28 10:21:35 2009
@@ -0,0 +1,3 @@
+/tuscany/branches/sca-java-1.3/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java:671193
+/tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java:713805-714043
+/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaNamespaceHandler.java:694816-713804

Copied: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java (from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java)
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java?p2=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java&p1=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java&r1=769264&r2=769322&rev=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java Tue Apr 28 10:21:35 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  */
-package org.apache.tuscany.sca.implementation.spring;
+package org.apache.tuscany.sca.implementation.spring.namespace;
 
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.xml.BeanDefinitionParser;

Propchange: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 28 10:21:35 2009
@@ -0,0 +1,3 @@
+/tuscany/branches/sca-java-1.3/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java:671193
+/tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java:713805-714043
+/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaPropertyBeanDefinitionParser.java:694816-713804

Copied: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java (from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java)
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java?p2=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java&p1=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java&r1=769264&r2=769322&rev=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java Tue Apr 28 10:21:35 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  */
-package org.apache.tuscany.sca.implementation.spring;
+package org.apache.tuscany.sca.implementation.spring.namespace;
 
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.xml.BeanDefinitionParser;

Propchange: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 28 10:21:35 2009
@@ -0,0 +1,3 @@
+/tuscany/branches/sca-java-1.3/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java:671193
+/tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java:713805-714043
+/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaReferenceBeanDefinitionParser.java:694816-713804

Copied: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java (from r769264, tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java)
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java?p2=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java&p1=tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java&r1=769264&r2=769322&rev=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java Tue Apr 28 10:21:35 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  */
-package org.apache.tuscany.sca.implementation.spring;
+package org.apache.tuscany.sca.implementation.spring.namespace;
 
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.xml.BeanDefinitionParser;

Propchange: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 28 10:21:35 2009
@@ -0,0 +1,3 @@
+/tuscany/branches/sca-java-1.3/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java:671193
+/tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java:713805-714043
+/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/ScaServiceBeanDefinitionParser.java:694816-713804

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java?rev=769322&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java Tue Apr 28 10:21:35 2009
@@ -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.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+
+import org.springframework.util.Assert;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
+
+    private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+    
+    private RuntimeComponent component;
+    
+    public ComponentNameAnnotationProcessor (RuntimeComponent component) {
+        this.component = component;
+    }
+    
+    /**
+     * 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 = component.getName();   
+                        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 = component.getName();                    
+                        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.");
+                    }
+                }
+            }
+        });
+    }
+}

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java?rev=769322&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java Tue Apr 28 10:21:35 2009
@@ -0,0 +1,119 @@
+/*
+ * 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.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Constructor;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.util.Assert;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+
+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;
+    }
+}

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java?rev=769322&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java Tue Apr 28 10:21:35 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.Init;
+import org.oasisopen.sca.annotation.Destroy;
+import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
+import org.springframework.util.Assert;
+
+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);
+    }
+}

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java?rev=769322&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java Tue Apr 28 10:21:35 2009
@@ -0,0 +1,220 @@
+/*
+ * 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.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.springframework.util.Assert;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+import org.oasisopen.sca.annotation.Property;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class PropertyAnnotationProcessor implements BeanPostProcessor {
+
+    private Class<? extends Annotation> propertyAnnotationType = Property.class;
+    
+    private RuntimeComponent component;
+    
+    private JavaPropertyValueObjectFactory propertyFactory;
+    
+    public PropertyAnnotationProcessor (JavaPropertyValueObjectFactory propertyFactory, 
+                                        RuntimeComponent component) {
+        this.propertyFactory = propertyFactory;
+        this.component = component;
+    }
+
+    /**
+     * 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) {
+                //Annotation annotation = method.getAnnotation(getPropertyAnnotationType());                
+                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, getPropertyObj(pd.getPropertyType(), pd.getName()));
+                        } else {
+                            injectProperty(bean, pd, getPropertyObj(pd.getPropertyType(), propName));
+                        }
+                    }
+                }
+            }
+        });
+        
+        ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+            public void doWith(Field field) {
+                //Annotation annotation = field.getAnnotation(getPropertyAnnotationType());
+                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 = getPropertyObj(field.getType(), field.getName());                        
+                    } else {
+                        propertyObj = getPropertyObj(field.getType(), propName);
+                    }
+                    
+                    if (propertyObj != null)
+                        ReflectionUtils.setField(field, bean, propertyObj);
+                }
+            }
+        });
+    }
+    
+    /**
+     * Processes a property descriptor to inject a service.
+     */
+    public Object getPropertyObj(Class requiredType, String name) {
+        
+        Object propertyObj = null;
+        
+        List<ComponentProperty> props = component.getProperties();
+        for (ComponentProperty prop : props) {
+            if (prop.getName().equals(name)) {
+                // On finding the property, create a factory for it and create a Bean using
+                // the factory
+                ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
+                propertyObj = factory.getInstance();
+            } // end if
+        } // end for        
+        
+        return 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);
+            }
+        }
+    }
+    
+    /**
+     * Processes a property descriptor to inject a service.
+     */
+    /*public void injectMethod(Object bean, Method method) {
+        PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);        
+
+        if (pd != null) {
+            Object propertyObj = null;
+            
+            List<ComponentProperty> props = component.getProperties();
+            for (ComponentProperty prop : props) {
+                if (prop.getName().equals(pd.getName())) {
+                    // On finding the property, create a factory for it and create a Bean using
+                    // the factory
+                    ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), pd.getPropertyType());
+                    propertyObj = factory.getInstance();
+                } // end if
+            } // end for
+
+            if (propertyObj != null) {
+                try {                                                       
+                    pd.getWriteMethod().invoke(bean, new Object[] { propertyObj });
+                } catch (Throwable e) {
+                    throw new FatalBeanException("Problem injecting property:  " + e.getMessage(), e);
+                }
+            }
+        }
+    }*/
+}

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java?rev=769322&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java Tue Apr 28 10:21:35 2009
@@ -0,0 +1,186 @@
+/*
+ * 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.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+
+import org.springframework.util.Assert;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class ReferenceAnnotationProcessor implements BeanPostProcessor {
+
+    private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+    
+    private RuntimeComponent component;
+    
+    public ReferenceAnnotationProcessor (RuntimeComponent 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) {
+                //Annotation annotation = method.getAnnotation(getReferenceAnnotationType());                
+                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) {
+                //Annotation annotation = field.getAnnotation(getReferenceAnnotationType());                
+                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.getComponentContext().getService(field.getType(), field.getName());
+                    } else {
+                        referenceObj = component.getComponentContext().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.getComponentContext().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);
+            }
+        }
+    }
+    
+    /**
+     * Processes a property descriptor to inject a service.
+     */
+    /*public void injectMethod(Object bean, Method method) {
+        PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);        
+
+        if (pd != null) {            
+            Object referenceObj = component.getComponentContext().getService(pd.getPropertyType(), pd.getName());
+
+            if (referenceObj != null) {
+                try {                                                       
+                    pd.getWriteMethod().invoke(bean, new Object[] { referenceObj });
+                } catch (Throwable e) {
+                    throw new FatalBeanException("Problem injecting reference:  " + e.getMessage(), e);
+                }
+            }
+        }
+    }*/
+}

Modified: tuscany/java/sca/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers?rev=769322&r1=769321&r2=769322&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers Tue Apr 28 10:21:35 2009
@@ -1 +1 @@
-http\://www.springframework.org/schema/sca=org.apache.tuscany.sca.implementation.spring.ScaNamespaceHandler
+http\://www.springframework.org/schema/sca=org.apache.tuscany.sca.implementation.spring.namespace.ScaNamespaceHandler