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 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:
PropertyMetadata#ACCESS_READABLE access.FunctionData.PropertyMetadata#ACCESS_WRITABLE access.FunctionData.FunctionData
subclass, if there are no equal types.MyFunctionData bean with BigDecimal value for a
data property. Valid setters are setData(MyFunctionData data)
and setData(BigDecimal data).MySecondFunctionData bean with BigDecimal prefix and
BigDecimal suffix for a data property. 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
setData(MySecondFunctionData data).PropertyMetadata#ACCESS_EVENTABLE access.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.String.java.lang.Number.
The numerical type must follow these conventions:
valueOf that
returns an instance of the given type and takes a single String
argument or a public constructor which takes a single String
argument.String argument 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.
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:
java.lang.Object and this interface methods.| Modifier and Type | Field 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. |
| Modifier and Type | Method and Description |
|---|---|
| public OperationMetadata | Returns: The operation metadata for the given operation name.null
if the operation metadata is not available.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.The function property name, for which metadata is
requested. propertyName)Provides metadata about the function property. |
| public Object | Returns: The property value ornull if the property key cannot be
mapped to a value.The property key. propKey)Returns the current value of the specified property. |
| public String[] | Returns: An array with all function service property keys, cannot benull.Returns an array with all function service property keys. |
| SERVICE_DESCRIPTION | back 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 | |
| SERVICE_DEVICE_UID | back 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 | |
| SERVICE_OPERATION_NAMES | back 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 | |
| SERVICE_PROPERTY_NAMES | back 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 | |
| SERVICE_REFERENCE_UIDS | back 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
| |
| SERVICE_TYPE | back 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 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_UID | back 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 function UID ::= device-id ':' function-id function UID - function unique identifier
device-id - the value of the 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_VERSION | back 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
| |
| getOperationMetadata | back 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.
| |
| getPropertyMetadata | back 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.
| |
| getServiceProperty | back to summary |
|---|---|
| public Object getServiceProperty(String propKey) Returns the current value of the specified property. The method will
return the same value as This method must continue to return property values after the device function service has been unregistered. | |
| getServicePropertyKeys | back to summary |
|---|---|
| public String[] getServicePropertyKeys() Returns an array with all function service property keys. The method will
return the same value as
| |