KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > cm > ConfigurationEvent


1 /*
2  * $Header: /cvshome/build/org.osgi.service.cm/src/org/osgi/service/cm/ConfigurationEvent.java,v 1.9 2006/06/16 16:31:28 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2004, 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.cm;
19
20 import org.osgi.framework.ServiceReference;
21
22 /**
23  * A Configuration Event.
24  *
25  * <p>
26  * <code>ConfigurationEvent</code> objects are delivered to all registered
27  * <code>ConfigurationListener</code> service objects. ConfigurationEvents
28  * must be asynchronously delivered in chronological order with respect to each
29  * listener.
30  *
31  * <p>
32  * A type code is used to identify the type of event. The following event types
33  * are defined:
34  * <ul>
35  * <li>{@link #CM_UPDATED}
36  * <li>{@link #CM_DELETED}
37  * </ul>
38  * Additional event types may be defined in the future.
39  *
40  * <p>
41  * Security Considerations. <code>ConfigurationEvent</code> objects do not
42  * provide <code>Configuration</code> objects, so no sensitive configuration
43  * information is available from the event. If the listener wants to locate the
44  * <code>Configuration</code> object for the specified pid, it must use
45  * <code>ConfigurationAdmin</code>.
46  *
47  * @see ConfigurationListener
48  *
49  * @version $Revision: 1.9 $
50  * @since 1.2
51  */

52 public class ConfigurationEvent {
53     /**
54      * A <code>Configuration</code> has been updated.
55      *
56      * <p>
57      * This <code>ConfigurationEvent</code> type that indicates that a
58      * <code>Configuration</code> object has been updated with new properties.
59      *
60      * An event is fired when a call to <code>Configuration.update</code>
61      * successfully changes a configuration.
62      *
63      * <p>
64      * The value of <code>CM_UPDATED</code> is 1.
65      */

66     public static final int CM_UPDATED = 1;
67     /**
68      * A <code>Configuration</code> has been deleted.
69      *
70      * <p>
71      * This <code>ConfigurationEvent</code> type that indicates that a
72      * <code>Configuration</code> object has been deleted.
73      *
74      * An event is fired when a call to <code>Configuration.delete</code>
75      * successfully deletes a configuration.
76      *
77      * <p>
78      * The value of <code>CM_DELETED</code> is 2.
79      */

80     public static final int CM_DELETED = 2;
81     /**
82      * Type of this event.
83      *
84      * @see #getType
85      */

86     private final int type;
87     /**
88      * The factory pid associated with this event.
89      */

90     private final String JavaDoc factoryPid;
91     /**
92      * The pid associated with this event.
93      */

94     private final String JavaDoc pid;
95     /**
96      * The ConfigurationAdmin service which created this event.
97      */

98     private final ServiceReference reference;
99
100     /**
101      * Constructs a <code>ConfigurationEvent</code> object from the given
102      * <code>ServiceReference</code> object, event type, and pids.
103      *
104      * @param reference The <code>ServiceReference</code> object of the
105      * Configuration Admin service that created this event.
106      * @param type The event type. See {@link #getType}.
107      * @param factoryPid The factory pid of the associated configuration if the
108      * target of the configuration is a ManagedServiceFactory. Otherwise
109      * <code>null</code> if the target of the configuration is a
110      * ManagedService.
111      * @param pid The pid of the associated configuration.
112      */

113     public ConfigurationEvent(ServiceReference reference, int type,
114             String JavaDoc factoryPid, String JavaDoc pid) {
115         this.reference = reference;
116         this.type = type;
117         this.factoryPid = factoryPid;
118         this.pid = pid;
119     }
120
121     /**
122      * Returns the factory pid of the associated configuration.
123      *
124      * @return Returns the factory pid of the associated configuration if the
125      * target of the configuration is a ManagedServiceFactory. Otherwise
126      * <code>null</code> if the target of the configuration is a
127      * ManagedService.
128      */

129     public String JavaDoc getFactoryPid() {
130         return factoryPid;
131     }
132
133     /**
134      * Returns the pid of the associated configuration.
135      *
136      * @return Returns the pid of the associated configuration.
137      */

138     public String JavaDoc getPid() {
139         return pid;
140     }
141
142     /**
143      * Return the type of this event.
144      * <p>
145      * The type values are:
146      * <ul>
147      * <li>{@link #CM_UPDATED}
148      * <li>{@link #CM_DELETED}
149      * </ul>
150      *
151      * @return The type of this event.
152      */

153     public int getType() {
154         return type;
155     }
156
157     /**
158      * Return the <code>ServiceReference</code> object of the Configuration
159      * Admin service that created this event.
160      *
161      * @return The <code>ServiceReference</code> object for the Configuration
162      * Admin service that created this event.
163      */

164     public ServiceReference getReference() {
165         return reference;
166     }
167 }
168
Popular Tags