Package org.osgi.service.cm

Examples of org.osgi.service.cm.ConfigurationAdmin


  private void updateConfig() {
    try {
      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);
View Full Code Here


            "             will be listed." };

    public int cmdList(Dictionary opts, Reader in, PrintWriter out,
            Session session) {
        int retcode = 1; // 1 initially not set to 0 until end of try block
        ConfigurationAdmin srvCA = null;
        try {
            srvCA = getCA();

            String[] selection = (String[]) opts.get("selection");

            Configuration[] cs = null;
            if (selection == null) {
                cs = srvCA.listConfigurations(null);
            } else {
                cs = getConfigurations(session, srvCA, selection);
            }
            if (cs == null || cs.length == 0) {
                out.println("No configurations available");
View Full Code Here

            "             Use 'current' command to see the properties",
            "             of the currently edited configuration." };

    public int cmdShow(Dictionary opts, Reader in, PrintWriter out,
            Session session) {
        ConfigurationAdmin srvCA = null;

        try {
            srvCA = getCA();
            String[] selection = (String[]) opts.get("selection");
            Configuration[] cs = getConfigurations(session, srvCA, selection);
View Full Code Here

    public int cmdCreate(Dictionary opts, Reader in, PrintWriter out,
            Session session) {
        int retcode = 1; // 1 initially not set to 0 until end of try block
        setCurrent(session, null);
        setEditingDict(session, null);
        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);
            }

            if (cfg == null) {
                throw new Exception("Failed creating configuration for " + pid);
            }
View Full Code Here

            "             configuration it will have to be refined." };

    public int cmdDelete(Dictionary opts, Reader in, PrintWriter out,
            Session session) {
        int retcode = 1; // 1 initially not set to 0 until end of try block
        ConfigurationAdmin srvCA = null;
        try {
            String selection = (String) opts.get("selection");

            srvCA = getCA();
View Full Code Here

            Session session) {
        int retcode = 1; // 1 initially not set to 0 until end of try block
        setEditingDict(session, null);
        setCurrent(session, null);

        ConfigurationAdmin srvCA = null;
        try {
            String selection = (String) opts.get("selection");

            srvCA = getCA();
View Full Code Here

    public int cmdSave(Dictionary opts, Reader in, PrintWriter out,
            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");
            }
View Full Code Here

                throw new Exception("URL Object construction failed");
            }

            AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() throws Exception {
                    ConfigurationAdmin configAdmin = null;
                    PushbackReader reader = null;
                    try {
                        configAdmin = getCA();

                        CMDataReader cmDataReader = new CMDataReader();
                        reader = new PushbackReader(new BufferedReader(
                                new InputStreamReader(url.openStream(),
                                        CMDataReader.ENCODING), 8192), 8);
                        Hashtable[] configs = cmDataReader.readCMDatas(reader);

                        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);
                            }
View Full Code Here

     * retcode; }
     */

    /** Helper method that get the CA service. */
    ConfigurationAdmin getCA() throws Exception {
        ConfigurationAdmin srvCA = null;
        if (refCA == null) {
            throw new Exception("CM service is not available");
        }
        try {
            srvCA = (ConfigurationAdmin) AccessController
View Full Code Here

        configReg = bc.registerService(ManagedServiceFactory.class.getName(),
                serverFactory, parameters);

        ServiceReference adminRef = null;
        try {
            ConfigurationAdmin admin = null;
            Configuration[] configs = null;
            try {
                adminRef = bc.getServiceReference(ConfigurationAdmin.class
                        .getName());

                // Potential start order problem!
                if (adminRef != null) {
                    admin = (ConfigurationAdmin) bc.getService(adminRef);
                    String filter = "(&(service.factoryPid=" + FACTORY_PID
                            + ")" + "(|(service.bundleLocation="
                            + bc.getBundle().getLocation() + ")"
                            + "(service.bundleLocation=NULL)"
                            + "(!(service.bundleLocation=*))))";
                    configs = admin.listConfigurations(filter);
                }
            } catch (Exception e) {
                if (log.doDebug())
                    log.debug("Exception when trying to get CM", e);
            }
View Full Code Here

TOP

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

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.