Search in sources :

Example 1 with CacheableMetadataProvider

use of org.apache.felix.ipojo.manipulator.metadata.CacheableMetadataProvider in project felix by apache.

the class PojoizationPlugin method analyzeJar.

public boolean analyzeJar(Analyzer analyzer) throws Exception {
    long start = System.currentTimeMillis();
    // Wraps the Bnd Reporter
    BndReporter reporter = new BndReporter(this.m_reporter);
    // Build ResourceStore
    BndJarResourceStore store = new BndJarResourceStore(analyzer, this.m_reporter);
    store.setIncludeEmbedComponents(m_includeEmbedBundles);
    CompositeMetadataProvider provider = buildMetadataProvider(analyzer, reporter, store);
    // Quick exit
    CacheableMetadataProvider cache = new CacheableMetadataProvider(provider);
    if (cache.getMetadatas().isEmpty() && !hasEmbedComponents(analyzer)) {
        return false;
    }
    // Compute the classpath to build the classloader.
    List<Jar> jars = analyzer.getClasspath();
    Jar jar = analyzer.getJar();
    Set<String> paths = new LinkedHashSet<String>();
    if (jar != null && jar.getSource() != null) {
        paths.add(jar.getSource().getAbsolutePath());
    }
    for (Jar j : jars) {
        if (j.getSource() != null) {
            paths.add(j.getSource().getAbsolutePath());
        }
    }
    Classpath cp = new Classpath(paths);
    manipulateComponents(reporter, store, cache, cp.createClassLoader());
    int nbComponents = findElements(cache.getMetadatas(), "component").size();
    int nbHandlers = findElements(cache.getMetadatas(), "handler").size();
    this.m_reporter.trace("iPOJO manipulation performed performed in %s ms (%d components, %d handlers).", (System.currentTimeMillis() - start), nbComponents, nbHandlers);
    // Return true if a new run should be performed after the analyze
    return false;
}
Also used : Classpath(org.apache.felix.ipojo.manipulator.util.Classpath) CompositeMetadataProvider(org.apache.felix.ipojo.manipulator.metadata.CompositeMetadataProvider) Jar(aQute.bnd.osgi.Jar) CacheableMetadataProvider(org.apache.felix.ipojo.manipulator.metadata.CacheableMetadataProvider)

Aggregations

Jar (aQute.bnd.osgi.Jar)1 CacheableMetadataProvider (org.apache.felix.ipojo.manipulator.metadata.CacheableMetadataProvider)1 CompositeMetadataProvider (org.apache.felix.ipojo.manipulator.metadata.CompositeMetadataProvider)1 Classpath (org.apache.felix.ipojo.manipulator.util.Classpath)1