Package org.apache.felix.dm.annotation.plugin.bnd

Examples of org.apache.felix.dm.annotation.plugin.bnd.DescriptorGenerator


            analyzer = new Analyzer();
            analyzer.setJar(target);
            analyzer.analyze();

            // This helper class will parse classes using the analyzer we just created.
            DescriptorGenerator generator = new DescriptorGenerator(analyzer, new MvnLogger(getLog(), m_log));

            // Start scanning
            if (generator.execute())
            {
                // Some annotations have been parsed.
                // Add the list of generated component descriptors in our
                // special header.
                jar = analyzer.getJar();
                jar.getManifest().getMainAttributes()
                    .putValue( "DependencyManager-Component", generator.getDescriptorPaths() );

                // Add generated descriptors into the target bundle (we'll use a
                // temp file).
                Map<String, Resource> resources = generator.getDescriptors();
                for (Map.Entry<String, Resource> entry : resources.entrySet())
                {
                    addResource(entry.getKey(), entry.getValue().openInputStream());
                    jar.putResource(entry.getKey(), entry.getValue());
                }

                Resource metaType = generator.getMetaTypeResource();
                if (metaType != null)
                {
                    addResource("OSGI-INF/metatype/metatype.xml", metaType.openInputStream());
                    jar.putResource("OSGI-INF/metatype/metatype.xml", metaType);
                }

                // Possibly set the Import-Service/Export-Service header
                if (m_buildImportExportService)
                {
                    // Don't override Import-Service header, if it is found from
                    // the bnd directives.
                    if (jar.getManifest().getMainAttributes().getValue(IMPORT_SERVICE) == null)
                    {
                        buildImportExportService(jar, IMPORT_SERVICE, generator.getImportService());
                    }

                    // Don't override Export-Service header, if already defined
                    if (jar.getManifest().getMainAttributes().getValue(EXPORT_SERVICE) == null)
                    {
                        buildImportExportService(jar, EXPORT_SERVICE, generator.getExportService());
                    }
                }

                copy(jar, target);
            }
View Full Code Here

TOP

Related Classes of org.apache.felix.dm.annotation.plugin.bnd.DescriptorGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.