KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > wireadmin > Consumer


1 /*
2  * $Header: /cvshome/build/org.osgi.service.wireadmin/src/org/osgi/service/wireadmin/Consumer.java,v 1.10 2006/07/11 00:54:10 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2002, 2006). All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.osgi.service.wireadmin;
19
20 /**
21  * Data Consumer, a service that can receive udpated values from
22  * {@link Producer} services.
23  *
24  * <p>
25  * Service objects registered under the <code>Consumer</code> interface are
26  * expected to consume values from a Producer service via a <code>Wire</code>
27  * object. A Consumer service may poll the Producer service by calling the
28  * {@link Wire#poll} method. The Consumer service will also receive an updated
29  * value when called at it's {@link #updated} method. The Producer service
30  * should have coerced the value to be an instance of one of the types specified
31  * by the {@link Wire#getFlavors} method, or one of their subclasses.
32  *
33  * <p>
34  * Consumer service objects must register with a <code>service.pid</code> and a
35  * {@link WireConstants#WIREADMIN_CONSUMER_FLAVORS} property. It is recommended
36  * that Consumer service objects also register with a
37  * <code>service.description</code> property.
38  *
39  * <p>
40  * If an <code>Exception</code> is thrown by any of the <code>Consumer</code>
41  * methods, a <code>WireAdminEvent</code> of type
42  * {@link WireAdminEvent#CONSUMER_EXCEPTION} is broadcast by the Wire Admin
43  * service.
44  *
45  * <p>
46  * Security Considerations - Data consuming bundles will require
47  * <code>ServicePermission[Consumer,REGISTER]</code>. In general, only the Wire
48  * Admin service bundle should have this permission. Thus only the Wire Admin
49  * service may directly call a Consumer service. Care must be taken in the
50  * sharing of <code>Wire</code> objects with other bundles.
51  * <p>
52  * Consumer services must be registered with their scope when they can receive
53  * different types of objects from the Producer service. The Consumer service
54  * should have <code>WirePermission</code> for each of these scope names.
55  *
56  * @version $Revision: 1.10 $
57  */

58 public interface Consumer {
59     /**
60      * Update the value. This Consumer service is called by the <code>Wire</code>
61      * object with an updated value from the Producer service.
62      *
63      * <p>
64      * Note: This method may be called by a <code>Wire</code> object prior to this
65      * object being notified that it is connected to that <code>Wire</code> object
66      * (via the {@link #producersConnected} method).
67      * <p>
68      * When the Consumer service can receive <code>Envelope</code> objects, it
69      * must have registered all scope names together with the service object,
70      * and each of those names must be permitted by the bundle's
71      * <code>WirePermission</code>. If an <code>Envelope</code> object is delivered
72      * with the <code>updated</code> method, then the Consumer service should
73      * assume that the security check has been performed.
74      *
75      * @param wire The <code>Wire</code> object which is delivering the updated
76      * value.
77      * @param value The updated value. The value should be an instance of one of
78      * the types specified by the {@link Wire#getFlavors} method.
79      */

80     public void updated(Wire wire, Object JavaDoc value);
81
82     /**
83      * Update the list of <code>Wire</code> objects to which this Consumer service
84      * is connected.
85      *
86      * <p>
87      * This method is called when the Consumer service is first registered and
88      * subsequently whenever a <code>Wire</code> associated with this Consumer
89      * service becomes connected, is modified or becomes disconnected.
90      *
91      * <p>
92      * The Wire Admin service must call this method asynchronously. This implies
93      * that implementors of Consumer can be assured that the callback will not
94      * take place during registration when they execute the registration in a
95      * synchronized method.
96      *
97      * @param wires An array of the current and complete list of <code>Wire</code>
98      * objects to which this Consumer service is connected. May be
99      * <code>null</code> if the Consumer service is not currently connected
100      * to any <code>Wire</code> objects.
101      */

102     public void producersConnected(Wire[] wires);
103 }
104
Popular Tags