Package com.volantis.osgi.cm.service

Examples of com.volantis.osgi.cm.service.ServiceAssociation


        String pid = configuration.getPid();
        String factoryPid = configuration.getFactoryPid();
        if (factoryPid == null) {

            // Create the assocation.
            ServiceAssociation association = new ServiceAssociation(
                    log, pid, configuration);

            // Store the association away, making sure that it does not clash
            // with another association.
            if (pid2Association.containsKey(pid)) {
                throw new IllegalStateException("PID '" + pid + "' clashes");
            }
            pid2Association.put(pid, association);
        } else {

            // Get the factory association.
            FactoryAssociation association = getFactoryAssociation(factoryPid);

            // Add a configuration object to the factory association.
            association.addConfiguration(configuration);
        }

        // Store the configuration away, making sure that it does not clash
        // with another configuration.
        if (pid2Configuration.containsKey(pid)) {
View Full Code Here


     * @param pid The pid.
     * @return The association.
     */
    private ServiceAssociation getServiceAssociation(String pid) {

        ServiceAssociation serviceAssociation;
        Association association = (Association) pid2Association.get(pid);
        if (association == null) {

            // No association has been registered by anyone so it is ok to
            // use, without permission.
            serviceAssociation = new ServiceAssociation(log, pid, null);

            pid2Association.put(pid, serviceAssociation);

        } else if (association instanceof ServiceAssociation) {

View Full Code Here

                            "configuration for other bundles");
        }

        // Get the association for the PID. This may use an existing
        // association, or create a new one.
        ServiceAssociation association = getServiceAssociation(pid);

        // Make sure that the association has a configuration associated with
        // it.
        InternalConfiguration configuration;
        configuration = association.getConfiguration();
        if (configuration == null) {
            configuration = store.createConfiguration(pid, bundleLocation);
            association.setConfiguration(configuration);

            pid2Configuration.put(pid, configuration);
        }

        String boundLocation =
                configuration.getBundleLocation();
        if (boundLocation == null) {
            if (usingAdminMethod) {
                // The specification specifically states that the admin
                // method must not update the bundle location of an
                // already existing configuration (if this configuration
                // was newly created in this method then it would already
                // have been bound). The presumption is that the caller
                // will use the accessors on the configuration itself to
                // manage the bundle location.
            } else {
                // The non admin method must bind the configuration to
                // the location of the calling bundle.
                configuration.setSpecifiedLocation(bundleLocation);
            }

        } else if (!boundLocation.equals(callingLocation)) {

            if (!hasConfigurationPermission) {
                // The configuration has been bound to another location but
                // the caller does not have permission to modify the
                // configuration of other bundles so this must fail.
                throw new SecurityException(
                        "Bundle '" + callingLocation +
                                "' does not have permission to create " +
                                "configuration for " +
                                FrameworkConstants.SERVICE_PID +
                                " '" + pid +
                                "' which is bound to bundle '" +
                                boundLocation + "'");
            }
        }

        // If the association has already been bound to a specific location
        // then try and bind the configuration to the same location.
        String serviceLocation = association.getBundleLocation();
        if (serviceLocation != null) {
            configuration.bindToLocation(serviceLocation);
        }

        // Return the configuration.
View Full Code Here

        // to dispatch events and store the configuration.
        pid = configuration.getPid();
        factoryPid = configuration.getFactoryPid();

        if (factoryPid == null) {
            ServiceAssociation association = (ServiceAssociation)
                    pid2Association.get(pid);
            if (association == null) {
                // Shouldn't happen.
            } else {
                // Remove the configuration from the association.
                association.setConfiguration(null);

                if (association.hasConfiguration()
                        || association.hasTargets()) {

                    dispatcher.managedServiceConfigurationDeleted(pid,
                            association.getConfigurationTargets());
                } else {
                    // The association has no configuration and no targets so
                    // discard it to prevent it becoming a memory leak.
                    pid2Association.remove(pid);
                }
            }
        } else {
            FactoryAssociation association = (FactoryAssociation)
                    pid2Association.get(factoryPid);
            if (association == null) {
                // Shouldn't happen.
            } else {
                // Remove the configuration from the association.
                association.removeConfiguration(pid);

                if (association.hasConfiguration() ||
                        association.hasTargets()) {
                    dispatcher.managedServiceFactoryConfigurationDeleted(
                            factoryPid,
                            pid, association.getConfigurationTargets());
                } else {
                    // The association is not useful so discard it.
                    pid2Association.remove(factoryPid);
                }
            }
View Full Code Here

     */
    private void serviceRegisteredInternal(
            String pid, ServiceReference reference) {

        // Get an association for the service creating one if necessary.
        ServiceAssociation association = getServiceAssociation(pid);

        // Attempt to bind the target to the association if it cannot then
        // return immediately.
        if (!bindTargetToAssociation(association, reference)) {
            return;
        }

        // Get the configuration.
        ConfigurationSnapshot snapshot;
        InternalConfiguration configuration =
                association.getConfiguration();
        if (configuration == null) {
            // No configuration is available.
            snapshot = null;
        } else {
            snapshot = configuration.createSnapshot();
View Full Code Here

        String newPid = getServicePID(reference);

        // The properties associated with the ManagedService have changed
        // so that could include the pid. Get the association that was used
        // for this reference.
        ServiceAssociation association =
                (ServiceAssociation) reference2Association.get(reference);
        if (association == null) {
            // When this service registered there was a problem attempting
            // to create an association probably because it used a pid that
            // was already bound to some other bundle. The pid may have
            // changed so try again.
        } else {

            String currentPid = association.getServicePid();

            // If the pid hasn't changed then this has no impact.
            if (currentPid.equals(newPid)) {
                return;
            }
View Full Code Here

    // Javadoc inherited.
    public synchronized void serviceUnregistering(ServiceReference reference) {

        // Get the association for this service.
        ServiceAssociation association = (ServiceAssociation)
                reference2Association.get(reference);
        if (association == null) {
            // When this service registered there was a problem attempting
            // to create an association so just return. It was probably
            // because it used a pid that was already bound to some other
View Full Code Here

TOP

Related Classes of com.volantis.osgi.cm.service.ServiceAssociation

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.