aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alien11...@apache.org
Subject svn commit: r1758251 - in /aries/trunk/blueprint/blueprint-maven-plugin/src: main/java/org/apache/aries/blueprint/plugin/ main/java/org/apache/aries/blueprint/plugin/javax/ main/java/org/apache/aries/blueprint/plugin/model/ main/java/org/apache/aries/b...
Date Mon, 29 Aug 2016 15:46:17 GMT
Author: alien11689
Date: Mon Aug 29 15:46:17 2016
New Revision: 1758251

URL: http://svn.apache.org/viewvc?rev=1758251&view=rev
Log:
[ARIES-1602] Use @PostConstruct and @PreDestroy annotations via spi handlers

Added:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java
      - copied, changed from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/InjectHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAnnotationHandler.java
      - copied, changed from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomBeanAnnotationHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java
      - copied, changed from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java
      - copied, changed from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAttributesResolver.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler
      - copied, changed from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler
      - copied, changed from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver
Removed:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAttributesResolver.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomBeanAnnotationHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler
Modified:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/DependsOnAttributeResolver.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/LazyAttributeResolver.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java
Mon Aug 29 15:46:17 2016
@@ -20,12 +20,12 @@ package org.apache.aries.blueprint.plugi
 
 import org.apache.aries.blueprint.plugin.model.AbstractTransactionalFactory;
 import org.apache.aries.blueprint.plugin.model.ExtensionTransactionFactory;
-import org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver;
 import org.apache.aries.blueprint.plugin.spi.BeanFinder;
-import org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.InjectLikeHandler;
+import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.NamedLikeHandler;
 import org.apache.aries.blueprint.plugin.spi.TransactionalFactory;
 import org.apache.aries.blueprint.plugin.spi.ValueInjectionHandler;
@@ -39,13 +39,13 @@ public class Extensions {
     public static final List<Class<? extends Annotation>> beanMarkingAnnotationClasses
= new ArrayList<>();
     public static final List<Class<? extends Annotation>> singletons = new ArrayList<>();
     public static final List<AbstractTransactionalFactory> transactionalFactories =
new ArrayList<>();
-    public static final List<BeanAttributesResolver> beanAttributesResolvers = new
ArrayList<>();
     public static final List<InjectLikeHandler<? extends Annotation>> beanInjectLikeHandlers
= new ArrayList<>();
     public static final List<NamedLikeHandler> namedLikeHandlers = new ArrayList<>();
     public static final List<ValueInjectionHandler<? extends Annotation>> valueInjectionHandlers
= new ArrayList<>();
-    public static final List<CustomBeanAnnotationHandler<? extends Annotation>>
customBeanAnnotationHandlers = new ArrayList<>();
+    public static final List<BeanAnnotationHandler<? extends Annotation>> BEAN_ANNOTATION_HANDLERs
= new ArrayList<>();
     public static final List<CustomFactoryMethodAnnotationHandler<? extends Annotation>>
customFactoryMethodAnnotationHandlers = new ArrayList<>();
     public static final List<CustomDependencyAnnotationHandler<? extends Annotation>>
customDependencyAnnotationHandlers = new ArrayList<>();
+    public static final List<MethodAnnotationHandler<? extends Annotation>> methodAnnotationHandlers
= new ArrayList<>();
 
     static {
         for (BeanFinder beanFinder : ServiceLoader.load(BeanFinder.class)) {
@@ -59,10 +59,6 @@ public class Extensions {
             transactionalFactories.add(new ExtensionTransactionFactory(transactionalFactory));
         }
 
-        for (BeanAttributesResolver beanAttributesResolverExtenstion : ServiceLoader.load(BeanAttributesResolver.class))
{
-            beanAttributesResolvers.add(beanAttributesResolverExtenstion);
-        }
-
         for (InjectLikeHandler<? extends Annotation> injectLikeHandler : ServiceLoader.load(InjectLikeHandler.class))
{
             beanInjectLikeHandlers.add(injectLikeHandler);
         }
@@ -75,8 +71,8 @@ public class Extensions {
             valueInjectionHandlers.add(valueInjectionHandler);
         }
 
-        for (CustomBeanAnnotationHandler<? extends Annotation> customBeanAnnotationHandler
: ServiceLoader.load(CustomBeanAnnotationHandler.class)) {
-            customBeanAnnotationHandlers.add(customBeanAnnotationHandler);
+        for (BeanAnnotationHandler<? extends Annotation> beanAnnotationHandler : ServiceLoader.load(BeanAnnotationHandler.class))
{
+            BEAN_ANNOTATION_HANDLERs.add(beanAnnotationHandler);
         }
 
         for (CustomFactoryMethodAnnotationHandler<? extends Annotation> customFactoryMethodAnnotationHandler
: ServiceLoader.load(CustomFactoryMethodAnnotationHandler.class)) {
@@ -86,5 +82,9 @@ public class Extensions {
         for (CustomDependencyAnnotationHandler<? extends Annotation> customDependencyAnnotationHandler
: ServiceLoader.load(CustomDependencyAnnotationHandler.class)) {
             customDependencyAnnotationHandlers.add(customDependencyAnnotationHandler);
         }
+
+        for (MethodAnnotationHandler<? extends Annotation> methodAnnotationHandler
: ServiceLoader.load(MethodAnnotationHandler.class)) {
+            methodAnnotationHandlers.add(methodAnnotationHandler);
+        }
     }
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java
Mon Aug 29 15:46:17 2016
@@ -163,12 +163,6 @@ public class Generator implements Proper
         if (bean instanceof ProducedBean) {
             writeFactory((ProducedBean) bean);
         }
-        if (bean.initMethod != null) {
-            writer.writeAttribute("init-method", bean.initMethod);
-        }
-        if (bean.destroyMethod != null) {
-            writer.writeAttribute("destroy-method", bean.destroyMethod);
-        }
         writer.writeCharacters("\n");
 
         if (namespaces.contains(NS_TX)) {

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java
(from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/InjectHandler.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/InjectHandler.java&r1=1757990&r2=1758251&rev=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/InjectHandler.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java
Mon Aug 29 15:46:17 2016
@@ -18,13 +18,24 @@
  */
 package org.apache.aries.blueprint.plugin.javax;
 
-import org.apache.aries.blueprint.plugin.spi.InjectLikeHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
 
-import javax.inject.Inject;
+import javax.annotation.PostConstruct;
+import java.lang.reflect.Method;
+import java.util.List;
 
-public class InjectHandler implements InjectLikeHandler<Inject> {
+public class PostConstructHandler implements MethodAnnotationHandler<PostConstruct>
{
     @Override
-    public Class<Inject> getAnnotation() {
-        return Inject.class;
+    public Class<PostConstruct> getAnnotation() {
+        return PostConstruct.class;
+    }
+
+    @Override
+    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods,
BeanEnricher beanEnricher) {
+        if(methods.size() > 1){
+            throw new IllegalArgumentException("There can be only one method annotated with
@PostConstruct in bean");
+        }
+        beanEnricher.addAttribute("init-method", methods.get(0).getName());
     }
 }

Added: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java?rev=1758251&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java
(added)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java
Mon Aug 29 15:46:17 2016
@@ -0,0 +1,41 @@
+/**
+ * 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.aries.blueprint.plugin.javax;
+
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
+
+import javax.annotation.PreDestroy;
+import java.lang.reflect.Method;
+import java.util.List;
+
+public class PreDestroyHandler implements MethodAnnotationHandler<PreDestroy> {
+    @Override
+    public Class<PreDestroy> getAnnotation() {
+        return PreDestroy.class;
+    }
+
+    @Override
+    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods,
BeanEnricher beanEnricher) {
+        if(methods.size() > 1){
+            throw new IllegalArgumentException("There can be only one method annotated with
@PreDestroy in bean");
+        }
+        beanEnricher.addAttribute("destroy-method", methods.get(0).getName());
+    }
+}

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
Mon Aug 29 15:46:17 2016
@@ -19,16 +19,15 @@
 package org.apache.aries.blueprint.plugin.model;
 
 import org.apache.aries.blueprint.plugin.Extensions;
-import org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
 import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
-import org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.InjectLikeHandler;
+import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.NamedLikeHandler;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceUnit;
 import java.lang.annotation.Annotation;
@@ -47,9 +46,7 @@ import java.util.TreeSet;
 
 import static org.apache.aries.blueprint.plugin.model.AnnotationHelper.findValue;
 
-public class Bean extends BeanRef implements ContextEnricher {
-    public final String initMethod;
-    public String destroyMethod;
+public class Bean extends BeanRef implements ContextEnricher, BeanEnricher {
     public SortedSet<Property> properties = new TreeSet<>();
     public List<Argument> constructorArguments = new ArrayList<>();
     public List<Field> persistenceFields;
@@ -63,9 +60,6 @@ public class Bean extends BeanRef implem
         super(clazz, BeanRef.getBeanName(clazz));
         Introspector introspector = new Introspector(clazz);
 
-        initMethod = findMethodAnnotatedWith(introspector, PostConstruct.class);
-        destroyMethod = findMethodAnnotatedWith(introspector, PreDestroy.class);
-
         interpretTransactionalMethods(clazz);
 
         this.isPrototype = isPrototype(clazz);
@@ -73,24 +67,25 @@ public class Bean extends BeanRef implem
 
         setQualifiersFromAnnotations(clazz.getAnnotations());
 
-        resolveBeanAttributes();
-
         handleCustomBeanAnnotations();
+
+        handleMethodsAnnotation(introspector);
     }
 
-    private void resolveBeanAttributes() {
-        for (BeanAttributesResolver beanAttributesResolver : Extensions.beanAttributesResolvers)
{
-            if (clazz.getAnnotation(beanAttributesResolver.getAnnotation()) != null) {
-                attributes.putAll(beanAttributesResolver.resolveAttributes(clazz, clazz));
+    private void handleMethodsAnnotation(Introspector introspector) {
+        for (MethodAnnotationHandler methodAnnotationHandler : Extensions.methodAnnotationHandlers)
{
+            List<Method> methods = introspector.methodsWith(methodAnnotationHandler.getAnnotation());
+            if (methods.size() > 0) {
+                methodAnnotationHandler.handleMethodAnnotation(clazz, methods, this);
             }
         }
     }
 
     private void handleCustomBeanAnnotations() {
-        for (CustomBeanAnnotationHandler customBeanAnnotationHandler : Extensions.customBeanAnnotationHandlers)
{
-            Object annotation = AnnotationHelper.findAnnotation(clazz.getAnnotations(), customBeanAnnotationHandler.getAnnotation());
+        for (BeanAnnotationHandler beanAnnotationHandler : Extensions.BEAN_ANNOTATION_HANDLERs)
{
+            Object annotation = AnnotationHelper.findAnnotation(clazz.getAnnotations(), beanAnnotationHandler.getAnnotation());
             if (annotation != null) {
-                customBeanAnnotationHandler.handleBeanAnnotation(clazz, id, this);
+                beanAnnotationHandler.handleBeanAnnotation(clazz, id, this, this);
             }
         }
     }
@@ -105,14 +100,6 @@ public class Bean extends BeanRef implem
         }
     }
 
-    private String findMethodAnnotatedWith(Introspector introspector, Class<? extends
Annotation> annotation) {
-        Method initMethod = introspector.methodWith(annotation);
-        if (initMethod == null) {
-            return null;
-        }
-        return initMethod.getName();
-    }
-
     private boolean isPrototype(Class<?> clazz) {
         return !findSingleton(clazz);
     }
@@ -254,4 +241,9 @@ public class Bean extends BeanRef implem
     public void addBlueprintWriter(String id, BlueprintWriter blueprintWriter) {
         blueprintWriters.put(id, blueprintWriter);
     }
+
+    @Override
+    public void addAttribute(String key, String value) {
+        attributes.put(key, value);
+    }
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java
Mon Aug 29 15:46:17 2016
@@ -20,7 +20,7 @@ package org.apache.aries.blueprint.plugi
 
 
 import org.apache.aries.blueprint.plugin.Extensions;
-import org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 
 import java.lang.reflect.Method;
 
@@ -41,13 +41,14 @@ public class ProducedBean extends Bean {
         this.factoryBean = factoryBean;
         this.factoryMethod = factoryMethod.getName();
         this.producingMethod = factoryMethod;
-        resolveBeanAttributes();
+        handleCustomBeanAnnotations();
     }
 
-    private void resolveBeanAttributes() {
-        for (BeanAttributesResolver beanAttributesResolver : Extensions.beanAttributesResolvers)
{
-            if (producingMethod.getAnnotation(beanAttributesResolver.getAnnotation()) !=
null) {
-                attributes.putAll(beanAttributesResolver.resolveAttributes(clazz, producingMethod));
+    private void handleCustomBeanAnnotations() {
+        for (BeanAnnotationHandler beanAnnotationHandler : Extensions.BEAN_ANNOTATION_HANDLERs)
{
+            Object annotation = AnnotationHelper.findAnnotation(producingMethod.getAnnotations(),
beanAnnotationHandler.getAnnotation());
+            if (annotation != null) {
+                beanAnnotationHandler.handleBeanAnnotation(producingMethod, id, this, this);
             }
         }
     }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
Mon Aug 29 15:46:17 2016
@@ -20,9 +20,10 @@ package org.apache.aries.blueprint.plugi
 
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
 import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
-import org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler;
 import org.ops4j.pax.cdi.api.OsgiServiceProvider;
 import org.ops4j.pax.cdi.api.Properties;
@@ -35,7 +36,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-public class OsgiServiceProviderHandler implements CustomBeanAnnotationHandler<OsgiServiceProvider>,
CustomFactoryMethodAnnotationHandler<OsgiServiceProvider> {
+public class OsgiServiceProviderHandler implements BeanAnnotationHandler<OsgiServiceProvider>,
CustomFactoryMethodAnnotationHandler<OsgiServiceProvider> {
     @Override
     public Class<OsgiServiceProvider> getAnnotation() {
         return OsgiServiceProvider.class;
@@ -47,7 +48,7 @@ public class OsgiServiceProviderHandler
     }
 
     @Override
-    public void handleBeanAnnotation(AnnotatedElement annotatedElement, final String id,
ContextEnricher contextEnricher) {
+    public void handleBeanAnnotation(AnnotatedElement annotatedElement, final String id,
ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
         handleAnnotation(annotatedElement, id, contextEnricher);
     }
 

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAnnotationHandler.java
(from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomBeanAnnotationHandler.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAnnotationHandler.java?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAnnotationHandler.java&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomBeanAnnotationHandler.java&r1=1758211&r2=1758251&rev=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomBeanAnnotationHandler.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAnnotationHandler.java
Mon Aug 29 15:46:17 2016
@@ -21,8 +21,8 @@ package org.apache.aries.blueprint.plugi
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 
-public interface CustomBeanAnnotationHandler<A extends Annotation> {
+public interface BeanAnnotationHandler<A extends Annotation> {
     Class<A> getAnnotation();
 
-    void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, ContextEnricher
contextEnricher);
+    void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, ContextEnricher
contextEnricher, BeanEnricher beanEnricher);
 }

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java
(from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java&r1=1758211&r2=1758251&rev=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java
Mon Aug 29 15:46:17 2016
@@ -18,7 +18,6 @@
  */
 package org.apache.aries.blueprint.plugin.spi;
 
-public interface ContextEnricher {
-    void addBean(String id, Class<?> clazz);
-    void addBlueprintWriter(String id, BlueprintWriter blueprintWriter);
+public interface BeanEnricher {
+    void addAttribute(String key, String value);
 }

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java
(from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAttributesResolver.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAttributesResolver.java&r1=1757990&r2=1758251&rev=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanAttributesResolver.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java
Mon Aug 29 15:46:17 2016
@@ -19,11 +19,11 @@
 package org.apache.aries.blueprint.plugin.spi;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Map;
+import java.lang.reflect.Method;
+import java.util.List;
 
-public interface BeanAttributesResolver<A extends Annotation> {
+public interface MethodAnnotationHandler<A extends Annotation> {
     Class<A> getAnnotation();
 
-    Map<String, String> resolveAttributes(Class<?> clazz, AnnotatedElement annotatedElement);
+    void handleMethodAnnotation(Class<?> clazz, List<Method> methods, BeanEnricher
beanEnricher);
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/DependsOnAttributeResolver.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/DependsOnAttributeResolver.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/DependsOnAttributeResolver.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/DependsOnAttributeResolver.java
Mon Aug 29 15:46:17 2016
@@ -6,9 +6,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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
@@ -18,30 +18,29 @@
  */
 package org.apache.aries.blueprint.plugin.spring;
 
-import org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.context.annotation.DependsOn;
 
 import java.lang.reflect.AnnotatedElement;
-import java.util.HashMap;
-import java.util.Map;
 
-public class DependsOnAttributeResolver implements BeanAttributesResolver<DependsOn>
{
+public class DependsOnAttributeResolver implements BeanAnnotationHandler<DependsOn>
{
     @Override
     public Class<DependsOn> getAnnotation() {
         return DependsOn.class;
     }
 
     @Override
-    public Map<String, String> resolveAttributes(Class<?> clazz, AnnotatedElement
annotatedElement) {
+    public void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, ContextEnricher
contextEnricher, BeanEnricher beanEnricher) {
         DependsOn annotation = annotatedElement.getAnnotation(DependsOn.class);
-        if (annotation == null || annotation.value().length == 0) {
-            return new HashMap<>();
-        }
         String[] value = annotation.value();
+        if (value.length == 0) {
+            return;
+        }
         String dependsOnValue = StringUtils.join(value, " ");
-        Map<String, String> map = new HashMap<>();
-        map.put("depends-on", dependsOnValue);
-        return map;
+        beanEnricher.addAttribute("depends-on", dependsOnValue);
     }
+
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/LazyAttributeResolver.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/LazyAttributeResolver.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/LazyAttributeResolver.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/LazyAttributeResolver.java
Mon Aug 29 15:46:17 2016
@@ -6,9 +6,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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
@@ -18,24 +18,23 @@
  */
 package org.apache.aries.blueprint.plugin.spring;
 
-import org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.springframework.context.annotation.Lazy;
 
 import java.lang.reflect.AnnotatedElement;
-import java.util.HashMap;
-import java.util.Map;
 
-public class LazyAttributeResolver implements BeanAttributesResolver<Lazy> {
+public class LazyAttributeResolver implements BeanAnnotationHandler<Lazy> {
     @Override
     public Class<Lazy> getAnnotation() {
         return Lazy.class;
     }
 
     @Override
-    public Map<String, String> resolveAttributes(Class<?> clazz, AnnotatedElement
annotatedElement) {
+    public void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, ContextEnricher
contextEnricher, BeanEnricher beanEnricher) {
         Lazy lazy = annotatedElement.getAnnotation(Lazy.class);
-        Map<String, String> map = new HashMap<>();
-        map.put("activation", lazy.value() ? "lazy" : "eager");
-        return map;
+        beanEnricher.addAttribute("activation", lazy.value() ? "lazy" : "eager");
     }
+
 }

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler
(from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler&r1=1758211&r2=1758251&rev=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler
Mon Aug 29 15:46:17 2016
@@ -15,4 +15,6 @@
 # limitations under the License.
 #
 
-org.apache.aries.blueprint.plugin.pax.OsgiServiceProviderHandler
\ No newline at end of file
+org.apache.aries.blueprint.plugin.pax.OsgiServiceProviderHandler
+org.apache.aries.blueprint.plugin.spring.LazyAttributeResolver
+org.apache.aries.blueprint.plugin.spring.DependsOnAttributeResolver
\ No newline at end of file

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler
(from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver&r1=1757990&r2=1758251&rev=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler
Mon Aug 29 15:46:17 2016
@@ -15,5 +15,5 @@
 # limitations under the License.
 #
 
-org.apache.aries.blueprint.plugin.spring.LazyAttributeResolver
-org.apache.aries.blueprint.plugin.spring.DependsOnAttributeResolver
\ No newline at end of file
+org.apache.aries.blueprint.plugin.javax.PostConstructHandler
+org.apache.aries.blueprint.plugin.javax.PreDestroyHandler
\ No newline at end of file

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java?rev=1758251&r1=1758250&r2=1758251&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
Mon Aug 29 15:46:17 2016
@@ -39,7 +39,6 @@ import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 public class BeanTest {
@@ -50,8 +49,6 @@ public class BeanTest {
         bean.resolve(new Context());
         assertEquals(MyBean1.class, bean.clazz);
         assertEquals("myBean1", bean.id); // Name derived from class name
-        assertEquals("init", bean.initMethod);
-        assertEquals("destroy", bean.destroyMethod);
         Assert.assertEquals(2, bean.persistenceFields.size());
         assertEquals("em", bean.persistenceFields.get(0).getName());
         assertEquals("emf", bean.persistenceFields.get(1).getName());
@@ -77,8 +74,6 @@ public class BeanTest {
         bean.resolve(new Context());
         assertEquals(MyBean3.class, bean.clazz);
         assertEquals("myBean3", bean.id); // Name derived from class name
-        assertNull("There should be no initMethod", bean.initMethod);
-        assertNull("There should be no destroyMethod", bean.destroyMethod);
         assertEquals("There should be no persistence fields", 0, bean.persistenceFields.size());
         assertEquals(5, bean.properties.size());
         assertTrue(bean.isPrototype);
@@ -100,8 +95,6 @@ public class BeanTest {
         String definedName = ServiceAImpl1.class.getAnnotation(Named.class).value();
         assertEquals("my1", definedName);
         assertEquals("Name should be defined using @Named", definedName, bean.id);
-        assertNull("There should be no initMethod", bean.initMethod);
-        assertNull("There should be no destroyMethod", bean.destroyMethod);
         assertEquals("There should be no persistence fields", 0, bean.persistenceFields.size());
         assertTrue("There should be no transaction definition", bean.transactionDefs.isEmpty());
         assertEquals("There should be no properties", 0, bean.properties.size());
@@ -162,8 +155,6 @@ public class BeanTest {
         bean.resolve(new Context());
         assertEquals(MyBean5.class, bean.clazz);
         assertEquals("myBean5", bean.id); // Name derived from class name
-        assertNull("There should be no initMethod", bean.initMethod);
-        assertNull("There should be no destroyMethod", bean.destroyMethod);
         assertTrue("There should be no persistenceUnit", bean.persistenceFields.isEmpty());
         assertEquals(0, bean.properties.size());
         assertEquals(8, bean.constructorArguments.size());




Mime
View raw message