• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Introduction
    • How to install bnd
    • Guided Tour
    • Guided Tour Workspace & Projects
    • Concepts
    • Best practices
    • Build
    • Project Setup
    • Generating JARs
    • Versioning
    • Baselining
    • Service Components
    • Metatype
    • Contracts
    • Bundle Annotations
    • Accessor Properties
    • SPI Annotations
    • Resolving Dependencies
    • Launching
    • Startlevels
    • Testing
    • Testing with Launchpad
    • Packaging Applications
    • JPMS Libraries
    • Wrapping Libraries to OSGi Bundles
    • Generating Documentation
    • Commands
    • For Developers
    • Tips for Windows users
    • Tools bound to bnd
    • Reference
    • Headers
    • Instruction Reference
    • Instruction Index
    • Macro Reference
    • Macro Index
    • Plugins
    • External Plugins
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
  • Meta-Persistence ::= ( RESOURCE ( ',' RESOURCE )* )?
    Header

    /**
     * Verify the Meta-Persistence header
     * 
     * @throws Exception
     */
    
    public void verifyMetaPersistence() throws Exception {
    	List<String> list = new ArrayList<String>();
    	String mp = dot.getManifest().getMainAttributes().getValue(META_PERSISTENCE);
    	for (String location : OSGiHeader.parseHeader(mp).keySet()) {
    		String[] parts = location.split("!/");
    
    		Resource resource = dot.getResource(parts[0]);
    		if (resource == null)
    			list.add(location);
    		else {
    			if (parts.length > 1) {
    				Jar jar = new Jar("", resource.openInputStream());
    				try {
    					resource = jar.getResource(parts[1]);
    					if (resource == null)
    						list.add(location);
    				}
    				catch (Exception e) {
    					list.add(location);
    				}
    				finally {
    					jar.close();
    				}
    			}
    		}
    	}
    	if (list.isEmpty())
    		return;
    
    	error(Constants.META_PERSISTENCE + " refers to resources not in the bundle: %s", list).header(Constants.META_PERSISTENCE);
    }
    
    • GitHub