Author: alien11689
Date: Mon Aug 29 12:18:13 2016
New Revision: 1758211

URL: http://svn.apache.org/viewvc?rev=1758211&view=rev
Log:
[ARIES-1602] Replace pax annotations with spi handlers

Added:
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java
      - copied, changed from r1757990, 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.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/spi/BlueprintWriter.java
    
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/CustomBeanAnnotationHandler.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomDependencyAnnotationHandler.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomFactoryMethodAnnotationHandler.java
    
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.CustomDependencyAnnotationHandler
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler
Removed:
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceRefWriter.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/OsgiServiceRef.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/service/
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/Context.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/model/Property.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java
    
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithSetters.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=1758211&r1=1758210&r2=1758211&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 12:18:13 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
@@ -22,6 +22,9 @@ import org.apache.aries.blueprint.plugin
 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.CustomDependencyAnnotationHandler;
+import 
org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.InjectLikeHandler;
 import org.apache.aries.blueprint.plugin.spi.NamedLikeHandler;
 import org.apache.aries.blueprint.plugin.spi.TransactionalFactory;
@@ -40,6 +43,9 @@ public class Extensions {
     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<CustomFactoryMethodAnnotationHandler<? extends 
Annotation>> customFactoryMethodAnnotationHandlers = new ArrayList<>();
+    public static final List<CustomDependencyAnnotationHandler<? extends 
Annotation>> customDependencyAnnotationHandlers = new ArrayList<>();
 
     static {
         for (BeanFinder beanFinder : ServiceLoader.load(BeanFinder.class)) {
@@ -68,5 +74,17 @@ public class Extensions {
         for (ValueInjectionHandler<? extends Annotation> valueInjectionHandler 
: ServiceLoader.load(ValueInjectionHandler.class)) {
             valueInjectionHandlers.add(valueInjectionHandler);
         }
+
+        for (CustomBeanAnnotationHandler<? extends Annotation> 
customBeanAnnotationHandler : 
ServiceLoader.load(CustomBeanAnnotationHandler.class)) {
+            customBeanAnnotationHandlers.add(customBeanAnnotationHandler);
+        }
+
+        for (CustomFactoryMethodAnnotationHandler<? extends Annotation> 
customFactoryMethodAnnotationHandler : 
ServiceLoader.load(CustomFactoryMethodAnnotationHandler.class)) {
+            
customFactoryMethodAnnotationHandlers.add(customFactoryMethodAnnotationHandler);
+        }
+
+        for (CustomDependencyAnnotationHandler<? extends Annotation> 
customDependencyAnnotationHandler : 
ServiceLoader.load(CustomDependencyAnnotationHandler.class)) {
+            
customDependencyAnnotationHandlers.add(customDependencyAnnotationHandler);
+        }
     }
 }

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=1758211&r1=1758210&r2=1758211&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 12:18:13 2016
@@ -26,7 +26,7 @@ import org.apache.aries.blueprint.plugin
 import org.apache.aries.blueprint.plugin.model.Property;
 import org.apache.aries.blueprint.plugin.model.PropertyWriter;
 import org.apache.aries.blueprint.plugin.model.TransactionalDef;
-import org.apache.aries.blueprint.plugin.model.service.ServiceProviderWriter;
+import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
 
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceUnit;
@@ -89,8 +89,9 @@ public class Generator implements Proper
                 writer.writeCharacters("\n");
             }
 
-            new OsgiServiceRefWriter(writer).write(context.getServiceRefs());
-            new 
ServiceProviderWriter(writer).write(context.getServiceProviders());
+            for (BlueprintWriter bw : context.getBlueprintWriters().values()) {
+                bw.write(writer);
+            }
 
             writer.writeEndElement();
             writer.writeCharacters("\n");

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=1758211&r1=1758210&r2=1758211&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 12:18:13 2016
@@ -19,10 +19,13 @@
 package org.apache.aries.blueprint.plugin.model;
 
 import org.apache.aries.blueprint.plugin.Extensions;
-import org.apache.aries.blueprint.plugin.model.service.ServiceProvider;
 import org.apache.aries.blueprint.plugin.spi.BeanAttributesResolver;
+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.CustomDependencyAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.InjectLikeHandler;
-import org.ops4j.pax.cdi.api.OsgiService;
+import org.apache.aries.blueprint.plugin.spi.NamedLikeHandler;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -42,21 +45,19 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import static 
org.apache.aries.blueprint.plugin.model.AnnotationHelper.findAnnotation;
-import static 
org.apache.aries.blueprint.plugin.model.AnnotationHelper.findName;
 import static 
org.apache.aries.blueprint.plugin.model.AnnotationHelper.findValue;
 
-public class Bean extends BeanRef {
+public class Bean extends BeanRef implements ContextEnricher {
     public final String initMethod;
     public String destroyMethod;
     public SortedSet<Property> properties = new TreeSet<>();
     public List<Argument> constructorArguments = new ArrayList<>();
-    public Set<OsgiServiceRef> serviceRefs = new HashSet<>();
     public List<Field> persistenceFields;
     public Set<TransactionalDef> transactionDefs = new HashSet<>();
     public boolean isPrototype;
-    public List<ServiceProvider> serviceProviders = new ArrayList<>();
     public final Map<String, String> attributes = new HashMap<>();
+    public final Set<BeanRef> refs = new HashSet<>();
+    public final Map<String, BlueprintWriter> blueprintWriters = new 
HashMap<>();
 
     public Bean(Class<?> clazz) {
         super(clazz, BeanRef.getBeanName(clazz));
@@ -72,9 +73,9 @@ public class Bean extends BeanRef {
 
         setQualifiersFromAnnotations(clazz.getAnnotations());
 
-        interpretServiceProvider();
-
         resolveBeanAttributes();
+
+        handleCustomBeanAnnotations();
     }
 
     private void resolveBeanAttributes() {
@@ -85,10 +86,12 @@ public class Bean extends BeanRef {
         }
     }
 
-    private void interpretServiceProvider() {
-        ServiceProvider serviceProvider = ServiceProvider.fromBean(this);
-        if (serviceProvider != null) {
-            serviceProviders.add(serviceProvider);
+    private void handleCustomBeanAnnotations() {
+        for (CustomBeanAnnotationHandler customBeanAnnotationHandler : 
Extensions.customBeanAnnotationHandlers) {
+            Object annotation = 
AnnotationHelper.findAnnotation(clazz.getAnnotations(), 
customBeanAnnotationHandler.getAnnotation());
+            if (annotation != null) {
+                customBeanAnnotationHandler.handleBeanAnnotation(clazz, id, 
this);
+            }
         }
     }
 
@@ -123,22 +126,22 @@ public class Bean extends BeanRef {
         return false;
     }
 
-    public void resolve(Matcher matcher) {
+    public void resolve(BlueprinRegister matcher) {
         resolveArguments(matcher);
         resolveFields(matcher);
         resolveMethods(matcher);
     }
 
-    private void resolveMethods(Matcher matcher) {
+    private void resolveMethods(BlueprinRegister blueprinRegister) {
         for (Method method : new 
Introspector(clazz).methodsWith(AnnotationHelper.injectDependencyAnnotations)) {
-            Property prop = Property.create(matcher, method);
+            Property prop = Property.create(blueprinRegister, method);
             if (prop != null) {
                 properties.add(prop);
             }
         }
     }
 
-    private void resolveFields(Matcher matcher) {
+    private void resolveFields(BlueprinRegister matcher) {
         for (Field field : new 
Introspector(clazz).fieldsWith(AnnotationHelper.injectDependencyAnnotations)) {
             Property prop = Property.create(matcher, field);
             if (prop != null) {
@@ -147,7 +150,7 @@ public class Bean extends BeanRef {
         }
     }
 
-    protected void resolveArguments(Matcher matcher) {
+    protected void resolveArguments(BlueprinRegister matcher) {
         Constructor<?>[] declaredConstructors = 
clazz.getDeclaredConstructors();
         for (Constructor constructor : declaredConstructors) {
             if (declaredConstructors.length == 1 || shouldInject(constructor)) 
{
@@ -166,24 +169,27 @@ public class Bean extends BeanRef {
         return false;
     }
 
-    protected void resolveArguments(Matcher matcher, Class[] parameterTypes, 
Annotation[][] parameterAnnotations) {
+    protected void resolveArguments(BlueprinRegister blueprinRegister, Class[] 
parameterTypes, Annotation[][] parameterAnnotations) {
         for (int i = 0; i < parameterTypes.length; ++i) {
             Annotation[] annotations = parameterAnnotations[i];
             String value = findValue(annotations);
-            String ref = null;
+            String ref = findName(annotations);
 
-            OsgiService osgiServiceAnnotation = findAnnotation(annotations, 
OsgiService.class);
-            if (osgiServiceAnnotation != null) {
-                String name = findName(annotations);
-                ref = name != null ? name : 
getBeanNameFromSimpleName(parameterTypes[i].getSimpleName());
-                OsgiServiceRef osgiServiceRef = new 
OsgiServiceRef(parameterTypes[i], osgiServiceAnnotation, ref);
-                serviceRefs.add(osgiServiceRef);
+            for (CustomDependencyAnnotationHandler 
customDependencyAnnotationHandler : 
Extensions.customDependencyAnnotationHandlers) {
+                Annotation annotation = (Annotation) 
AnnotationHelper.findAnnotation(annotations, 
customDependencyAnnotationHandler.getAnnotation());
+                if (annotation != null) {
+                    String generatedRef = 
customDependencyAnnotationHandler.handleDependencyAnnotation(parameterTypes[i], 
annotation, ref, blueprinRegister);
+                    if (generatedRef != null) {
+                        ref = generatedRef;
+                        break;
+                    }
+                }
             }
 
-            if (ref == null && value == null && osgiServiceAnnotation == null) 
{
+            if (ref == null && value == null) {
                 BeanRef template = new BeanRef(parameterTypes[i]);
                 template.setQualifiersFromAnnotations(annotations);
-                BeanRef bean = matcher.getMatching(template);
+                BeanRef bean = blueprinRegister.getMatching(template);
                 if (bean != null) {
                     ref = bean.id;
                 } else {
@@ -200,6 +206,19 @@ public class Bean extends BeanRef {
         }
     }
 
+    private String findName(Annotation[] annotations) {
+        for (NamedLikeHandler namedLikeHandler : Extensions.namedLikeHandlers) 
{
+            Object annotation = AnnotationHelper.findAnnotation(annotations, 
namedLikeHandler.getAnnotation());
+            if (annotation != null) {
+                String name = namedLikeHandler.getName(annotation);
+                if (name != null) {
+                    return name;
+                }
+            }
+        }
+        return null;
+    }
+
     @Override
     public String toString() {
         return clazz.getName();
@@ -225,4 +244,14 @@ public class Bean extends BeanRef {
         }
         return false;
     }
+
+    @Override
+    public void addBean(String id, Class<?> clazz) {
+        refs.add(new BeanRef(clazz, id));
+    }
+
+    @Override
+    public void addBlueprintWriter(String id, BlueprintWriter blueprintWriter) 
{
+        blueprintWriters.put(id, blueprintWriter);
+    }
 }

Copied: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java
 (from r1757990, 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java)
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java&r1=1757990&r2=1758211&rev=1758211&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java
 Mon Aug 29 12:18:13 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,6 +18,8 @@
  */
 package org.apache.aries.blueprint.plugin.model;
 
-public interface Matcher {
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+
+public interface BlueprinRegister extends ContextEnricher{
     BeanRef getMatching(BeanRef template);
 }

Modified: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java?rev=1758211&r1=1758210&r2=1758211&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
 Mon Aug 29 12:18:13 2016
@@ -18,27 +18,28 @@
  */
 package org.apache.aries.blueprint.plugin.model;
 
-import org.apache.aries.blueprint.plugin.model.service.ServiceProvider;
-import org.ops4j.pax.cdi.api.OsgiService;
+import org.apache.aries.blueprint.plugin.Extensions;
+import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+import 
org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.container.Converter;
 
 import javax.enterprise.inject.Produces;
-import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-public class Context implements Matcher {
+public class Context implements BlueprinRegister, ContextEnricher {
 
     SortedSet<BeanRef> reg = new TreeSet<BeanRef>();
-    private final List<ServiceProvider> serviceProviders = new ArrayList<>();
+    private final Map<String, BlueprintWriter> blueprintWriters = new 
HashMap<>();
 
     public Context(Class<?>... beanClasses) {
         this(Arrays.asList(beanClasses));
@@ -65,13 +66,9 @@ public class Context implements Matcher
     private void addBean(Class<?> clazz) {
         Bean bean = new Bean(clazz);
         reg.add(bean);
-        addServiceRefs(clazz);
+        reg.addAll(bean.refs);
+        blueprintWriters.putAll(bean.blueprintWriters);
         addProducedBeans(bean);
-        addServiceProviders(bean);
-    }
-
-    private void addServiceProviders(Bean bean) {
-        serviceProviders.addAll(bean.serviceProviders);
     }
 
     private void addProducedBeans(BeanRef factoryBean) {
@@ -90,34 +87,21 @@ public class Context implements Matcher
                     producedBean.setSingleton();
                 }
                 reg.add(producedBean);
-                ServiceProvider serviceProvider = 
ServiceProvider.fromMethod(producedBean, method);
-                if (serviceProvider != null) {
-                    serviceProviders.add(serviceProvider);
+                for (CustomFactoryMethodAnnotationHandler 
customFactoryMethodAnnotationHandler : 
Extensions.customFactoryMethodAnnotationHandlers) {
+                    if 
(AnnotationHelper.findAnnotation(method.getAnnotations(), 
customFactoryMethodAnnotationHandler.getAnnotation()) != null) {
+                        
customFactoryMethodAnnotationHandler.handleFactoryMethodAnnotation(method, 
producedBean.id, this);
+                    }
                 }
             }
         }
     }
 
-    private void addServiceRefs(Class<?> clazz) {
-        for (Field field : new 
Introspector(clazz).fieldsWith(OsgiService.class)) {
-            reg.add(new OsgiServiceRef(field));
-        }
-        for (Method method : new 
Introspector(clazz).methodsWith(OsgiService.class)) {
-            reg.add(new OsgiServiceRef(method));
-        }
-    }
-
     public void resolve() {
         for (Bean bean : getBeans()) {
             bean.resolve(this);
-            addServiceRefs(bean);
         }
     }
 
-    private void addServiceRefs(Bean bean) {
-        reg.addAll(bean.serviceRefs);
-    }
-
     public BeanRef getMatching(BeanRef template) {
         for (BeanRef bean : reg) {
             if (bean.matches(template)) {
@@ -137,17 +121,18 @@ public class Context implements Matcher
         return beans;
     }
 
-    public SortedSet<OsgiServiceRef> getServiceRefs() {
-        TreeSet<OsgiServiceRef> serviceRefs = new TreeSet<OsgiServiceRef>();
-        for (BeanRef ref : reg) {
-            if (ref instanceof OsgiServiceRef) {
-                serviceRefs.add((OsgiServiceRef) ref);
-            }
-        }
-        return serviceRefs;
+    public Map<String, BlueprintWriter> getBlueprintWriters() {
+        return blueprintWriters;
+    }
+
+    @Override
+    public void addBean(String id, Class<?> clazz) {
+        reg.add(new BeanRef(clazz, id));
+
     }
 
-    public List<ServiceProvider> getServiceProviders() {
-        return serviceProviders;
+    @Override
+    public void addBlueprintWriter(String id, BlueprintWriter blueprintWriter) 
{
+        blueprintWriters.put(id, blueprintWriter);
     }
 }

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=1758211&r1=1758210&r2=1758211&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 12:18:13 2016
@@ -57,7 +57,7 @@ public class ProducedBean extends Bean {
     }
 
     @Override
-    protected void resolveArguments(Matcher matcher) {
+    protected void resolveArguments(BlueprinRegister matcher) {
         resolveArguments(matcher, producingMethod.getParameterTypes(), 
producingMethod.getParameterAnnotations());
     }
 }

Modified: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java?rev=1758211&r1=1758210&r2=1758211&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
 Mon Aug 29 12:18:13 2016
@@ -19,8 +19,10 @@
 package org.apache.aries.blueprint.plugin.model;
 
 import org.apache.aries.blueprint.plugin.Extensions;
+import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.NamedLikeHandler;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -38,14 +40,28 @@ public class Property implements Compara
         this.isField = isField;
     }
 
-    public static Property create(Matcher matcher, Field field) {
+    public static Property create(BlueprinRegister blueprinRegister, Field 
field) {
         if (needsInject(field)) {
             String value = AnnotationHelper.findValue(field.getAnnotations());
             if (value != null) {
                 return new Property(field.getName(), null, value, true);
             }
-            BeanRef matching = matcher.getMatching(new BeanRef(field));
-            String ref = (matching == null) ? getRefName(field) : matching.id;
+            String ref = getForcedRefName(field);
+            for (CustomDependencyAnnotationHandler 
customDependencyAnnotationHandler : 
Extensions.customDependencyAnnotationHandlers) {
+                Annotation annotation = (Annotation) 
AnnotationHelper.findAnnotation(field.getAnnotations(), 
customDependencyAnnotationHandler.getAnnotation());
+                if (annotation != null) {
+                    String generatedRef = 
customDependencyAnnotationHandler.handleDependencyAnnotation(field, ref, 
blueprinRegister);
+                    if (generatedRef != null) {
+                        ref = generatedRef;
+                        break;
+                    }
+                }
+            }
+            if (ref != null) {
+                return new Property(field.getName(), ref, null, true);
+            }
+            BeanRef matching = blueprinRegister.getMatching(new 
BeanRef(field));
+            ref = (matching == null) ? getDefaultRefName(field) : matching.id;
             return new Property(field.getName(), ref, null, true);
         } else {
             // Field is not a property
@@ -53,7 +69,7 @@ public class Property implements Compara
         }
     }
 
-    public static Property create(Matcher matcher, Method method) {
+    public static Property create(BlueprinRegister blueprinRegister, Method 
method) {
         String propertyName = resolveProperty(method);
         if (propertyName == null) {
             return null;
@@ -65,9 +81,41 @@ public class Property implements Compara
         }
 
         if (needsInject(method)) {
+            String ref = getForcedRefName(method);
+            if (ref == null) {
+                ref = getForcedRefName(method.getParameterAnnotations()[0]);
+            }
+            for (CustomDependencyAnnotationHandler 
customDependencyAnnotationHandler : 
Extensions.customDependencyAnnotationHandlers) {
+                Annotation annotation = (Annotation) 
AnnotationHelper.findAnnotation(method.getAnnotations(), 
customDependencyAnnotationHandler.getAnnotation());
+                if (annotation != null) {
+                    String generatedRef = 
customDependencyAnnotationHandler.handleDependencyAnnotation(method, ref, 
blueprinRegister);
+                    if (generatedRef != null) {
+                        ref = generatedRef;
+                        break;
+                    }
+                }
+            }
+            if (ref != null) {
+                return new Property(propertyName, ref, null, false);
+            }
+
+            for (CustomDependencyAnnotationHandler 
customDependencyAnnotationHandler : 
Extensions.customDependencyAnnotationHandlers) {
+                Annotation annotation = (Annotation) 
AnnotationHelper.findAnnotation(method.getParameterAnnotations()[0], 
customDependencyAnnotationHandler.getAnnotation());
+                if (annotation != null) {
+                    String generatedRef = 
customDependencyAnnotationHandler.handleDependencyAnnotation(method.getParameterTypes()[0],
 annotation, ref, blueprinRegister);
+                    if (generatedRef != null) {
+                        ref = generatedRef;
+                        break;
+                    }
+                }
+            }
+            if (ref != null) {
+                return new Property(propertyName, ref, null, false);
+            }
+
             BeanRef beanRef = new BeanRef(method);
-            BeanRef matching = matcher.getMatching(beanRef);
-            String ref = (matching == null) ? beanRef.id : matching.id;
+            BeanRef matching = blueprinRegister.getMatching(beanRef);
+            ref = (matching == null) ? beanRef.id : matching.id;
             return new Property(propertyName, ref, null, false);
         }
 
@@ -88,7 +136,11 @@ public class Property implements Compara
      * @param field
      * @return
      */
-    private static String getRefName(Field field) {
+    private static String getDefaultRefName(Field field) {
+        return Bean.getBeanName(field.getType());
+    }
+
+    private static String getForcedRefName(Field field) {
         for (NamedLikeHandler namedLikeHandler : Extensions.namedLikeHandlers) 
{
             if (field.getAnnotation(namedLikeHandler.getAnnotation()) != null) 
{
                 String name = namedLikeHandler.getName(field.getType(), field);
@@ -97,7 +149,32 @@ public class Property implements Compara
                 }
             }
         }
-        return Bean.getBeanName(field.getType());
+        return null;
+    }
+
+    private static String getForcedRefName(Method method) {
+        for (NamedLikeHandler namedLikeHandler : Extensions.namedLikeHandlers) 
{
+            if (method.getAnnotation(namedLikeHandler.getAnnotation()) != 
null) {
+                String name = 
namedLikeHandler.getName(method.getParameterTypes()[0], method);
+                if (name != null) {
+                    return name;
+                }
+            }
+        }
+        return null;
+    }
+
+    private static String getForcedRefName(Annotation[] annotations) {
+        for (NamedLikeHandler namedLikeHandler : Extensions.namedLikeHandlers) 
{
+            Annotation annotation = (Annotation) 
AnnotationHelper.findAnnotation(annotations, namedLikeHandler.getAnnotation());
+            if (annotation != null) {
+                String name = namedLikeHandler.getName(annotation);
+                if (name != null) {
+                    return name;
+                }
+            }
+        }
+        return null;
     }
 
     private static boolean needsInject(AnnotatedElement annotatedElement) {

Added: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,158 @@
+/**
+ * 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
+ * <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
+ * 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.pax;
+
+import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
+import org.ops4j.pax.cdi.api.OsgiService;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public class OsgiServiceHandler implements 
CustomDependencyAnnotationHandler<OsgiService> {
+    @Override
+    public Class<OsgiService> getAnnotation() {
+        return OsgiService.class;
+    }
+
+    @Override
+    public String handleDependencyAnnotation(AnnotatedElement 
annotatedElement, String name, ContextEnricher contextEnricher) {
+        final ServiceFilter serviceFilter = 
extractServiceFilter(annotatedElement);
+        final String id = name != null ? name : 
generateReferenceId(getClass(annotatedElement), serviceFilter);
+        final Class<?> clazz = getClass(annotatedElement);
+
+        contextEnricher.addBean(id, getClass(annotatedElement));
+        contextEnricher.addBlueprintWriter(id, new BlueprintWriter() {
+            @Override
+            public void write(XMLStreamWriter writer) throws 
XMLStreamException {
+                writer.writeEmptyElement("reference");
+                writer.writeAttribute("id", id);
+                writer.writeAttribute("interface", clazz.getName());
+                if (serviceFilter.filter != null && 
!"".equals(serviceFilter.filter)) {
+                    writer.writeAttribute("filter", serviceFilter.filter);
+                }
+                if (serviceFilter.compName != null && 
!"".equals(serviceFilter.compName)) {
+                    writer.writeAttribute("component-name", 
serviceFilter.compName);
+                }
+                writer.writeCharacters("\n");
+            }
+        });
+        return id;
+    }
+
+    @Override
+    public String handleDependencyAnnotation(final Class<?> clazz, OsgiService 
annotation, String name, ContextEnricher contextEnricher) {
+        final ServiceFilter serviceFilter = extractServiceFilter(annotation);
+        final String id = name != null ? name : generateReferenceId(clazz, 
serviceFilter);
+
+        contextEnricher.addBean(id, clazz);
+        contextEnricher.addBlueprintWriter(id, new BlueprintWriter() {
+            @Override
+            public void write(XMLStreamWriter writer) throws 
XMLStreamException {
+                writer.writeEmptyElement("reference");
+                writer.writeAttribute("id", id);
+                writer.writeAttribute("interface", clazz.getName());
+                if (serviceFilter.filter != null && 
!"".equals(serviceFilter.filter)) {
+                    writer.writeAttribute("filter", serviceFilter.filter);
+                }
+                if (serviceFilter.compName != null && 
!"".equals(serviceFilter.compName)) {
+                    writer.writeAttribute("component-name", 
serviceFilter.compName);
+                }
+                writer.writeCharacters("\n");
+            }
+        });
+        return id;
+    }
+
+    private Class<?> getClass(AnnotatedElement annotatedElement) {
+        if (annotatedElement instanceof Class<?>) {
+            return (Class<?>) annotatedElement;
+        }
+        if (annotatedElement instanceof Method) {
+            return ((Method) annotatedElement).getParameterTypes()[0];
+        }
+        if (annotatedElement instanceof Field) {
+            return ((Field) annotatedElement).getType();
+        }
+        throw new RuntimeException("Unknown annotated element");
+    }
+
+    private ServiceFilter extractServiceFilter(AnnotatedElement 
annotatedElement) {
+        OsgiService osgiService = 
annotatedElement.getAnnotation(OsgiService.class);
+        return extractServiceFilter(osgiService);
+    }
+
+    private ServiceFilter extractServiceFilter(OsgiService osgiService) {
+        String filterValue = osgiService.filter();
+        return new ServiceFilter(filterValue);
+    }
+
+    private String generateReferenceId(Class clazz, ServiceFilter 
serviceFilter) {
+        String prefix = getBeanNameFromSimpleName(clazz.getSimpleName());
+        String suffix = createIdSuffix(serviceFilter);
+        return prefix + suffix;
+    }
+
+    protected static String getBeanNameFromSimpleName(String name) {
+        return name.substring(0, 1).toLowerCase() + name.substring(1, 
name.length());
+    }
+
+    private String createIdSuffix(ServiceFilter serviceFilter) {
+        if (serviceFilter.filter != null) {
+            return "-" + getId(serviceFilter.filter);
+        }
+        if (serviceFilter.compName != null) {
+            return "-" + serviceFilter.compName;
+        }
+        return "";
+    }
+
+    private String getId(String raw) {
+        StringBuilder builder = new StringBuilder();
+        for (int c = 0; c < raw.length(); c++) {
+            char ch = raw.charAt(c);
+            if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' 
&& ch <= '9') {
+                builder.append(ch);
+            }
+        }
+        return builder.toString();
+    }
+
+    private static class ServiceFilter {
+        final public String filter;
+        final public String compName;
+
+        public ServiceFilter(String filterValue) {
+            if (filterValue == null) {
+                filter = null;
+                compName = null;
+            } else if (filterValue.contains("(")) {
+                filter = filterValue;
+                compName = null;
+            } else {
+                filter = null;
+                compName = filterValue;
+            }
+        }
+    }
+}

Added: 
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=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
 Mon Aug 29 12:18:13 2016
@@ -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
+ * <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
+ * 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.pax;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+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.CustomFactoryMethodAnnotationHandler;
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+import org.ops4j.pax.cdi.api.Properties;
+import org.ops4j.pax.cdi.api.Property;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.lang.reflect.AnnotatedElement;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class OsgiServiceProviderHandler implements 
CustomBeanAnnotationHandler<OsgiServiceProvider>, 
CustomFactoryMethodAnnotationHandler<OsgiServiceProvider> {
+    @Override
+    public Class<OsgiServiceProvider> getAnnotation() {
+        return OsgiServiceProvider.class;
+    }
+
+    @Override
+    public void handleFactoryMethodAnnotation(AnnotatedElement 
annotatedElement, String id, ContextEnricher contextEnricher) {
+        handleAnnotation(annotatedElement, id, contextEnricher);
+    }
+
+    @Override
+    public void handleBeanAnnotation(AnnotatedElement annotatedElement, final 
String id, ContextEnricher contextEnricher) {
+        handleAnnotation(annotatedElement, id, contextEnricher);
+    }
+
+    private void handleAnnotation(AnnotatedElement annotatedElement, final 
String id, ContextEnricher contextEnricher) {
+        final OsgiServiceProvider serviceProvider = 
annotatedElement.getAnnotation(OsgiServiceProvider.class);
+        Properties properties = 
annotatedElement.getAnnotation(Properties.class);
+
+        final List<String> interfaceNames = 
extractServiceInterfaces(serviceProvider);
+
+        final Map<String, String> propertiesAsMap = 
extractProperties(properties);
+
+        contextEnricher.addBlueprintWriter("OsgiServiceProvider/" + 
annotatedElement + "/" + id, new BlueprintWriter() {
+            @Override
+            public void write(XMLStreamWriter writer) throws 
XMLStreamException {
+                writeService(writer, propertiesAsMap, interfaceNames, id);
+            }
+        });
+    }
+
+    private void writeService(XMLStreamWriter writer, Map<String, String> 
propertiesAsMap, List<String> interfaceNames, String id) throws 
XMLStreamException {
+        // If there are no properties to write and only one service attribute 
(either
+        // interface="MyServiceInterface" or auto-export="interfaces") then 
create an
+        // empty element
+        boolean writeEmptyElement = propertiesAsMap.isEmpty() && 
interfaceNames.size() < 2;
+        if (writeEmptyElement) {
+            writer.writeEmptyElement("service");
+        } else {
+            writer.writeStartElement("service");
+        }
+        writer.writeAttribute("ref", id);
+
+        if (interfaceNames.size() == 0) {
+            writer.writeAttribute("auto-export", "interfaces");
+        } else if (interfaceNames.size() == 1) {
+            writer.writeAttribute("interface", 
Iterables.getOnlyElement(interfaceNames));
+        } else {
+            writeInterfacesElement(writer, interfaceNames);
+        }
+
+        writer.writeCharacters("\n");
+
+        if (!propertiesAsMap.isEmpty()) {
+            writeProperties(writer, propertiesAsMap);
+        }
+
+        if (!writeEmptyElement) {
+            writer.writeEndElement();
+            writer.writeCharacters("\n");
+        }
+    }
+
+    private static Map<String, String> extractProperties(Properties 
properties) {
+        Map<String, String> propertiesAsMap = new HashMap<>();
+        if (properties != null) {
+            for (Property property : properties.value()) {
+                propertiesAsMap.put(property.name(), property.value());
+            }
+        }
+        return propertiesAsMap;
+    }
+
+    private static List<String> extractServiceInterfaces(OsgiServiceProvider 
serviceProvider) {
+        List<String> interfaceNames = Lists.newArrayList();
+        for (Class<?> serviceIf : serviceProvider.classes()) {
+            interfaceNames.add(serviceIf.getName());
+        }
+        return interfaceNames;
+    }
+
+    private void writeInterfacesElement(XMLStreamWriter writer, 
Iterable<String> interfaceNames) throws XMLStreamException {
+        writer.writeCharacters("\n");
+        writer.writeCharacters("    ");
+        writer.writeStartElement("interfaces");
+        writer.writeCharacters("\n");
+        for (String interfaceName : interfaceNames) {
+            writer.writeCharacters("        ");
+            writer.writeStartElement("value");
+            writer.writeCharacters(interfaceName);
+            writer.writeEndElement();
+            writer.writeCharacters("\n");
+        }
+        writer.writeCharacters("    ");
+        writer.writeEndElement();
+    }
+
+    private void writeProperties(XMLStreamWriter writer, Map<String, String> 
properties) throws XMLStreamException {
+        writer.writeCharacters("    ");
+        writer.writeStartElement("service-properties");
+        writer.writeCharacters("\n");
+        for (Map.Entry<String, String> property : properties.entrySet()) {
+            writer.writeCharacters("        ");
+            writer.writeEmptyElement("entry");
+            writer.writeAttribute("key", property.getKey());
+            writer.writeAttribute("value", property.getValue());
+            writer.writeCharacters("\n");
+        }
+        writer.writeCharacters("    ");
+        writer.writeEndElement();
+        writer.writeCharacters("\n");
+    }
+}

Added: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,8 @@
+package org.apache.aries.blueprint.plugin.spi;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+public interface BlueprintWriter {
+    void write(XMLStreamWriter xmlStreamWriter) throws XMLStreamException;
+}

Added: 
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/ContextEnricher.java?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,24 @@
+/**
+ * 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
+ * <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
+ * 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.spi;
+
+public interface ContextEnricher {
+    void addBean(String id, Class<?> clazz);
+    void addBlueprintWriter(String id, BlueprintWriter blueprintWriter);
+}

Added: 
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/CustomBeanAnnotationHandler.java?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomBeanAnnotationHandler.java
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomBeanAnnotationHandler.java
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,28 @@
+/**
+ * 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
+ * <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
+ * 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.spi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+public interface CustomBeanAnnotationHandler<A extends Annotation> {
+    Class<A> getAnnotation();
+
+    void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, 
ContextEnricher contextEnricher);
+}

Added: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomDependencyAnnotationHandler.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomDependencyAnnotationHandler.java?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomDependencyAnnotationHandler.java
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomDependencyAnnotationHandler.java
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,30 @@
+/**
+ * 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
+ * <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
+ * 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.spi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+public interface CustomDependencyAnnotationHandler<A extends Annotation> {
+    Class<A> getAnnotation();
+
+    String handleDependencyAnnotation(AnnotatedElement annotatedElement, 
String name, ContextEnricher contextEnricher);
+
+    String handleDependencyAnnotation(Class<?> clazz, A annotation, String 
name, ContextEnricher contextEnricher);
+}

Added: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomFactoryMethodAnnotationHandler.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomFactoryMethodAnnotationHandler.java?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomFactoryMethodAnnotationHandler.java
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/CustomFactoryMethodAnnotationHandler.java
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,28 @@
+/**
+ * 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
+ * <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
+ * 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.spi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+public interface CustomFactoryMethodAnnotationHandler<A extends Annotation> {
+    Class<A> getAnnotation();
+
+    void handleFactoryMethodAnnotation(AnnotatedElement annotatedElement, 
String id, ContextEnricher contextEnricher);
+}

Added: 
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.CustomBeanAnnotationHandler?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomBeanAnnotationHandler
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.aries.blueprint.plugin.pax.OsgiServiceProviderHandler
\ No newline at end of file

Added: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.aries.blueprint.plugin.pax.OsgiServiceHandler
\ No newline at end of file

Added: 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler?rev=1758211&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler
 (added)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler
 Mon Aug 29 12:18:13 2016
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.aries.blueprint.plugin.pax.OsgiServiceProviderHandler
\ No newline at end of file

Modified: 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java?rev=1758211&r1=1758210&r2=1758211&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java
 Mon Aug 29 12:18:13 2016
@@ -277,7 +277,7 @@ public class GeneratorTest {
 
         assertXpathEquals(bean1, "property[@name='myValue']/@value", "test");
         assertXpathEquals(bean1, "property[@name='serviceA1']/@ref", "my1");
-        assertXpathEquals(bean1, "property[@name='serviceA2']/@ref", "my1");
+        assertXpathEquals(bean1, "property[@name='serviceA2']/@ref", "my2");
         assertXpathEquals(bean1, "property[@name='serviceB']/@ref", 
"serviceABImpl");
         assertXpathEquals(bean1, "property[@name='serviceB2']/@ref", 
"serviceB2Id");
         assertXpathEquals(bean1, "property[@name='serviceBRef']/@ref", 
"serviceB-typeB1Ref");

Modified: 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java?rev=1758211&r1=1758210&r2=1758211&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java
 Mon Aug 29 12:18:13 2016
@@ -18,14 +18,8 @@
  */
 package org.apache.aries.blueprint.plugin.model;
 
-import static org.junit.Assert.assertEquals;
-
-import org.apache.aries.blueprint.plugin.test.MyBean3;
 import org.apache.aries.blueprint.plugin.test.MyFactoryBean;
 import org.apache.aries.blueprint.plugin.test.MyProduced;
-import org.apache.aries.blueprint.plugin.test.ServiceB;
-import org.apache.aries.blueprint.plugin.test.ServiceReferences;
-import org.apache.aries.blueprint.plugin.test.ServiceReferencesParent;
 import org.junit.Assert;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
@@ -33,30 +27,32 @@ import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.container.Converter;
 
+import static org.junit.Assert.assertEquals;
+
 public class ContextTest {
 
-    @Test
-    public void testLists()  {
-        Context context = new Context(MyBean3.class);
-        Assert.assertEquals(1, context.getBeans().size());
-        Assert.assertEquals(0, context.getServiceRefs().size());
-    }
-
-    @Test
-    public void testLists2()  {
-        Context context = new Context(ServiceReferences.class);
-        Assert.assertEquals(1, context.getBeans().size());
-        Assert.assertEquals(3, context.getServiceRefs().size());
-    }
-
-    @Test
-    public void testMatching() throws NoSuchFieldException, SecurityException  
{
-        Context context = new Context(ServiceReferences.class);
-        BeanRef matching = context.getMatching(new 
BeanRef(ServiceReferencesParent.class.getDeclaredField("serviceB")));
-        Assert.assertEquals(OsgiServiceRef.class, matching.getClass());
-        Assert.assertEquals(ServiceB.class, matching.clazz);
-        Assert.assertEquals("serviceB-typeB1", matching.id);
-    }
+//    @Test
+//    public void testLists()  {
+//        Context context = new Context(MyBean3.class);
+//        Assert.assertEquals(1, context.getBeans().size());
+//        Assert.assertEquals(0, context.getServiceRefs().size());
+//    }
+//
+//    @Test
+//    public void testLists2()  {
+//        Context context = new Context(ServiceReferences.class);
+//        Assert.assertEquals(1, context.getBeans().size());
+//        Assert.assertEquals(3, context.getServiceRefs().size());
+//    }
+
+//    @Test
+//    public void testMatching() throws NoSuchFieldException, 
SecurityException  {
+//        Context context = new Context(ServiceReferences.class);
+//        BeanRef matching = context.getMatching(new 
BeanRef(ServiceReferencesParent.class.getDeclaredField("serviceB")));
+//        Assert.assertEquals(OsgiServiceRef.class, matching.getClass());
+//        Assert.assertEquals(ServiceB.class, matching.clazz);
+//        Assert.assertEquals("serviceB-typeB1", matching.id);
+//    }
 
     private void assertSpecialRef(String expectedId, Class<?> clazz) {
         Context context = new Context();

Modified: 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithSetters.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithSetters.java?rev=1758211&r1=1758210&r2=1758211&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithSetters.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithSetters.java
 Mon Aug 29 12:18:13 2016
@@ -75,11 +75,9 @@ public class BeanWithSetters {
     }
 
     @Inject
-    @OsgiService(filter = "(type=B1Ref)")
-    public void setServiceBRef(ServiceB serviceBRef) {
+    public void setServiceBRef(@OsgiService(filter = "(type=B1Ref)") ServiceB 
serviceBRef) {
     }
 
-
     @Inject
     @Named("serviceB2IdRef")
     @OsgiService(filter = "(type=B2Ref)")


Reply via email to