From af521d94680cd286525f2c73fb841d3eac6e808a Mon Sep 17 00:00:00 2001 From: Dominik Adam Przybysz Date: Sat, 5 Mar 2016 18:03:48 +0100 Subject: [PATCH] [ARIES-1501] Add constructor injection and component name in reference --- .../aries/blueprint/plugin/Generator.java | 62 +++-- .../plugin/OsgiServiceProviderWriter.java | 16 +- .../plugin/OsgiServiceRefWriter.java | 10 +- .../blueprint/plugin/model/Argument.java | 37 +++ .../plugin/model/ArgumentWriter.java | 23 ++ .../aries/blueprint/plugin/model/Bean.java | 113 ++++++--- .../aries/blueprint/plugin/model/BeanRef.java | 57 +++-- .../plugin/model/BuiltInBeanRef.java | 25 -- .../aries/blueprint/plugin/model/Context.java | 5 + .../aries/blueprint/plugin/model/Matcher.java | 2 - .../plugin/model/OsgiServiceRef.java | 26 ++- .../blueprint/plugin/AnnotatedService.java | 12 + .../aries/blueprint/plugin/GeneratorTest.java | 215 +++++++++++------- .../blueprint/plugin/model/BeanTest.java | 70 ++++-- .../aries/blueprint/plugin/test/MyBean5.java | 61 +++++ .../plugin/test/ServiceAImplQualified.java | 28 +++ .../aries/blueprint/plugin/test/ServiceC.java | 23 ++ 17 files changed, 577 insertions(+), 208 deletions(-) create mode 100644 blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java create mode 100644 blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ArgumentWriter.java delete mode 100644 blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BuiltInBeanRef.java create mode 100644 blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/AnnotatedService.java create mode 100644 blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/MyBean5.java create mode 100644 blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceAImplQualified.java create mode 100644 blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceC.java diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java index b8d85636d6..42e56abb54 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java @@ -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 - * + *

+ * 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 @@ -18,19 +18,8 @@ */ package org.apache.aries.blueprint.plugin; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceUnit; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - +import org.apache.aries.blueprint.plugin.model.Argument; +import org.apache.aries.blueprint.plugin.model.ArgumentWriter; import org.apache.aries.blueprint.plugin.model.Bean; import org.apache.aries.blueprint.plugin.model.Context; import org.apache.aries.blueprint.plugin.model.ProducedBean; @@ -38,7 +27,19 @@ import org.apache.aries.blueprint.plugin.model.PropertyWriter; import org.apache.aries.blueprint.plugin.model.TransactionalDef; -public class Generator implements PropertyWriter { +import javax.persistence.PersistenceContext; +import javax.persistence.PersistenceUnit; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class Generator implements PropertyWriter, ArgumentWriter { private static final String NS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0"; private static final String NS_EXT = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"; public static final String NS_JPA = "http://aries.apache.org/xmlns/jpa/v1.1.0"; @@ -81,6 +82,7 @@ public void generate() { } for (Bean bean : context.getBeans()) { writeBeanStart(bean); + bean.writeArguments(this); bean.writeProperties(this); writer.writeEndElement(); writer.writeCharacters("\n"); @@ -102,9 +104,9 @@ public void generate() { private boolean isJpaUsed() { boolean jpaUsed = false; for (Bean bean : context.getBeans()) { - if (bean.persistenceFields.size() > 0) { - jpaUsed = true; - } + if (bean.persistenceFields.size() > 0) { + jpaUsed = true; + } } return jpaUsed; } @@ -131,7 +133,8 @@ private void writeBlueprint() throws XMLStreamException { private String getPrefixForNamesapace(String namespace) { if (namespace.contains("jpa")) { return "jpa"; - } if (namespace.contains("transactions")) { + } + if (namespace.contains("transactions")) { return "tx"; } return "other"; @@ -146,7 +149,7 @@ public void writeBeanStart(Bean bean) throws XMLStreamException { writer.writeAttribute("scope", "prototype"); } if (bean instanceof ProducedBean) { - writeFactory((ProducedBean)bean); + writeFactory((ProducedBean) bean); } if (bean.initMethod != null) { writer.writeAttribute("init-method", bean.initMethod); @@ -225,4 +228,19 @@ public void writeProperty(Property property) { } } + @Override + public void writeArgument(Argument argument) { + try { + writer.writeCharacters(" "); + writer.writeEmptyElement("argument"); + if (argument.getRef() != null) { + writer.writeAttribute("ref", argument.getRef()); + } else if (argument.getValue() != null) { + writer.writeAttribute("value", argument.getValue()); + } + writer.writeCharacters("\n"); + } catch (XMLStreamException e) { + throw new RuntimeException(e.getMessage(), e); + } + } } diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceProviderWriter.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceProviderWriter.java index 37d4782bb2..fd901d485a 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceProviderWriter.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceProviderWriter.java @@ -18,22 +18,20 @@ */ package org.apache.aries.blueprint.plugin; -import java.util.Collection; -import java.util.List; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import org.apache.aries.blueprint.plugin.model.Bean; import org.ops4j.pax.cdi.api.OsgiServiceProvider; import org.ops4j.pax.cdi.api.Properties; import org.ops4j.pax.cdi.api.Property; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.util.Collection; +import java.util.List; public class OsgiServiceProviderWriter { - private XMLStreamWriter writer; + private final XMLStreamWriter writer; public OsgiServiceProviderWriter(XMLStreamWriter writer) { this.writer = writer; diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceRefWriter.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceRefWriter.java index f3e813232c..ec9124a280 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceRefWriter.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/OsgiServiceRefWriter.java @@ -18,15 +18,14 @@ */ package org.apache.aries.blueprint.plugin; -import java.util.Collection; +import org.apache.aries.blueprint.plugin.model.OsgiServiceRef; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; - -import org.apache.aries.blueprint.plugin.model.OsgiServiceRef; +import java.util.Collection; public class OsgiServiceRefWriter { - private XMLStreamWriter writer; + private final XMLStreamWriter writer; public OsgiServiceRefWriter(XMLStreamWriter writer) { this.writer = writer; @@ -45,6 +44,9 @@ private void writeServiceRef(OsgiServiceRef serviceBean) throws XMLStreamExcepti if (serviceBean.filter != null && !"".equals(serviceBean.filter)) { writer.writeAttribute("filter", serviceBean.filter); } + if (serviceBean.compName != null && !"".equals(serviceBean.compName)) { + writer.writeAttribute("component-name", serviceBean.compName); + } writer.writeCharacters("\n"); } diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java new file mode 100644 index 0000000000..8902b14928 --- /dev/null +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java @@ -0,0 +1,37 @@ +/** + * 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.model; + +public class Argument { + private final String ref; + private final String value; + + public Argument(String ref, String value) { + this.ref = ref; + this.value = value; + } + + public String getRef() { + return this.ref; + } + + public String getValue() { + return this.value; + } +} diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ArgumentWriter.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ArgumentWriter.java new file mode 100644 index 0000000000..29705e4b4e --- /dev/null +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ArgumentWriter.java @@ -0,0 +1,23 @@ +/** + * 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.model; + +public interface ArgumentWriter { + void writeArgument(Argument argument); +} diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java index 9805cfa676..b382b3187f 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java @@ -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 - * + *

+ * 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 @@ -18,31 +18,37 @@ */ package org.apache.aries.blueprint.plugin.model; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import org.ops4j.pax.cdi.api.OsgiService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; import javax.persistence.PersistenceContext; import javax.persistence.PersistenceUnit; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; public class Bean extends BeanRef { public String initMethod; public String destroyMethod; - public SortedSet properties; + public SortedSet properties = new TreeSet<>(); + public List constructorArguments = new ArrayList<>(); + public Set serviceRefs = new HashSet<>(); public List persistenceFields; - public Set transactionDefs = new HashSet(); + public Set transactionDefs = new HashSet<>(); public boolean isPrototype; public Bean(Class clazz) { @@ -66,15 +72,15 @@ public Bean(Class clazz) { transactionDefs.addAll(new SpringTransactionFactory().create(clazz)); this.isPrototype = isPrototype(clazz); this.persistenceFields = introspector.fieldsWith(PersistenceContext.class, PersistenceUnit.class); - properties = new TreeSet(); + setQualifiersFromAnnotations(clazz.getAnnotations()); } - private boolean isPrototype(Class clazz) - { + private boolean isPrototype(Class clazz) { return clazz.getAnnotation(Singleton.class) == null && clazz.getAnnotation(Component.class) == null; } public void resolve(Matcher matcher) { + resolveConstructorArguments(matcher); for (Field field : new Introspector(clazz).fieldsWith(Value.class, Autowired.class, Inject.class)) { Property prop = Property.create(matcher, field); if (prop != null) { @@ -83,15 +89,61 @@ public void resolve(Matcher matcher) { } } + private void resolveConstructorArguments(Matcher matcher) { + for (Constructor constructor : clazz.getDeclaredConstructors()) { + Annotation inject = constructor.getAnnotation(Inject.class); + Annotation autowired = constructor.getAnnotation(Autowired.class); + if (inject != null || autowired != null) { + Class[] parameterTypes = constructor.getParameterTypes(); + Annotation[][] parameterAnnotations = constructor.getParameterAnnotations(); + for (int i = 0; i < parameterTypes.length; ++i) { + Annotation[] annotations = parameterAnnotations[i]; + String ref = null; + String value = null; + Value valueAnnotation = findAnnotation(annotations, Value.class); + OsgiService osgiServiceAnnotation = findAnnotation(annotations, OsgiService.class); + + if (valueAnnotation != null) { + value = valueAnnotation.value(); + } + + if (osgiServiceAnnotation != null) { + Named namedAnnotation = findAnnotation(annotations, Named.class); + ref = namedAnnotation != null ? namedAnnotation.value() : getBeanNameFromSimpleName(parameterTypes[i].getSimpleName()); + OsgiServiceRef osgiServiceRef = new OsgiServiceRef(parameterTypes[i], osgiServiceAnnotation, ref); + serviceRefs.add(osgiServiceRef); + } + + if (ref == null && value == null && osgiServiceAnnotation == null) { + BeanRef template = new BeanRef(parameterTypes[i]); + template.setQualifiersFromAnnotations(annotations); + BeanRef bean = matcher.getMatching(template); + if (bean != null) { + ref = bean.id; + } else { + Named namedAnnotation = findAnnotation(annotations, Named.class); + if (namedAnnotation != null) { + ref = namedAnnotation.value(); + } else { + ref = getBeanName(parameterTypes[i]); + } + } + } + + constructorArguments.add(new Argument(ref, value)); + } + break; + } + } + } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((clazz == null) ? 0 : clazz.getName().hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; + private static T findAnnotation(Annotation[] annotations, Class annotation) { + for (Annotation a : annotations) { + if (a.annotationType() == annotation) { + return annotation.cast(a); + } + } + return null; } @Override @@ -105,4 +157,11 @@ public void writeProperties(PropertyWriter writer) { } } + public void writeArguments(ArgumentWriter writer) { + for (Argument argument : constructorArguments) { + writer.writeArgument(argument); + } + } + + } diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java index 19b1cb59e0..d340f0d84f 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java @@ -1,28 +1,26 @@ package org.apache.aries.blueprint.plugin.model; +import org.springframework.stereotype.Component; + +import javax.inject.Named; +import javax.inject.Qualifier; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; -import javax.inject.Named; - -import org.springframework.stereotype.Component; - public class BeanRef implements Comparable { public String id; public Class clazz; - public Map, Annotation> qualifiers; - + public Map, Annotation> qualifiers = new HashMap<>(); + /** - * * @param clazz interface or implementation class */ public BeanRef(Class clazz) { this.clazz = clazz; - this.qualifiers = new HashMap, Annotation>(); } - + public BeanRef(Class clazz, String id) { this(clazz); this.id = id; @@ -30,15 +28,20 @@ public BeanRef(Class clazz, String id) { public BeanRef(Field field) { this(field.getType()); - for (Annotation ann : field.getAnnotations()) { + Annotation[] annotations = field.getAnnotations(); + setQualifiersFromAnnotations(annotations); + } + + protected void setQualifiersFromAnnotations(Annotation[] annotations) { + for (Annotation ann : annotations) { if (isQualifier(ann) != null) { this.qualifiers.put(ann.annotationType(), ann); } } } - private javax.inject.Qualifier isQualifier(Annotation ann) { - return ann.annotationType().getAnnotation(javax.inject.Qualifier.class); + private Qualifier isQualifier(Annotation ann) { + return ann.annotationType().getAnnotation(Qualifier.class); } public static String getBeanName(Class clazz) { @@ -47,17 +50,17 @@ public static String getBeanName(Class clazz) { if (component != null && !"".equals(component.value())) { return component.value(); } else if (named != null && !"".equals(named.value())) { - return named.value(); + return named.value(); } else { String name = clazz.getSimpleName(); return getBeanNameFromSimpleName(name); } } - private static String getBeanNameFromSimpleName(String name) { + protected static String getBeanNameFromSimpleName(String name) { return name.substring(0, 1).toLowerCase() + name.substring(1, name.length()); } - + public boolean matches(BeanRef template) { boolean assignable = template.clazz.isAssignableFrom(this.clazz); return assignable && qualifiers.values().containsAll(template.qualifiers.values()); @@ -67,9 +70,31 @@ public boolean matches(BeanRef template) { public int compareTo(BeanRef other) { return this.id.compareTo(other.id); } - + @Override public String toString() { return this.clazz.getSimpleName() + "(" + this.id + ")"; } + + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof BeanRef)) return false; + final BeanRef other = (BeanRef) o; + if (!other.canEqual(this)) return false; + if (this.id == null ? other.id != null : !this.id.equals(other.id)) return false; + if (this.clazz == null ? other.clazz != null : !this.clazz.equals(other.clazz)) return false; + return true; + } + + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + (this.id == null ? 0 : this.id.hashCode()); + result = result * PRIME + (this.clazz == null ? 0 : this.clazz.hashCode()); + return result; + } + + protected boolean canEqual(Object other) { + return other instanceof BeanRef; + } } diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BuiltInBeanRef.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BuiltInBeanRef.java deleted file mode 100644 index ab6eec186c..0000000000 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BuiltInBeanRef.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.apache.aries.blueprint.plugin.model; - -import com.google.inject.name.Named; - -public class BuiltInBeanRef extends BeanRef { - - public BuiltInBeanRef(Class clazz, String id) { - super(clazz); - this.id = id; - } - - @Override - public boolean matches(BeanRef template) { - if (template.clazz != this.clazz || template.qualifiers.size() > 1) { - return false; - } - if (template.qualifiers.size() == 0) { - return true; - } - Named name = (Named)template.qualifiers.get(Named.class); - return name != null && id.equals(name.value()); - } - - -} diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java index 85f361db3c..9bc552fb61 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java @@ -87,9 +87,14 @@ private void addServiceRefs(Class clazz) { 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)) { diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java index ebca220b5f..ab94b8e375 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Matcher.java @@ -18,8 +18,6 @@ */ package org.apache.aries.blueprint.plugin.model; - - public interface Matcher { BeanRef getMatching(BeanRef template); } diff --git a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/OsgiServiceRef.java b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/OsgiServiceRef.java index c05e198d69..ce4f7b4e27 100644 --- a/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/OsgiServiceRef.java +++ b/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/OsgiServiceRef.java @@ -27,18 +27,40 @@ */ public class OsgiServiceRef extends BeanRef { - public String filter; + final public String filter; + final public String compName; + public OsgiServiceRef(Field field) { super(field); OsgiService osgiService = field.getAnnotation(OsgiService.class); - filter = osgiService.filter(); + String filterValue = osgiService.filter(); + if (filterValue.contains("(")) { + filter = filterValue; + compName = null; + } else { + compName = filterValue; + filter = null; + } id = getBeanName(clazz); if (filter != null) { id = id + "-" + getId(filter); } } + public OsgiServiceRef(Class clazz, OsgiService osgiService, String name) { + super(clazz, name); + String filterValue = osgiService.filter(); + if (filterValue.contains("(")) { + filter = filterValue; + compName = null; + } else { + compName = filterValue; + filter = null; + } + } + + private String getId(String raw) { StringBuilder builder = new StringBuilder(); for (int c = 0; c < raw.length(); c++) { diff --git a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/AnnotatedService.java b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/AnnotatedService.java new file mode 100644 index 0000000000..cabb97eee7 --- /dev/null +++ b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/AnnotatedService.java @@ -0,0 +1,12 @@ +package org.apache.aries.blueprint.plugin; + +import javax.inject.Named; +import javax.inject.Qualifier; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@Qualifier +@Named("annotatedService") +public @interface AnnotatedService { +} diff --git a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java index 71547dd37e..acfa3433fa 100644 --- a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java +++ b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java @@ -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 - * + *

+ * 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 @@ -18,23 +18,7 @@ */ package org.apache.aries.blueprint.plugin; -import static java.util.Arrays.asList; -import static org.apache.aries.blueprint.plugin.FilteredClassFinder.findClasses; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; - +import com.google.common.collect.Sets; import org.apache.aries.blueprint.plugin.model.Context; import org.apache.aries.blueprint.plugin.model.TransactionalDef; import org.apache.aries.blueprint.plugin.test.MyBean1; @@ -42,25 +26,41 @@ import org.apache.aries.blueprint.plugin.test.ServiceB; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.xbean.finder.ClassFinder; -import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import com.google.common.collect.Sets; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import static org.apache.aries.blueprint.plugin.FilteredClassFinder.findClasses; +import static org.junit.Assert.assertEquals; public class GeneratorTest { - private XPath xpath; - private Document document; + private static XPath xpath; + private static Document document; - @Test - public void testGenerate() throws Exception { - ClassFinder classFinder = new ClassFinder(this.getClass().getClassLoader()); + @BeforeClass + public static void setUp() throws Exception { + ClassFinder classFinder = new ClassFinder(GeneratorTest.class.getClassLoader()); String packageName = MyBean1.class.getPackage().getName(); - Set> beanClasses = findClasses(classFinder, asList(packageName)); + Set> beanClasses = findClasses(classFinder, Collections.singletonList(packageName)); Context context = new Context(beanClasses); context.resolve(); ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -70,17 +70,23 @@ public void testGenerate() throws Exception { document = readToDocument(os); xpath = XPathFactory.newInstance().newXPath(); - //xpath.setNamespaceContext(new NameSpaces(document)); - Node bean1 = (Node) xpath.evaluate("/blueprint/bean[@id='myBean1']", document, XPathConstants.NODE); + } + + @Test + public void testGenerateBeanWithInitDestroyAndfieldInjection() throws Exception { + Node bean1 = getBeanById("myBean1"); + + assertEquals(MyBean1.class.getName(), xpath.evaluate("@class", bean1)); + assertEquals("init", xpath.evaluate("@init-method", bean1)); + assertEquals("destroy", xpath.evaluate("@destroy-method", bean1)); + assertEquals("true", xpath.evaluate("@field-injection", bean1)); + assertEquals("", xpath.evaluate("@scope", bean1)); + } - // Bean - Assert.assertEquals(MyBean1.class.getName(), xpath.evaluate("@class", bean1)); - Assert.assertEquals("init", xpath.evaluate("@init-method", bean1)); - Assert.assertEquals("destroy", xpath.evaluate("@destroy-method", bean1)); - Assert.assertEquals("true", xpath.evaluate("@field-injection", bean1)); - Assert.assertEquals("", xpath.evaluate("@scope", bean1)); + @Test + public void testGenerateTransactional() throws Exception { + Node bean1 = getBeanById("myBean1"); - // @Transactional NodeList txs = (NodeList) xpath.evaluate("transaction", bean1, XPathConstants.NODESET); Set defs = new HashSet(); for (int i = 0; i < txs.getLength(); ++i) { @@ -88,41 +94,59 @@ public void testGenerate() throws Exception { defs.add(new TransactionalDef(xpath.evaluate("@method", tx), xpath.evaluate("@value", tx))); } Set expectedDefs = Sets.newHashSet(new TransactionalDef("*", "RequiresNew"), - new TransactionalDef("txNotSupported", "NotSupported"), - new TransactionalDef("txMandatory", "Mandatory"), - new TransactionalDef("txNever", "Never"), - new TransactionalDef("txRequired", "Required"), - new TransactionalDef("txOverridenWithRequiresNew", "RequiresNew"), - new TransactionalDef("txSupports", "Supports")); - Assert.assertEquals(expectedDefs, defs); - - // @PersistenceContext - Assert.assertEquals("person", xpath.evaluate("context/@unitname", bean1)); - Assert.assertEquals("em", xpath.evaluate("context/@property", bean1)); - - // @PersistenceUnit - Assert.assertEquals("person", xpath.evaluate("unit/@unitname", bean1)); - Assert.assertEquals("emf", xpath.evaluate("unit/@property", bean1)); - - // @Autowired - Assert.assertEquals("my1", xpath.evaluate("property[@name='bean2']/@ref", bean1)); - - // Service with 1 interface - Node serviceAImpl2 = (Node) xpath.evaluate("/blueprint/service[@ref='my2']", document, XPathConstants.NODE); - Assert.assertEquals(ServiceA.class.getName(), xpath.evaluate("@interface", serviceAImpl2)); - Assert.assertEquals("", xpath.evaluate("@auto-export", serviceAImpl2)); - Assert.assertEquals("", xpath.evaluate("interfaces", serviceAImpl2)); - - // Service with 0 interfaces (using auto-export=interfaces instead) - Node serviceAImpl3 = (Node) xpath.evaluate("/blueprint/service[@ref='serviceAImpl3']", document, XPathConstants.NODE); - Assert.assertEquals("", xpath.evaluate("@interface", serviceAImpl3)); - Assert.assertEquals("interfaces", xpath.evaluate("@auto-export", serviceAImpl3)); - Assert.assertEquals("", xpath.evaluate("interfaces", serviceAImpl3)); - - // Service with 2 interfaces (using ServiceAServiceB - Node serviceABImpl = (Node) xpath.evaluate("/blueprint/service[@ref='serviceABImpl']", document, XPathConstants.NODE); - Assert.assertEquals("", xpath.evaluate("@interface", serviceABImpl)); - Assert.assertEquals("", xpath.evaluate("@auto-export", serviceABImpl)); + new TransactionalDef("txNotSupported", "NotSupported"), + new TransactionalDef("txMandatory", "Mandatory"), + new TransactionalDef("txNever", "Never"), + new TransactionalDef("txRequired", "Required"), + new TransactionalDef("txOverridenWithRequiresNew", "RequiresNew"), + new TransactionalDef("txSupports", "Supports")); + assertEquals(expectedDefs, defs); + } + + @Test + public void testGeneratePersistenceContext() throws Exception { + Node bean1 = getBeanById("myBean1"); + + assertEquals("person", xpath.evaluate("context/@unitname", bean1)); + assertEquals("em", xpath.evaluate("context/@property", bean1)); + } + + @Test + public void testGeneratePersistenceUnit() throws Exception { + Node bean1 = getBeanById("myBean1"); + + assertEquals("person", xpath.evaluate("unit/@unitname", bean1)); + assertEquals("emf", xpath.evaluate("unit/@property", bean1)); + } + + @Test + public void testGenerateAutowiredBean() throws Exception { + Node bean1 = getBeanById("myBean1"); + + assertEquals("my1", xpath.evaluate("property[@name='bean2']/@ref", bean1)); + } + + @Test + public void testGenerateServiceWithOneInterface() throws Exception { + Node serviceAImpl2 = getServiceByRef("my2"); + assertEquals(ServiceA.class.getName(), xpath.evaluate("@interface", serviceAImpl2)); + assertEquals("", xpath.evaluate("@auto-export", serviceAImpl2)); + assertEquals("", xpath.evaluate("interfaces", serviceAImpl2)); + } + + @Test + public void testGenerateServiceWithAutoExport() throws Exception { + Node serviceAImpl3 = getServiceByRef("serviceAImpl3"); + assertEquals("", xpath.evaluate("@interface", serviceAImpl3)); + assertEquals("interfaces", xpath.evaluate("@auto-export", serviceAImpl3)); + assertEquals("", xpath.evaluate("interfaces", serviceAImpl3)); + } + + @Test + public void testGenerateServiceWith2Interfaces() throws Exception { + Node serviceABImpl = getServiceByRef("serviceABImpl"); + assertEquals("", xpath.evaluate("@interface", serviceABImpl)); + assertEquals("", xpath.evaluate("@auto-export", serviceABImpl)); NodeList interfaceValues = (NodeList) xpath.evaluate("interfaces/value", serviceABImpl, XPathConstants.NODESET); Set interfaceNames = new HashSet(); @@ -130,16 +154,55 @@ public void testGenerate() throws Exception { Node interfaceValue = interfaceValues.item(i); interfaceNames.add(interfaceValue.getTextContent()); } - Assert.assertEquals(Sets.newHashSet(ServiceA.class.getName(), ServiceB.class.getName()), - interfaceNames); + assertEquals(Sets.newHashSet(ServiceA.class.getName(), ServiceB.class.getName()), + interfaceNames); + } + + @Test + public void testGenerateBeanWithConstructorInjection() throws Exception { + // Bean with constructor injection + Node myBean5 = getBeanById("myBean5"); + assertEquals("my2", xpath.evaluate("argument[1]/@ref", myBean5)); + assertEquals("my1", xpath.evaluate("argument[2]/@ref", myBean5)); + assertEquals("serviceABImpl", xpath.evaluate("argument[3]/@ref", myBean5)); + assertEquals("100", xpath.evaluate("argument[4]/@value", myBean5)); + assertEquals("ser1", xpath.evaluate("argument[5]/@ref", myBean5)); + assertEquals("ser2", xpath.evaluate("argument[6]/@ref", myBean5)); + assertEquals("serviceAImplQualified", xpath.evaluate("argument[7]/@ref", myBean5)); + } + + @Test + public void testGenerateReferenceWithComponentName() throws Exception { + Node ser1 = getReferenceById("ser1"); + assertEquals("myRef", xpath.evaluate("@component-name", ser1)); + assertEquals("", xpath.evaluate("@filter", ser1)); } - private Document readToDocument(ByteArrayOutputStream os) throws ParserConfigurationException, - SAXException, IOException { + @Test + public void testGenerateReferenceWithFilter() throws Exception { + Node ser2 = getReferenceById("ser2"); + assertEquals("", xpath.evaluate("@component-name", ser2)); + assertEquals("(mode=123)", xpath.evaluate("@filter", ser2)); + } + + private static Document readToDocument(ByteArrayOutputStream os) throws ParserConfigurationException, + SAXException, IOException { InputStream is = new ByteArrayInputStream(os.toByteArray()); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); return builder.parse(is); } + private static Node getBeanById(String id) throws XPathExpressionException { + return (Node) xpath.evaluate("/blueprint/bean[@id='" + id + "']", document, XPathConstants.NODE); + } + + private static Node getServiceByRef(String id) throws XPathExpressionException { + return (Node) xpath.evaluate("/blueprint/service[@ref='" + id + "']", document, XPathConstants.NODE); + } + + private static Node getReferenceById(String id) throws XPathExpressionException { + return (Node) xpath.evaluate("/blueprint/reference[@id='" + id + "']", document, XPathConstants.NODE); + } + } diff --git a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java index 2b64e8c91d..75fc7d0e97 100644 --- a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java +++ b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java @@ -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 - * + *

+ * 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 @@ -18,15 +18,7 @@ */ package org.apache.aries.blueprint.plugin.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.Set; - -import javax.inject.Named; - +import com.google.common.collect.Sets; import org.apache.aries.blueprint.plugin.bad.BadBean1; import org.apache.aries.blueprint.plugin.bad.BadBean2; import org.apache.aries.blueprint.plugin.bad.BadBean3; @@ -37,11 +29,18 @@ import org.apache.aries.blueprint.plugin.test.MyBean1; import org.apache.aries.blueprint.plugin.test.MyBean3; import org.apache.aries.blueprint.plugin.test.MyBean4; +import org.apache.aries.blueprint.plugin.test.MyBean5; import org.apache.aries.blueprint.plugin.test.ServiceAImpl1; import org.junit.Assert; import org.junit.Test; -import com.google.common.collect.Sets; +import javax.inject.Named; +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 { @@ -63,12 +62,12 @@ public void testParseMyBean1() { assertEquals("serviceA", prop.ref); Set expectedTxs = Sets.newHashSet(new TransactionalDef("*", "RequiresNew"), - new TransactionalDef("txNotSupported", "NotSupported"), - new TransactionalDef("txMandatory", "Mandatory"), - new TransactionalDef("txNever", "Never"), - new TransactionalDef("txRequired", "Required"), - new TransactionalDef("txOverridenWithRequiresNew", "RequiresNew"), - new TransactionalDef("txSupports", "Supports")); + new TransactionalDef("txNotSupported", "NotSupported"), + new TransactionalDef("txMandatory", "Mandatory"), + new TransactionalDef("txNever", "Never"), + new TransactionalDef("txRequired", "Required"), + new TransactionalDef("txOverridenWithRequiresNew", "RequiresNew"), + new TransactionalDef("txSupports", "Supports")); assertEquals(expectedTxs, bean.transactionDefs); } @@ -85,12 +84,12 @@ public void testParseMyBean3() { assertTrue(bean.isPrototype); Set expectedTxs = Sets.newHashSet(new TransactionalDef("*", "RequiresNew"), - new TransactionalDef("txNotSupported", "NotSupported"), - new TransactionalDef("txMandatory", "Mandatory"), - new TransactionalDef("txNever", "Never"), - new TransactionalDef("txRequired", "Required"), - new TransactionalDef("txRequiresNew", "RequiresNew"), - new TransactionalDef("txSupports", "Supports")); + new TransactionalDef("txNotSupported", "NotSupported"), + new TransactionalDef("txMandatory", "Mandatory"), + new TransactionalDef("txNever", "Never"), + new TransactionalDef("txRequired", "Required"), + new TransactionalDef("txRequiresNew", "RequiresNew"), + new TransactionalDef("txSupports", "Supports")); assertEquals(expectedTxs, bean.transactionDefs); } @@ -156,4 +155,25 @@ public void testBadFieldBean3() { public void testFieldBean4() { new Context(FieldBean4.class).resolve(); } + + @Test + public void testParseBeanWithConstructorInject() { + Bean bean = new Bean(MyBean5.class); + 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(7, bean.constructorArguments.size()); + assertEquals("my2", bean.constructorArguments.get(0).getRef()); + assertEquals("serviceA", bean.constructorArguments.get(1).getRef()); + assertEquals("serviceB", bean.constructorArguments.get(2).getRef()); + assertEquals("100", bean.constructorArguments.get(3).getValue()); + assertEquals("ser1", bean.constructorArguments.get(4).getRef()); + assertEquals("ser2", bean.constructorArguments.get(5).getRef()); + assertEquals("serviceA", bean.constructorArguments.get(6).getRef()); + } + } diff --git a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/MyBean5.java b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/MyBean5.java new file mode 100644 index 0000000000..ea2fba9bad --- /dev/null +++ b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/MyBean5.java @@ -0,0 +1,61 @@ +/** + * 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.test; + +import org.apache.aries.blueprint.plugin.AnnotatedService; +import org.ops4j.pax.cdi.api.OsgiService; +import org.springframework.beans.factory.annotation.Value; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +@Singleton +public class MyBean5 { + + ServiceA serviceA1; + + ServiceA serviceA2; + + ServiceB serviceB; + + int bla; + + ServiceC myReference; + ServiceC myReference2; + + ServiceA serviceAAnnotated; + + @Inject + public MyBean5(@Named("my2") ServiceA serviceA1, + ServiceA serviceA2, + ServiceB serviceB, + @Value("100") int bla, + @OsgiService(filter = "myRef") @Named("ser1") ServiceC myReference, + @OsgiService(filter = "(mode=123)") @Named("ser2") ServiceC myReference2, + @AnnotatedService ServiceA serviceAAnnotated) { + this.serviceA1 = serviceA1; + this.serviceA2 = serviceA2; + this.serviceB = serviceB; + this.bla = bla; + this.myReference = myReference; + this.myReference2 = myReference2; + this.serviceAAnnotated = serviceAAnnotated; + } +} diff --git a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceAImplQualified.java b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceAImplQualified.java new file mode 100644 index 0000000000..26edb86e9c --- /dev/null +++ b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceAImplQualified.java @@ -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 + *

+ * 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.test; + +import org.apache.aries.blueprint.plugin.AnnotatedService; + +import javax.inject.Singleton; + +@Singleton +@AnnotatedService +public class ServiceAImplQualified implements ServiceA { +} diff --git a/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceC.java b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceC.java new file mode 100644 index 0000000000..5db52d144a --- /dev/null +++ b/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/ServiceC.java @@ -0,0 +1,23 @@ +/** + * 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.test; + +public interface ServiceC { + +}