• Intro Headers Instructions Macros
  • Fork me on GitHub
    • Release
    • Introduction
    • How to install bnd
    • Guided Tour
    • Guided Tour Workspace & Projects
    • Concepts
    • Best practices
    • Build
    • Generating JARs
    • Versioning
    • Baselining
    • Service Components
    • Metatype
    • Contracts
    • Manifest Annotations
    • Resolving Dependencies
    • Launching
    • Testing
    • Packaging Applications
    • Wrapping Libraries to OSGi Bundles
    • From the command line
    • For Developers
    • Plugins
    • Tools bound to bnd
    • File Format
    • Header Reference
    • Instruction
    • Instruction Index
    • Macro Reference
    • Command Reference
    • Plugins Reference
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
    Supported by OSGi enRoute
  • -dsannotations SELECTORS

    /**
     * Analyze the class space for any classes that have an OSGi annotation for DS.
     */
    public class DSAnnotations implements AnalyzerPlugin {
    
    	public boolean analyzeJar(Analyzer analyzer) throws Exception {
    		Parameters header = OSGiHeader.parseHeader(analyzer.getProperty(Constants.DSANNOTATIONS));
    		if (header.size() == 0)
    			return false;
    
    		Instructions instructions = new Instructions(header);
    		Collection<Clazz> list = analyzer.getClassspace().values();
    		String sc = analyzer.getProperty(Constants.SERVICE_COMPONENT);
    		List<String> names = new ArrayList<String>();
    		if (sc != null && sc.trim().length() > 0)
    			names.add(sc);
    
    		for (Clazz c: list) {
    			for (Instruction instruction : instructions.keySet()) {
    
    				if (instruction.matches(c.getFQN())) {
    					if (instruction.isNegated())
    						break;
    					ComponentDef definition = AnnotationReader.getDefinition(c, analyzer);
    					if (definition != null) {
    						definition.sortReferences();
    						definition.prepare(analyzer);
    						String name = "OSGI-INF/" + definition.name + ".xml";
    						names.add(name);
    						analyzer.getJar().putResource(name, new TagResource(definition.getTag()));
    					}
    				}
    			}
    		}
    		sc = Processor.append(names.toArray(new String[names.size()]));
    		analyzer.setProperty(Constants.SERVICE_COMPONENT, sc);
    		return false;
    	}
    
    	@Override
    	public String toString() {
    		return "DSAnnotations";
    	}
    }
    
    • Contact
    • Developers
    • More