Package org.osgi.service.component

Examples of org.osgi.service.component.ComponentFactory


        final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
            + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
        TestCase.assertNotNull( refs );
        TestCase.assertEquals( 1, refs.length );
        final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
        TestCase.assertNotNull( factory );

        // create the factory instance
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put( "service.pid", "myFactoryInstance" );
        final ComponentInstance instance = factory.newInstance( props );
        TestCase.assertNotNull( instance );

        TestCase.assertNotNull( instance.getInstance() );

        //The referring service should now be active
View Full Code Here


       
        final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
            + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
        TestCase.assertNotNull( refs );
        TestCase.assertEquals( 1, refs.length );
        final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
        TestCase.assertNotNull( factory );

        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put( PROP_NAME_FACTORY, PROP_NAME_FACTORY );
        props.put("ref.target", "(value=service2)");
        final ComponentInstance instance = factory.newInstance( props );
        TestCase.assertNotNull( instance );

        TestCase.assertNotNull( instance.getInstance() );
        TestCase.assertEquals( SimpleComponent.INSTANCE, instance.getInstance() );
        TestCase.assertEquals( PROP_NAME_FACTORY, SimpleComponent.INSTANCE.getProperty( PROP_NAME_FACTORY ) );
View Full Code Here

       
        final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
            + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
        TestCase.assertNotNull( refs );
        TestCase.assertEquals( 1, refs.length );
        final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
        TestCase.assertNotNull( factory );
       
        s1.drop();
    }
View Full Code Here

        final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
            + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
        TestCase.assertNotNull( refs );
        TestCase.assertEquals( 1, refs.length );
        final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
        TestCase.assertNotNull( factory );

        final String factoryConfigPid = createFactoryConfiguration( componentname );
        delay();
View Full Code Here

        // create a component instance
        final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
            + ComponentConstants.COMPONENT_FACTORY + "=" + factoryPid + ")" );
        TestCase.assertNotNull( refs );
        TestCase.assertEquals( 1, refs.length );
        final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
        TestCase.assertNotNull( factory );

        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put( PROP_NAME_FACTORY, PROP_NAME_FACTORY );
        final ComponentInstance instance = factory.newInstance( props );
        TestCase.assertNotNull( instance );
        TestCase.assertNotNull( instance.getInstance() );
        TestCase.assertEquals( SimpleComponent.INSTANCE, instance.getInstance() );

        final SimpleComponent comp10 = SimpleComponent.INSTANCE;
View Full Code Here

        public void serviceChanged(ServiceEvent event) {
            Object eventComponentName = event.getServiceReference().getProperty("component.name");
            if (event.getType() == ServiceEvent.REGISTERED) {
                log.info("Process ServiceEvent for ComponentFactory {} and State REGISTERED",
                    eventComponentName);
                ComponentFactory factory =
                        (ComponentFactory) bundleContext.getService(event.getServiceReference());
                if (siteConfiguration.getEntityDereferencerType() != null
                        && siteConfiguration.getEntityDereferencerType().equals(eventComponentName)) {
                    createDereferencerComponent(factory);
                }
View Full Code Here

    public BridgeDefinitionsResource(@Context ServletContext context) {
        try {
            BundleContext bundleContext = (BundleContext) context.getAttribute(BundleContext.class.getName());
            ServiceReference serviceReference = bundleContext.getServiceReferences(null,
                MAPPING_ENGINE_COMPONENT_FACTORY_FILTER)[0];
            ComponentFactory componentFactory = (ComponentFactory) bundleContext.getService(serviceReference);
            @SuppressWarnings("rawtypes")
            ComponentInstance componentInstance = componentFactory.newInstance(new Hashtable());
            this.engine = (MappingEngine) componentInstance.getInstance();

        } catch (InvalidSyntaxException e) {
            logger.warn("Mapping engine instance could not be instantiated", e);
            throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
View Full Code Here

    public ObjectTypesResource(@Context ServletContext context) {
        try {
            BundleContext bundleContext = (BundleContext) context.getAttribute(BundleContext.class.getName());
            ServiceReference serviceReference = bundleContext.getServiceReferences(null,
                "(component.factory=org.apache.stanbol.cmsadapter.servicesapi.mapping.MappingEngineFactory)")[0];
            ComponentFactory componentFactory = (ComponentFactory) bundleContext.getService(serviceReference);
            ComponentInstance componentInstance = componentFactory
                    .newInstance(new Hashtable<Object,Object>());
            this.engine = (MappingEngine) componentInstance.getInstance();
            this.tcManager = (TcManager) ContextHelper.getServiceFromContext(TcManager.class, context);

        } catch (InvalidSyntaxException e) {
View Full Code Here

        public void serviceChanged(ServiceEvent event) {
            Object eventComponentName = event.getServiceReference().getProperty("component.name");
            if (event.getType() == ServiceEvent.REGISTERED) {
                log.info("Process ServiceEvent for ComponentFactory {} and State REGISTERED",
                    eventComponentName);
                ComponentFactory factory =
                        (ComponentFactory) bundleContext.getService(event.getServiceReference());
                if (siteConfiguration.getEntityDereferencerType() != null
                        && siteConfiguration.getEntityDereferencerType().equals(eventComponentName)) {
                    createDereferencerComponent(factory);
                }
View Full Code Here

        public void serviceChanged(ServiceEvent event) {
            Object eventComponentName = event.getServiceReference().getProperty("component.name");
            if(event.getType() == ServiceEvent.REGISTERED){
                log.info("Process ServiceEvent for ComponentFactory {} and State REGISTERED",
                        eventComponentName);
                ComponentFactory factory = (ComponentFactory)bundleContext.getService(event.getServiceReference());
                if(siteConfiguration.getEntityDereferencerType() != null &&
                        siteConfiguration.getEntityDereferencerType().equals(eventComponentName)){
                    createDereferencerComponent(factory);
                }
                if(siteConfiguration.getEntitySearcherType()!= null &&
View Full Code Here

TOP

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

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.