public interface Function
The function service is registered in the service registry with these service properties:
SERVICE_UID- mandatory service property. The property value contains the function unique identifier.
SERVICE_DEVICE_UID- optional service property. The property value is the Functional Device identifiers. The function belongs to those devices.
SERVICE_REFERENCE_UIDS- optional service property. The property value contains the reference function unique identifiers.
SERVICE_TYPE- mandatory service property. The property value is the function type.
SERVICE_VERSION- optional service property. The property value contains the function version.
SERVICE_DESCRIPTION- optional service property. The property value is the function description.
SERVICE_OPERATION_NAMES- optional service property. The property is missing when there are no function operations and property must be set when there are function operations. The property value is the function operation names.
SERVICE_PROPERTY_NAMES- optional service property. The property is missing when there are no function properties and property must be set when there are function properties. The property value is the function property names.
On start up, the
Function services are registered before the
Device services. It's possible that
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
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
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
To simplify the generic function discovery, the
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:
FunctionDatasubclass, if there are no equal types.
BigDecimalvalue for a
dataproperty. Valid setters are
BigDecimalsuffix for a
dataproperty. The prefix and suffix are using equal types and we cannot have a setter with the values used by
MySecondFunctionData. The only one possible setter is
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:
java.lang.Number. The numerical type must follow these conventions:
valueOfthat returns an instance of the given type and takes a single
Stringargument or a public constructor which takes a single
Stringargument from the previous bullet can be provided by
toString()method of the instance.
Beans, but the beans properties must use those rules. Java Beans are defined in JavaBeans specification.
java.util.Maps. The keys can be
java.lang.String. The values of a single type follow these rules.
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:
java.lang.Objectand this interface methods.
|Modifier and Type||Field and Description|
The service property value contains the function description.
The service property value contains the device unique identifier.
The service property value contains the function operation names.
The service property value contains the function property names.
The service property value contains the reference function unique identifiers.
The service property value contains the function type.
The service property value contains the function unique identifier.
The service property value contains the function version.
|Modifier and Type||Method and Description|
Provides metadata about the function operation.
Provides metadata about the function property.
Returns the current value of the specified property.
Returns an array with all function service property keys.
static final String SERVICE_UID
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
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.
static final String SERVICE_TYPE
Organizations that want to use function types that do not clash with OSGi Alliance defined types should prefix their types in own namespace.
The type doesn't mandate specific function interface. It can be used with different functions.
static final String SERVICE_VERSION
static final String SERVICE_DEVICE_UID
static final String SERVICE_REFERENCE_UIDS
java.lang.String. It can be used to represent different relationships between the functions.
static final String SERVICE_DESCRIPTION
static final String SERVICE_PROPERTY_NAMES
java.lang.String. It's not possible to exist two or more function properties with the same name.
static final String SERVICE_OPERATION_NAMES
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.
PropertyMetadata getPropertyMetadata(String propertyName)
This method must continue to return the property metadata after the function service has been unregistered.
propertyName- The function property name, for which metadata is requested.
nullif the property metadata is not available.
IllegalArgumentException- If the function property with the specified name is not available.
OperationMetadata getOperationMetadata(String operationName)
This method must continue to return the operation metadata after the function service has been unregistered.
operationName- The function operation name, for which metadata is requested.
nullif the operation metadata is not available.
IllegalArgumentException- If the function operation with the specified name is not available.
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.
propKey- The property key.
nullif the property key cannot be mapped to a value.
ServiceReference.getPropertyKeys()for the service reference of this function. The result cannot be
Copyright © OSGi Alliance (2000, 2015). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0