Package org.osgi.service.component

Examples of org.osgi.service.component.ComponentContext


                logger.debug("Registering {} resources with OSGi installer: {}", resources.size(), resources);
                installer.registerResources(URL_SCHEME, resources.toArray(new InstallableResource[resources.size()]));
            } catch (final RepositoryException re) {
                logger.error("Repository exception during startup - deactivating installer!", re);
                active = false;
                final ComponentContext ctx = componentContext;
                if ( ctx  != null ) {
                    final String name = (String) componentContext.getProperties().get(
                            ComponentConstants.COMPONENT_NAME);
                    ctx.disableComponent(name);
                }
            }
            while (active) {
                runOneCycle();
            }
View Full Code Here


                }
            }
        };
        ctxA.addServiceListener(listener);

        ComponentContext ccA1 = srvA.getServiceA1().getComponentContext();
        ccA1.disableComponent(ServiceA1.class.getName());

        Assert.assertTrue(latch.await(2, TimeUnit.SECONDS));

        ServiceReference<ServiceA> srefA = ctxA.getServiceReference(ServiceA.class);
        Assert.assertNull("ServiceReference null", srefA);
View Full Code Here

        // lets set up the component configuration
        final Dictionary<String, Object> componentConfig = this.getComponentConfig();

        // lets set up the compnent context
        final ComponentContext componentContext = this.getMockery().mock(ComponentContext.class);
        this.getMockery().checking(new Expectations() {{
            allowing(componentContext).getBundleContext();
            will(returnValue(bundleContext));
            allowing(componentContext).getProperties();
            will(returnValue(componentConfig));
View Full Code Here

        }
        rootNode.save();
        // lets set up the bundle context with the sling id
        final BundleContext bundleContext = this.getMockery().mock(BundleContext.class);

        final ComponentContext componentContext = this.getMockery().mock(ComponentContext.class);
        this.getMockery().checking(new Expectations() {{
            allowing(componentContext).getBundleContext();
            will(returnValue(bundleContext));
        }});
        this.handler.deactivate(componentContext);
View Full Code Here

        factory.bindJcrResourceTypeProvider(new ServiceReferenceImpl(3, 2L, 100L));
        factory.bindJcrResourceTypeProvider(new ServiceReferenceImpl(5, 3L, 50L));
        factory.bindJcrResourceTypeProvider(new ServiceReferenceImpl(6, 4L, 50L));
        factory.bindJcrResourceTypeProvider(new ServiceReferenceImpl(2, 6L, 150L));
        // lets set up the compnent context
        final ComponentContext componentContext = this.getMockery().mock(ComponentContext.class);
        this.getMockery().checking(new Expectations() {{
            allowing(componentContext).locateService(with(any(String.class)), with(any(ServiceReference.class)));
            will(returnValue(null));
        }});
        assertTrue(factory.jcrResourceTypeProviders.isEmpty());
View Full Code Here

  public void testGetCustomPrefix() throws Exception {
    Dictionary properties = new Hashtable();
    String[] mappings = new String[1];
    mappings[0] = "org.example.TestBundle=/custom";
    properties.put("mappings", mappings);
    ComponentContext context = createComponentContextMock(properties);
    ConfigurationAdmin configAdmin = createConfigAdminMock(new Hashtable());

    BundlePrefixManager prefixManager = createBundlePrefixManager(
        configAdmin, context);
   
View Full Code Here

    assertEquals("/custom", prefixManager.getPrefix(bundle));
  }
 
  @Test
  public void testGetDefaultPrefix() throws Exception {
    ComponentContext context = createComponentContextMock(new Hashtable());
    ConfigurationAdmin configAdmin = createConfigAdminMock(new Hashtable());

    BundlePrefixManager prefixManager = createBundlePrefixManager(
        configAdmin, context);
   
View Full Code Here

  public void testCustomPriorDefault() throws Exception {
    Dictionary properties = new Hashtable();
    String[] mappings = new String[1];
    mappings[0] = "org.example.TestBundle=/custom";
    properties.put("mappings", mappings);
    ComponentContext context = createComponentContextMock(properties);
    ConfigurationAdmin configAdmin = createConfigAdminMock(new Hashtable());

    BundlePrefixManager prefixManager = createBundlePrefixManager(
        configAdmin, context);
   
View Full Code Here

    Dictionary properties = new Hashtable();
    String[] mappings = new String[1];
    mappings[0] = "org.example.TestBundle=/custom";
    properties.put("mappings", mappings);
    properties.put(TriaxrsPrefixManager.TRIAXRS_USE_CUSTOM_PREFIXES, false);
    ComponentContext context = createComponentContextMock(properties);
    ConfigurationAdmin configAdmin = createConfigAdminMock(new Hashtable());

    BundlePrefixManager prefixManager = createBundlePrefixManager(
        configAdmin, context);
   
View Full Code Here

    String[] mappings = new String[1];
    mappings[0] = "org.example.TestBundle=/custom";
    properties.put("mappings", mappings);
    properties.put(TriaxrsPrefixManager.TRIAXRS_USE_CUSTOM_PREFIXES, false);
    properties.put(TriaxrsPrefixManager.TRIAXRS_USE_DEFAULT_PREFIXES, false);
    ComponentContext context = createComponentContextMock(properties);
    ConfigurationAdmin configAdmin = createConfigAdminMock(new Hashtable());

    BundlePrefixManager prefixManager = createBundlePrefixManager(
        configAdmin, context);
   
View Full Code Here

TOP

Related Classes of org.osgi.service.component.ComponentContext

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.