Examples of ServiceRegistration


Examples of org.osgi.framework.ServiceRegistration

            final Repository repo,
            final Map<String, Object> props) {
        logger.info("Providing new configuration printer for {} : {}", repo, props);
        final Long key = (Long)props.get(Constants.SERVICE_ID);
        final RepositoryPrinter printer = new RepositoryPrinter(repo, props);
        final ServiceRegistration reg = processContext.registerService(RepositoryPrinter.class.getName(),
                printer, printer.getProperties());
        synchronized ( this.registrations ) {
            this.registrations.put(key, reg);
        }
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

    protected void unbindRepository(final Repository repo, final Map<String, Object> props) {
        synchronized ( pendingServices ) {
            this.pendingServices.remove(new PendingService(repo, props));
        }
        final Long key = (Long)props.get(Constants.SERVICE_ID);
        final ServiceRegistration reg;
        synchronized ( this.registrations ) {
            reg = this.registrations.remove(key);
        }
        if ( reg != null ) {
            reg.unregister();
        }
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        };
        ch.qos.logback.classic.Logger bar = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(loggers[0]);
        bar.setLevel(Level.INFO);

        props.put("loggers", loggers);
        ServiceRegistration sr = bundleContext.registerService(Appender.class.getName(), ta, props);

        delay();

        // Level should be INFO now
        assertEquals(java.util.logging.Level.INFO, julLogger.getLevel());
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        config.put(RequestLoggerService.PARAM_FORMAT, format);
        config.put(RequestLoggerService.PARAM_OUTPUT, output);
        config.put(RequestLoggerService.PARAM_OUTPUT_TYPE, outputType);

        final RequestLoggerService service = new RequestLoggerService(bundleContext, config);
        final ServiceRegistration reg = bundleContext.registerService(service.getClass().getName(), service, config);
        services.put(reg, service);
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        bar.debug("Test");
        assertEquals(1, ta.events.size());

        SimpleTurboFilter stf = new SimpleTurboFilter();
        ServiceRegistration sr  = bundleContext.registerService(TurboFilter.class.getName(), stf, null);

        delay();

        assertNotNull("Filter should have context set",stf.getContext());
        assertTrue("Filter should be started", stf.isStarted());

        ta.events.clear();

        //Filter would reject calls for this logger hence it should not be false
        assertFalse(bar.isDebugEnabled());

        //No events should be logged as filter would have rejected that
        bar.debug("Test");
        assertTrue(ta.events.isEmpty());

        //Now unregister and earlier asserts should work
        sr.unregister();

        delay();
        ta.events.clear();

        assertTrue(bar.isDebugEnabled());
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        assertEquals(1, ta.events.size());

        SimpleFilter stf = new SimpleFilter();
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put("appenders", "TestAppender");
        ServiceRegistration sr  = bundleContext.registerService(Filter.class.getName(), stf, props);

        delay();

        assertNotNull("Filter should have context set",stf.getContext());
        assertTrue("Filter should be started", stf.isStarted());

        ta.events.clear();

        //A filter attached to an appender cannot influence isXXXEnabled call
        assertTrue(bar.isDebugEnabled());

        //No events should be logged as filter would have rejected that
        bar.debug("Test");
        assertTrue(ta.events.isEmpty());

        //Now unregister and earlier asserts should work
        sr.unregister();

        delay();
        ta.events.clear();

        assertTrue(bar.isDebugEnabled());
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        when(resourceResolver.adaptTo(Session.class)).thenReturn(session);

        // collect a list of all service registrations to validate that they are all unregistered on shutdown
        when(bundleContext.registerService(anyString(), anyObject(), any(Dictionary.class))).thenAnswer(new Answer<ServiceRegistration>() {
            public ServiceRegistration answer(InvocationOnMock invocation) {
                final ServiceRegistration mockRegistration = mock(ServiceRegistration.class);
                serviceRegistrations.add(mockRegistration);
                doAnswer(new Answer() {
                    public Object answer(InvocationOnMock invocation) {
                        return serviceRegistrations.remove(mockRegistration);
                    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        bar.setLevel(Level.DEBUG);
        ch.qos.logback.classic.Logger baz = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(loggers[1]);
        baz.setLevel(Level.INFO);

        props.put("loggers", loggers);
        ServiceRegistration sr = bundleContext.registerService(Appender.class.getName(), ta, props);

        delay();
        return ta;
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        final Dictionary<String, Object> params = new Hashtable<String, Object>();
        params.put(ResourceProvider.ROOTS, provider.getServletPaths());
        params.put(Constants.SERVICE_DESCRIPTION, "ServletResourceProvider for Servlets at "
                + Arrays.asList(provider.getServletPaths()));

        final ServiceRegistration reg = context.getBundleContext()
                .registerService(ResourceProvider.SERVICE_NAME, provider, params);

        LOGGER.info("Registered {}", provider.toString());
        synchronized (this.servletsByReference) {
            servletsByReference.put(reference, new ServletReg(servlet, reg));
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        String topic = JobHandlingReplicationQueue.REPLICATION_QUEUE_TOPIC + '/' + agentName;
        String childTopic = topic + "/*";
        jobProps.put(JobConsumer.PROPERTY_TOPICS, new String[]{topic, childTopic});
        synchronized (jobConsumers) {
            log.info("registering job consumer for agent {}", agentName);
            ServiceRegistration jobReg = context.registerService(JobConsumer.class.getName(),
                    new ReplicationAgentJobConsumer(queueProcessor), jobProps);
            if (jobReg != null) {
                jobConsumers.put(agentName, jobReg);
            }
            log.info("job consumer for agent {} registered", agentName);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.