org.apache.felix.ipojo.util

## Class ContextSourceManager

- java.lang.Object
- - org.apache.felix.ipojo.util.ContextSourceManager

All Implemented Interfaces:
  ContextListener

    public class ContextSourceManager
    extends java.lang.Object
    implements ContextListener

This class manages context-source management.

Author:
  Felix Project Team

### Field Summary

Fields
`static java.util.List<java.lang.Character>` `FORBIDDEN_CHARACTERS` List of characters forbidden in variable names
`static char` `VARIABLE_END` The variable end
`static java.lang.String` `VARIABLE_START` The variable prefix

### Constructor Summary

Constructors
Constructor and Description
`ContextSourceManager(DependencyModel dependency)` Creates the context source manager.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addContextSource(ContextSource source)` A context source appears.
`static java.util.List<java.lang.String>` `extractVariablesFromFilter(java.lang.String filter)` Extracts the variables (${name}) from the given filter.
`void` `removeContextSource(ContextSource source)` A context source disappears.
`void` `start()` Start the context management.
`void` `stop()` Stop the context management.
`static java.lang.String` `substitute(java.lang.String str, java.util.Dictionary values)` This method substitutes ${var} substring by values stored in a map.
`void` `update(ContextSource source, java.lang.String property, java.lang.Object value)` A context source has modified a monitored property.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### VARIABLE_START

    public static final java.lang.String VARIABLE_START

The variable prefix

See Also:
  Constant Field Values

#### VARIABLE_END

    public static final char VARIABLE_END

The variable end

See Also:
  Constant Field Values

#### FORBIDDEN_CHARACTERS

    public static final java.util.List<java.lang.Character> FORBIDDEN_CHARACTERS

List of characters forbidden in variable names

### Constructor Detail

#### ContextSourceManager

    public ContextSourceManager(DependencyModel dependency)
                         throws org.osgi.framework.InvalidSyntaxException

Creates the context source manager.

Parameters:
  `dependency` - the dependency model on which this manager is plugged.
Throws:
  `org.osgi.framework.InvalidSyntaxException`

### Method Detail

#### substitute

    public static java.lang.String substitute(java.lang.String str,
                                              java.util.Dictionary values)

This method substitutes ${var} substring by values stored in a map.

Parameters:
  `str` - : string with variables
  `values` - : dictionary containing the variable name and the value.
Returns:
  resulted string

#### extractVariablesFromFilter

    public static java.util.List<java.lang.String> extractVariablesFromFilter(java.lang.String filter)
                                                                       throws org.osgi.framework.InvalidSyntaxException

Extracts the variables (${name}) from the given filter.

Parameters:
  `filter` - : string form of the filter.
Returns:
  the list of found properties.
Throws:
  `org.osgi.framework.InvalidSyntaxException` - thrown when the variables are not consistent.

#### start

    public void start()

Start the context management.

#### stop

    public void stop()

Stop the context management.

#### update

    public void update(ContextSource source,
                       java.lang.String property,
                       java.lang.Object value)

A context source has modified a monitored property.

Specified by:
  `update` in interface `ContextListener`
Parameters:
  `source` - : source
  `property` - : modified property
  `value` - : new value.
See Also:
  `ContextListener.update(org.apache.felix.ipojo.ContextSource, String, Object)`

#### addContextSource

    public void addContextSource(ContextSource source)

A context source appears.

Parameters:
  `source` - : new context source.

#### removeContextSource

    public void removeContextSource(ContextSource source)

A context source disappears.

Parameters:
  `source` - : leaving context source.