com.eclipsesource.jaxrs.publisher.internal.ServletConfigurationTracker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of publisher Show documentation
Show all versions of publisher Show documentation
With the connector OSGi services can be published as RESTful web services by simply registering them as OSGi services.
The newest version!
/*******************************************************************************
* Copyright (c) 2015 Ivan Iliev 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:
* Ivan Iliev - initial API and implementation
* Holger Staudacher - ongoing development
******************************************************************************/
package com.eclipsesource.jaxrs.publisher.internal;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import com.eclipsesource.jaxrs.publisher.ServletConfiguration;
/**
*
* Tracker for OSGi Services implementing the {@link ServletConfiguration} interface.
*
*/
public class ServletConfigurationTracker extends ServiceTracker {
private final JAXRSConnector connector;
ServletConfigurationTracker( BundleContext context, JAXRSConnector connector ) {
super( context, ServletConfiguration.class.getName(), null );
this.connector = connector;
}
@Override
public Object addingService( ServiceReference reference ) {
return connector.setServletConfiguration( reference );
}
@Override
public void removedService( ServiceReference reference, Object service ) {
if( service instanceof ServletConfiguration ) {
connector.unsetServletConfiguration( reference, ( ServletConfiguration )service );
}
}
}