Search in sources :

Example 1 with Blueprint

use of org.apache.aries.blueprint.plugin.model.Blueprint in project aries by apache.

the class GenerateMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    List<String> toScan = getPackagesToScan();
    if (!sourcesChanged()) {
        getLog().info("Skipping blueprint generation because source files were not changed");
        return;
    }
    BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, defaultActivation, customParameters);
    try {
        ClassFinder classFinder = createProjectScopeFinder();
        Set<Class<?>> classes = FilteredClassFinder.findClasses(classFinder, toScan);
        Blueprint blueprint = new Blueprint(blueprintConfiguration, classes);
        writeBlueprintIfNeeded(blueprint);
    } catch (Exception e) {
        throw new MojoExecutionException("Error building commands help", e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Blueprint(org.apache.aries.blueprint.plugin.model.Blueprint) ClassFinder(org.apache.xbean.finder.ClassFinder) MalformedURLException(java.net.MalformedURLException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 2 with Blueprint

use of org.apache.aries.blueprint.plugin.model.Blueprint in project aries by apache.

the class EnableAnnotationTest method writeXML.

private void writeXML(String namespace, String enableAnnotations) throws XMLStreamException, UnsupportedEncodingException, ParserConfigurationException, SAXException, IOException {
    Set<String> namespaces = new HashSet<>(Arrays.asList(NS_JPA, namespace));
    Map<String, String> customParameters = new HashMap<>();
    customParameters.put("transaction.enableAnnotation", enableAnnotations);
    BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null, customParameters);
    Blueprint blueprint = new Blueprint(blueprintConfiguration, beanClasses);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    new BlueprintFileWriter(os).write(blueprint);
    xmlAsBytes = os.toByteArray();
    System.out.println(new String(xmlAsBytes, "UTF-8"));
    document = readToDocument(xmlAsBytes, false);
    xpath = XPathFactory.newInstance().newXPath();
}
Also used : HashMap(java.util.HashMap) Blueprint(org.apache.aries.blueprint.plugin.model.Blueprint) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) HashSet(java.util.HashSet)

Example 3 with Blueprint

use of org.apache.aries.blueprint.plugin.model.Blueprint in project aries by apache.

the class BlueprintFileWriterTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    ClassFinder classFinder = new ClassFinder(BlueprintFileWriterTest.class.getClassLoader());
    long start = System.currentTimeMillis();
    Set<Class<?>> beanClasses = findClasses(classFinder, Arrays.asList(MyBean1.class.getPackage().getName(), ReferenceListenerToProduceWithoutAnnotation.class.getPackage().getName()));
    Set<String> namespaces = new HashSet<>(Arrays.asList(NS_JPA, NS_TX1));
    Map<String, String> customParameters = new HashMap<>();
    customParameters.put("ex.t", "1");
    customParameters.put("example.p1", "v1");
    customParameters.put("example.p2", "v2");
    BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null, customParameters);
    Blueprint blueprint = new Blueprint(blueprintConfiguration, beanClasses);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    new BlueprintFileWriter(os).write(blueprint);
    xmlAsBytes = os.toByteArray();
    System.out.println("Generation took " + (System.currentTimeMillis() - start) + " millis");
    System.out.println(new String(xmlAsBytes, "UTF-8"));
    document = readToDocument(xmlAsBytes, false);
    xpath = XPathFactory.newInstance().newXPath();
}
Also used : HashMap(java.util.HashMap) Blueprint(org.apache.aries.blueprint.plugin.model.Blueprint) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) ReferenceListenerToProduceWithoutAnnotation(org.apache.aries.blueprint.plugin.test.referencelistener.ReferenceListenerToProduceWithoutAnnotation) ClassFinder(org.apache.xbean.finder.ClassFinder) BeforeClass(org.junit.BeforeClass) MyBean1(org.apache.aries.blueprint.plugin.test.MyBean1) HashSet(java.util.HashSet) BeforeClass(org.junit.BeforeClass)

Aggregations

Blueprint (org.apache.aries.blueprint.plugin.model.Blueprint)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)2 ClassFinder (org.apache.xbean.finder.ClassFinder)2 MalformedURLException (java.net.MalformedURLException)1 MyBean1 (org.apache.aries.blueprint.plugin.test.MyBean1)1 ReferenceListenerToProduceWithoutAnnotation (org.apache.aries.blueprint.plugin.test.referencelistener.ReferenceListenerToProduceWithoutAnnotation)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 BeforeClass (org.junit.BeforeClass)1