blob: 3b96d1d38b5678b41792c4bea4bb9e373cad5754 [file] [log] [blame]
/*******************************************************************************
* 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();
}
}
}