Package org.osgi.framework

Examples of org.osgi.framework.ServiceRegistration


        }
    }

    public void unregister(@Nonnull ReplicationRequestHandler requestHandler) throws ReplicationTriggerException {
        ServiceRegistration serviceRegistration = registrations.get(requestHandler.toString());
        if (serviceRegistration != null) {
            serviceRegistration.unregister();
        }
    }
View Full Code Here


    @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

                final Dictionary<Object, Object> props = new Hashtable<Object, Object>();
                props.put(ResourceProvider.ROOTS, mergeRoot);
                props.put(ResourceProvider.OWNS_ROOTS, true);

                final Long key = (Long) reference.getProperty(Constants.SERVICE_ID);
                final ServiceRegistration reg = bundleContext.registerService(ResourceProviderFactory.class.getName(), providerFactory, props);

                serviceRegistrations.put(key, reg);

            }
            return picker;
View Full Code Here

        addingService(reference);
    }

    public void removedService(final ServiceReference reference, final Object service) {
        final Long key = (Long) reference.getProperty(Constants.SERVICE_ID);
        final ServiceRegistration reg = serviceRegistrations.get(key);
        if ( reg != null ) {
            reg.unregister();
            this.bundleContext.ungetService(reference);
        }
    }
View Full Code Here

        Dictionary<Object, Object> serviceProps = new Hashtable<Object, Object>();
        if (key.baseName != null) {
            serviceProps.put("baseName", key.baseName);
        }
        serviceProps.put("locale", key.locale.toString());
        ServiceRegistration serviceReg = bundleContext.registerService(ResourceBundle.class.getName(),
                resourceBundle, serviceProps);
        synchronized (this) {
            bundleServiceRegistrations.add(serviceReg);
        }
View Full Code Here

    @Before public void setup() {
        filter = new ReferrerFilter();
        final ComponentContext ctx = mock(ComponentContext.class);
        final BundleContext bundleCtx = mock(BundleContext.class);
        final ServiceRegistration reg = mock(ServiceRegistration.class);
        final Dictionary<String, Object> props = new Hashtable<String, Object>(){{
            put("allow.hosts", new String[]{"relhost"});
            put("allow.hosts.regexp", new String[]{"http://([^.]*.)?abshost:80"});
        }};
        doReturn(props).when(ctx).getProperties();
View Full Code Here

             * I have to unregister the UPnPDevice and register it again
             * with the updated properties 
             */
            UPnPDeviceImpl device =
                          ((OSGiDeviceInfo) devices.get(udn)).getOSGiDevice();
            ServiceRegistration registar =
                          ((OSGiDeviceInfo) devices.get(udn)).getRegistration();
            String[] oldServicesID =
                          (String[]) (device.getDescriptions(null).get(UPnPService.ID));
            String[] oldServiceType =
                          (String[]) (device.getDescriptions(null).get(UPnPService.TYPE));
View Full Code Here

     * ServiceRegistration and UPnPDevice reference to the hashtable
     * that contains local devices
     */
    if (prop == null && upnpDev == null) {
      UPnPDeviceImpl newDevice = new UPnPDeviceImpl(dev, context);
      ServiceRegistration registration =
                context.registerService(UPnPDevice.class.getName(),
                                        newDevice,
                                        newDevice.getDescriptions(null));
      OSGiDeviceInfo deviceInfo =
                new OSGiDeviceInfo(newDevice,registration);
           
            String udn = (String) ((newDevice.getDescriptions(null)).get(UPnPDevice.UDN));
      devices.put(udn, deviceInfo);
    } else {
      ServiceRegistration registration =
                context.registerService(UPnPDevice.class.getName(), upnpDev, prop);
      OSGiDeviceInfo deviceInfo =
                new OSGiDeviceInfo(upnpDev,  registration);
      devices.put(upnpDev.getDescriptions(null).get(UPnPDevice.UDN),deviceInfo);
    }
View Full Code Here

        if (!isSerPresent) {
            /*
             * The serivice doesn't exist so it's new.
             * Find the udn of owner device and re-register the owner
             */
            ServiceRegistration registar =
                ((OSGiDeviceInfo) devices.remove(udn)).getRegistration();
            String[] oldServicesID =
                (String[]) device.getDescriptions(null).get(UPnPServiceImpl.ID);
            String[] oldServicesType =
                (String[]) device.getDescriptions(null).get(UPnPServiceImpl.TYPE);
View Full Code Here

                    }
                };
            }
        };

        ServiceRegistration reg = m_context.registerService(ConnectorFactory.class.getName(), factory, null);

        // Should be opened automatically when picked up by the Jetty implementation...
        assertTrue("Felix HTTP Jetty did not open the Connection or pick up the registered ConnectionFactory", openLatch.await(5, TimeUnit.SECONDS));

        // Should close our connection...
        reg.unregister();

        assertTrue("Felix HTTP Jetty did not close the Connection", closeLatch.await(5, TimeUnit.SECONDS));
    }
View Full Code Here

TOP

Related Classes of org.osgi.framework.ServiceRegistration

Copyright © 2018 www.massapicom. 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.