Examples of registerService()


Examples of org.osgi.framework.BundleContext.registerService()

        BundleContext bundleContext = mock(BundleContext.class);
        when(bundleContext.createFilter(any(String.class))).thenReturn(null);
        when(bundleContext.getServiceReference(any(String.class))).thenReturn(null);
        when(bundleContext.getService(null)).thenReturn(mockEA);
        when(bundleContext.registerService(any(String.class), any(Object.class), any(Dictionary.class)))
                .thenAnswer(new Answer<ServiceRegistration>() {
                    public ServiceRegistration answer(InvocationOnMock invocation) throws Throwable {
                        Object[] arguments = invocation.getArguments();
                        registerObserver(whiteboard, (Observer) arguments[1]);
                        return mock(ServiceRegistration.class);
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

    @Test
    public void testRegister() throws Exception {
        String path = "/some/path";
        BundleContext bundleContext = mock(BundleContext.class);
        ServiceRegistration registration = mock(ServiceRegistration.class);
        when(bundleContext.registerService(any(String.class), any(Object.class), any(Dictionary.class))).thenReturn(registration);
        ResourceEventReplicationTrigger resourceEventReplicationTrigger = new ResourceEventReplicationTrigger(path, bundleContext);
        ReplicationRequestHandler handler = mock(ReplicationRequestHandler.class);
        resourceEventReplicationTrigger.register(handler);
    }
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

            try {
                m_objectName = new ObjectName(getObjectNameString());

                properties.put("jmxagent.objectName", m_objectName.toString());

                m_serviceRegistration = bundleContext.registerService(
                    javax.management.DynamicMBean.class.getName(), m_MBean,
                    properties);

                m_registered = true;
            } catch (Exception e) {
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

    public static ServiceRegistration<?> register(Plugin plugin) {

        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(DebugOptions.LISTENER_SYMBOLICNAME, plugin.getBundle().getSymbolicName());
        BundleContext ctx = plugin.getBundle().getBundleContext();
        return ctx.registerService(new String[] { DebugOptionsListener.class.getName(), Logger.class.getName() },
                new Tracer(plugin), props);
    }
}
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

                }

                synchronized(discoveredServices) {
                    if (unknownEndpointId(sd)) {
                        ServiceRegistration proxyRegistration =
                            actualContext.registerService(interfaceName,
                                                          new ClientServiceFactory(actualContext, iClass, sd, handler),
                                                          new Hashtable<String, Object>(getProperties(sd)));
                        cacheEndpointId(sd, proxyRegistration);
                    }
                }
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

                true, getBundleFilter(), getBundleVersion(), getBundleDirectives());

        // must register override properties early in OSGi containers
        Properties extra = useOverridePropertiesWithPropertiesComponent();
        if (extra != null) {
            answer.registerService(PropertiesComponent.OVERRIDE_PROPERTIES, extra, null);
        }

        Map<String, KeyValueHolder<Object, Dictionary>> map = new LinkedHashMap<String, KeyValueHolder<Object, Dictionary>>();
        addServicesOnStartup(map);
        for (Map.Entry<String, KeyValueHolder<Object, Dictionary>> entry : map.entrySet()) {
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

        for (Map.Entry<String, KeyValueHolder<Object, Dictionary>> entry : map.entrySet()) {
            String clazz = entry.getKey();
            Object service = entry.getValue().getKey();
            Dictionary dict = entry.getValue().getValue();
            log.debug("Registering service {} -> {}", clazz, service);
            ServiceRegistration<?> reg = answer.registerService(clazz, service, dict);
            if (reg != null) {
                services.add(reg);
            }
        }
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

        expectedProps.put(ServicePublication.SERVICE_PROPERTIES, props);
        expectedProps.put(ServicePublication.SERVICE_INTERFACE_NAME, Collections.singleton(String.class.getName()));
        expectedProps.put(ServicePublication.ENDPOINT_LOCATION, new URI("http://localhost/xyz"));
       
        BundleContext bc = EasyMock.createMock(BundleContext.class);
        EasyMock.expect(bc.registerService(
            EasyMock.eq(ServicePublication.class.getName()),
            EasyMock.anyObject(),
            (Dictionary<?, ?>) EasyMock.anyObject()))
                .andAnswer(new IAnswer<ServiceRegistration>() {
                    public ServiceRegistration answer() throws Throwable {
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

        Hashtable<String, String> ht = new Hashtable<String, String>();
        EasyMock.expect(b.getHeaders()).andReturn(ht).anyTimes();
       
        final Map<Object, Dictionary> services = new HashMap<Object, Dictionary>();
        BundleContext bc = control.createMock(BundleContext.class);
        EasyMock.expect(bc.registerService(
            (String) EasyMock.anyObject(),
            EasyMock.anyObject(),
            (Dictionary) EasyMock.anyObject())).andAnswer(new IAnswer<ServiceRegistration>() {
                public ServiceRegistration answer() throws Throwable {
                    services.put(EasyMock.getCurrentArguments()[1],
View Full Code Here

Examples of org.osgi.framework.BundleContext.registerService()

        Hashtable<String, String> ht = new Hashtable<String, String>();
        EasyMock.expect(b.getHeaders()).andReturn(ht).anyTimes();
       
        final Map<Object, Dictionary> services = new HashMap<Object, Dictionary>();
        BundleContext bc = control.createMock(BundleContext.class);
        EasyMock.expect(bc.registerService(
            (String) EasyMock.anyObject(),
            EasyMock.anyObject(),
            (Dictionary) EasyMock.anyObject())).andAnswer(new IAnswer<ServiceRegistration>() {
                public ServiceRegistration answer() throws Throwable {
                    services.put(EasyMock.getCurrentArguments()[1],
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.