Interface Producer
-
public interface ProducerData Producer, a service that can generate values to be used byConsumerservices.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
Wireobject, the Producer service should coerce the value to be an instance of one of the types specified byWire.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
updatemethod on each ofWireobjects passed in the most recent call to this object'sconsumersConnected(Wire[])method. TheseWireobjects will pass the value on to the associatedConsumerservice object.The Producer service may use the information in the
Wireobject's properties to schedule the delivery of values to theWireobject.Producer service objects must register with a
service.pidand aWireConstants.WIREADMIN_PRODUCER_FLAVORSproperty. It is recommended that a Producer service object also registers with aservice.descriptionproperty. Producer service objects must register with aWireConstants.WIREADMIN_PRODUCER_FILTERSproperty if the Producer service will be performing filtering instead of theWireobject.If an exception is thrown by a Producer object method, a
WireAdminEventof typeWireAdminEvent.PRODUCER_EXCEPTIONis 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 haveServicePermission[Producer,GET]. Thus only the Wire Admin service may directly call a Producer service. Care must be taken in the sharing ofWireobjects 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
WirePermissionfor each of these scope names.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidconsumersConnected(Wire[] wires)Update the list ofWireobjects to which thisProducerobject is connected.java.lang.Objectpolled(Wire wire)Return the current value of thisProducerobject.
-
-
-
Method Detail
-
polled
java.lang.Object polled(Wire wire)
Return the current value of thisProducerobject.This method is called by a
Wireobject in response to the Consumer service calling theWireobject'spollmethod. The Producer should coerce the value to be an instance of one of the types specified byWire.getFlavors(). The types are specified in order of preference. The returned value should be as new or newer than the last value furnished by this object.Note: This method may be called by a
Wireobject prior to this object being notified that it is connected to thatWireobject (via theconsumersConnected(Wire[])method).If the Producer service returns an
Envelopeobject that has an impermissible scope name, then the Wire object must ignore (or remove) the transfer.If the
Wireobject has a scope set, the return value must be an array ofEnvelopeobjects (Envelope[]). TheWireobject must have removed anyEnvelopeobjects that have a scope name that is not in the Wire object's scope.- Parameters:
wire- TheWireobject which is polling this service.- Returns:
- The current value of the Producer service or
nullif the value cannot be coerced into a compatible type. Or an array ofEnvelopeobjects.
-
consumersConnected
void consumersConnected(Wire[] wires)
Update the list ofWireobjects to which thisProducerobject is connected.This method is called when the Producer service is first registered and subsequently whenever a
Wireassociated with this Producer becomes connected, is modified or becomes disconnected.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.
- Parameters:
wires- An array of the current and complete list ofWireobjects to which this Producer service is connected. May benullif the Producer is not currently connected to anyWireobjects.
-
-