use of org.osgi.framework.BundleContext in project aries by apache.
the class Activator method start.
@Override
public void start(BundleContext context) throws Exception {
this.context = context;
synchronized (this) {
open = true;
}
Dictionary<String, Object> properties = getMSProperties();
logger.info("Registering for configuration updates {}", properties);
ManagedService service = c -> configurationUpdated(c, false);
msReg = context.registerService(ManagedService.class, service, properties);
new Thread(() -> {
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
configurationUpdated(null, true);
}).start();
}
use of org.osgi.framework.BundleContext in project aries by apache.
the class DefaultWorker method clearBundles.
private void clearBundles(Bundle b) {
// we have been told about the system bundle, so we need to clear up any state for this framework.
BundleContext ctx = b.getBundleContext();
ctx.removeBundleListener(this);
Bundle[] bundles = ctx.getBundles();
for (Bundle bundle : bundles) {
remove(bundle);
}
}
use of org.osgi.framework.BundleContext in project jackrabbit-oak by apache.
the class BaseDocumentDiscoveryLiteServiceTest method createInstance.
SimplifiedInstance createInstance(DocumentNodeStore ns, String workingDir) throws NoSuchFieldException {
DocumentDiscoveryLiteService discoveryLite = new DocumentDiscoveryLiteService();
PrivateAccessor.setField(discoveryLite, "nodeStore", ns);
BundleContext bc = mock(BundleContext.class);
ComponentContext c = mock(ComponentContext.class);
when(c.getBundleContext()).thenReturn(bc);
final Map<String, Object> registeredServices = new HashMap<String, Object>();
when(bc.registerService(anyString(), anyObject(), (Properties) anyObject())).then(new Answer<ServiceRegistration>() {
@Override
public ServiceRegistration answer(InvocationOnMock invocation) {
registeredServices.put((String) invocation.getArguments()[0], invocation.getArguments()[1]);
return null;
}
});
discoveryLite.activate(c);
Descriptors d = (Descriptors) registeredServices.get(Descriptors.class.getName());
final SimplifiedInstance result = new SimplifiedInstance(discoveryLite, ns, d, registeredServices, 500, workingDir);
allInstances.add(result);
logger.info("Created " + result);
return result;
}
use of org.osgi.framework.BundleContext in project jackrabbit-oak by apache.
the class DocumentDiscoveryLiteServiceTest method testActivateDeactivate.
@Test
public void testActivateDeactivate() throws Exception {
// then test normal start with a DocumentNodeStore
DocumentMK mk1 = createMK(1, 0);
DocumentDiscoveryLiteService discoveryLite = new DocumentDiscoveryLiteService();
PrivateAccessor.setField(discoveryLite, "nodeStore", mk1.nodeStore);
BundleContext bc = mock(BundleContext.class);
ComponentContext c = mock(ComponentContext.class);
when(c.getBundleContext()).thenReturn(bc);
discoveryLite.activate(c);
verify(c, times(0)).disableComponent(DocumentDiscoveryLiteService.COMPONENT_NAME);
discoveryLite.deactivate();
}
use of org.osgi.framework.BundleContext in project jackrabbit-oak by apache.
the class ExternalPrincipalConfigurationTest method testRemoveSyncHandler.
@Test
public void testRemoveSyncHandler() throws Exception {
Dictionary<String, Object> enableProps = new Hashtable(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true));
Dictionary<String, Object> disableProps = new Hashtable(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, false));
DefaultSyncHandler sh = new DefaultSyncHandler();
BundleContext bundleContext = context.bundleContext();
ServiceRegistration registration1 = bundleContext.registerService(SyncHandler.class.getName(), sh, enableProps);
ServiceRegistration registration2 = bundleContext.registerService(SyncHandler.class.getName(), sh, enableProps);
ServiceRegistration registration3 = bundleContext.registerService(SyncHandler.class.getName(), sh, disableProps);
assertIsEnabled(principalConfiguration, true);
registration2.unregister();
assertIsEnabled(principalConfiguration, true);
registration1.unregister();
assertIsEnabled(principalConfiguration, false);
registration3.unregister();
assertIsEnabled(principalConfiguration, false);
}
Aggregations