Interface Consumer
-
public interface ConsumerData Consumer, a service that can receive updated values fromProducerservices.Service objects registered under the
Consumerinterface are expected to consume values from a Producer service via aWireobject. A Consumer service may poll the Producer service by calling theWire.poll()method. The Consumer service will also receive an updated value when called at it'supdated(Wire, Object)method. The Producer service should have coerced the value to be an instance of one of the types specified by theWire.getFlavors()method, or one of their subclasses.Consumer service objects must register with a
service.pidand aWireConstants.WIREADMIN_CONSUMER_FLAVORSproperty. It is recommended that Consumer service objects also register with aservice.descriptionproperty.If an
Exceptionis thrown by any of theConsumermethods, aWireAdminEventof typeWireAdminEvent.CONSUMER_EXCEPTIONis broadcast by the Wire Admin service.Security Considerations - Data consuming bundles will require
ServicePermission[Consumer,REGISTER]. In general, only the Wire Admin service bundle should have this permission. Thus only the Wire Admin service may directly call a Consumer service. Care must be taken in the sharing ofWireobjects with other bundles.Consumer services must be registered with their scope when they can receive different types of objects from the Producer service. The Consumer service should have
WirePermissionfor each of these scope names.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidproducersConnected(Wire[] wires)Update the list ofWireobjects to which this Consumer service is connected.voidupdated(Wire wire, java.lang.Object value)Update the value.
-
-
-
Method Detail
-
updated
void updated(Wire wire, java.lang.Object value)
Update the value. This Consumer service is called by theWireobject with an updated value from the Producer service.Note: This method may be called by a
Wireobject prior to this object being notified that it is connected to thatWireobject (via theproducersConnected(Wire[])method).When the Consumer service can receive
Envelopeobjects, it must have registered all scope names together with the service object, and each of those names must be permitted by the bundle'sWirePermission. If anEnvelopeobject is delivered with theupdatedmethod, then the Consumer service should assume that the security check has been performed.- Parameters:
wire- TheWireobject which is delivering the updated value.value- The updated value. The value should be an instance of one of the types specified by theWire.getFlavors()method.
-
producersConnected
void producersConnected(Wire[] wires)
Update the list ofWireobjects to which this Consumer service is connected.This method is called when the Consumer service is first registered and subsequently whenever a
Wireassociated with this Consumer service becomes connected, is modified or becomes disconnected.The Wire Admin service must call this method asynchronously. This implies that implementors of Consumer 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 Consumer service is connected. May benullif the Consumer service is not currently connected to anyWireobjects.
-
-