blob: 3b96d1d38b5678b41792c4bea4bb9e373cad5754 (
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
|
/*******************************************************************************
* Copyright (c) 2014 Raymond Augé and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Raymond Augé <raymond.auge@liferay.com> - Bug 436698
******************************************************************************/
package org.eclipse.equinox.http.servlet.tests.tb1;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.equinox.http.servlet.tests.tb.AbstractTestResource;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
/**
* @author Raymond Augé
*/
public class TestResource3 extends AbstractTestResource {
private final Collection<ServiceRegistration<?>> registrations = new ArrayList<>();
@Override
public void activate(ComponentContext componentContext) {
Dictionary<String, String> resourceProps = new Hashtable<>();
resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, regexAlias());
resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, getName());
registrations.add(componentContext.getBundleContext().registerService(TestResource3.class, this, resourceProps));
}
@Override
public void deactivate() {
for (ServiceRegistration<?> registration : registrations) {
registration.unregister();
}
}
}
|