Package org.osgi.service.component

Examples of org.osgi.service.component.ComponentContext


        assertTrue(adapter instanceof ITestAdapter);
    }

    public void testAdaptExtended2() {

        ComponentContext cc = new MockComponentContext();
        am.activate(cc);

        Bundle bundle = new MockBundle(1L);
        MockServiceReference ref = new MockServiceReference(bundle);
        ref.setProperty(Constants.SERVICE_ID, 1L);
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

                }
            }
        };
        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

    }

    @Override
    public Object addingService(ServiceReference reference) {
        invalidateExecutionPlan();
        ComponentContext context = this.context;
        if(context != null){
            return context.getBundleContext().getService(reference);
        } else {
            log.warn("Unable to get EnhancementEngine for Reference {} because" +
                "this {} seams already be deactivated -> return null",
                reference.getProperty(EnhancementEngine.PROPERTY_NAME),
                toString());
View Full Code Here

    }

    @Override
    public void removedService(ServiceReference reference, Object service) {
        invalidateExecutionPlan();
        ComponentContext context = this.context;
        if(context != null){
            context.getBundleContext().ungetService(reference);
        }
    }
View Full Code Here

    public static void init() throws ConfigurationException {
        Dictionary<String,Object> config = new Hashtable<String,Object>();
        config.put(LuceneLabelTokenizer.PROPERTY_TOKENIZER_FACTORY, TOKENIZER_FACTORY_CLASS);
        config.put(LuceneLabelTokenizer.PROPERTY_TOKEN_FILTER_FACTORY,TOKEN_FILTER_FACTORY_CLASSES);
        config.put(LabelTokenizer.SUPPORTED_LANUAGES, "zh");
        ComponentContext cc = new MockComponentContext(config);
        luceneLabelTokenizer = new LuceneLabelTokenizer();
        luceneLabelTokenizer.activate(cc);
    }
View Full Code Here

    @BeforeClass
    public static void init() throws ConfigurationException {
        Dictionary<String,Object> config = new Hashtable<String,Object>();
        config.put(LuceneLabelTokenizer.PROPERTY_TOKENIZER_FACTORY, TOKENIZER_FACTORY_CLASS);
        config.put(LabelTokenizer.SUPPORTED_LANUAGES, "en");
        ComponentContext cc = new MockComponentContext(config);
        luceneLabelTokenizer = new LuceneLabelTokenizer();
        luceneLabelTokenizer.activate(cc);
    }
View Full Code Here

     *            "o.s.r.project" package
     * @throws IOException
     */
    private void setUpWorkingDirectory(final String relativePath)
            throws IOException {
        final ComponentContext mockComponentContext = mock(ComponentContext.class);
        final BundleContext mockBundleContext = mock(BundleContext.class);
        when(mockComponentContext.getBundleContext()).thenReturn(
                mockBundleContext);
        final File workingDirectory = new File(
                "target/test-classes/org/springframework/roo/project",
                relativePath);
        when(
View Full Code Here

        final BundleContext mockBundleContext = mock(BundleContext.class);
        when(
                mockBundleContext
                        .getProperty(OSGiUtils.ROO_WORKING_DIRECTORY_PROPERTY))
                .thenReturn(rooWorkingDirectory);
        final ComponentContext mockComponentContext = mock(ComponentContext.class);
        when(mockComponentContext.getBundleContext()).thenReturn(
                mockBundleContext);
        return mockComponentContext;
    }
View Full Code Here

    public void testGetRooWorkingDirectory() {
        // Set up
        final BundleContext mockBundleContext = mock(BundleContext.class);
        when(mockBundleContext.getProperty(ROO_WORKING_DIRECTORY_PROPERTY))
                .thenReturn(ROO_WORKING_DIRECTORY);
        final ComponentContext mockComponentContext = mock(ComponentContext.class);
        when(mockComponentContext.getBundleContext()).thenReturn(
                mockBundleContext);

        // Invoke
        final String rooWorkingDirectory = OSGiUtils
                .getRooWorkingDirectory(mockComponentContext);
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.