• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • How to install bnd
      • Guided Tour
      • Guided Tour Workspace & Projects
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Introduction
      • Concepts
      • Best practices
    • Build and Development
      • Project Setup
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • gestalt ';' NAME ( ';' NAME (';' ANY )? )?
    Workspace

    provides access to the gestalt properties that describe the environment.

    /**
     * Add a gestalt to all workspaces. The gestalt is a set of parts describing
     * the environment. Each part has a name and optionally attributes. This
     * method adds a gestalt to the VM. Per workspace it is possible to augment
     * this.
     */
    
    public static void addGestalt(String part, Attrs attrs) {
    	Attrs already = overallGestalt.get(part);
    	if (attrs == null)
    		attrs = new Attrs();
    
    	if (already != null) {
    		already.putAll(attrs);
    	} else
    		already = attrs;
    
    	overallGestalt.put(part, already);
    }
    
    /**
     * Get the attrs for a gestalt part
     */
    public Attrs getGestalt(String part) {
    	if (gestalt == null) {
    		gestalt = new Parameters(getProperty(Constants.GESTALT));
    		gestalt.mergeWith(overallGestalt, false);
    	}
    	return gestalt.get(part);
    }
    
    /**
     * The macro to access the gestalt
     * <p>
     * {@code $ gestalt;part[;key[;value]]}}
     */
    
    public String _gestalt(String args[]) {
    	if (args.length >= 2) {
    		Attrs attrs = getGestalt(args[1]);
    		if (attrs == null)
    			return "";
    
    		if (args.length == 2)
    			return args[1];
    
    		String s = attrs.get(args[2]);
    		if (args.length == 3) {
    			if (s == null)
    				s = "";
    			return s;
    		}
    
    		if (args.length == 4) {
    			if (args[3].equals(s))
    				return s;
    			else
    				return "";
    		}
    	}
    	throw new IllegalArgumentException("${gestalt;<part>[;key[;<value>]]} has too many arguments");
    }
    
Search
    • Home