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/01/29 20:24:36 UTC
svn commit: r1780850 - in
/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src:
main/java/org/apache/aries/blueprint/plugin/
main/java/org/apache/aries/blueprint/plugin/handlers/
main/java/org/apache/aries/blueprint/plugin/model/ test/java/org/apac...
Author: alien11689
Date: Sun Jan 29 20:24:36 2017
New Revision: 1780850
URL: http://svn.apache.org/viewvc?rev=1780850&view=rev
Log:
[MAINTENANCE] Remove spring-blueprint dependency and continue cleaning model package
Added:
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java
- copied, changed from r1780849, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegistry.java
- copied, changed from r1780849, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegister.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Registry.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java
- copied, changed from r1780849, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java
Removed:
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegister.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java
Modified:
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/Handlers.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java Sun Jan 29 20:24:36 2017
@@ -18,8 +18,7 @@
*/
package org.apache.aries.blueprint.plugin;
-import org.apache.aries.blueprint.plugin.model.Context;
-import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
+import org.apache.aries.blueprint.plugin.model.Blueprint;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
@@ -45,15 +44,15 @@ class BlueprintFileWriter {
this.os = os;
}
- void generate(Context context) {
- generateXml(context);
+ void write(Blueprint blueprint) {
+ generateXml(blueprint);
printFormatted();
}
- private void generateXml(Context context) {
+ private void generateXml(Blueprint blueprint) {
try {
writer.writeStartDocument();
- context.write(writer);
+ blueprint.write(writer);
writer.writeEndDocument();
writer.close();
} catch (XMLStreamException e) {
@@ -64,7 +63,6 @@ class BlueprintFileWriter {
private void printFormatted() {
try {
TransformerFactory factory = TransformerFactory.newInstance();
-
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java Sun Jan 29 20:24:36 2017
@@ -30,7 +30,7 @@ class FilteredClassFinder {
@SuppressWarnings("unchecked")
static Set<Class<?>> findClasses(ClassFinder finder, Collection<String> packageNames) {
- return findClasses(finder, packageNames, Handlers.beanMarkingAnnotationClasses.toArray(new Class[Handlers.beanMarkingAnnotationClasses.size()]));
+ return findClasses(finder, packageNames, Handlers.BEAN_MARKING_ANNOTATION_CLASSES.toArray(new Class[Handlers.BEAN_MARKING_ANNOTATION_CLASSES.size()]));
}
private static Set<Class<?>> findClasses(ClassFinder finder, Collection<String> packageNames, Class<? extends Annotation>[] annotations) {
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java Sun Jan 29 20:24:36 2017
@@ -18,9 +18,8 @@
*/
package org.apache.aries.blueprint.plugin;
-import org.apache.aries.blueprint.plugin.model.Context;
+import org.apache.aries.blueprint.plugin.model.Blueprint;
import org.apache.aries.blueprint.plugin.spi.Activation;
-import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -48,7 +47,7 @@ import java.util.Set;
/**
* Generates blueprint from CDI annotations
*/
-@Mojo(name = "blueprint-generate", requiresDependencyResolution = ResolutionScope.COMPILE,
+@Mojo(name = "blueprint-write", requiresDependencyResolution = ResolutionScope.COMPILE,
defaultPhase = LifecyclePhase.PROCESS_CLASSES, inheritByDefault = false)
public class GenerateMojo extends AbstractMojo {
@@ -68,13 +67,13 @@ public class GenerateMojo extends Abstra
private BuildContext buildContext;
/**
- * Name of file to generate
+ * Name of file to write
*/
@Parameter(defaultValue = "autowire.xml")
protected String generatedFileName;
/**
- * Base directory to generate into
+ * Base directory to write into
* (relative to ${project.build.directory}/generated-sources/blueprint).
*/
@Parameter(defaultValue = "OSGI-INF/blueprint/")
@@ -109,27 +108,26 @@ public class GenerateMojo extends Abstra
try {
ClassFinder classFinder = createProjectScopeFinder();
Set<Class<?>> classes = FilteredClassFinder.findClasses(classFinder, toScan);
- Context context = new Context(blueprintConfiguration, classes);
- writeBlueprint(blueprintConfiguration, context);
+ Blueprint blueprint = new Blueprint(blueprintConfiguration, classes);
+ writeBlueprintIfNeeded(blueprint);
} catch (Exception e) {
throw new MojoExecutionException("Error building commands help", e);
}
}
- private void writeBlueprint(BlueprintConfigurationImpl blueprintConfiguration, Context context) throws Exception {
- if (context.getBeans().size() > 0) {
- writeBlueprint(context, blueprintConfiguration);
+ private void writeBlueprintIfNeeded(Blueprint blueprint) throws Exception {
+ if (blueprint.shouldBeGenerated()) {
+ writeBlueprint(blueprint);
} else {
getLog().warn("Skipping blueprint generation because beans were not found");
}
}
-
private boolean sourcesChanged() {
return !buildContext.hasDelta(new File(project.getCompileSourceRoots().iterator().next()));
}
- private void writeBlueprint(Context context, BlueprintConfiguration blueprintConfiguration) throws Exception {
+ private void writeBlueprint(Blueprint blueprint) throws Exception {
String generatedBaseDir = ResourceInitializer.generateResourceEntry(project);
File dir = new File(generatedBaseDir, generatedDir);
@@ -138,7 +136,7 @@ public class GenerateMojo extends Abstra
getLog().info("Generating blueprint to " + file);
OutputStream fos = buildContext.newFileOutputStream(file);
- new BlueprintFileWriter(fos).generate(context);
+ new BlueprintFileWriter(fos).write(blueprint);
fos.close();
}
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/Handlers.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/Handlers.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/Handlers.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/Handlers.java Sun Jan 29 20:24:36 2017
@@ -36,65 +36,65 @@ import java.util.List;
import java.util.ServiceLoader;
public class Handlers {
- public static final List<Class<? extends Annotation>> beanMarkingAnnotationClasses = new ArrayList<>();
- public static final List<Class<? extends Annotation>> singletons = new ArrayList<>();
- public static final List<InjectLikeHandler<? extends Annotation>> beanInjectLikeHandlers = new ArrayList<>();
- public static final List<NamedLikeHandler> namedLikeHandlers = new ArrayList<>();
- public static final List<ValueInjectionHandler<? extends Annotation>> valueInjectionHandlers = new ArrayList<>();
- public static final List<BeanAnnotationHandler<? extends Annotation>> BEAN_ANNOTATION_HANDLERs = new ArrayList<>();
- public static final List<CustomDependencyAnnotationHandler<? extends Annotation>> customDependencyAnnotationHandlers = new ArrayList<>();
- public static final List<MethodAnnotationHandler<? extends Annotation>> methodAnnotationHandlers = new ArrayList<>();
- public static final List<FieldAnnotationHandler<? extends Annotation>> fieldAnnotationHandlers = new ArrayList<>();
- public static final List<Class<? extends Annotation>> factoryMethodAnnotationClasses = new ArrayList<>();
- public static final List<Class<? extends Annotation>> qualifingAnnotationClasses = new ArrayList<>();
- public static final List<ContextInitializationHandler> contextInitializationHandlers = new ArrayList<>();
+ public static final List<Class<? extends Annotation>> BEAN_MARKING_ANNOTATION_CLASSES = new ArrayList<>();
+ public static final List<Class<? extends Annotation>> SINGLETONS = new ArrayList<>();
+ public static final List<InjectLikeHandler<? extends Annotation>> BEAN_INJECT_LIKE_HANDLERS = new ArrayList<>();
+ public static final List<NamedLikeHandler> NAMED_LIKE_HANDLERS = new ArrayList<>();
+ public static final List<ValueInjectionHandler<? extends Annotation>> VALUE_INJECTION_HANDLERS = new ArrayList<>();
+ public static final List<BeanAnnotationHandler<? extends Annotation>> BEAN_ANNOTATION_HANDLERS = new ArrayList<>();
+ public static final List<CustomDependencyAnnotationHandler<? extends Annotation>> CUSTOM_DEPENDENCY_ANNOTATION_HANDLERS = new ArrayList<>();
+ public static final List<MethodAnnotationHandler<? extends Annotation>> METHOD_ANNOTATION_HANDLERS = new ArrayList<>();
+ public static final List<FieldAnnotationHandler<? extends Annotation>> FIELD_ANNOTATION_HANDLERS = new ArrayList<>();
+ public static final List<Class<? extends Annotation>> FACTORY_METHOD_ANNOTATION_CLASSES = new ArrayList<>();
+ public static final List<Class<? extends Annotation>> QUALIFING_ANNOTATION_CLASSES = new ArrayList<>();
+ public static final List<ContextInitializationHandler> CONTEXT_INITIALIZATION_HANDLERS = new ArrayList<>();
static {
for (BeanFinder beanFinder : ServiceLoader.load(BeanFinder.class)) {
- beanMarkingAnnotationClasses.add(beanFinder.getAnnotation());
+ BEAN_MARKING_ANNOTATION_CLASSES.add(beanFinder.getAnnotation());
if (beanFinder.isSingleton()) {
- singletons.add(beanFinder.getAnnotation());
+ SINGLETONS.add(beanFinder.getAnnotation());
}
}
for (InjectLikeHandler<? extends Annotation> injectLikeHandler : ServiceLoader.load(InjectLikeHandler.class)) {
- beanInjectLikeHandlers.add(injectLikeHandler);
+ BEAN_INJECT_LIKE_HANDLERS.add(injectLikeHandler);
}
for (NamedLikeHandler namedLikeHandler : ServiceLoader.load(NamedLikeHandler.class)) {
- namedLikeHandlers.add(namedLikeHandler);
+ NAMED_LIKE_HANDLERS.add(namedLikeHandler);
}
for (ValueInjectionHandler<? extends Annotation> valueInjectionHandler : ServiceLoader.load(ValueInjectionHandler.class)) {
- valueInjectionHandlers.add(valueInjectionHandler);
+ VALUE_INJECTION_HANDLERS.add(valueInjectionHandler);
}
for (BeanAnnotationHandler<? extends Annotation> beanAnnotationHandler : ServiceLoader.load(BeanAnnotationHandler.class)) {
- BEAN_ANNOTATION_HANDLERs.add(beanAnnotationHandler);
+ BEAN_ANNOTATION_HANDLERS.add(beanAnnotationHandler);
}
for (CustomDependencyAnnotationHandler<? extends Annotation> customDependencyAnnotationHandler : ServiceLoader.load(CustomDependencyAnnotationHandler.class)) {
- customDependencyAnnotationHandlers.add(customDependencyAnnotationHandler);
+ CUSTOM_DEPENDENCY_ANNOTATION_HANDLERS.add(customDependencyAnnotationHandler);
}
for (MethodAnnotationHandler<? extends Annotation> methodAnnotationHandler : ServiceLoader.load(MethodAnnotationHandler.class)) {
- methodAnnotationHandlers.add(methodAnnotationHandler);
+ METHOD_ANNOTATION_HANDLERS.add(methodAnnotationHandler);
}
for (FieldAnnotationHandler<? extends Annotation> fieldAnnotationHandler : ServiceLoader.load(FieldAnnotationHandler.class)) {
- fieldAnnotationHandlers.add(fieldAnnotationHandler);
+ FIELD_ANNOTATION_HANDLERS.add(fieldAnnotationHandler);
}
for (FactoryMethodFinder<? extends Annotation> factoryMethodFinder : ServiceLoader.load(FactoryMethodFinder.class)) {
- factoryMethodAnnotationClasses.add((Class<? extends Annotation>) factoryMethodFinder.getAnnotation());
+ FACTORY_METHOD_ANNOTATION_CLASSES.add((Class<? extends Annotation>) factoryMethodFinder.getAnnotation());
}
for (QualifingAnnotationFinder<? extends Annotation> qualifingAnnotationFinder : ServiceLoader.load(QualifingAnnotationFinder.class)) {
- qualifingAnnotationClasses.add((Class<? extends Annotation>) qualifingAnnotationFinder.getAnnotation());
+ QUALIFING_ANNOTATION_CLASSES.add((Class<? extends Annotation>) qualifingAnnotationFinder.getAnnotation());
}
for (ContextInitializationHandler contextInitializationHandler : ServiceLoader.load(ContextInitializationHandler.class)) {
- contextInitializationHandlers.add(contextInitializationHandler);
+ CONTEXT_INITIALIZATION_HANDLERS.add(contextInitializationHandler);
}
}
}
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java Sun Jan 29 20:24:36 2017
@@ -32,17 +32,17 @@ class AnnotationHelper {
private static Class<? extends Annotation>[] findInjectDependencyAnnotations() {
List<Class<? extends Annotation>> classes = new ArrayList<>();
- for (InjectLikeHandler<? extends Annotation> injectLikeHandler : Handlers.beanInjectLikeHandlers) {
+ for (InjectLikeHandler<? extends Annotation> injectLikeHandler : Handlers.BEAN_INJECT_LIKE_HANDLERS) {
classes.add(injectLikeHandler.getAnnotation());
}
- for (ValueInjectionHandler<? extends Annotation> valueInjectionHandler : Handlers.valueInjectionHandlers) {
+ for (ValueInjectionHandler<? extends Annotation> valueInjectionHandler : Handlers.VALUE_INJECTION_HANDLERS) {
classes.add(valueInjectionHandler.getAnnotation());
}
return classes.toArray(new Class[classes.size()]);
}
static String findValue(Annotation[] annotations) {
- for (ValueInjectionHandler valueInjectionHandler : Handlers.valueInjectionHandlers) {
+ for (ValueInjectionHandler valueInjectionHandler : Handlers.VALUE_INJECTION_HANDLERS) {
Object annotation = findAnnotation(annotations, valueInjectionHandler.getAnnotation());
if (annotation != null) {
String value = valueInjectionHandler.getValue(annotation);
@@ -55,7 +55,7 @@ class AnnotationHelper {
}
static String findName(Annotation[] annotations) {
- for (NamedLikeHandler namedLikeHandler : Handlers.namedLikeHandlers) {
+ for (NamedLikeHandler namedLikeHandler : Handlers.NAMED_LIKE_HANDLERS) {
Object annotation = findAnnotation(annotations, namedLikeHandler.getAnnotation());
if (annotation != null) {
String value = namedLikeHandler.getName(annotation);
@@ -77,7 +77,7 @@ class AnnotationHelper {
}
static boolean findSingletons(Annotation[] annotations) {
- for (Class<? extends Annotation> singletonAnnotation : Handlers.singletons) {
+ for (Class<? extends Annotation> singletonAnnotation : Handlers.SINGLETONS) {
Object annotation = findAnnotation(annotations, singletonAnnotation);
if (annotation != null) {
return true;
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java Sun Jan 29 20:24:36 2017
@@ -37,26 +37,23 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import static org.apache.aries.blueprint.plugin.model.AnnotationHelper.findName;
import static org.apache.aries.blueprint.plugin.model.AnnotationHelper.findValue;
-public class Bean extends BeanRef implements BeanEnricher {
+class Bean extends BeanRef implements BeanEnricher {
public SortedSet<Property> properties = new TreeSet<>();
public List<Argument> constructorArguments = new ArrayList<>();
public boolean isPrototype;
public final Map<String, String> attributes = new HashMap<>();
- public final Set<BeanRef> refs = new HashSet<>();
public final Map<String, XmlWriter> beanContentWriters = new HashMap<>();
protected final ContextEnricher contextEnricher;
- public Bean(Class<?> clazz, ContextEnricher contextEnricher) {
+ Bean(Class<?> clazz, ContextEnricher contextEnricher) {
super(clazz, BeanRef.getBeanName(clazz));
this.contextEnricher = contextEnricher;
Introspector introspector = new Introspector(clazz);
@@ -72,14 +69,14 @@ public class Bean extends BeanRef implem
handleMethodsAnnotation(introspector);
}
- public void resolve(BlueprintRegister blueprintRegister) {
- resolveArguments(blueprintRegister);
- resolveFields(blueprintRegister);
- resolveMethods(blueprintRegister);
+ void resolve(BlueprintRegistry blueprintRegistry) {
+ resolveArguments(blueprintRegistry);
+ resolveFields(blueprintRegistry);
+ resolveMethods(blueprintRegistry);
}
private void handleMethodsAnnotation(Introspector introspector) {
- for (MethodAnnotationHandler methodAnnotationHandler : Handlers.methodAnnotationHandlers) {
+ for (MethodAnnotationHandler methodAnnotationHandler : Handlers.METHOD_ANNOTATION_HANDLERS) {
List<Method> methods = introspector.methodsWith(methodAnnotationHandler.getAnnotation());
if (methods.size() > 0) {
methodAnnotationHandler.handleMethodAnnotation(clazz, methods, contextEnricher, this);
@@ -88,7 +85,7 @@ public class Bean extends BeanRef implem
}
private void handleFieldsAnnotation(Introspector introspector) {
- for (FieldAnnotationHandler fieldAnnotationHandler : Handlers.fieldAnnotationHandlers) {
+ for (FieldAnnotationHandler fieldAnnotationHandler : Handlers.FIELD_ANNOTATION_HANDLERS) {
List<Field> fields = introspector.fieldsWith(fieldAnnotationHandler.getAnnotation());
if (fields.size() > 0) {
fieldAnnotationHandler.handleFieldAnnotation(clazz, fields, contextEnricher, this);
@@ -97,7 +94,7 @@ public class Bean extends BeanRef implem
}
private void handleCustomBeanAnnotations() {
- for (BeanAnnotationHandler beanAnnotationHandler : Handlers.BEAN_ANNOTATION_HANDLERs) {
+ for (BeanAnnotationHandler beanAnnotationHandler : Handlers.BEAN_ANNOTATION_HANDLERS) {
Object annotation = AnnotationHelper.findAnnotation(clazz.getAnnotations(), beanAnnotationHandler.getAnnotation());
if (annotation != null) {
beanAnnotationHandler.handleBeanAnnotation(clazz, id, contextEnricher, this);
@@ -110,7 +107,7 @@ public class Bean extends BeanRef implem
}
private boolean findSingleton(Class clazz) {
- for (Class<?> singletonAnnotation : Handlers.singletons) {
+ for (Class<?> singletonAnnotation : Handlers.SINGLETONS) {
if (clazz.getAnnotation(singletonAnnotation) != null) {
return true;
}
@@ -119,16 +116,16 @@ public class Bean extends BeanRef implem
}
- private void resolveMethods(BlueprintRegister blueprintRegister) {
+ private void resolveMethods(BlueprintRegistry blueprintRegistry) {
for (Method method : new Introspector(clazz).methodsWith(AnnotationHelper.injectDependencyAnnotations)) {
- Property prop = Property.create(blueprintRegister, method);
+ Property prop = Property.create(blueprintRegistry, method);
if (prop != null) {
properties.add(prop);
}
}
}
- private void resolveFields(BlueprintRegister matcher) {
+ private void resolveFields(BlueprintRegistry matcher) {
for (Field field : new Introspector(clazz).fieldsWith(AnnotationHelper.injectDependencyAnnotations)) {
Property prop = Property.create(matcher, field);
if (prop != null) {
@@ -137,7 +134,7 @@ public class Bean extends BeanRef implem
}
}
- protected void resolveArguments(BlueprintRegister matcher) {
+ protected void resolveArguments(BlueprintRegistry matcher) {
Constructor<?>[] declaredConstructors = clazz.getDeclaredConstructors();
for (Constructor constructor : declaredConstructors) {
if (declaredConstructors.length == 1 || shouldInject(constructor)) {
@@ -148,7 +145,7 @@ public class Bean extends BeanRef implem
}
private boolean shouldInject(AnnotatedElement annotatedElement) {
- for (InjectLikeHandler injectLikeHandler : Handlers.beanInjectLikeHandlers) {
+ for (InjectLikeHandler injectLikeHandler : Handlers.BEAN_INJECT_LIKE_HANDLERS) {
if (annotatedElement.getAnnotation(injectLikeHandler.getAnnotation()) != null) {
return true;
}
@@ -156,16 +153,16 @@ public class Bean extends BeanRef implem
return false;
}
- protected void resolveArguments(BlueprintRegister blueprintRegister, Class[] parameterTypes, Annotation[][] parameterAnnotations) {
+ protected void resolveArguments(BlueprintRegistry blueprintRegistry, Class[] parameterTypes, Annotation[][] parameterAnnotations) {
for (int i = 0; i < parameterTypes.length; ++i) {
Annotation[] annotations = parameterAnnotations[i];
String value = findValue(annotations);
String ref = findName(annotations);
- for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.customDependencyAnnotationHandlers) {
+ for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.CUSTOM_DEPENDENCY_ANNOTATION_HANDLERS) {
Annotation annotation = (Annotation) AnnotationHelper.findAnnotation(annotations, customDependencyAnnotationHandler.getAnnotation());
if (annotation != null) {
- String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(parameterTypes[i], annotation, ref, blueprintRegister);
+ String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(parameterTypes[i], annotation, ref, blueprintRegistry);
if (generatedRef != null) {
ref = generatedRef;
break;
@@ -176,7 +173,7 @@ public class Bean extends BeanRef implem
if (ref == null && value == null) {
BeanRef template = new BeanRef(parameterTypes[i]);
template.setQualifiersFromAnnotations(annotations);
- BeanRef bean = blueprintRegister.getMatching(template);
+ BeanRef bean = blueprintRegistry.getMatching(template);
if (bean != null) {
ref = bean.id;
} else {
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java Sun Jan 29 20:24:36 2017
@@ -46,7 +46,7 @@ class BeanFromFactory extends Bean {
}
private void handleCustomBeanAnnotations() {
- for (BeanAnnotationHandler beanAnnotationHandler : Handlers.BEAN_ANNOTATION_HANDLERs) {
+ for (BeanAnnotationHandler beanAnnotationHandler : Handlers.BEAN_ANNOTATION_HANDLERS) {
Object annotation = AnnotationHelper.findAnnotation(producingMethod.getAnnotations(), beanAnnotationHandler.getAnnotation());
if (annotation != null) {
beanAnnotationHandler.handleBeanAnnotation(producingMethod, id, contextEnricher, this);
@@ -59,7 +59,7 @@ class BeanFromFactory extends Bean {
}
@Override
- protected void resolveArguments(BlueprintRegister matcher) {
+ protected void resolveArguments(BlueprintRegistry matcher) {
resolveArguments(matcher, producingMethod.getParameterTypes(), producingMethod.getParameterAnnotations());
}
}
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java Sun Jan 29 20:24:36 2017
@@ -69,7 +69,7 @@ class BeanRef implements Comparable<Bean
}
private Object isQualifier(Annotation ann) {
- for (Class<? extends Annotation> qualifingAnnotationClass : Handlers.qualifingAnnotationClasses) {
+ for (Class<? extends Annotation> qualifingAnnotationClass : Handlers.QUALIFING_ANNOTATION_CLASSES) {
Object annotation = ann.annotationType().getAnnotation(qualifingAnnotationClass);
if (annotation != null) {
return annotation;
@@ -82,8 +82,8 @@ class BeanRef implements Comparable<Bean
return getBeanName(clazz, clazz);
}
- static String getBeanName(Class<?> clazz, AnnotatedElement annotatedElement) {
- for (NamedLikeHandler namedLikeHandler : Handlers.namedLikeHandlers) {
+ private static String getBeanName(Class<?> clazz, AnnotatedElement annotatedElement) {
+ for (NamedLikeHandler namedLikeHandler : Handlers.NAMED_LIKE_HANDLERS) {
if (annotatedElement.getAnnotation(namedLikeHandler.getAnnotation()) != null) {
String name = namedLikeHandler.getName(clazz, annotatedElement);
if (name != null) {
@@ -95,7 +95,7 @@ class BeanRef implements Comparable<Bean
return getBeanNameFromSimpleName(name);
}
- protected static String getBeanNameFromSimpleName(String name) {
+ private static String getBeanNameFromSimpleName(String name) {
return name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
}
Copied: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java (from r1780849, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java?p2=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java&p1=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java&r1=1780849&r2=1780850&rev=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java Sun Jan 29 20:24:36 2017
@@ -35,19 +35,19 @@ import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
-public class Context implements BlueprintRegister, ContextEnricher, XmlWriter {
+public class Blueprint implements BlueprintRegistry, ContextEnricher, XmlWriter {
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";
- SortedSet<BeanRef> reg = new TreeSet<BeanRef>();
+ private Registry registry = new Registry();
private final Map<String, XmlWriter> blueprintWriters = new HashMap<>();
private final BlueprintConfiguration blueprintConfiguration;
- Context(BlueprintConfiguration blueprintConfiguration, Class<?>... beanClasses) {
+ Blueprint(BlueprintConfiguration blueprintConfiguration, Class<?>... beanClasses) {
this(blueprintConfiguration, Arrays.asList(beanClasses));
}
- public Context(BlueprintConfiguration blueprintConfiguration, Collection<Class<?>> beanClasses) {
+ public Blueprint(BlueprintConfiguration blueprintConfiguration, Collection<Class<?>> beanClasses) {
this.blueprintConfiguration = blueprintConfiguration;
initContext();
addBeans(beanClasses);
@@ -55,7 +55,7 @@ public class Context implements Blueprin
}
private void initContext() {
- for (ContextInitializationHandler contextInitializationHandler : Handlers.contextInitializationHandlers) {
+ for (ContextInitializationHandler contextInitializationHandler : Handlers.CONTEXT_INITIALIZATION_HANDLERS) {
contextInitializationHandler.initContext(this);
}
}
@@ -68,8 +68,7 @@ public class Context implements Blueprin
private void addBean(Class<?> clazz) {
Bean bean = new Bean(clazz, this);
- reg.add(bean);
- reg.addAll(bean.refs);
+ registry.addBean(bean);
addBeansFromFactories(bean);
}
@@ -89,13 +88,13 @@ public class Context implements Blueprin
if (AnnotationHelper.findSingletons(method.getAnnotations())) {
beanFromFactory.setSingleton();
}
- reg.add(beanFromFactory);
+ registry.addBean(beanFromFactory);
}
}
private boolean isFactoryMethod(Method method) {
boolean isFactoryMethod = false;
- for (Class<? extends Annotation> factoryMethodAnnotationClass : Handlers.factoryMethodAnnotationClasses) {
+ for (Class<? extends Annotation> factoryMethodAnnotationClass : Handlers.FACTORY_METHOD_ANNOTATION_CLASSES) {
Annotation annotation = AnnotationHelper.findAnnotation(method.getAnnotations(), factoryMethodAnnotationClass);
if (annotation != null) {
isFactoryMethod = true;
@@ -112,7 +111,7 @@ public class Context implements Blueprin
}
public BeanRef getMatching(BeanRef template) {
- for (BeanRef bean : reg) {
+ for (BeanRef bean : registry.getBeans()) {
if (bean.matches(template)) {
return bean;
}
@@ -120,9 +119,9 @@ public class Context implements Blueprin
return null;
}
- public SortedSet<Bean> getBeans() {
+ SortedSet<Bean> getBeans() {
TreeSet<Bean> beans = new TreeSet<Bean>();
- for (BeanRef ref : reg) {
+ for (BeanRef ref : registry.getBeans()) {
if (ref instanceof Bean) {
beans.add((Bean) ref);
}
@@ -130,13 +129,13 @@ public class Context implements Blueprin
return beans;
}
- public Map<String, XmlWriter> getBlueprintWriters() {
+ Map<String, XmlWriter> getBlueprintWriters() {
return blueprintWriters;
}
@Override
public void addBean(String id, Class<?> clazz) {
- reg.add(new BeanRef(clazz, id));
+ registry.addBean(new BeanRef(clazz, id));
}
@@ -203,4 +202,8 @@ public class Context implements Blueprin
writer.writeAttribute("factory-ref", bean.factoryBean.id);
writer.writeAttribute("factory-method", bean.factoryMethod);
}
+
+ public boolean shouldBeGenerated() {
+ return !getBeans().isEmpty();
+ }
}
Copied: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegistry.java (from r1780849, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegister.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegistry.java?p2=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegistry.java&p1=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegister.java&r1=1780849&r2=1780850&rev=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegister.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintRegistry.java Sun Jan 29 20:24:36 2017
@@ -20,6 +20,6 @@ package org.apache.aries.blueprint.plugi
import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
-public interface BlueprintRegister extends ContextEnricher {
+interface BlueprintRegistry extends ContextEnricher {
BeanRef getMatching(BeanRef template);
}
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java Sun Jan 29 20:24:36 2017
@@ -45,17 +45,17 @@ class Property implements Comparable<Pro
this.isField = isField;
}
- static Property create(BlueprintRegister blueprintRegister, Field field) {
+ static Property create(BlueprintRegistry blueprintRegistry, Field field) {
if (needsInject(field)) {
String value = AnnotationHelper.findValue(field.getAnnotations());
if (value != null) {
return new Property(field.getName(), null, value, true);
}
String ref = getForcedRefName(field);
- for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.customDependencyAnnotationHandlers) {
+ for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.CUSTOM_DEPENDENCY_ANNOTATION_HANDLERS) {
Annotation annotation = (Annotation) AnnotationHelper.findAnnotation(field.getAnnotations(), customDependencyAnnotationHandler.getAnnotation());
if (annotation != null) {
- String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(field, ref, blueprintRegister);
+ String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(field, ref, blueprintRegistry);
if (generatedRef != null) {
ref = generatedRef;
break;
@@ -65,7 +65,7 @@ class Property implements Comparable<Pro
if (ref != null) {
return new Property(field.getName(), ref, null, true);
}
- BeanRef matching = blueprintRegister.getMatching(new BeanRef(field));
+ BeanRef matching = blueprintRegistry.getMatching(new BeanRef(field));
ref = (matching == null) ? getDefaultRefName(field) : matching.id;
return new Property(field.getName(), ref, null, true);
} else {
@@ -74,7 +74,7 @@ class Property implements Comparable<Pro
}
}
- static Property create(BlueprintRegister blueprintRegister, Method method) {
+ static Property create(BlueprintRegistry blueprintRegistry, Method method) {
String propertyName = resolveProperty(method);
if (propertyName == null) {
return null;
@@ -90,10 +90,10 @@ class Property implements Comparable<Pro
if (ref == null) {
ref = findName(method.getParameterAnnotations()[0]);
}
- for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.customDependencyAnnotationHandlers) {
+ for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.CUSTOM_DEPENDENCY_ANNOTATION_HANDLERS) {
Annotation annotation = (Annotation) AnnotationHelper.findAnnotation(method.getAnnotations(), customDependencyAnnotationHandler.getAnnotation());
if (annotation != null) {
- String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(method, ref, blueprintRegister);
+ String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(method, ref, blueprintRegistry);
if (generatedRef != null) {
ref = generatedRef;
break;
@@ -104,10 +104,10 @@ class Property implements Comparable<Pro
return new Property(propertyName, ref, null, false);
}
- for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.customDependencyAnnotationHandlers) {
+ for (CustomDependencyAnnotationHandler customDependencyAnnotationHandler : Handlers.CUSTOM_DEPENDENCY_ANNOTATION_HANDLERS) {
Annotation annotation = (Annotation) AnnotationHelper.findAnnotation(method.getParameterAnnotations()[0], customDependencyAnnotationHandler.getAnnotation());
if (annotation != null) {
- String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(method.getParameterTypes()[0], annotation, ref, blueprintRegister);
+ String generatedRef = customDependencyAnnotationHandler.handleDependencyAnnotation(method.getParameterTypes()[0], annotation, ref, blueprintRegistry);
if (generatedRef != null) {
ref = generatedRef;
break;
@@ -119,7 +119,7 @@ class Property implements Comparable<Pro
}
BeanRef beanRef = new BeanRef(method);
- BeanRef matching = blueprintRegister.getMatching(beanRef);
+ BeanRef matching = blueprintRegistry.getMatching(beanRef);
ref = (matching == null) ? beanRef.id : matching.id;
return new Property(propertyName, ref, null, false);
}
@@ -146,7 +146,7 @@ class Property implements Comparable<Pro
}
private static String getForcedRefName(Field field) {
- for (NamedLikeHandler namedLikeHandler : Handlers.namedLikeHandlers) {
+ for (NamedLikeHandler namedLikeHandler : Handlers.NAMED_LIKE_HANDLERS) {
if (field.getAnnotation(namedLikeHandler.getAnnotation()) != null) {
String name = namedLikeHandler.getName(field.getType(), field);
if (name != null) {
@@ -158,7 +158,7 @@ class Property implements Comparable<Pro
}
private static String getForcedRefName(Method method) {
- for (NamedLikeHandler namedLikeHandler : Handlers.namedLikeHandlers) {
+ for (NamedLikeHandler namedLikeHandler : Handlers.NAMED_LIKE_HANDLERS) {
if (method.getAnnotation(namedLikeHandler.getAnnotation()) != null) {
String name = namedLikeHandler.getName(method.getParameterTypes()[0], method);
if (name != null) {
Added: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Registry.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Registry.java?rev=1780850&view=auto
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Registry.java (added)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Registry.java Sun Jan 29 20:24:36 2017
@@ -0,0 +1,17 @@
+package org.apache.aries.blueprint.plugin.model;
+
+import java.util.Collection;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+class Registry {
+ private SortedSet<BeanRef> reg = new TreeSet<BeanRef>();
+
+ void addBean(BeanRef beanRef) {
+ reg.add(beanRef);
+ }
+
+ Collection<BeanRef> getBeans(){
+ return reg;
+ }
+}
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=1780850&r1=1780849&r2=1780850&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 Sun Jan 29 20:24:36 2017
@@ -19,7 +19,7 @@
package org.apache.aries.blueprint.plugin;
import com.google.common.collect.Sets;
-import org.apache.aries.blueprint.plugin.model.Context;
+import org.apache.aries.blueprint.plugin.model.Blueprint;
import org.apache.aries.blueprint.plugin.model.TransactionalDef;
import org.apache.aries.blueprint.plugin.test.MyBean1;
import org.apache.aries.blueprint.plugin.test.MyProduced;
@@ -85,9 +85,9 @@ public class BlueprintFileWriterTest {
customParameters.put("example.p1", "v1");
customParameters.put("example.p2", "v2");
BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null, customParameters);
- Context context = new Context(blueprintConfiguration, beanClasses);
+ Blueprint blueprint = new Blueprint(blueprintConfiguration, beanClasses);
ByteArrayOutputStream os = new ByteArrayOutputStream();
- new BlueprintFileWriter(os).generate(context);
+ new BlueprintFileWriter(os).write(blueprint);
System.out.println(os.toString("UTF-8"));
xmlAsBytes = os.toByteArray();
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java?rev=1780850&r1=1780849&r2=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java Sun Jan 29 20:24:36 2017
@@ -52,12 +52,12 @@ public class BeanTest {
private final Set<String> namespaces = new HashSet<String>(Arrays.asList(NS_JPA1, NS_TX1));
private final BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null, null);
- private final Context context = new Context(blueprintConfiguration);
+ private final Blueprint blueprint = new Blueprint(blueprintConfiguration);
@Test
public void testParseMyBean1() {
- Bean bean = new Bean(MyBean1.class, context);
- bean.resolve(context);
+ Bean bean = new Bean(MyBean1.class, blueprint);
+ bean.resolve(blueprint);
assertEquals(MyBean1.class, bean.clazz);
assertEquals("myBean1", bean.id); // Name derived from class name
assertEquals(2, getPersistenceFields(bean).size());
@@ -80,8 +80,8 @@ public class BeanTest {
@Test
public void testParseMyBean3() {
- Bean bean = new Bean(MyBean3.class, context);
- bean.resolve(context);
+ Bean bean = new Bean(MyBean3.class, blueprint);
+ bean.resolve(blueprint);
assertEquals(MyBean3.class, bean.clazz);
assertEquals("myBean3", bean.id); // Name derived from class name
assertEquals("There should be no persistence fields", 0, getPersistenceFields(bean).size());
@@ -100,8 +100,8 @@ public class BeanTest {
@Test
public void testParseNamedBean() {
- Bean bean = new Bean(ServiceAImpl1.class, context);
- bean.resolve(context);
+ Bean bean = new Bean(ServiceAImpl1.class, blueprint);
+ bean.resolve(blueprint);
String definedName = ServiceAImpl1.class.getAnnotation(Named.class).value();
assertEquals("my1", definedName);
assertEquals("Name should be defined using @Named", definedName, bean.id);
@@ -113,8 +113,8 @@ public class BeanTest {
@Test
public void testBlueprintBundleContext() {
- Bean bean = new Bean(MyBean4.class, context);
- bean.resolve(context);
+ Bean bean = new Bean(MyBean4.class, blueprint);
+ bean.resolve(blueprint);
Property bcProp = bean.properties.iterator().next();
assertEquals("bundleContext", bcProp.name);
assertEquals("blueprintBundleContext", bcProp.ref);
@@ -149,43 +149,43 @@ public class BeanTest {
@Test(expected = IllegalArgumentException.class)
public void testMultipleInitMethods() {
- new Bean(BadBean1.class, context);
+ new Bean(BadBean1.class, blueprint);
}
@Test(expected = IllegalArgumentException.class)
public void testMultipleDestroyMethods() {
- new Bean(BadBean2.class, context);
+ new Bean(BadBean2.class, blueprint);
}
@Test(expected = UnsupportedOperationException.class)
public void testSpringNestedTransactionNotSupported() {
- new Bean(BadBean3.class, context);
+ new Bean(BadBean3.class, blueprint);
}
@Test(expected = UnsupportedOperationException.class)
public void testBadFieldBean1() {
- new Context(blueprintConfiguration, BadFieldBean1.class);
+ new Blueprint(blueprintConfiguration, BadFieldBean1.class);
}
@Test(expected = UnsupportedOperationException.class)
public void testBadFieldBean2() {
- new Context(blueprintConfiguration, BadFieldBean2.class);
+ new Blueprint(blueprintConfiguration, BadFieldBean2.class);
}
@Test(expected = UnsupportedOperationException.class)
public void testBadFieldBean3() {
- new Context(blueprintConfiguration, BadFieldBean3.class);
+ new Blueprint(blueprintConfiguration, BadFieldBean3.class);
}
@Test
public void testFieldBean4() {
- new Context(blueprintConfiguration, FieldBean4.class);
+ new Blueprint(blueprintConfiguration, FieldBean4.class);
}
@Test
public void testParseBeanWithConstructorInject() {
- Bean bean = new Bean(MyBean5.class, context);
- bean.resolve(context);
+ Bean bean = new Bean(MyBean5.class, blueprint);
+ bean.resolve(blueprint);
assertEquals(MyBean5.class, bean.clazz);
assertEquals("myBean5", bean.id); // Name derived from class name
assertTrue("There should be no persistenceUnit", getPersistenceFields(bean).isEmpty());
@@ -203,8 +203,8 @@ public class BeanTest {
@Test
public void testParseBeanWithConfig() {
- Bean bean = new Bean(BeanWithConfig.class, context);
- bean.resolve(context);
+ Bean bean = new Bean(BeanWithConfig.class, blueprint);
+ bean.resolve(blueprint);
assertEquals("There should be a property", 1, bean.properties.size());
Property prop = bean.properties.iterator().next();
assertEquals("title", prop.name);
Copied: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java (from r1780849, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java?p2=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java&p1=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java&r1=1780849&r2=1780850&rev=1780850&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java (original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java Sun Jan 29 20:24:36 2017
@@ -36,7 +36,7 @@ import java.util.Set;
import static org.junit.Assert.assertEquals;
-public class ContextTest {
+public class BlueprintTest {
private static final String NS_JPA1 = "http://aries.apache.org/xmlns/jpa/v1.0.0";
private static final String NS_TX1 = "http://aries.apache.org/xmlns/transactions/v1.0.0";
@@ -45,20 +45,20 @@ public class ContextTest {
@Test
public void testLists() {
- Context context = new Context(blueprintConfiguration, MyBean3.class);
- Assert.assertEquals(1, context.getBeans().size());
- Assert.assertEquals(0, getOsgiServices(context).size());
+ Blueprint blueprint = new Blueprint(blueprintConfiguration, MyBean3.class);
+ Assert.assertEquals(1, blueprint.getBeans().size());
+ Assert.assertEquals(0, getOsgiServices(blueprint).size());
}
@Test
public void testLists2() {
- Context context = new Context(blueprintConfiguration, ServiceReferences.class);
- Assert.assertEquals(1, context.getBeans().size());
- Assert.assertEquals(3, getOsgiServices(context).size());
+ Blueprint blueprint = new Blueprint(blueprintConfiguration, ServiceReferences.class);
+ Assert.assertEquals(1, blueprint.getBeans().size());
+ Assert.assertEquals(3, getOsgiServices(blueprint).size());
}
- private Set<String> getOsgiServices(Context context) {
- Set<String> blueprintWritersKeys = context.getBlueprintWriters().keySet();
+ private Set<String> getOsgiServices(Blueprint blueprint) {
+ Set<String> blueprintWritersKeys = blueprint.getBlueprintWriters().keySet();
Set<String> osgiServices = new HashSet<>();
for (String blueprintWritersKey : blueprintWritersKeys) {
if (blueprintWritersKey.startsWith("osgiService/")) {
@@ -69,8 +69,8 @@ public class ContextTest {
}
private void assertSpecialRef(String expectedId, Class<?> clazz) {
- Context context = new Context(blueprintConfiguration);
- BeanRef ref = context.getMatching(new BeanRef(clazz));
+ Blueprint blueprint = new Blueprint(blueprintConfiguration);
+ BeanRef ref = blueprint.getMatching(new BeanRef(clazz));
assertEquals(expectedId, ref.id);
}
@@ -84,8 +84,8 @@ public class ContextTest {
@Test
public void testProduced() throws NoSuchFieldException, SecurityException {
- Context context = new Context(blueprintConfiguration, MyFactoryBean.class);
- BeanFromFactory matching = (BeanFromFactory) context.getMatching(new BeanRef(MyProduced.class));
+ Blueprint blueprint = new Blueprint(blueprintConfiguration, MyFactoryBean.class);
+ BeanFromFactory matching = (BeanFromFactory) blueprint.getMatching(new BeanRef(MyProduced.class));
Assert.assertEquals(MyProduced.class, matching.clazz);
Assert.assertEquals("myFactoryBean", matching.factoryBean.id);
Assert.assertEquals("create", matching.factoryMethod);