Package org.osgi.framework

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


        System.out.println(" " + names[i]);
       
      }
      */
      BundleContext regBC = sr.getBundle().getBundleContext();
      reg = regBC.registerService(Object.class.getName(), dispatcher, props);
    } else {
      // System.out.println("no names in " + cg);
    }
  }

View Full Code Here


        properties.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
        properties.put(Constants.SERVICE_DESCRIPTION, "Sling Models OSGi Service Disposal Job");
        properties.put("scheduler.concurrent", false);
        properties.put("scheduler.period", Long.valueOf(30));

        this.jobRegistration = bundleContext.registerService(Runnable.class.getName(), this, properties);

        this.listener = new ModelPackageBundleListener(ctx.getBundleContext(), this, this.adapterImplementations);

        Hashtable<Object, Object> printerProps = new Hashtable<Object, Object>();
        printerProps.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
View Full Code Here

        printerProps.put(Constants.SERVICE_DESCRIPTION, "Sling Models Configuration Printer");
        printerProps.put("felix.webconsole.label", "slingmodels");
        printerProps.put("felix.webconsole.title", "Sling Models");
        printerProps.put("felix.webconsole.configprinter.modes", "always");

        this.configPrinterRegistration = bundleContext.registerService(Object.class.getName(),
                new ModelConfigurationPrinter(this), printerProps);
    }

    @Deactivate
    protected void deactivate() {
View Full Code Here

        assertNull(sampleObject.adaptTo(String.class));

        BundleContext bundleContext = MockOsgi.newBundleContext();
        MockSling.setAdapterManagerBundleContext(bundleContext);

        bundleContext.registerService(AdapterFactory.class.getName(), new AdapterFactory() {
            @SuppressWarnings("unchecked")
            @Override
            public <AdapterType> AdapterType getAdapter(final Object adaptable, final Class<AdapterType> type) {
                if (adaptable instanceof AdaptableTest && type.isAssignableFrom(String.class)) {
                    return (AdapterType) ((AdaptableTest) adaptable).toString();
View Full Code Here

        final SlingPostOperation service = (SlingPostOperation) this.bundleContext.getService(serviceReference);
        final PostOperationProxy proxy = new PostOperationProxy(service);

        final BundleContext bundleContext = serviceReference.getBundle().getBundleContext();
        final Dictionary<String, Object> props = copyServiceProperties(serviceReference);
        final ServiceRegistration reg = bundleContext.registerService(
            PostOperation.SERVICE_NAME, proxy, props);

        log.debug("Registering {}", proxy);
        synchronized (this.proxies) {
            this.proxies.put(serviceReference, reg);
View Full Code Here

    @SuppressWarnings("unchecked")
    @Before
    public void setup() throws Exception {
        final BundleContext bc = Mockito.mock(BundleContext.class);
        Mockito.when(bc.registerService(Mockito.any(String[].class),
                Mockito.any(),
                Mockito.any(Dictionary.class))).thenReturn(null);

        final SlingSettingsService otherSettings = Mockito.mock(SlingSettingsService.class);
        Mockito.when(otherSettings.getSlingId()).thenReturn(OTHER_APP_ID);
View Full Code Here

        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

    @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

            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

    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

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.