Skip to main content
summaryrefslogtreecommitdiffstats
blob: a5ed6a481f3833e5b1a0cf914dce2ae7d7cf4074 (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
/*******************************************************************************
 * Copyright (c) 2008 Martin Lippert 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:
 *   Martin Lippert               initial implementation      
 *******************************************************************************/

package org.eclipse.equinox.weaving.hooks;

import org.eclipse.equinox.service.weaving.SupplementerRegistry;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.SynchronousBundleListener;

public class SupplementBundleListener implements SynchronousBundleListener {

	private final SupplementerRegistry supplementerRegistry;

	public SupplementBundleListener(SupplementerRegistry supplementerRegistry) {
		this.supplementerRegistry = supplementerRegistry;
	}

	public void bundleChanged(BundleEvent event) {
		Bundle bundle = event.getBundle();
		if (event.getType() == BundleEvent.INSTALLED) {
			supplementerRegistry.addSupplementer(bundle);
		}
		else if (event.getType() == BundleEvent.UNINSTALLED) {
			supplementerRegistry.removeSupplementer(bundle);
		}
		else if (event.getType() == BundleEvent.UPDATED) {
			supplementerRegistry.removeSupplementer(bundle);
			supplementerRegistry.addSupplementer(bundle);
		}
	}

}

Back to the top