Top Description Fields Methods
org.osgi.service.dal

public Interface Function


Function service provides specific device operations and properties. Each function service must implement this interface. In additional to this interface, the implementation can provide own:

The function service is registered in the service registry with these service properties:

On start up, the Function services are registered before the Device services. It's possible that SERVICE_DEVICE_UID point to missing services at the moment of the registration. The reverse order is used when the services are unregistered. Function services are unregistered last after Device services.

The Function service should be registered only under the function class hierarchy. Other classes can be used if there are no ambiguous representations. For example, an ambiguous representation can be a function registered under two independent function classes like BinarySwitch and Meter. In this example, both functions support the same property state with different meaning. getPropertyMetadata(String propertyName) method cannot determinate which property is requested. It can be BinarySwitch state or Meter state.

To simplify the generic function discovery, the Function interface must be used for the service registration. In this way, the generic applications can easily find all services, which are functions in the service registry. Because of this rule, this registration is not allowed:

context.registerService(MeterV1.class.getName(), this, regProps);

If the implementation would like to mark that there is a function, but no specific function interface exists, the registration can be:

context.registerService(Function.class.getName(), this, regProps);

Note that such functions usually don't have operations and properties.

The function properties must be integrated according to these rules:

The accessor method names must be defined according JavaBeans specification.

The function operations are java methods, which cannot override the property accessor methods. They can have zero or more parameters and zero or one return value.

Operation arguments and function properties are restricted by the same set of rules. The data type can be one of the following types:

The properties metadata is accessible with getPropertyMetadata(String). The operations metadata is accessible with getOperationMetadata(String).

In order to provide common behavior, all functions must follow a set of common rules related to the implementation of their setters, getters, operations and events:

Field Summary

Modifier and TypeField and Description
public static final String
SERVICE_DESCRIPTION

The service property value contains the function description.

public static final String
SERVICE_DEVICE_UID

The service property value contains the device unique identifier.

public static final String
SERVICE_OPERATION_NAMES

The service property value contains the function operation names.

public static final String
SERVICE_PROPERTY_NAMES

The service property value contains the function property names.

public static final String
SERVICE_REFERENCE_UIDS

The service property value contains the reference function unique identifiers.

public static final String
SERVICE_TYPE

The service property value contains the function type.

public static final String
SERVICE_UID

The service property value contains the function unique identifier.

public static final String
SERVICE_VERSION

The service property value contains the function version.

Method Summary

Modifier and TypeMethod and Description
public OperationMetadata

Returns:

The operation metadata for the given operation name. null if the operation metadata is not available.
getOperationMetadata
(String
The function operation name, for which metadata is requested.
operationName
)

Provides metadata about the function operation.

public PropertyMetadata

Returns:

The property metadata for the given property name. null if the property metadata is not available.
getPropertyMetadata
(String
The function property name, for which metadata is requested.
propertyName
)

Provides metadata about the function property.

public Object

Returns:

The property value or null if the property key cannot be mapped to a value.
getServiceProperty
(String
The property key.
propKey
)

Returns the current value of the specified property.

public String[]

Returns:

An array with all function service property keys, cannot be null.
getServicePropertyKeys
()

Returns an array with all function service property keys.

Field Detail

SERVICE_DESCRIPTIONback to summary
public static final String SERVICE_DESCRIPTION

The service property value contains the function description. It's an optional property. The value type is java.lang.String.

SERVICE_DEVICE_UIDback to summary
public static final String SERVICE_DEVICE_UID

The service property value contains the device unique identifier. The function belongs to this device. It's an optional property. The value type is java.lang.String.

SERVICE_OPERATION_NAMESback to summary
public static final String SERVICE_OPERATION_NAMES

The service property value contains the function operation names. It's an optional property. The property is missing when there are no function operations and property must be set when there are function operations. The value type is java.lang.String[]. It's not possible to exist two or more function operations with the same name i.e. the operation overloading is not allowed.

SERVICE_PROPERTY_NAMESback to summary
public static final String SERVICE_PROPERTY_NAMES

The service property value contains the function property names. It's an optional property. The property is missing when there are no function properties and property must be set when there are function properties. The value type is java.lang.String[]. It's not possible to exist two or more function properties with the same name.

SERVICE_REFERENCE_UIDSback to summary
public static final String SERVICE_REFERENCE_UIDS

The service property value contains the reference function unique identifiers. It's an optional property. The value type is java.lang.String[]. It can be used to represent different relationships between the functions.

SERVICE_TYPEback to summary
public static final String SERVICE_TYPE

The service property value contains the function type. It's an optional property. For example, the sensor function can have different types like temperature, pressure, etc. The value type is java.lang.String.

Organizations that want to use function types that do not clash with OSGi Working Group defined types should prefix their types in own namespace.

The type doesn't mandate specific function interface. It can be used with different functions.

SERVICE_UIDback to summary
public static final String SERVICE_UID

The service property value contains the function unique identifier. It's a mandatory property. The value type is java.lang.String. To simplify the unique identifier generation, the property value must follow the rule:

function UID ::= device-id ':' function-id

function UID - function unique identifier

device-id - the value of the Device#SERVICE_UID Device service property

function-id - function identifier in the scope of the device

If the function is not bound to a device, the function unique identifier can be device independent.

SERVICE_VERSIONback to summary
public static final String SERVICE_VERSION

The service property value contains the function version. That version can point to specific implementation version and vary in the different vendor implementations. It's an optional property. The value type is java.lang.String.

Method Detail

getOperationMetadataback to summary
public OperationMetadata getOperationMetadata(String operationName)

Provides metadata about the function operation.

This method must continue to return the operation metadata after the function service has been unregistered.

Parameters
operationName:String

The function operation name, for which metadata is requested.

Returns:OperationMetadata

The operation metadata for the given operation name. null if the operation metadata is not available.

Exceptions
IllegalArgumentException:
If the function operation with the specified name is not available.
getPropertyMetadataback to summary
public PropertyMetadata getPropertyMetadata(String propertyName)

Provides metadata about the function property.

This method must continue to return the property metadata after the function service has been unregistered.

Parameters
propertyName:String

The function property name, for which metadata is requested.

Returns:PropertyMetadata

The property metadata for the given property name. null if the property metadata is not available.

Exceptions
IllegalArgumentException:
If the function property with the specified name is not available.
getServicePropertyback to summary
public Object getServiceProperty(String propKey)

Returns the current value of the specified property. The method will return the same value as ServiceReference.getProperty(String) for the service reference of this function.

This method must continue to return property values after the device function service has been unregistered.

Parameters
propKey:String

The property key.

Returns:Object

The property value or null if the property key cannot be mapped to a value.

getServicePropertyKeysback to summary
public String[] getServicePropertyKeys()

Returns an array with all function service property keys. The method will return the same value as ServiceReference.getPropertyKeys() for the service reference of this function. The result cannot be null .

Returns:String[]

An array with all function service property keys, cannot be null.