use of org.osgi.framework.ServiceRegistration in project sling by apache.
the class MockBundleContextDynamicReferencesTest method testAddRemoveOptionalMultipleService.
@Test
public void testAddRemoveOptionalMultipleService() {
ServiceRegistration reg3a = bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a, null);
assertDependencies3(dependency3a);
ServiceRegistration reg3b = bundleContext.registerService(ServiceInterface3.class.getName(), dependency3b, null);
assertDependencies3(dependency3a, dependency3b);
reg3a.unregister();
assertDependencies3(dependency3b);
reg3b.unregister();
assertDependencies3();
}
use of org.osgi.framework.ServiceRegistration in project sling by apache.
the class AbstractSlingLaunchpadOakTestSupport method testOsgiResourceEvents.
@Test
public void testOsgiResourceEvents() throws RepositoryException {
final ResourceEventListener listener = new ResourceEventListener();
final ServiceRegistration reg = listener.register(bundleContext, SlingConstants.TOPIC_RESOURCE_ADDED);
final Session s = slingRepository.loginAdministrative(null);
final int nPaths = 2500 * TEST_SCALE;
final int timeoutMsec = 2 * nPaths;
final String prefix = uniqueName("testOsgiResourceEvents");
// for each of them
try {
for (int i = 0; i < nPaths; i++) {
s.getRootNode().addNode(prefix + i);
}
s.save();
logger.info("Added {} nodes, checking what ResourceEventListener got...", nPaths);
final long timeout = System.currentTimeMillis() + timeoutMsec;
final Set<String> missing = new HashSet<String>();
while (System.currentTimeMillis() < timeout) {
missing.clear();
final Set<String> paths = listener.getPaths();
for (int i = 0; i < nPaths; i++) {
final String path = "/" + prefix + i;
if (!paths.contains(path)) {
missing.add(path);
}
}
if (missing.isEmpty()) {
break;
}
}
if (!missing.isEmpty()) {
final String missingStr = missing.size() > 10 ? missing.size() + " paths missing" : missing.toString();
fail("OSGi add resource events are missing for " + missing.size() + "/" + nPaths + " paths after " + timeoutMsec + " msec: " + missingStr);
}
} finally {
reg.unregister();
s.logout();
}
logger.info("Successfuly detected OSGi observation events for " + nPaths + " paths");
}
use of org.osgi.framework.ServiceRegistration in project sling by apache.
the class PostOperationProxyProvider method unregister.
/**
* Unregister proxy and unget SlingPostOperation service
* <p>
* Called by serviceChanged
*/
private void unregister(final ServiceReference serviceReference) {
final ServiceRegistration proxyRegistration;
synchronized (this.proxies) {
proxyRegistration = this.proxies.remove(serviceReference);
}
if (proxyRegistration != null) {
log.debug("Unregistering {}", proxyRegistration);
this.bundleContext.ungetService(serviceReference);
proxyRegistration.unregister();
}
}
use of org.osgi.framework.ServiceRegistration in project sling by apache.
the class LogTracer method deactivate.
@Deactivate
private void deactivate() {
if (logServlet != null) {
logServlet.unregister();
}
if (slingFilterRegistration != null) {
slingFilterRegistration.unregister();
slingFilterRegistration = null;
}
if (filterRegistration != null) {
filterRegistration.unregister();
filterRegistration = null;
}
ServiceRegistration reg = logCollectorReg.getAndSet(null);
if (reg != null) {
reg.unregister();
}
requestContextHolder.remove();
}
use of org.osgi.framework.ServiceRegistration in project sling by apache.
the class StartupFilterImplTest method setup.
@Before
public void setup() {
activeFilterCount = new AtomicInteger();
mockery = new Mockery();
request = mockery.mock(HttpServletRequest.class);
response = mockery.mock(HttpServletResponse.class);
chain = mockery.mock(FilterChain.class);
serviceRegistration = mockery.mock(ServiceRegistration.class);
filter = new TestFilterImpl();
requestPath = "/NO_PATH_YET";
}
Aggregations