use of org.osgi.util.tracker.ServiceTracker in project sling by apache.
the class SlingAuthenticator method activate.
// ---------- SCR integration
@SuppressWarnings("unused")
@Activate
private void activate(final BundleContext bundleContext, final Map<String, Object> properties) {
modified(properties);
AuthenticatorWebConsolePlugin plugin = new AuthenticatorWebConsolePlugin(this);
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put("felix.webconsole.label", plugin.getLabel());
props.put("felix.webconsole.title", plugin.getTitle());
props.put("felix.webconsole.category", "Sling");
props.put(Constants.SERVICE_DESCRIPTION, "Sling Request Authenticator WebConsole Plugin");
props.put(Constants.SERVICE_VENDOR, properties.get(Constants.SERVICE_VENDOR));
webConsolePlugin = bundleContext.registerService("javax.servlet.Servlet", plugin, props);
serviceListener = SlingAuthenticatorServiceListener.createListener(bundleContext, this.authRequiredCache);
authHandlerTracker = new AuthenticationHandlerTracker(bundleContext, authHandlerCache);
engineAuthHandlerTracker = new EngineAuthenticationHandlerTracker(bundleContext, authHandlerCache);
authInfoPostProcessorTracker = new ServiceTracker(bundleContext, AuthenticationInfoPostProcessor.SERVICE_NAME, null);
authInfoPostProcessorTracker.open();
}
use of org.osgi.util.tracker.ServiceTracker in project sling by apache.
the class Activator method start.
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) {
this.bundleContext = context;
this.packageAdminTracker = new ServiceTracker(this.bundleContext, PACKAGE_ADMIN_NAME, null);
this.packageAdminTracker.open();
// register service
this.registerManagerFactory();
this.bundleContext.addBundleListener(this);
}
use of org.osgi.util.tracker.ServiceTracker in project sling by apache.
the class AdapterWebConsolePlugin method activate.
protected void activate(final ComponentContext ctx) throws InvalidSyntaxException {
this.bundleContext = ctx.getBundleContext();
this.adapterServiceReferences = new HashMap<>();
this.adapterBundles = new HashMap<>();
for (final Bundle bundle : this.bundleContext.getBundles()) {
if (bundle.getState() == Bundle.ACTIVE) {
addBundle(bundle);
}
}
this.bundleContext.addBundleListener(this);
final Filter filter = this.bundleContext.createFilter("(&(adaptables=*)(adapters=*)(" + Constants.OBJECTCLASS + "=" + AdapterFactory.SERVICE_NAME + "))");
this.adapterTracker = new ServiceTracker(this.bundleContext, filter, this);
this.adapterTracker.open();
}
use of org.osgi.util.tracker.ServiceTracker in project sling by apache.
the class ResourceProviderTracker method activate.
public void activate(final BundleContext bundleContext, final EventAdmin eventAdmin, final ChangeListener listener) {
this.bundleContext = bundleContext;
this.eventAdmin = eventAdmin;
this.listener = listener;
this.tracker = new ServiceTracker(bundleContext, ResourceProvider.class.getName(), new ServiceTrackerCustomizer() {
@Override
public void removedService(final ServiceReference reference, final Object service) {
final ServiceReference ref = (ServiceReference) service;
final ResourceProviderInfo info = infos.remove(ref);
if (info != null) {
Object pid = ref.getProperty(Constants.SERVICE_PID);
if (pid != null && !(pid instanceof String)) {
pid = null;
}
unregister(info, (String) pid);
}
}
@Override
public void modifiedService(final ServiceReference reference, final Object service) {
removedService(reference, service);
addingService(reference);
}
@Override
public Object addingService(final ServiceReference reference) {
final ResourceProviderInfo info = new ResourceProviderInfo(reference);
infos.put(reference, info);
register(info);
return reference;
}
});
this.tracker.open();
}
use of org.osgi.util.tracker.ServiceTracker in project sling by apache.
the class HealthCheckMBeanCreator method activate.
@Activate
protected void activate(final BundleContext btx) {
this.hcTracker = new ServiceTracker(btx, HealthCheck.class.getName(), null) {
@Override
public Object addingService(final ServiceReference reference) {
return registerHCMBean(btx, reference);
}
@Override
public void modifiedService(final ServiceReference reference, final Object service) {
unregisterHCMBean(btx, reference);
registerHCMBean(btx, reference);
}
@Override
public void removedService(final ServiceReference reference, final Object service) {
unregisterHCMBean(btx, reference);
}
};
this.hcTracker.open();
}
Aggregations