tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r411432 - in /incubator/tuscany/sandbox/jboynes/sca/spi/src: main/java/org/apache/tuscany/spi/annotation/ test/java/org/apache/tuscany/spi/annotation/
Date Sat, 03 Jun 2006 13:30:12 GMT
Author: jboynes
Date: Sat Jun  3 06:30:11 2006
New Revision: 411432

URL: http://svn.apache.org/viewvc?rev=411432&view=rev
Log:
experimental support for constructor injection

Added:
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Constructor.java
  (with props)
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/
    incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
  (with props)
Modified:
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java?rev=411432&r1=411431&r2=411432&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
Sat Jun  3 06:30:11 2006
@@ -15,6 +15,7 @@
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
@@ -24,7 +25,7 @@
  *
  * @version $Rev: 395110 $ $Date: 2006-04-18 19:32:30 -0700 (Tue, 18 Apr 2006) $
  */
-@Target({METHOD, FIELD})
+@Target({METHOD, FIELD, PARAMETER})
 @Retention(RUNTIME)
 public @interface Autowire {
 

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Constructor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Constructor.java?rev=411432&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Constructor.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Constructor.java
Sat Jun  3 06:30:11 2006
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ *  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.spi.annotation;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Target(CONSTRUCTOR)
+@Retention(RUNTIME)
+public @interface Constructor {
+    String[] value();
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Constructor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Constructor.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java?rev=411432&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
Sat Jun  3 06:30:11 2006
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ *  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.spi.annotation;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorAnnotationTest extends TestCase {
+    public void testSingleName() throws NoSuchMethodException {
+        Constructor ann = Foo1.class.getConstructor(String.class).getAnnotation(Constructor.class);
+        assertNotNull(ann);
+        String[] names = ann.value();
+        assertTrue(Arrays.equals(new String[]{"prop"}, names));
+    }
+
+    public void testMultipleNames() throws NoSuchMethodException {
+        Constructor ann = Foo1.class.getConstructor(String.class, String.class).getAnnotation(Constructor.class);
+        assertNotNull(ann);
+        String[] names = ann.value();
+        assertTrue(Arrays.equals(new String[]{"prop", "ref"}, names));
+    }
+
+    public static class Foo1 {
+        @Constructor({"prop", "ref"})
+        public Foo1(String prop, String ref) {
+        }
+
+        @Constructor("prop")
+        public Foo1(String prop) {
+        }
+    }
+
+    public static class Foo2 {
+        public Foo2(@Autowire String prop,
+                    @Autowire String ref) {
+        }
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message