Package org.osgi.service.deploymentadmin.spi

Examples of org.osgi.service.deploymentadmin.spi.ResourceProcessorException


        List existingResources = null;
        try {
            existingResources = persistencyManager.load(name);
        }
        catch (IOException ioe) {
            throw new ResourceProcessorException(ResourceProcessorException.CODE_PREPARE, "Unable to read existing resources for resource " + name, ioe);
        }
       
        // update configuration
        if (m_resource.isFactoryConfig()) {
            // check if this is an factory config instance update
            for (Iterator i = existingResources.iterator(); i.hasNext();) {
                AutoConfResource existingResource = (AutoConfResource) i.next();
                if (m_resource.equalsTargetConfiguration(existingResource)) {
                    // existing instance found
                    configuration = configAdmin.getConfiguration(existingResource.getGeneratedPid(), bundleLocation);
                    existingResources.remove(existingResource);
                    break;
                }
            }
            if (configuration == null) {
                // no existing instance, create new
                configuration = configAdmin.createFactoryConfiguration(m_resource.getFactoryPid(), bundleLocation);
            }
            m_resource.setGeneratedPid(configuration.getPid());
        }
        else {
            for (Iterator i = existingResources.iterator(); i.hasNext();) {
                AutoConfResource existingResource = (AutoConfResource) i.next();
                if (m_resource.getPid().equals(existingResource.getPid())) {
                    // existing resource found
                    existingResources.remove(existingResource);
                    break;
                }
            }
            configuration = configAdmin.getConfiguration(m_resource.getPid(), bundleLocation);
            if (!bundleLocation.equals(configuration.getBundleLocation())) {
                // an existing configuration exists that is bound to a different location, which is not allowed
                throw new ResourceProcessorException(ResourceProcessorException.CODE_PREPARE, "Existing configuration was bound to " + configuration.getBundleLocation() + " instead of " + bundleLocation);
            }
        }
        if (m_resource.isMerge()) {
            Dictionary existingProperties = configuration.getProperties();
            if (existingProperties != null) {
View Full Code Here

TOP

Related Classes of org.osgi.service.deploymentadmin.spi.ResourceProcessorException

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.