Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3750d209c67829eb48f48782a87e1a80b7bc0e52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * Copyright (c) OSGi Alliance (2001, 2015). All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.osgi.service.useradmin;

import org.osgi.framework.ServiceReference;

/**
 * {@code Role} change event.
 * <p>
 * {@code UserAdminEvent} objects are delivered asynchronously to any
 * {@code UserAdminListener} objects when a change occurs in any of the
 * {@code Role} objects managed by a User Admin service.
 * 
 * <p>
 * A type code is used to identify the event. The following event types are
 * defined: {@link #ROLE_CREATED} type, {@link #ROLE_CHANGED} type, and
 * {@link #ROLE_REMOVED} type. Additional event types may be defined in the
 * future.
 * 
 * @see UserAdmin
 * @see UserAdminListener
 * 
 * @author $Id$
 */
public class UserAdminEvent {
	private ServiceReference<UserAdmin>	ref;
	private int					type;
	private Role				role;
	/**
	 * A {@code Role} object has been created.
	 * 
	 * <p>
	 * The value of {@code ROLE_CREATED} is 0x00000001.
	 */
	public static final int		ROLE_CREATED	= 0x00000001;
	/**
	 * A {@code Role} object has been modified.
	 * 
	 * <p>
	 * The value of {@code ROLE_CHANGED} is 0x00000002.
	 */
	public static final int		ROLE_CHANGED	= 0x00000002;
	/**
	 * A {@code Role} object has been removed.
	 * 
	 * <p>
	 * The value of {@code ROLE_REMOVED} is 0x00000004.
	 */
	public static final int		ROLE_REMOVED	= 0x00000004;

	/**
	 * Constructs a {@code UserAdminEvent} object from the given
	 * {@code ServiceReference} object, event type, and {@code Role} object.
	 * 
	 * @param ref The {@code ServiceReference} object of the User Admin service
	 *        that generated this event.
	 * @param type The event type.
	 * @param role The {@code Role} object on which this event occurred.
	 */
	public UserAdminEvent(ServiceReference<UserAdmin> ref, int type, Role role) {
		this.ref = ref;
		this.type = type;
		this.role = role;
	}

	/**
	 * Gets the {@code ServiceReference} object of the User Admin service that
	 * generated this event.
	 * 
	 * @return The User Admin service's {@code ServiceReference} object.
	 */
	public ServiceReference<UserAdmin> getServiceReference() {
		return ref;
	}

	/**
	 * Returns the type of this event.
	 * 
	 * <p>
	 * The type values are {@link #ROLE_CREATED} type, {@link #ROLE_CHANGED}
	 * type, and {@link #ROLE_REMOVED} type.
	 * 
	 * @return The event type.
	 */
	public int getType() {
		return type;
	}

	/**
	 * Gets the {@code Role} object this event was generated for.
	 * 
	 * @return The {@code Role} object this event was generated for.
	 */
	public Role getRole() {
		return role;
	}
}

Back to the top