You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by al...@apache.org on 2017/09/30 12:22:16 UTC
svn commit: r1810198 - in /aries/trunk/blueprint/plugin:
blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/
blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/
b...
Author: alien11689
Date: Sat Sep 30 12:22:15 2017
New Revision: 1810198
URL: http://svn.apache.org/viewvc?rev=1810198&view=rev
Log:
[ARIES-1743] Add @Service and @ServiceProperty annotations with handler
Added:
aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/AutoExport.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Service.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/ServiceProperty.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceId.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceParameters.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServiceHandler.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServicePropertyWriter.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service1.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service2.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceProducer.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithAllClasses.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithClassHierarchy.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithManyInterfaces.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithOneInterface.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithProperties.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingAndProperty.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingParameter.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/SimplestService.java
Modified:
aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Reference.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceHandler.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/AutoExport.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/AutoExport.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/AutoExport.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/AutoExport.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,26 @@
+/**
+ * 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.annotation.service;
+
+public enum AutoExport {
+ DISABLED,
+ INTERFACES,
+ CLASS_HIERARCHY,
+ ALL_CLASSES
+}
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Reference.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Reference.java?rev=1810198&r1=1810197&r2=1810198&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Reference.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Reference.java Sat Sep 30 12:22:15 2017
@@ -24,8 +24,7 @@ import java.lang.annotation.RetentionPol
import java.lang.annotation.Target;
/**
- * Annotate dependency to inject service.
- * It will generate reference element.
+ * Annotate dependency to inject a service.
*/
@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Service.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Service.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Service.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/Service.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,54 @@
+/**
+ * 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.annotation.service;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotate bean which should be registered as a service
+ */
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Service {
+
+ /**
+ * @return the list of classes or interfaces with which the service will be registered
+ * When the list is empty than the service will be registered according to {@link #autoExport()}
+ */
+ Class<?>[] classes() default {};
+
+ /**
+ * @return auto export policy (used when {@link #classes()} are not provided)
+ */
+ AutoExport autoExport() default AutoExport.INTERFACES;
+
+ /**
+ * @return service.ranking property of service
+ * this parameter override service.ranking property (in {@link #properties()}) if it has value not equal to 0
+ */
+ int ranking() default 0;
+
+ /**
+ * @return the list of service properties
+ */
+ ServiceProperty[] properties() default {};
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/ServiceProperty.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/ServiceProperty.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/ServiceProperty.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/annotation/service/ServiceProperty.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,40 @@
+/**
+ * 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.annotation.service;
+
+/**
+ * Service property for service registration
+ */
+public @interface ServiceProperty {
+
+ /**
+ * @return name of property
+ */
+ String name();
+
+ /**
+ * @return array of property values
+ */
+ String[] values();
+
+ /**
+ * @return type of value or type of each value in values array
+ */
+ Class<?> type() default String.class;
+}
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceHandler.java?rev=1810198&r1=1810197&r2=1810198&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceHandler.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceHandler.java Sat Sep 30 12:22:15 2017
@@ -19,7 +19,6 @@
package org.apache.aries.blueprint.plugin.handlers.blueprint.service;
import org.apache.aries.blueprint.annotation.service.Reference;
-import org.apache.aries.blueprint.plugin.spi.Availability;
import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
import org.apache.aries.blueprint.plugin.spi.XmlWriter;
@@ -30,6 +29,9 @@ import java.lang.reflect.AnnotatedElemen
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import static org.apache.aries.blueprint.plugin.handlers.blueprint.service.ReferenceParameters.needAvailability;
+import static org.apache.aries.blueprint.plugin.handlers.blueprint.service.ReferenceParameters.needTimeout;
+
public class ReferenceHandler implements CustomDependencyAnnotationHandler<Reference> {
@Override
public Class<Reference> getAnnotation() {
@@ -40,15 +42,12 @@ public class ReferenceHandler implements
public String handleDependencyAnnotation(AnnotatedElement annotatedElement, String name, ContextEnricher contextEnricher) {
Reference reference = annotatedElement.getAnnotation(Reference.class);
final Class<?> clazz = getClass(annotatedElement);
- final String id = name != null ? name : generateReferenceId(clazz, reference, contextEnricher);
- contextEnricher.addBean(id, clazz);
- contextEnricher.addBlueprintContentWriter(getWriterId(id, clazz), getXmlWriter(id, clazz, reference, contextEnricher));
- return id;
+ return handleDependencyAnnotation(clazz, reference, name, contextEnricher);
}
@Override
public String handleDependencyAnnotation(final Class<?> clazz, Reference reference, String name, ContextEnricher contextEnricher) {
- final String id = name != null ? name : generateReferenceId(clazz, reference, contextEnricher);
+ final String id = name != null ? name : ReferenceId.generateReferenceId(clazz, reference, contextEnricher);
contextEnricher.addBean(id, clazz);
contextEnricher.addBlueprintContentWriter(getWriterId(id, clazz), getXmlWriter(id, clazz, reference, contextEnricher));
return id;
@@ -77,17 +76,6 @@ public class ReferenceHandler implements
};
}
- private boolean needTimeout(Reference reference) {
- return reference.timeout() >= 0;
- }
-
- private boolean needAvailability(ContextEnricher contextEnricher, Reference reference) {
- org.apache.aries.blueprint.annotation.service.Availability availability = reference.availability();
- Availability defaultAvailability = contextEnricher.getBlueprintConfiguration().getDefaultAvailability();
- return defaultAvailability == null && availability.equals(org.apache.aries.blueprint.annotation.service.Availability.OPTIONAL) ||
- defaultAvailability != null && !defaultAvailability.name().equals(reference.availability().name());
- }
-
private String getWriterId(String id, Class<?> clazz) {
return "reference/" + clazz.getName() + "/" + id;
}
@@ -105,40 +93,4 @@ public class ReferenceHandler implements
throw new RuntimeException("Unknown annotated element");
}
- private String generateReferenceId(Class clazz, Reference reference, ContextEnricher contextEnricher) {
- StringBuilder sb = new StringBuilder();
- writeBeanNameFromSimpleName(sb, clazz.getSimpleName());
- sb.append("-");
- if (!"".equals(reference.filter())) {
- writeEscapedFilter(sb, reference.filter());
- }
- sb.append("-");
- if (!"".equals(reference.componentName())) {
- sb.append(reference.componentName());
- }
- sb.append("-");
- if (needAvailability(contextEnricher, reference)) {
- sb.append(reference.availability().name().toLowerCase());
- }
- sb.append("-");
- if (needTimeout(reference)) {
- sb.append(reference.timeout());
- }
- return sb.toString().replaceAll("-+$", "");
- }
-
- private static void writeBeanNameFromSimpleName(StringBuilder sb, String name) {
- sb.append(name.substring(0, 1).toLowerCase());
- sb.append(name.substring(1, name.length()));
- }
-
- private void writeEscapedFilter(StringBuilder sb, String filter) {
- for (int c = 0; c < filter.length(); c++) {
- char ch = filter.charAt(c);
- if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9') {
- sb.append(ch);
- }
- }
- }
-
}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceId.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceId.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceId.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceId.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,63 @@
+/**
+ * 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.handlers.blueprint.service;
+
+import org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+
+import static org.apache.aries.blueprint.plugin.handlers.blueprint.service.ReferenceParameters.needAvailability;
+import static org.apache.aries.blueprint.plugin.handlers.blueprint.service.ReferenceParameters.needTimeout;
+
+class ReferenceId {
+ static String generateReferenceId(Class clazz, Reference reference, ContextEnricher contextEnricher) {
+ StringBuilder sb = new StringBuilder();
+ writeBeanNameFromSimpleName(sb, clazz.getSimpleName());
+ sb.append("-");
+ if (!"".equals(reference.filter())) {
+ writeEscapedFilter(sb, reference.filter());
+ }
+ sb.append("-");
+ if (!"".equals(reference.componentName())) {
+ sb.append(reference.componentName());
+ }
+ sb.append("-");
+ if (needAvailability(contextEnricher, reference)) {
+ sb.append(reference.availability().name().toLowerCase());
+ }
+ sb.append("-");
+ if (needTimeout(reference)) {
+ sb.append(reference.timeout());
+ }
+ return sb.toString().replaceAll("-+$", "");
+ }
+
+ private static void writeBeanNameFromSimpleName(StringBuilder sb, String name) {
+ sb.append(name.substring(0, 1).toLowerCase());
+ sb.append(name.substring(1, name.length()));
+ }
+
+ private static void writeEscapedFilter(StringBuilder sb, String filter) {
+ for (int c = 0; c < filter.length(); c++) {
+ char ch = filter.charAt(c);
+ if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9') {
+ sb.append(ch);
+ }
+ }
+ }
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceParameters.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceParameters.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceParameters.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ReferenceParameters.java Sat Sep 30 12:22:15 2017
@@ -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
+ * <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.handlers.blueprint.service;
+
+import org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.plugin.spi.Availability;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+
+class ReferenceParameters {
+
+ static boolean needTimeout(Reference reference) {
+ return reference.timeout() >= 0;
+ }
+
+ static boolean needAvailability(ContextEnricher contextEnricher, Reference reference) {
+ org.apache.aries.blueprint.annotation.service.Availability availability = reference.availability();
+ Availability defaultAvailability = contextEnricher.getBlueprintConfiguration().getDefaultAvailability();
+ return defaultAvailability == null && availability.equals(org.apache.aries.blueprint.annotation.service.Availability.OPTIONAL) ||
+ defaultAvailability != null && !defaultAvailability.name().equals(reference.availability().name());
+ }
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServiceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServiceHandler.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServiceHandler.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServiceHandler.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,94 @@
+/**
+ * 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.handlers.blueprint.service;
+
+import org.apache.aries.blueprint.annotation.service.AutoExport;
+import org.apache.aries.blueprint.annotation.service.Service;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.lang.reflect.AnnotatedElement;
+
+public class ServiceHandler implements BeanAnnotationHandler<Service> {
+ @Override
+ public Class<Service> getAnnotation() {
+ return Service.class;
+ }
+
+ @Override
+ public void handleBeanAnnotation(final AnnotatedElement annotatedElement, final String id, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
+ final Service annotation = annotatedElement.getAnnotation(Service.class);
+ contextEnricher.addBlueprintContentWriter("service/" + id, new XmlWriter() {
+ @Override
+ public void write(XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeStartElement("service");
+ writer.writeAttribute("ref", id);
+ writeRanking(writer, annotation);
+ writeExportSpecification(writer, annotation);
+ new ServicePropertyWriter(annotation.properties(), annotation.ranking()).writeProperties(writer);
+ writer.writeEndElement();
+ }
+ });
+ }
+
+ private void writeRanking(XMLStreamWriter writer, Service annotation) throws XMLStreamException {
+ if (annotation.ranking() != 0) {
+ writer.writeAttribute("ranking", String.valueOf(annotation.ranking()));
+ }
+ }
+
+ private void writeExportSpecification(XMLStreamWriter writer, Service annotation) throws XMLStreamException {
+ if (annotation.classes().length == 0) {
+ if (annotation.autoExport() != AutoExport.DISABLED) {
+ writer.writeAttribute("auto-export", autoExport(annotation.autoExport()));
+ }
+ } else if (annotation.classes().length == 1) {
+ writer.writeAttribute("interface", annotation.classes()[0].getName());
+ } else {
+ writeInterfaces(writer, annotation.classes());
+ }
+ }
+
+ private String autoExport(AutoExport autoExport) {
+ switch (autoExport) {
+ case INTERFACES:
+ return "interfaces";
+ case ALL_CLASSES:
+ return "all-classes";
+ case CLASS_HIERARCHY:
+ return "class-hierarchy";
+ default:
+ throw new IllegalStateException("unkown " + autoExport);
+ }
+ }
+
+ private void writeInterfaces(XMLStreamWriter writer, Class<?>[] classes) throws XMLStreamException {
+ writer.writeStartElement("interfaces");
+ for (Class<?> singleClass : classes) {
+ writer.writeStartElement("value");
+ writer.writeCharacters(singleClass.getName());
+ writer.writeEndElement();
+ }
+ writer.writeEndElement();
+ }
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServicePropertyWriter.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServicePropertyWriter.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServicePropertyWriter.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/service/ServicePropertyWriter.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,101 @@
+/**
+ * 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.handlers.blueprint.service;
+
+import org.apache.aries.blueprint.annotation.service.ServiceProperty;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+class ServicePropertyWriter {
+ private final List<ServiceProperty> serviceProperties;
+
+ ServicePropertyWriter(ServiceProperty[] serviceProperties, int ranking) {
+ this.serviceProperties = filterProperties(serviceProperties, ranking != 0);
+ }
+
+ private List<ServiceProperty> filterProperties(ServiceProperty[] properties, boolean rankingAlreadyProvided) {
+ List<ServiceProperty> filtered = new ArrayList<>();
+ for (ServiceProperty sp : properties) {
+ if (rankingAlreadyProvided && sp.name().equals("service.ranking")) {
+ continue;
+ }
+ if (sp.values().length == 0) {
+ continue;
+ }
+ filtered.add(sp);
+ }
+ return filtered;
+ }
+
+ void writeProperties(XMLStreamWriter writer) throws XMLStreamException {
+ if (!serviceProperties.isEmpty()) {
+ writer.writeStartElement("service-properties");
+ for (ServiceProperty serviceProperty : serviceProperties) {
+ writeServiceProperty(writer, serviceProperty);
+ }
+ writer.writeEndElement();
+ }
+ }
+
+ private void writeServiceProperty(XMLStreamWriter writer, ServiceProperty serviceProperty) throws XMLStreamException {
+ writer.writeStartElement("entry");
+ writer.writeAttribute("key", serviceProperty.name());
+ if (isSingleValue(serviceProperty)) {
+ writeOneValueProperty(writer, serviceProperty);
+ } else {
+ writeMultiValueProperty(writer, serviceProperty);
+ }
+ writer.writeEndElement();
+ }
+
+ private boolean isSingleValue(ServiceProperty serviceProperty) {
+ return serviceProperty.values().length == 1;
+ }
+
+ private boolean isStringProperty(ServiceProperty serviceProperty) {
+ return serviceProperty.type().equals(String.class);
+ }
+
+ private void writeOneValueProperty(XMLStreamWriter writer, ServiceProperty serviceProperty) throws XMLStreamException {
+ if (isStringProperty(serviceProperty)) {
+ writer.writeAttribute("value", serviceProperty.values()[0]);
+ } else {
+ writer.writeStartElement("value");
+ writer.writeAttribute("type", serviceProperty.type().getName());
+ writer.writeCharacters(serviceProperty.values()[0]);
+ writer.writeEndElement();
+ }
+ }
+
+ private void writeMultiValueProperty(XMLStreamWriter writer, ServiceProperty serviceProperty) throws XMLStreamException {
+ writer.writeStartElement("array");
+ if (!isStringProperty(serviceProperty)) {
+ writer.writeAttribute("value-type", serviceProperty.type().getName());
+ }
+ for (String value : serviceProperty.values()) {
+ writer.writeStartElement("value");
+ writer.writeCharacters(value);
+ writer.writeEndElement();
+ }
+ writer.writeEndElement();
+ }
+}
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler?rev=1810198&r1=1810197&r2=1810198&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler Sat Sep 30 12:22:15 2017
@@ -19,4 +19,5 @@ org.apache.aries.blueprint.plugin.handle
org.apache.aries.blueprint.plugin.handlers.javax.CdiTransactionFactory
org.apache.aries.blueprint.plugin.handlers.blueprint.config.ConfigAnnotationHandler
org.apache.aries.blueprint.plugin.handlers.blueprint.referencelistener.ReferenceListenerHandler
-org.apache.aries.blueprint.plugin.handlers.blueprint.bean.BeanHandler
\ No newline at end of file
+org.apache.aries.blueprint.plugin.handlers.blueprint.bean.BeanHandler
+org.apache.aries.blueprint.plugin.handlers.blueprint.service.ServiceHandler
\ No newline at end of file
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java?rev=1810198&r1=1810197&r2=1810198&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java Sat Sep 30 12:22:15 2017
@@ -36,6 +36,8 @@ import org.apache.aries.blueprint.plugin
import org.apache.aries.blueprint.plugin.test.reference.Ref3;
import org.apache.aries.blueprint.plugin.test.reference.Ref4;
import org.apache.aries.blueprint.plugin.test.referencelistener.ReferenceListenerToProduceWithoutAnnotation;
+import org.apache.aries.blueprint.plugin.test.service.Service1;
+import org.apache.aries.blueprint.plugin.test.service.Service2;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.xbean.finder.ClassFinder;
import org.junit.BeforeClass;
@@ -1055,6 +1057,166 @@ public class BlueprintFileWriterTest {
assertXpathEquals(ref1ForCons, "@timeout", "1000");
}
+ @Test
+ public void shouldGenerateSimplestServiceFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("simplestService");
+ assertXpathEquals(service, "@auto-export", "interfaces");
+ assertXpathDoesNotExist(service, "service-properties");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithAllClassesFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("serviceWithAllClasses");
+ assertXpathEquals(service, "@auto-export", "all-classes");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithClassHierarchyFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("serviceWithClassHierarchy");
+ assertXpathEquals(service, "@auto-export", "class-hierarchy");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithOneInterfaceFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("serviceWithOneInterface");
+ assertXpathEquals(service, "count(@auto-export)", "0");
+ assertXpathEquals(service, "count(interfaces)", "0");
+ assertXpathEquals(service, "@interface", Service1.class.getName());
+ }
+
+ @Test
+ public void shouldGenerateServiceWithManyInterfacesFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("serviceWithManyInterfaces");
+ assertXpathEquals(service, "count(@auto-export)", "0");
+ assertXpathEquals(service, "count(@interface)", "0");
+ assertXpathEquals(service, "count(interfaces/value)", "2");
+ assertXpathEquals(service, "interfaces/value[1]", Service1.class.getName());
+ assertXpathEquals(service, "interfaces/value[2]", Service2.class.getName());
+ }
+
+ @Test
+ public void shouldGenerateServiceWithRankingFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("serviceWithRankingParameter");
+ assertXpathEquals(service, "@ranking", "1000");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithRankingAndPropertyFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("serviceWithRankingAndProperty");
+ assertXpathEquals(service, "@ranking", "2");
+ assertXpathDoesNotExist(service, "service-properties");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithPropertiesFromBean() throws XPathExpressionException {
+ Node service = getServiceByRef("serviceWithProperties");
+ assertXpathEquals(service, "count(service-properties/entry)", "4");
+ assertXpathEquals(service, "service-properties/entry[@key='oneValue']/@value", "test");
+ assertXpathEquals(service, "count(service-properties/entry[@key='oneValue']/value)", "0");
+
+ assertXpathEquals(service, "count(service-properties/entry[@key='intValue']/@value)", "0");
+ assertXpathEquals(service, "service-properties/entry[@key='intValue']/value/@type", Integer.class.getName());
+ assertXpathEquals(service, "service-properties/entry[@key='intValue']/value/text()", "1");
+
+ assertXpathEquals(service, "count(service-properties/entry[@key='longArray']/@value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='longArray']/value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='longArray']/array/value)", "3");
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/@value-type", Long.class.getName());
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/value[1]", "1");
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/value[2]", "2");
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/value[3]", "3");
+
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/@value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/array/value)", "2");
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/array/@value-type)", "0");
+ assertXpathEquals(service, "service-properties/entry[@key='stringArray']/array/value[1]", "a");
+ assertXpathEquals(service, "service-properties/entry[@key='stringArray']/array/value[2]", "b");
+ }
+
+ @Test
+ public void shouldGenerateSimplestServiceFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedSimplestService");
+ assertXpathEquals(service, "@auto-export", "interfaces");
+ assertXpathDoesNotExist(service, "service-properties");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithAllClassesFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedServiceWithAllClasses");
+ assertXpathEquals(service, "@auto-export", "all-classes");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithClassHierarchyFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedServiceWithClassHierarchy");
+ assertXpathEquals(service, "@auto-export", "class-hierarchy");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithOneInterfaceFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedServiceWithOneInterface");
+ assertXpathEquals(service, "count(@auto-export)", "0");
+ assertXpathEquals(service, "count(interfaces)", "0");
+ assertXpathEquals(service, "@interface", Service2.class.getName());
+ }
+
+ @Test
+ public void shouldGenerateServiceWithManyInterfacesFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedServiceWithManyInterfaces");
+ assertXpathEquals(service, "count(@auto-export)", "0");
+ assertXpathEquals(service, "count(@interface)", "0");
+ assertXpathEquals(service, "count(interfaces/value)", "2");
+ assertXpathEquals(service, "interfaces/value[1]", Service1.class.getName());
+ assertXpathEquals(service, "interfaces/value[2]", Service2.class.getName());
+ }
+
+ @Test
+ public void shouldGenerateServiceWithRankingFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedServiceWithRanking");
+ assertXpathEquals(service, "@ranking", "200");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithRankingAndPropertyFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedServiceWithRankingAndProperies");
+ assertXpathEquals(service, "@ranking", "-9");
+ assertXpathEquals(service, "count(service-properties/entry)", "1");
+ assertXpathEquals(service, "service-properties/entry[@key='a']/@value", "1");
+ }
+
+ @Test
+ public void shouldGenerateServiceWithPropertiesFromFactory() throws XPathExpressionException {
+ Node service = getServiceByRef("producedServiceWithProperies");
+ assertXpathEquals(service, "count(service-properties/entry)", "5");
+ assertXpathEquals(service, "service-properties/entry[@key='oneValue']/@value", "test");
+ assertXpathEquals(service, "count(service-properties/entry[@key='oneValue']/value)", "0");
+
+ assertXpathEquals(service, "count(service-properties/entry[@key='intValue']/@value)", "0");
+ assertXpathEquals(service, "service-properties/entry[@key='intValue']/value/@type", Integer.class.getName());
+ assertXpathEquals(service, "service-properties/entry[@key='intValue']/value/text()", "1");
+
+ assertXpathEquals(service, "count(service-properties/entry[@key='longArray']/@value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='longArray']/value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='longArray']/array/value)", "3");
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/@value-type", Long.class.getName());
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/value[1]", "1");
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/value[2]", "2");
+ assertXpathEquals(service, "service-properties/entry[@key='longArray']/array/value[3]", "3");
+
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/@value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/value)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/array/value)", "2");
+ assertXpathEquals(service, "count(service-properties/entry[@key='stringArray']/array/@value-type)", "0");
+ assertXpathEquals(service, "service-properties/entry[@key='stringArray']/array/value[1]", "a");
+ assertXpathEquals(service, "service-properties/entry[@key='stringArray']/array/value[2]", "b");
+
+ assertXpathEquals(service, "count(@ranking)", "0");
+ assertXpathEquals(service, "count(service-properties/entry[@key='service.ranking']/@value)", "0");
+ assertXpathEquals(service, "service-properties/entry[@key='service.ranking']/value/@type", Integer.class.getName());
+ assertXpathEquals(service, "service-properties/entry[@key='service.ranking']/value/text()", "5");
+ }
+
private void assertXpathDoesNotExist(Node node, String xpathExpression) throws XPathExpressionException {
assertXpathEquals(node, "count(" + xpathExpression + ")", "0");
}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service1.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service1.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service1.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service1.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,22 @@
+/**
+ * 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.service;
+
+public interface Service1 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service2.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service2.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service2.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/Service2.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,22 @@
+/**
+ * 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.service;
+
+public interface Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceProducer.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceProducer.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceProducer.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceProducer.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,88 @@
+/**
+ * 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.test.service;
+
+import org.apache.aries.blueprint.annotation.bean.Bean;
+import org.apache.aries.blueprint.annotation.service.AutoExport;
+import org.apache.aries.blueprint.annotation.service.Service;
+import org.apache.aries.blueprint.annotation.service.ServiceProperty;
+
+import javax.inject.Singleton;
+
+@Singleton
+public class ServiceProducer implements Service1, Service2 {
+
+ @Service
+ @Bean(id = "producedSimplestService")
+ public Service1 simplestServiceProduced() {
+ return null;
+ }
+
+ @Service(ranking = 200)
+ @Bean(id = "producedServiceWithRanking")
+ public Service1 serviceWithRanking() {
+ return null;
+ }
+
+ @Service(autoExport = AutoExport.ALL_CLASSES)
+ @Bean(id = "producedServiceWithAllClasses")
+ public Service1 serviceWithAllClasses() {
+ return null;
+ }
+
+ @Service(autoExport = AutoExport.CLASS_HIERARCHY)
+ @Bean(id = "producedServiceWithClassHierarchy")
+ public Service1 serviceWithClassHierarchy() {
+ return null;
+ }
+
+ @Service(classes = {Service1.class, Service2.class})
+ @Bean(id = "producedServiceWithManyInterfaces")
+ public Service1 serviceWithManyInterfaces() {
+ return null;
+ }
+
+ @Service(classes = Service2.class)
+ @Bean(id = "producedServiceWithOneInterface")
+ public Service2 serviceWithOneInterface() {
+ return null;
+ }
+
+ @Service(ranking = -9, properties = {
+ @ServiceProperty(name = "service.ranking", values = "-2"),
+ @ServiceProperty(name = "a", values = "1")
+ })
+ @Bean(id = "producedServiceWithRankingAndProperies")
+ public Service2 serviceWithRankingAndProperties() {
+ return null;
+ }
+
+ @Service(properties = {
+ @ServiceProperty(name = "oneValue", values = "test"),
+ @ServiceProperty(name = "intValue", values = "1", type = Integer.class),
+ @ServiceProperty(name = "longArray", values = {"1", "2", "3"}, type = Long.class),
+ @ServiceProperty(name = "emptyArray", values = {}),
+ @ServiceProperty(name = "stringArray", values = {"a", "b"}),
+ @ServiceProperty(name = "service.ranking", values = "5", type = Integer.class),
+ })
+ @Bean(id = "producedServiceWithProperies")
+ public Service2 serviceWithProperties() {
+ return null;
+ }
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithAllClasses.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithAllClasses.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithAllClasses.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithAllClasses.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,29 @@
+/**
+ * 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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.AutoExport;
+import org.apache.aries.blueprint.annotation.service.Service;
+
+import javax.inject.Singleton;
+
+@Service(autoExport = AutoExport.ALL_CLASSES)
+@Singleton
+public class ServiceWithAllClasses implements Service1, Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithClassHierarchy.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithClassHierarchy.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithClassHierarchy.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithClassHierarchy.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,29 @@
+/**
+ * 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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.AutoExport;
+import org.apache.aries.blueprint.annotation.service.Service;
+
+import javax.inject.Singleton;
+
+@Service(autoExport = AutoExport.CLASS_HIERARCHY)
+@Singleton
+public class ServiceWithClassHierarchy implements Service1, Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithManyInterfaces.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithManyInterfaces.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithManyInterfaces.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithManyInterfaces.java Sat Sep 30 12:22:15 2017
@@ -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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.Service;
+
+import javax.inject.Singleton;
+
+@Service(classes = {Service1.class, Service2.class})
+@Singleton
+public class ServiceWithManyInterfaces implements Service1, Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithOneInterface.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithOneInterface.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithOneInterface.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithOneInterface.java Sat Sep 30 12:22:15 2017
@@ -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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.Service;
+
+import javax.inject.Singleton;
+
+@Service(classes = Service1.class)
+@Singleton
+public class ServiceWithOneInterface implements Service1, Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithProperties.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithProperties.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithProperties.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithProperties.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,35 @@
+/**
+ * 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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.Service;
+import org.apache.aries.blueprint.annotation.service.ServiceProperty;
+
+import javax.inject.Singleton;
+
+@Service(properties = {
+ @ServiceProperty(name = "oneValue", values = "test"),
+ @ServiceProperty(name = "intValue", values = "1", type = Integer.class),
+ @ServiceProperty(name = "longArray", values = {"1", "2", "3"}, type = Long.class),
+ @ServiceProperty(name = "emptyArray", values = {}),
+ @ServiceProperty(name = "stringArray", values = {"a", "b"}),
+})
+@Singleton
+public class ServiceWithProperties implements Service1, Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingAndProperty.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingAndProperty.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingAndProperty.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingAndProperty.java Sat Sep 30 12:22:15 2017
@@ -0,0 +1,29 @@
+/**
+ * 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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.Service;
+import org.apache.aries.blueprint.annotation.service.ServiceProperty;
+
+import javax.inject.Singleton;
+
+@Service(ranking = 2, properties = @ServiceProperty(name = "service.ranking", values = "3"))
+@Singleton
+public class ServiceWithRankingAndProperty implements Service1, Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingParameter.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingParameter.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingParameter.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/ServiceWithRankingParameter.java Sat Sep 30 12:22:15 2017
@@ -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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.Service;
+
+import javax.inject.Singleton;
+
+@Service(ranking = 1000)
+@Singleton
+public class ServiceWithRankingParameter implements Service1, Service2 {
+}
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/SimplestService.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/SimplestService.java?rev=1810198&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/SimplestService.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/service/SimplestService.java Sat Sep 30 12:22:15 2017
@@ -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.test.service;
+
+import org.apache.aries.blueprint.annotation.service.Service;
+
+import javax.inject.Singleton;
+
+@Service
+@Singleton
+public class SimplestService implements Service1, Service2 {
+}