use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class ConfigurationManager method stop.
@Override
public void stop(BundleContext bundleContext) {
// stop handling bundle events immediately
handleBundleEvents = false;
// stop handling ManagedService[Factory] services
managedServiceFactoryTracker.close();
managedServiceTracker.close();
// see FELIX-2813 for details
if (updateThread != null) {
updateThread.terminate();
}
if (eventThread != null) {
eventThread.terminate();
}
// immediately unregister the Configuration Admin before cleaning up
// clearing the field before actually unregistering the service
// prevents IllegalStateException in getServiceReference() if
// the field is not null but the service already unregistered
final ServiceRegistration caReg = configurationAdminRegistration;
configurationAdminRegistration = null;
if (caReg != null) {
caReg.unregister();
}
// consider inactive after unregistering such that during
// unregistration the manager is still alive and can react
isActive = false;
// don't care for PersistenceManagers any more
persistenceManagerTracker.close();
// shutdown the file persistence manager
final ServiceRegistration filePmReg = filepmRegistration;
filepmRegistration = null;
if (filePmReg != null) {
filePmReg.unregister();
}
// stop listening for events
bundleContext.removeBundleListener(this);
if (configurationListenerTracker != null) {
configurationListenerTracker.close();
}
if (syncConfigurationListenerTracker != null) {
syncConfigurationListenerTracker.close();
}
if (logTracker != null) {
logTracker.close();
}
// just ensure the configuration cache is empty
synchronized (configurations) {
configurations.clear();
}
this.bundleContext = null;
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class AspectAnnotationTest method testAspectChain.
public void testAspectChain() throws Throwable {
Ensure e = new Ensure();
// Activate service consumer
ServiceRegistration scSequencer = register(e, ServiceConsumer.ENSURE);
// Activate service provider
ServiceRegistration spSequencer = register(e, ServiceProvider.ENSURE);
// Activate service aspect 2
ServiceRegistration sa2Sequencer = register(e, ServiceAspect2.ENSURE);
// Activate service aspect 3
ServiceRegistration sa3Sequencer = register(e, ServiceAspect3.ENSURE);
// Activate service aspect 1
ServiceRegistration sa1Sequencer = register(e, ServiceAspect1.ENSURE);
e.step();
e.waitForStep(6, 10000);
// Deactivate service provider
spSequencer.unregister();
// Make sure that service aspect 1 has been called in ts removed and stop callbacks
e.waitForStep(8, 10000);
e.ensure();
scSequencer.unregister();
sa1Sequencer.unregister();
sa2Sequencer.unregister();
sa3Sequencer.unregister();
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class AspectLifecycleAnnotationTest method testAnnotatedAspect.
public void testAnnotatedAspect() {
Ensure e = new Ensure();
// Provide the Sequencer server to the ServiceProvider service
ServiceRegistration sr1 = register(e, ServiceProvider.ENSURE);
// Check if the ServiceProvider has been injected in the AspectTest service.
e.waitForStep(1, 10000);
// Provide the Sequencer server to the ServiceProviderAspect service
ServiceRegistration sr2 = register(e, ServiceProviderAspect.ENSURE);
// Check if the AspectTest has been injected with the aspect
e.waitForStep(3, 10000);
// Stop the ServiceProviderAspect service.
sr2.unregister();
// And check if the aspect has been called in its stop/destroy methods.
e.waitForStep(7, 10000);
sr1.unregister();
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class AspectLifecycleWithDynamicProxyAnnotationTest method testAnnotatedAspect.
public void testAnnotatedAspect() {
Ensure e = new Ensure();
// Provide the Sequencer server to the ServiceProvider service
ServiceRegistration sr1 = register(e, ServiceProvider.ENSURE);
// Check if the ServiceProvider has been injected in the AspectTest service.
e.waitForStep(1, 10000);
// Provide the Sequencer server to the ServiceProviderAspect service
ServiceRegistration sr2 = register(e, ServiceProviderAspect.ENSURE);
// Check if the AspectTest has been injected with the aspect
e.waitForStep(3, 10000);
// Remove the ServiceProviderAspect service
sr2.unregister();
// And check if the aspect has been called in its stop/destroy methods.
e.waitForStep(7, 10000);
sr1.unregister();
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class BundleDependencyAnnotationTest method testBundleAdapterServiceAnnotation.
/**
* Tests a Bundle Adapter, which adapts the dependency manager bundle to a "ServiceInterface" service.
* @throws Throwable
*/
public void testBundleAdapterServiceAnnotation() throws Throwable {
Ensure e = new Ensure();
ServiceRegistration sr = register(e, BundleDependencyAnnotation.ENSURE_ADAPTER);
e.waitForStep(3, 10000);
e.ensure();
sr.unregister();
}
Aggregations