use of org.osgi.framework.ServiceRegistration in project jetty.project by eclipse.
the class AbstractOSGiApp method registerAsOSGiService.
/* ------------------------------------------------------------ */
public void registerAsOSGiService() throws Exception {
if (_registration == null) {
Dictionary<String, String> properties = new Hashtable<String, String>();
properties.put(OSGiWebappConstants.WATERMARK, OSGiWebappConstants.WATERMARK);
if (getBundleSymbolicName() != null)
properties.put(OSGiWebappConstants.OSGI_WEB_SYMBOLICNAME, getBundleSymbolicName());
if (getBundleVersionAsString() != null)
properties.put(OSGiWebappConstants.OSGI_WEB_VERSION, getBundleVersionAsString());
properties.put(OSGiWebappConstants.OSGI_WEB_CONTEXTPATH, getContextPath());
ServiceRegistration rego = FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(ContextHandler.class.getName(), getContextHandler(), properties);
setRegistration(rego);
}
}
use of org.osgi.framework.ServiceRegistration in project opennms by OpenNMS.
the class ApplicationFactoryServiceTracker method removedService.
@Override
public void removedService(ServiceReference reference, Object service) {
ApplicationFactory factory = (ApplicationFactory) context.getService(reference);
final ServiceRegistration servletRegistration = m_serviceRegistration.remove(factory);
if (servletRegistration != null) {
servletRegistration.unregister();
}
super.removedService(reference, service);
}
use of org.osgi.framework.ServiceRegistration in project jackrabbit-oak by apache.
the class SecurityProviderRegistration method maybeRegister.
private void maybeRegister() {
BundleContext context;
log.info("Trying to register a SecurityProvider...");
synchronized (this) {
if (this.context == null) {
log.info("Aborting: no BundleContext is available");
return;
}
if (!preconditions.areSatisfied()) {
log.info("Aborting: preconditions are not satisfied: {}", preconditions);
return;
}
if (registration != null) {
log.info("Aborting: a SecurityProvider is already registered");
return;
}
if (registering) {
log.info("Aborting: a SecurityProvider is already being registered");
return;
}
// Mark the start of a registration process.
registering = true;
// Save the BundleContext for local usage.
context = this.context;
}
// Register the SecurityProvider.
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put("type", "default");
ServiceRegistration registration = context.registerService(SecurityProvider.class.getName(), createSecurityProvider(context), properties);
synchronized (this) {
this.registration = registration;
this.registering = false;
}
log.info("SecurityProvider instance registered");
}
use of org.osgi.framework.ServiceRegistration in project jackrabbit-oak by apache.
the class SecurityProviderRegistration method maybeUnregister.
private void maybeUnregister() {
ServiceRegistration registration;
log.info("Trying to unregister the SecurityProvider...");
synchronized (this) {
if (this.registration == null) {
log.info("Aborting: no SecurityProvider is registered");
return;
}
if (preconditions.areSatisfied()) {
log.info("Aborting: preconditions are satisfied");
return;
}
// Save the ServiceRegistration for local use.
registration = this.registration;
this.registration = null;
}
registration.unregister();
log.info("SecurityProvider instance unregistered");
}
use of org.osgi.framework.ServiceRegistration in project jackrabbit-oak by apache.
the class SegmentCachingDataStoreStatsTest method testUseCachingBlobStore.
@Test
public void testUseCachingBlobStore() {
ServiceRegistration delegateReg = context.bundleContext().registerService(AbstractSharedCachingDataStore.class.getName(), mock(AbstractSharedCachingDataStore.class), null);
assertNotNull(context.getService(AbstractSharedCachingDataStore.class));
registerBlobStore();
registerSegmentNodeStoreService(true);
assertServiceActivated();
ConsolidatedDataStoreCacheStats dataStoreStats = context.registerInjectActivateService(new ConsolidatedDataStoreCacheStats());
assertNotNull(context.getService(ConsolidatedDataStoreCacheStatsMBean.class));
deactivate(dataStoreStats, context.bundleContext());
unregisterSegmentNodeStoreService();
unregisterBlobStore();
delegateReg.unregister();
}
Aggregations