Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1f014d4a992fb20eebf54d9029cb972b7785a912 (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
/*******************************************************************************
 * Copyright (c) 2012 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.container.tests.dummys;

import java.util.EnumSet;
import java.util.Map;
import org.eclipse.osgi.container.*;
import org.eclipse.osgi.container.Module.Settings;
import org.eclipse.osgi.container.tests.dummys.DummyModuleDatabase.DummyContainerEvent;
import org.eclipse.osgi.container.tests.dummys.DummyModuleDatabase.DummyModuleEvent;
import org.osgi.framework.FrameworkListener;

public class DummyContainerAdaptor extends ModuleContainerAdaptor {

	private final ModuleCollisionHook collisionHook;
	private final ModuleResolverHookFactory resolverHookFactory;
	private final Map<String, String> configuration;
	private final DummyModuleDatabase moduleDatabase;
	private final ModuleContainer container;

	public DummyContainerAdaptor(ModuleCollisionHook collisionHook, ModuleResolverHookFactory resolverHookFactory, Map<String, String> configuration) {
		this.collisionHook = collisionHook;
		this.resolverHookFactory = resolverHookFactory;
		this.configuration = configuration;
		this.moduleDatabase = new DummyModuleDatabase(this);
		this.container = new ModuleContainer(this, moduleDatabase);
	}

	@Override
	public ModuleCollisionHook getModuleCollisionHook() {
		return collisionHook;
	}

	@Override
	public ModuleResolverHookFactory getResolverHookFactory() {
		return resolverHookFactory;
	}

	@Override
	public void publishContainerEvent(ContainerEvent type, Module module,
			Throwable error, FrameworkListener... listeners) {
		moduleDatabase.addEvent(new DummyContainerEvent(type, module, error, listeners));

	}

	@Override
	public String getProperty(String key) {
		return configuration.get(key);
	}

	@Override
	public Module createModule(String location, long id, EnumSet<Settings> settings, int startlevel) {
		return new DummyModule(id, location, container, moduleDatabase, settings, startlevel);
	}

	@Override
	public SystemModule createSystemModule() {
		return new DummySystemModule(container, moduleDatabase);
	}

	public ModuleContainer getContainer() {
		return container;
	}

	public DummyModuleDatabase getDatabase() {
		return moduleDatabase;
	}

	@Override
	public void publishModuleEvent(ModuleEvent type, Module module, Module origin) {
		moduleDatabase.addEvent(new DummyModuleEvent(module, type, module.getState()));
	}
}

Back to the top