aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r942140 - in /incubator/aries/sandbox/linsun/blueprint: blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/ blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/ blueprint-sample-annot...
Date Fri, 07 May 2010 16:06:57 GMT
Author: linsun
Date: Fri May  7 16:06:56 2010
New Revision: 942140

URL: http://svn.apache.org/viewvc?rev=942140&view=rev
Log:
[blueprint annotation] update code to support the inject annotation in constructor and factorymethod
annotation

Removed:
    incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Properties.java
Modified:
    incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Element.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/ListBindingListener.java
    incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/NewAccount.java

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Element.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Element.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Element.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/Element.java
Fri May  7 16:06:56 2010
@@ -21,6 +21,10 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+/**
+ * used to annotate the element of the list.
+ *
+ */
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Element {
@@ -29,8 +33,11 @@ public @interface Element {
     
     public enum ElementType {
         STRING,
-        INTEGER,
-        DATE
+        LONG,
+        BYTE,
+        BOOLEAN,
+        INT,
+        SHORT
     }
 
 }

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-api/src/main/java/org/apache/aries/blueprint/annotation/List.java
Fri May  7 16:06:56 2010
@@ -21,9 +21,16 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+/**
+ * used to annotate list value in property
+ * I am not convinced that we want to support this via annotation
+ *
+ */
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface List {
-  public Element[] value();
+    
+    // the element of the list
+    public Element[] value();
   
 }

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-annotation-impl/src/main/java/org/apache/aries/blueprint/annotation/impl/BlueprintAnnotationScannerImpl.java
Fri May  7 16:06:56 2010
@@ -16,12 +16,9 @@
  */
 package org.apache.aries.blueprint.annotation.impl;
 
-import java.io.DataInputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.math.BigInteger;
@@ -34,14 +31,24 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 
-import org.apache.xbean.finder.BundleAnnotationFinder;
-import org.apache.aries.blueprint.annotation.impl.BlueprintAnnotationException;
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Blueprint;
+import org.apache.aries.blueprint.annotation.Destroy;
+import org.apache.aries.blueprint.annotation.FactoryMethod;
+import org.apache.aries.blueprint.annotation.Init;
+import org.apache.aries.blueprint.annotation.Inject;
+import org.apache.aries.blueprint.annotation.Reference;
+import org.apache.aries.blueprint.annotation.ReferenceList;
+import org.apache.aries.blueprint.annotation.ReferenceListener;
+import org.apache.aries.blueprint.annotation.RegistrationListener;
+import org.apache.aries.blueprint.annotation.Service;
 import org.apache.aries.blueprint.annotation.service.BlueprintAnnotationScanner;
+import org.apache.aries.blueprint.jaxb.Targument;
 import org.apache.aries.blueprint.jaxb.Tbean;
+import org.apache.aries.blueprint.jaxb.Tblueprint;
 import org.apache.aries.blueprint.jaxb.Tdescription;
 import org.apache.aries.blueprint.jaxb.Tinterfaces;
 import org.apache.aries.blueprint.jaxb.Tproperty;
-import org.apache.aries.blueprint.jaxb.Tref;
 import org.apache.aries.blueprint.jaxb.Treference;
 import org.apache.aries.blueprint.jaxb.TreferenceList;
 import org.apache.aries.blueprint.jaxb.TreferenceListener;
@@ -49,20 +56,10 @@ import org.apache.aries.blueprint.jaxb.T
 import org.apache.aries.blueprint.jaxb.Tservice;
 import org.apache.aries.blueprint.jaxb.TtypeConverters;
 import org.apache.aries.blueprint.jaxb.Tvalue;
-import org.apache.aries.blueprint.jaxb.Tblueprint;
+import org.apache.xbean.finder.BundleAnnotationFinder;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.apache.aries.blueprint.annotation.Bean;
-import org.apache.aries.blueprint.annotation.Blueprint;
-import org.apache.aries.blueprint.annotation.Destroy;
-import org.apache.aries.blueprint.annotation.Init;
-import org.apache.aries.blueprint.annotation.Inject;
-import org.apache.aries.blueprint.annotation.Reference;
-import org.apache.aries.blueprint.annotation.ReferenceList;
-import org.apache.aries.blueprint.annotation.ReferenceListener;
-import org.apache.aries.blueprint.annotation.RegistrationListener;
-import org.apache.aries.blueprint.annotation.Service;
 import org.osgi.service.blueprint.container.Converter;
 import org.osgi.service.packageadmin.PackageAdmin;
 
@@ -245,7 +242,7 @@ public class BlueprintAnnotationScannerI
                 }
             }
                     
-            // check if the bean also declares init and destroy annotation
+            // check if the bean also declares init, destroy or inject or factoryMethod annotation
on methods
             Method[] methods = clazz.getDeclaredMethods();
             for (int i = 0; i < methods.length; i++) {
                 if (methods[i].isAnnotationPresent(Init.class)) {
@@ -256,10 +253,42 @@ public class BlueprintAnnotationScannerI
                     String propertyName = convertFromMethodName(methods[i].getName());
                     Tproperty tp = createTproperty(propertyName, methods[i].getAnnotation(Inject.class));
                     props.add(tp);
+                } else if (methods[i].isAnnotationPresent(FactoryMethod.class)) {
+                    FactoryMethod fm = (FactoryMethod)methods[i].getAnnotation(FactoryMethod.class);
+                    tbean.setFactoryMethod(methods[i].getName());
+                    String[] values = fm.values();
+                    for (int j = 0; j < fm.values().length; j++) {
+                        Targument targument = new Targument();
+                        targument.setValueAttribute(fm.values()[j]);
+                        props.add(targument);
+                    }
+                    
+                    
+                    
                 }
                 
             }
             
+            // check if the bean also declared inject annotation on constructors
+            Constructor[] constructors = clazz.getConstructors();
+            for (int i = 0; i < constructors.length; i++) {
+                if (constructors[i].isAnnotationPresent(Inject.class)) {
+                    Inject inj = (Inject)constructors[i].getAnnotation(Inject.class);
+                    
+                    if (inj.value().length() > 0) {
+                        Targument targument = new Targument();
+                        targument.setValueAttribute(inj.value());
+                        props.add(targument);
+                    } else if (inj.values().length > 0) {
+                        for (int j = 0; j < inj.values().length; j++) {
+                            Targument targument = new Targument();
+                            targument.setValueAttribute(inj.values()[j]);
+                            props.add(targument);
+                        }
+                    }
+                } 
+            }
+            
             // check if the bean also declares service
             if (clazz.getAnnotation(Service.class) != null) {
                 Tservice tservice = generateTservice(clazz, id);

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java
Fri May  7 16:06:56 2010
@@ -20,16 +20,16 @@ import org.apache.aries.blueprint.annota
 import org.apache.aries.blueprint.annotation.Inject;
 import org.apache.aries.blueprint.annotation.FactoryMethod;
 
-@Bean(id="accountFactory")
+//@Bean(id="accountFactory")
 public class AccountFactory {
     private String factoryName;
 
-    @Inject(value="account factory")
+    //@Inject(value="account factory")
     public AccountFactory(String factoryName) {
         this.factoryName = factoryName;
     }
 
-    @FactoryMethod(values="3")
+    //@FactoryMethod(values="3")
     public NewAccount createAccount(long number) {
         return new NewAccount(number);
     }

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java
Fri May  7 16:06:56 2010
@@ -16,15 +16,12 @@
  */
 package org.apache.aries.blueprint.sample;
 
-import java.util.Map;
 import java.util.List;
+import java.util.Map;
 
-import org.osgi.framework.ServiceReference;
 import org.apache.aries.blueprint.annotation.Bean;
-import org.apache.aries.blueprint.annotation.Blueprint;
 import org.apache.aries.blueprint.annotation.Init;
-import org.apache.aries.blueprint.annotation.Bind;
-import org.apache.aries.blueprint.annotation.Unbind;
+import org.osgi.framework.ServiceReference;
 
 @Bean(id="bindingListener")
 public class BindingListener {

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java
Fri May  7 16:06:56 2010
@@ -19,7 +19,6 @@ package org.apache.aries.blueprint.sampl
 import java.util.Currency;
 
 import org.apache.aries.blueprint.annotation.Bean;
-import org.apache.aries.blueprint.annotation.Blueprint;
 import org.osgi.service.blueprint.container.Converter;
 import org.osgi.service.blueprint.container.ReifiedType;
 

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java
Fri May  7 16:06:56 2010
@@ -20,9 +20,8 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-import org.apache.aries.blueprint.annotation.Inject;
 import org.apache.aries.blueprint.annotation.Bean;
-import org.apache.aries.blueprint.annotation.Blueprint;
+import org.apache.aries.blueprint.annotation.Inject;
 import org.osgi.service.blueprint.container.Converter;
 import org.osgi.service.blueprint.container.ReifiedType;
 

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java
Fri May  7 16:06:56 2010
@@ -20,7 +20,6 @@ import java.io.Serializable;
 import java.util.Map;
 
 import org.apache.aries.blueprint.annotation.Bean;
-import org.apache.aries.blueprint.annotation.Blueprint;
 
 
 @Bean(id="fooRegistrationListener")

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/ListBindingListener.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/ListBindingListener.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/ListBindingListener.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/ListBindingListener.java
Fri May  7 16:06:56 2010
@@ -16,15 +16,12 @@
  */
 package org.apache.aries.blueprint.sample;
 
-import java.util.Map;
 import java.util.List;
+import java.util.Map;
 
-import org.osgi.framework.ServiceReference;
 import org.apache.aries.blueprint.annotation.Bean;
-import org.apache.aries.blueprint.annotation.Blueprint;
 import org.apache.aries.blueprint.annotation.Init;
-import org.apache.aries.blueprint.annotation.Bind;
-import org.apache.aries.blueprint.annotation.Unbind;
+import org.osgi.framework.ServiceReference;
 
 @Bean(id="listBindingListener")
 public class ListBindingListener {

Modified: incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/NewAccount.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/NewAccount.java?rev=942140&r1=942139&r2=942140&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/NewAccount.java
(original)
+++ incubator/aries/sandbox/linsun/blueprint/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/NewAccount.java
Fri May  7 16:06:56 2010
@@ -18,7 +18,7 @@ package org.apache.aries.blueprint.sampl
 
 import org.apache.aries.blueprint.annotation.Bean;
 
-@Bean(id="accountThree", factoryRef="accountFactory")
+//@Bean(id="accountThree", factoryRef="accountFactory")
 public class NewAccount {
     
     private long accountNumber;



Mime
View raw message