Package org.osgi.service.cm

Examples of org.osgi.service.cm.Configuration


      ServiceReference sr = bc
          .getServiceReference(ConfigurationAdmin.class.getName());
      if (sr != null) {
        ConfigurationAdmin ca = (ConfigurationAdmin) bc.getService(sr);
        if (ca != null) {
          Configuration conf = ca.getConfiguration(pid);
          if (conf != null) {
            conf.update(configCollection);
          }
        }
        bc.ungetService(sr);
      }
    } catch (IOException io) {
View Full Code Here


        ConfigurationAdmin srvCA = null;
        try {
            srvCA = getCA();
            String pid = (String) opts.get("pid");
            boolean createFactoryConfiguration = opts.get("-f") != null;
            Configuration cfg = null;
            if (createFactoryConfiguration) {
                cfg = srvCA.createFactoryConfiguration(pid, null);
            } else {
                cfg = srvCA.getConfiguration(pid, null);
            }
View Full Code Here

                        "Selection didn't match any configurations. "
                                + "Change your selection to match exactly "
                                + "one configuration.");
            } else if (cs.length == 1) {
                out.println("Deleting " + cs[0].getPid());
                Configuration current = getCurrent(session);
                if (current != null && current.getPid().equals(cs[0].getPid())) {
                    setCurrent(session, null);
                    setEditingDict(session, null);
                }
                cs[0].delete();
            } else {
View Full Code Here

    public final static String[] HELP_CURRENT = new String[] { "Show the currently open configuration." };

    public int cmdCurrent(Dictionary opts, Reader in, PrintWriter out,
            Session session) {
        Configuration cfg = getCurrent(session);
        if (cfg == null) {
            out.println("No configuration open currently");
        } else {
            if (isEditing(session)) {
                printDictionary(out, getEditingDict(session));
            } else {
                Dictionary d = cfg.getProperties();
                if (d == null) {
                    out.println("No properties set in current configuration");
                } else {
                    printDictionary(out, d);
                }
View Full Code Here

            Session session) {
        int retcode = 1; // 1 initially not set to 0 until end of try block
        boolean forceOptionNotSpecified = opts.get("-force") == null;
        ConfigurationAdmin srvCA = null;
        try {
            Configuration cfg = getCurrent(session);
            if (cfg == null) {
                throw new Exception("No configuration open currently");
            }
            srvCA = getCA();

            if (forceOptionNotSpecified && configurationHasChanged(srvCA, cfg)) {
                throw new Exception(
                        "The configuration has changed in CM since it was opened."
                                + "Use -force option if you want to force saving of your changes.");
            }

            if (isEditing(session)) {
                cfg.update(getEditingDict(session));
                setEditingDict(session, null);
            } else {
                throw new Exception("No changes to save");
            }
            retcode = 0; // Success!
View Full Code Here

                        for (int i = 0; i < configs.length; i++) {
                            String pid = (String) configs[i]
                                    .get(CMDataReader.SERVICE_PID);
                            String fpid = (String) configs[i]
                                    .get(CMDataReader.FACTORY_PID);
                            Configuration config;
                            if (fpid == null) {
                                config = configAdmin
                                        .getConfiguration(pid, null);
                            } else {
                                config = configAdmin
                                        .createFactoryConfiguration(fpid, null);
                            }
                            if (config.getBundleLocation() != null) {
                                config.setBundleLocation(null);
                            }
                            if (configs[i].get("service.bundleLocation") != null) {
                                configs[i].remove("service.bundleLocation");
                            }
                            config.update(configs[i]);
                        }
                    } finally {
                        if (reader != null) {
                            reader.close();
                        }
View Full Code Here

     * is set but have no dictionary set yet.*
     **************************************************************************/
    private Dictionary getEditingDict(Session session) {
        Dictionary dict = (Dictionary) session.getProperties().get(EDITED);
        if (dict == null) {
            Configuration cfg = getCurrent(session);
            if (cfg != null) {
                dict = cfg.getProperties();
            }
            if (dict == null) {
                dict = new Hashtable();
            }
            setEditingDict(session, dict);
View Full Code Here

    }

    private boolean configurationHasChanged(ConfigurationAdmin ca,
            Configuration c1) throws Exception {
        String pid = c1.getPid();
        Configuration c2 = ca.getConfiguration(pid, null);
        return DictionaryUtils.dictionariesAreNotEqual(c1.getProperties(), c2
                .getProperties());
    }
View Full Code Here

    }

    private MavenConfiguration retrieveMavenConfiguration() {
        MavenConfiguration mavenConfiguration = null;
        try {
            Configuration configuration = configurationAdmin.getConfiguration(ServiceConstants.PID);
            if (configuration != null) {
                @SuppressWarnings("rawtypes")
        Dictionary dictonary = configuration.getProperties();
                if (dictonary != null) {
                    DictionaryPropertyResolver resolver = new DictionaryPropertyResolver(dictonary);
                    mavenConfiguration = new MavenConfigurationImpl(resolver, ServiceConstants.PID);
                }
            }
View Full Code Here

        }
      Dictionary props;

      //User selected to use file instead.
      if (useFile) {
        Configuration configuration = this.findConfigurationByFileName(admin, pid);
        if(configuration == null) {
          System.err.println("Could not find configuration with file install property set to:"+pid);
          return;
        }
        props = configuration.getProperties();
        pid = (String) configuration.getPid();
      } else {
        props = admin.getConfiguration(pid).getProperties();
        if (props == null) {
          props = new Properties();
        }
View Full Code Here

TOP

Related Classes of org.osgi.service.cm.Configuration

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.