Search in sources :

Example 1 with HttpServiceTracker

use of org.motechproject.osgi.web.tracker.internal.HttpServiceTracker in project motech by motech.

the class HttpServiceTrackers method addTrackerFor.

/**
 * Creates an {@link HttpServiceTracker} instance for the given bundle.
 * @param bundle the bundle for which the tracker should be created
 * @return the newly created tracker
 */
public HttpServiceTracker addTrackerFor(Bundle bundle) {
    LOGGER.debug("Adding HTTP service tracker for: {}", nullSafeSymbolicName(bundle));
    HttpServiceTracker httpServiceTracker = new HttpServiceTracker(bundle.getBundleContext(), getResourceMapping(new BundleHeaders(bundle)));
    trackers.put(nullSafeSymbolicName(bundle), httpServiceTracker);
    httpServiceTracker.start();
    LOGGER.debug("Registered HTTP service tracker for: {}", nullSafeSymbolicName(bundle));
    return httpServiceTracker;
}
Also used : HttpServiceTracker(org.motechproject.osgi.web.tracker.internal.HttpServiceTracker) BundleHeaders(org.motechproject.osgi.web.util.BundleHeaders)

Example 2 with HttpServiceTracker

use of org.motechproject.osgi.web.tracker.internal.HttpServiceTracker in project motech by motech.

the class HttpServiceTrackers method removeTrackerFor.

/**
 * Removes a tracker for a given bundle. The tracker is also unregistered and closed cleanly.
 * @param bundle the bundle to remove the tracker for
 * @return the closed tracker instance, dropped from this registry
 */
public HttpServiceTracker removeTrackerFor(Bundle bundle) {
    final String symbolicName = nullSafeSymbolicName(bundle);
    LOGGER.debug("Removing tracker for: {}", symbolicName);
    HttpServiceTracker trackerToRemove = trackers.remove(symbolicName);
    if (trackerToRemove != null) {
        trackerToRemove.unregister();
        trackerToRemove.close();
        LOGGER.debug("Tracker for {} closed", symbolicName);
    } else {
        LOGGER.debug("No tracker registered for: {}", symbolicName);
    }
    return trackerToRemove;
}
Also used : HttpServiceTracker(org.motechproject.osgi.web.tracker.internal.HttpServiceTracker)

Aggregations

HttpServiceTracker (org.motechproject.osgi.web.tracker.internal.HttpServiceTracker)2 BundleHeaders (org.motechproject.osgi.web.util.BundleHeaders)1