Consumer services.
Service objects registered under the Producer interface are expected to
produce values (internally generated or from external sensors). The value can
be of different types. When delivering a value to a Wire object, the
Producer service should coerce the value to be an instance of one of the
types specified by Wire#getFlavors(). The classes are specified in
order of preference.
When the data represented by the Producer object changes, this object should
send the updated value by calling the update method on each of
Wire objects passed in the most recent call to this object's
consumersConnected(Wire[]) method. These Wire objects will
pass the value on to the associated Consumer service object.
The Producer service may use the information in the Wire object's
properties to schedule the delivery of values to the Wire object.
Producer service objects must register with a service.pid and a
WireConstants#WIREADMIN_PRODUCER_FLAVORS property. It is recommended
that a Producer service object also registers with a
service.description property. Producer service objects must register
with a WireConstants#WIREADMIN_PRODUCER_FILTERS property if the
Producer service will be performing filtering instead of the Wire
object.
If an exception is thrown by a Producer object method, a
WireAdminEvent of type WireAdminEvent#PRODUCER_EXCEPTION is
broadcast by the Wire Admin service.
Security Considerations. Data producing bundles will require
ServicePermission[Producer,REGISTER] to register a Producer service.
In general, only the Wire Admin service should have
ServicePermission[Producer,GET]. Thus only the Wire Admin service may
directly call a Producer service. Care must be taken in the sharing of
Wire objects with other bundles.
Producer services must be registered with scope names when they can send
different types of objects (composite) to the Consumer service. The Producer
service should have WirePermission for each of these scope names.
| Modifier and Type | Method and Description |
|---|---|
| public void | consumersConnected(Wire[]
An array of the current and complete list of wires)Wire
objects to which this Producer service is connected. May be
null if the Producer is not currently connected to any
Wire objects.Update the list of |
| public Object |
| consumersConnected | back to summary |
|---|---|
| public void consumersConnected(Wire[] wires) Update the list of
This method is called when the Producer service is first registered and
subsequently whenever a The Wire Admin service must call this method asynchronously. This implies that implementors of a Producer service can be assured that the callback will not take place during registration when they execute the registration in a synchronized method.
| |
| polled | back to summary |
|---|---|
| public Object polled(Wire wire) Return the current value of this
This method is called by a Note This method may be called by a
If the Producer service returns an
If the | |