156 Condition Factory Specification

Version 1.0

156.1 Introduction

Conditions (ADD LINK TO CORE SPEC) can be used, to describe simple or complex runtime states. A Condition In and of itself is nothing more then a standardized way to announce themself to the Framework. The Condition Factory is intended to provide a configurable mechanism to aggregate complex states of your system by checking for the availability or absence of services. It then will provide a predefined Condition other services can track.

156.1.1 Essentials

  • Condition - A requirement somebody needs fulfilled at runtime.

  • Condition Factory - A factory to aggregate complex states of your system and register a Condition if all requirements are fulfilled.

156.1.2 Entities

  • Condition - A Maker Interface used to register a Condition as a Service

  • ConditionFactory - org.osgi.service.cm.ManagedServiceFactory that will register Conditions according to the given configuration

156.2 Operation

The implementation of the ConditionFactory must register a org.osgi.service.cm.ManagedServiceFactory with the service PID osgi.condition.factory. A configuration it might receive via ConfigurationAdmin can contain two lists of target filters. One for filters that MUST find at least one Service each in order to have a Condition registered. The other one represents a List of filters, that MUST NOT find any matching service. The moment all the included and non of the exclude filters match, a Condition is registered with the given identifier and the additional properties. If any of the include Services go away or an excluded Service becomes available, this Condition must be unregistered.

In case no match filters of any kind are given, the a condition will be registered the moment the configuration will be applied.

Table 156.1 Properties

Service Property Type Description

condition.id

String

required

The Constants.CONDITION_ID that will be set to the condition that will be registered if all filters are satisfied.

condtion.properties.*

any

optional

Properties like this will be registered with the condition, if all filters are satisfied. condtion.properties. will be cut away and the key will become the * part.

match.all

String+

optional

The value of this service property is a List of LDAP-style filter expressions. A Condition will be registered if each filter finds at least one matching service.

match.none

String+

optional

The value of this service property is a List of LDAP-style filter expressions. A Condition will be registered if none of the filters finds a matching service.


An example Configuration utilizing the Configurator Specification is listed below

{
    ":configurator:resource-version": 1,
    
    "osgi.condition.factory~test" : {
    	"condition.id" : "resulting.condition.id",
    	"condition.properties.custom.condition.prop" : "my.property",
    	"match.all" : [
    		"(&(objectClass=org.foo.Bar)(my.prop=foo))",
    		"(my.prop=bar)"
    	],
    	"match.none" : [
    		"(&(objectClass=org.foo.Fizz)(my.prop=buzz))"
    	]
    }
	}

156.3 Capabilities

What do we need here? It would make sense to provide a Capability

156.4 Security

Requires ??? to register and get Conditions

Requires permission to use the config Admin?

156.5 org.osgi.service.conditionfactory

Version 1.0

Condition Factory Service Package Version 1.0.

Bundles wishing to use this package must list the package in the Import-Package header of the bundle's manifest. This package has two types of users: the consumers that use the API in this package and the providers that implement the API in this package.

Example import for consumers using the API in this package:

Import-Package: org.osgi.service.conditionfactory; version="[1.0,2.0)"

Example import for providers implementing the API in this package:

Import-Package: org.osgi.service.conditionfactory; version="[1.0,1.1)"

156.5.1 Summary

156.5.2 public class ConditionFactoryConstants

Defines standard names for Condition Factory configurations.

Thread-safe

156.5.2.1 public static final String CONDITION_FACTORY_CONFIGURE_ID = "configure.id"

A condition factory configuration property identifying the condition's unique identifier that will be used to register the condition when all the match filters are satisfied.

CONDITION_FACTORY_MATCH_ALL, CONDITION_FACTORY_MATCH_NONE

156.5.2.2 public static final String CONDITION_FACTORY_MATCH_ALL = "match.all"

A condition factory configuration property identifying a list of target filters for the condition. The condition may be registered when each filter matches at least one service registration. The value of this configuration property must be of type Collection<String>.

156.5.2.3 public static final String CONDITION_FACTORY_MATCH_NONE = "match.none"

A condition factory configuration property identifying a list of target filters for the condition. The condition may not be registered if any of the target filters match at least one service registration. The value of this configuration property must be of type Collection<String>.

156.5.2.4 public static final String CONDITION_FACTORY_PID = "osgi.condition.factory"

The PID for the condition factory. The PID used to configure conditions with the condition factory.

156.5.2.5 public static final String CONDITION_FACTORY_PROPERTIES_PREFIX = "condition.properties."

A condition factory configuration property prefix identifying a service property of the condition. The service property key is the remaining content of the configuration property after the prefix. For example, a configuration that contains osgi.condition.configure.properties.prop1=value1 results in a service property prop1=value1 when the condition is registered.

156.5.2.6 public ConditionFactoryConstants()