summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminEvent.java
blob: 8f4ac717c84e8ad6868a4e993f8d59bfd3477072 (plain)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
 * Copyright (c) OSGi Alliance (2009). 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.remoteserviceadmin;

import org.osgi.framework.Bundle;

/**
 * Provides the event information for a Remote Admin event.
 * 
 * @Immutable
 * @version $Revision$
 */
public class RemoteServiceAdminEvent {
	/**
	 * Add an import registration. The Remote Services Admin will call this
	 * method when it imports a service. When this service is registered, the
	 * Remote Service Admin must notify the listener of all existing Import
	 * Registrations.
	 * 
	 */
	public static final int			IMPORT_REGISTRATION		= 1;

	/**
	 * Add an export registration. The Remote Services Admin will call this
	 * method when it exports a service. When this service is registered, the
	 * Remote Service Admin must notify the listener of all existing Export
	 * Registrations.
	 */
	public static final int			EXPORT_REGISTRATION		= 2;

	/**
	 * Remove an export registration. The Remote Services Admin will call this
	 * method when it removes the export of a service.
	 * 
	 */
	public static final int			EXPORT_UNREGISTRATION	= 3;

	/**
	 * Remove an import registration. The Remote Services Admin will call this
	 * method when it removes the import of a service.
	 * 
	 */
	public static final int			IMPORT_UNREGISTRATION	= 4;

	/**
	 * A fatal importing error occurred. The Import Registration has been
	 * closed.
	 */
	public static final int			IMPORT_ERROR			= 5;

	/**
	 * A fatal exporting error occurred. The Export Registration has been
	 * closed.
	 */
	public static final int			EXPORT_ERROR			= 6;

	/**
	 * A problematic situation occurred, the export is still active.
	 */
	public static final int			EXPORT_WARNING			= 7;
	/**
	 * A problematic situation occurred, the import is still active.
	 */
	public static final int			IMPORT_WARNING			= 8;

	private final ImportReference	importReference;
	private final ExportReference	exportReference;
	private final Throwable			exception;
	private final int				type;
	private final Bundle			source;

	/**
	 * Private constructor.
	 * 
	 * @param type The event type
	 * @param source The source bundle, must not be <code>null</code>.
	 * @param importReference The importReference, can be <code>null</code>.
	 * @param exportReference The exportReference, can be <code>null</code>.
	 * @param exception Any exceptions encountered, can be <code>null</code>
	 */
	private RemoteServiceAdminEvent(int type, Bundle source,
			ImportReference importReference, ExportReference exportReference,
			Throwable exception) {
		if (source == null) {
			throw new NullPointerException("source must not be null");
		}
		this.type = type;
		this.source = source;
		this.importReference = importReference;
		this.exportReference = exportReference;
		this.exception = exception;
	}

	/**
	 * Create a Remote Service Admin Event for an export notification.
	 * 
	 * @param type The event type.
	 * @param source The source bundle, must not be <code>null</code>.
	 * @param exportReference The exportReference, can not be <code>null</code>.
	 * @param exception Any exceptions encountered, can be <code>null</code>.
	 */
	public RemoteServiceAdminEvent(int type, Bundle source,
			ExportReference exportReference, Throwable exception) {
		this(type, source, null, exportReference, exception);
	}

	/**
	 * Create a Remote Service Admin Event for an import notification.
	 * 
	 * @param type The event type.
	 * @param source The source bundle, must not be <code>null</code>.
	 * @param importReference The importReference, can not be <code>null</code>.
	 * @param exception Any exceptions encountered, can be <code>null</code>.
	 */
	public RemoteServiceAdminEvent(int type, Bundle source,
			ImportReference importReference, Throwable exception) {
		this(type, source, importReference, null, exception);
	}

	/**
	 * Return the Import Reference for this event.
	 * 
	 * @return The Import Reference or <code>null</code>.
	 */
	public ImportReference getImportReference() {
		return importReference;
	}

	/**
	 * Return the Export Reference for this event.
	 * 
	 * @return The Export Reference or <code>null</code>.
	 */
	public ExportReference getExportReference() {
		return exportReference;
	}

	/**
	 * Return the exception for this event.
	 * 
	 * @return The exception or <code>null</code>.
	 */
	public Throwable getException() {
		return exception;
	}

	/**
	 * Return the type of this event.
	 * 
	 * @return The type of this event.
	 */
	public int getType() {
		return type;
	}

	/**
	 * Return the bundle source of this event.
	 * 
	 * @return The bundle source of this event.
	 */
	public Bundle getSource() {
		return source;
	}
}