Search in sources :

Example 1 with UIServiceTracker

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

the class UIServiceTrackers method removeTrackerFor.

/**
 * Closes and removes the {@link UIServiceTracker} for the bundle.
 * @param bundle the bundle to remove the tracker for
 * @return the closed and removed tracker
 */
public UIServiceTracker removeTrackerFor(Bundle bundle) {
    String symbolicName = bundle.getSymbolicName();
    LOGGER.debug("Removing tracker for: {}", symbolicName);
    UIServiceTracker removedTracker = trackers.remove(symbolicName);
    if (removedTracker != null) {
        removedTracker.close();
        LOGGER.debug("Tracker for {} was closed", symbolicName);
    } else {
        LOGGER.debug("No tracker registered for {}", symbolicName);
    }
    return removedTracker;
}
Also used : UIServiceTracker(org.motechproject.osgi.web.tracker.internal.UIServiceTracker)

Example 2 with UIServiceTracker

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

the class UIServiceTrackers method addTrackerFor.

/**
 * Creates a {@link UIServiceTracker} for the given bundle. The {@link org.motechproject.osgi.web.ModuleRegistrationData}
 * from the provided Spring context of the bundle will be used for registering the UI.
 * @param bundle the bundle to create the tracker for
 * @param applicationContext the Spring context of the bundle
 * @return the newly created {@link UIServiceTracker} instance
 */
public UIServiceTracker addTrackerFor(Bundle bundle, ApplicationContext applicationContext) {
    if (!applicationContext.containsBean(MODULE_REGISTRATION_DATA)) {
        LOGGER.warn("Bean moduleRegistrationData not found in {}", nullSafeSymbolicName(bundle));
        return null;
    }
    LOGGER.debug("Bean moduleRegistrationData found for bundle {}", nullSafeSymbolicName(bundle));
    ModuleRegistrationData moduleRegistrationData = (ModuleRegistrationData) applicationContext.getBean(MODULE_REGISTRATION_DATA);
    final UIServiceTracker uiServiceTracker = new UIServiceTracker(bundle.getBundleContext(), moduleRegistrationData);
    trackers.put(nullSafeSymbolicName(bundle), uiServiceTracker);
    uiServiceTracker.start();
    LOGGER.debug("UI Service Tracker registered for {}", nullSafeSymbolicName(bundle));
    return uiServiceTracker;
}
Also used : UIServiceTracker(org.motechproject.osgi.web.tracker.internal.UIServiceTracker) ModuleRegistrationData(org.motechproject.osgi.web.ModuleRegistrationData)

Aggregations

UIServiceTracker (org.motechproject.osgi.web.tracker.internal.UIServiceTracker)2 ModuleRegistrationData (org.motechproject.osgi.web.ModuleRegistrationData)1