use of org.osgi.framework.ServiceRegistration in project jackrabbit-oak by apache.
the class StatisticsProviderFactory method deactivate.
@Deactivate
private void deactivate() throws IOException {
for (ServiceRegistration reg : regs) {
reg.unregister();
}
regs.clear();
if (statisticsProvider instanceof Closeable) {
((Closeable) statisticsProvider).close();
}
new ExecutorCloser(executor).close();
}
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 deactivate.
@Deactivate
public void deactivate() {
ServiceRegistration registration;
synchronized (this) {
registration = this.registration;
this.registration = null;
this.registering = false;
this.context = null;
this.preconditions.clearPreconditions();
}
if (registration != null) {
registration.unregister();
}
}
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