org.eclipse.gemini.blueprint.extender.support.internal
Class ConfigUtils

java.lang.Object
  extended by org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils

public abstract class ConfigUtils
extends Object

Utility class for dealing with the extender configuration and OSGi bundle manifest headers. Defines Spring/OSGi constants and methods for configuring Spring application context.

Author:
Costin Leau

Field Summary
static String CONFIG_WILDCARD
           
static String CONTEXT_LOCATION_SEPARATOR
           
static String DIRECTIVE_CREATE_ASYNCHRONOUSLY
          Create asynchronously directive.
static boolean DIRECTIVE_CREATE_ASYNCHRONOUSLY_DEFAULT
           
static long DIRECTIVE_NO_TIMEOUT
           
static String DIRECTIVE_PUBLISH_CONTEXT
          Directive for publishing Spring application context as a service.
static boolean DIRECTIVE_PUBLISH_CONTEXT_DEFAULT
           
static String DIRECTIVE_SEPARATOR
          Token used for separating directives inside a header.
static String DIRECTIVE_TIMEOUT
          Directive for indicating wait-for time when satisfying mandatory dependencies defined in seconds
static long DIRECTIVE_TIMEOUT_DEFAULT
           
static String DIRECTIVE_TIMEOUT_VALUE_NONE
           
static String DIRECTIVE_WAIT_FOR_DEPS
          Wait for dependencies or directly start the context.
static boolean DIRECTIVE_WAIT_FOR_DEPS_DEFAULT
          DIRECTIVE_WAIT_FOR_DEPS default.
static String EQUALS
           
static String EXTENDER_VERSION
           
static String SPRING_CONTEXT_HEADER
          Manifest entry name for configuring Spring application context.
 
Constructor Summary
ConfigUtils()
           
 
Method Summary
static boolean getCreateAsync(Dictionary headers)
          Shortcut for finding the boolean value for DIRECTIVE_CREATE_ASYNCHRONOUSLY directive using the given headers.
static String getDirectiveValue(String header, String directive)
          Return the directive value as a String.
static String[] getHeaderLocations(Dictionary headers)
          Returns the location headers (if any) specified by the Spring-Context header (if available).
static String[] getLocationsFromHeader(String header, String defaultValue)
          Similar to getHeaderLocations(Dictionary) but looks at a specified header directly.
static boolean getPublishContext(Dictionary headers)
          Shortcut for finding the boolean value for DIRECTIVE_PUBLISH_CONTEXT directive using the given headers.
static String getSpringContextHeader(Dictionary headers)
          Return the "Spring-Context" if present from the given dictionary.
static long getTimeOut(Dictionary headers)
          Shortcut for finding the boolean value for DIRECTIVE_TIMEOUT directive using the given headers.
static boolean getWaitForDependencies(Dictionary headers)
          Shortcut for finding the boolean value for DIRECTIVE_WAIT_FOR_DEPS directive using the given headers.
static boolean isDirectiveDefined(Dictionary headers, String directiveName)
          Returns true if the given directive is present or false otherwise.
static boolean matchExtenderVersionRange(org.osgi.framework.Bundle bundle, String header, org.osgi.framework.Version versionToMatch)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENDER_VERSION

public static final String EXTENDER_VERSION
See Also:
Constant Field Values

CONFIG_WILDCARD

public static final String CONFIG_WILDCARD
See Also:
Constant Field Values

SPRING_CONTEXT_HEADER

public static final String SPRING_CONTEXT_HEADER
Manifest entry name for configuring Spring application context.

See Also:
Constant Field Values

DIRECTIVE_PUBLISH_CONTEXT

public static final String DIRECTIVE_PUBLISH_CONTEXT
Directive for publishing Spring application context as a service.

See Also:
Constant Field Values

DIRECTIVE_TIMEOUT

public static final String DIRECTIVE_TIMEOUT
Directive for indicating wait-for time when satisfying mandatory dependencies defined in seconds

See Also:
Constant Field Values

DIRECTIVE_TIMEOUT_VALUE_NONE

public static final String DIRECTIVE_TIMEOUT_VALUE_NONE
See Also:
Constant Field Values

DIRECTIVE_CREATE_ASYNCHRONOUSLY

public static final String DIRECTIVE_CREATE_ASYNCHRONOUSLY
Create asynchronously directive.

See Also:
Constant Field Values

DIRECTIVE_WAIT_FOR_DEPS

public static final String DIRECTIVE_WAIT_FOR_DEPS
Wait for dependencies or directly start the context.

See Also:
Constant Field Values

DIRECTIVE_WAIT_FOR_DEPS_DEFAULT

public static final boolean DIRECTIVE_WAIT_FOR_DEPS_DEFAULT
DIRECTIVE_WAIT_FOR_DEPS default.

See Also:
Constant Field Values

EQUALS

public static final String EQUALS
See Also:
Constant Field Values

DIRECTIVE_SEPARATOR

public static final String DIRECTIVE_SEPARATOR
Token used for separating directives inside a header.

See Also:
Constant Field Values

CONTEXT_LOCATION_SEPARATOR

public static final String CONTEXT_LOCATION_SEPARATOR
See Also:
Constant Field Values

DIRECTIVE_PUBLISH_CONTEXT_DEFAULT

public static final boolean DIRECTIVE_PUBLISH_CONTEXT_DEFAULT
See Also:
Constant Field Values

DIRECTIVE_CREATE_ASYNCHRONOUSLY_DEFAULT

public static final boolean DIRECTIVE_CREATE_ASYNCHRONOUSLY_DEFAULT
See Also:
Constant Field Values

DIRECTIVE_TIMEOUT_DEFAULT

public static final long DIRECTIVE_TIMEOUT_DEFAULT
See Also:
Constant Field Values

DIRECTIVE_NO_TIMEOUT

public static final long DIRECTIVE_NO_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

ConfigUtils

public ConfigUtils()
Method Detail

matchExtenderVersionRange

public static boolean matchExtenderVersionRange(org.osgi.framework.Bundle bundle,
                                                String header,
                                                org.osgi.framework.Version versionToMatch)

getSpringContextHeader

public static String getSpringContextHeader(Dictionary headers)
Return the "Spring-Context" if present from the given dictionary.

Parameters:
headers -
Returns:

getDirectiveValue

public static String getDirectiveValue(String header,
                                       String directive)
Return the directive value as a String. If the directive does not exist or is invalid (wrong format) a null string will be returned.

Parameters:
header -
directive -
Returns:

isDirectiveDefined

public static boolean isDirectiveDefined(Dictionary headers,
                                         String directiveName)
Returns true if the given directive is present or false otherwise.

Parameters:
headers -
directiveName -
Returns:

getPublishContext

public static boolean getPublishContext(Dictionary headers)
Shortcut for finding the boolean value for DIRECTIVE_PUBLISH_CONTEXT directive using the given headers. Assumes the headers belong to a Spring powered bundle.

Parameters:
headers -
Returns:

getCreateAsync

public static boolean getCreateAsync(Dictionary headers)
Shortcut for finding the boolean value for DIRECTIVE_CREATE_ASYNCHRONOUSLY directive using the given headers. Assumes the headers belong to a Spring powered bundle.

Parameters:
headers -
Returns:

getTimeOut

public static long getTimeOut(Dictionary headers)
Shortcut for finding the boolean value for DIRECTIVE_TIMEOUT directive using the given headers. Assumes the headers belong to a Spring powered bundle. Returns the timeout (in seconds) for which the application context should wait to have its dependencies satisfied.

Parameters:
headers -
Returns:

getWaitForDependencies

public static boolean getWaitForDependencies(Dictionary headers)
Shortcut for finding the boolean value for DIRECTIVE_WAIT_FOR_DEPS directive using the given headers. Assumes the headers belong to a Spring powered bundle.

Parameters:
headers -
Returns:

getHeaderLocations

public static String[] getHeaderLocations(Dictionary headers)
Returns the location headers (if any) specified by the Spring-Context header (if available). The returned Strings can be sent to a ResourceLoader for loading the configurations.

Parameters:
headers - bundle headers
Returns:
array of locations specified (if any)

getLocationsFromHeader

public static String[] getLocationsFromHeader(String header,
                                              String defaultValue)
Similar to getHeaderLocations(Dictionary) but looks at a specified header directly.

Parameters:
header - header to look at
defaultValue - default locations if none is specified
Returns:


Copyright © 2006-2013. All Rights Reserved.