blob: e66fc0993e9f986436987d1650af3e96e1dfd461 [file] [log] [blame]
Michael E. Rodriguez86f57b02006-03-29 21:05:08 +00001/*
2 * $Header: /cvshome/build/org.osgi.service.useradmin/src/org/osgi/service/useradmin/UserAdminEvent.java,v 1.7 2006/03/14 01:20:47 hargrave Exp $
3 *
4 * Copyright (c) OSGi Alliance (2001, 2005). 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 */
18package org.osgi.service.useradmin;
19
20import org.osgi.framework.ServiceReference;
21
22/**
23 * <code>Role</code> change event.
24 * <p>
25 * <code>UserAdminEvent</code> objects are delivered asynchronously to any
26 * <code>UserAdminListener</code> objects when a change occurs in any of the
27 * <code>Role</code> objects managed by a User Admin service.
28 *
29 * <p>
30 * A type code is used to identify the event. The following event types are
31 * defined: {@link #ROLE_CREATED}type, {@link #ROLE_CHANGED}type, and
32 * {@link #ROLE_REMOVED}type. Additional event types may be defined in the
33 * future.
34 *
35 * @see UserAdmin
36 * @see UserAdminListener
37 *
38 * @version $Revision: 1.7 $
39 */
40public class UserAdminEvent {
41 private ServiceReference ref;
42 private int type;
43 private Role role;
44 /**
45 * A <code>Role</code> object has been created.
46 *
47 * <p>
48 * The value of <code>ROLE_CREATED</code> is 0x00000001.
49 */
50 public static final int ROLE_CREATED = 0x00000001;
51 /**
52 * A <code>Role</code> object has been modified.
53 *
54 * <p>
55 * The value of <code>ROLE_CHANGED</code> is 0x00000002.
56 */
57 public static final int ROLE_CHANGED = 0x00000002;
58 /**
59 * A <code>Role</code> object has been removed.
60 *
61 * <p>
62 * The value of <code>ROLE_REMOVED</code> is 0x00000004.
63 */
64 public static final int ROLE_REMOVED = 0x00000004;
65
66 /**
67 * Constructs a <code>UserAdminEvent</code> object from the given
68 * <code>ServiceReference</code> object, event type, and <code>Role</code>
69 * object.
70 *
71 * @param ref The <code>ServiceReference</code> object of the User Admin
72 * service that generated this event.
73 * @param type The event type.
74 * @param role The <code>Role</code> object on which this event occurred.
75 */
76 public UserAdminEvent(ServiceReference ref, int type, Role role) {
77 this.ref = ref;
78 this.type = type;
79 this.role = role;
80 }
81
82 /**
83 * Gets the <code>ServiceReference</code> object of the User Admin service
84 * that generated this event.
85 *
86 * @return The User Admin service's <code>ServiceReference</code> object.
87 */
88 public ServiceReference getServiceReference() {
89 return ref;
90 }
91
92 /**
93 * Returns the type of this event.
94 *
95 * <p>
96 * The type values are {@link #ROLE_CREATED}type, {@link #ROLE_CHANGED}
97 * type, and {@link #ROLE_REMOVED}type.
98 *
99 * @return The event type.
100 */
101 public int getType() {
102 return type;
103 }
104
105 /**
106 * Gets the <code>Role</code> object this event was generated for.
107 *
108 * @return The <code>Role</code> object this event was generated for.
109 */
110 public Role getRole() {
111 return role;
112 }
113}