Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ca05b1e97bdd1cfd0684f02830f6a5001e3de874 (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
/*******************************************************************************
 * Copyright (c) 2009, 2017 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.osgi.internal.serviceregistry;

import java.util.Map;
import org.osgi.framework.*;

/**
 * ServiceEvent subtype for MODIFIED_ENDMATCH computation.
 *
 */
class ModifiedServiceEvent extends ServiceEvent {
	private static final long serialVersionUID = -5373850978543026102L;
	private final ServiceEvent modified;
	private final ServiceEvent modifiedEndMatch;
	private final Map<String, Object> previousProperties;

	/**
	 * Create a ServiceEvent containing the service properties prior to modification.
	 * 
	 * @param reference Reference to service with modified properties.
	 * @param previousProperties Service properties prior to modification.
	 */
	ModifiedServiceEvent(ServiceReference<?> reference, Map<String, Object> previousProperties) {
		super(ServiceEvent.MODIFIED, reference);
		this.modified = new ServiceEvent(ServiceEvent.MODIFIED, reference);
		this.modifiedEndMatch = new ServiceEvent(ServiceEvent.MODIFIED_ENDMATCH, reference);
		this.previousProperties = previousProperties;
	}

	/**
	 * Return the service event of type MODIFIED.
	 * 
	 * @return The service event of type MODIFIED.
	 */
	ServiceEvent getModifiedEvent() {
		return modified;
	}

	/**
	 * Return the service event of type MODIFIED_ENDMATCH.
	 * 
	 * @return The service event of type MODIFIED_ENDMATCH.
	 */
	ServiceEvent getModifiedEndMatchEvent() {
		return modifiedEndMatch;
	}

	/**
	 * Return if the specified filter matches the previous service 
	 * properties.
	 * 
	 * @param filter The filer to evaluate using the previous service 
	 * properties.
	 * @return True is the filter matches the previous service properties.
	 */
	boolean matchPreviousProperties(Filter filter) {
		/* We use matches here since ServiceProperties already 
		 * does case insensitive lookup.
		 */
		return filter.matches(previousProperties);
	}
}

Back to the top