Package org.apache.felix.dm

Examples of org.apache.felix.dm.Component


        m_manager.remove(newService);
    }
   
    public void swapped(ServiceReference oldRef, Object oldService, ServiceReference newRef, Object newService) {
        synchronized (m_services) {
          Component service = (Component) m_services.remove(oldRef);
            if (service == null) {
                throw new IllegalStateException("Service should not be null here.");
            }         
          m_services.put(newRef, service);
        }
View Full Code Here


        }
    }
   
    // callbacks for bundles
    public void added(Bundle bundle) {
        Component newService = createService(new Object[] { bundle });
        synchronized (m_services) {
            m_services.put(bundle, newService);
        }
        m_manager.add(newService);
    }
View Full Code Here

        }
        m_manager.add(newService);
    }
   
    public void removed(Bundle bundle) {
        Component newService;
        synchronized (m_services) {
            newService = (Component) m_services.remove(bundle);
        }
        if (newService == null) {
            throw new IllegalStateException("Service should not be null here.");
View Full Code Here

            if (m_propagateCallbackInstance != null && m_propagateCallbackMethod != null) {
                resourceDependency.setPropagate(m_propagateCallbackInstance, m_propagateCallbackMethod);
            } else {
                resourceDependency.setPropagate(m_propagate);
            }
            Component service = m_manager.createComponent()
                .setInterface(m_serviceInterfaces, props)
                .setImplementation(m_serviceImpl)
                .setFactory(m_factory, m_factoryCreateMethod) // if not set, no effect
                .setComposition(m_compositionInstance, m_compositionMethod) // if not set, no effect
                .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy) // if not set, no effect
                .add(resourceDependency);
           
            configureAutoConfigState(service, m_component);

            for (int i = 0; i < dependencies.size(); i++) {
                service.add(((Dependency) dependencies.get(i)).createCopy());
            }

            for (int i = 0; i < m_stateListeners.size(); i ++) {
                service.addStateListener((ComponentStateListener) m_stateListeners.get(i));
            }
            return service;
        }
View Full Code Here

            }
            List dependencies = m_component.getDependencies();
            // the first dependency is always the dependency on the bundle, which
            // will be replaced with a more specific dependency below
            dependencies.remove(0);
            Component service = m_manager.createComponent()
                .setInterface(m_serviceInterfaces, props)
                .setImplementation(m_serviceImpl)
                .setFactory(m_factory, m_factoryCreateMethod) // if not set, no effect
                .setComposition(m_compositionInstance, m_compositionMethod) // if not set, no effect
                .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy) // if not set, no effect
                .add(m_manager.createBundleDependency()
                    .setBundle(bundle)
                    .setStateMask(m_bundleStateMask)
                    .setPropagate(m_propagate)
                    .setCallbacks(null, "changed", null)
                    .setAutoConfig(true)
                    .setRequired(true));

            for (int i = 0; i < dependencies.size(); i++) {
                service.add(((Dependency) dependencies.get(i)).createCopy());
            }

            for (int i = 0; i < m_stateListeners.size(); i ++) {
                service.addStateListener((ComponentStateListener) m_stateListeners.get(i));
            }
            configureAutoConfigState(service, m_component);
            return service;
        }
View Full Code Here

            }
            dependency.setPropagate(this, "propagateAdapteeProperties");
           
//            dependency.setDebug("AdapterDependency#" + m_adapteeInterface.getSimpleName());

            Component service = m_manager.createComponent()
                .setInterface(m_serviceInterfaces, getServiceProperties(ref))
                .setImplementation(m_serviceImpl)
                .setFactory(m_factory, m_factoryCreateMethod) // if not set, no effect
                .setComposition(m_compositionInstance, m_compositionMethod) // if not set, no effect
                .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy) // if not set, no effect
                .add(dependency);
           
            configureAutoConfigState(service, m_component);
           
            for (int i = 0; i < dependencies.size(); i++) {
                service.add(((Dependency) dependencies.get(i)).createCopy());
            }
           
            for (int i = 0; i < m_stateListeners.size(); i ++) {
                service.addStateListener((ComponentStateListener) m_stateListeners.get(i));
            }
            return service;
        }
View Full Code Here

    public void updated(String pid, Dictionary dict) throws ConfigurationException {
        String ma = (String) dict.get(MA_NAME);
        String id = (String) dict.get(IdentificationConstants.IDENTIFICATION_TARGETID_KEY);

        boolean needToAddComponent = false;
        Component component;
        synchronized (m_instances) {
            component = (Component) m_instances.get(pid);
            if (component == null) {
                Properties props = new Properties();
                if ((ma != null) && (ma.length() > 0)) {
                    props.put(MA_NAME, ma);
                }
                props.put(IdentificationConstants.IDENTIFICATION_TARGETID_KEY, id);
                component = m_manager.createComponent()
                    .setInterface(Identification.class.getName(), props)
                    .setImplementation(new PropertyBasedIdentification(id))
                    .add(createServiceDependency()
                        .setService(LogService.class)
                        .setRequired(false)
                    );
                m_instances.put(pid, component);
                needToAddComponent = true;
            }
        }
        if (needToAddComponent) {
            m_manager.add(component);
        }
        else {
            Object service = component.getService();
            if (service instanceof PropertyBasedIdentification) {
                PropertyBasedIdentification identification = (PropertyBasedIdentification) service;
                identification.setID(id);
            }
        }
View Full Code Here

            }
        }
    }

    public void deleted(String pid) {
        Component log;
        synchronized (m_instances) {
            log = (Component) m_instances.remove(pid);
        }
        if (log != null) {
            m_manager.remove(log);
View Full Code Here

        String lcFilter = launchConfiguration.getProcessLifecycleListener();
        String psFilter = launchConfiguration.getProcessStreamListener();

        // Create the proper service dependencies for the process launcher...
        if (lcFilter != null || psFilter != null) {
            Component comp = m_dependencyManager.createComponent().setImplementation(processLauncher);

            if (psFilter != null) {
                comp.add(m_dependencyManager.createServiceDependency()
                    .setService(ProcessStreamListener.class, psFilter).setRequired(false));
            }

            if (lcFilter != null) {
                comp.add(m_dependencyManager.createServiceDependency()
                    .setService(ProcessLifecycleListener.class, lcFilter).setRequired(false));
            }

            m_dependencyManager.add(comp);
        }
View Full Code Here

     * @param sessionID the session ID to use.
     */
    @SuppressWarnings("unchecked")
    private void createSessionServices(SessionData sd, String sessionID) {
        RepositoryAdminImpl rai = new RepositoryAdminImpl(sessionID);
        Component comp1 = createComponent()
            .setInterface(RepositoryAdmin.class.getName(), rai.getSessionProps())
            .setImplementation(rai)
            .setComposition("getInstances")
            .add(createServiceDependency().setService(PreferencesService.class).setRequired(true))
            .add(createServiceDependency().setService(EventAdmin.class).setRequired(true))
            .add(createServiceDependency().setService(LogService.class).setRequired(false));

        String sessionFilter = "(" + SessionFactory.SERVICE_SID + "=" + sessionID + ")";
        String auditLogFilter = "(&(" + Constants.OBJECTCLASS + "=" + LogStore.class.getName() + ")(name=auditlog))";

        Dictionary topic = new Hashtable();
        topic.put(SessionFactory.SERVICE_SID, sessionID);
        topic.put(EventConstants.EVENT_FILTER, sessionFilter);
        topic.put(EventConstants.EVENT_TOPIC, new String[] {
            ArtifactObject.TOPIC_ALL,
            Artifact2FeatureAssociation.TOPIC_ALL,
            FeatureObject.TOPIC_ALL,
            Feature2DistributionAssociation.TOPIC_ALL,
            DistributionObject.TOPIC_ALL,
            Distribution2TargetAssociation.TOPIC_ALL,
            TargetObject.TOPIC_ALL,
            DeploymentVersionObject.TOPIC_ALL,
            RepositoryAdmin.TOPIC_REFRESH,
            RepositoryAdmin.TOPIC_LOGIN
        });
       
        StatefulTargetRepositoryImpl statefulTargetRepositoryImpl = new StatefulTargetRepositoryImpl(sessionID);
        Component comp2 = createComponent()
            .setInterface(new String[] { StatefulTargetRepository.class.getName(), EventHandler.class.getName() }, topic)
            .setImplementation(statefulTargetRepositoryImpl)
            .add(createServiceDependency().setService(ArtifactRepository.class, sessionFilter).setRequired(true))
            .add(createServiceDependency().setService(TargetRepository.class, sessionFilter).setRequired(true))
            .add(createServiceDependency().setService(DeploymentVersionRepository.class, sessionFilter).setRequired(true))
View Full Code Here

TOP

Related Classes of org.apache.felix.dm.Component

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.