Package org.osgi.service.prefs

Examples of org.osgi.service.prefs.Preferences


     * @param node
     * @throws BackingStoreException
     */
    private void clearPreferences( Preferences node ) throws BackingStoreException {
        for( String name : node.childrenNames() ) {
            Preferences child = node.node(name);
            child.removeNode();
        }
    }
View Full Code Here


     **/
    PreferencesService preferenceService = bundleContext
        .getService(bundleContext
            .getServiceReference(PreferencesService.class));
    if (preferenceService != null) {
      Preferences systemPreferences = preferenceService
          .getSystemPreferences();
      String logDirectory = systemPreferences
          .get("logDirectory", null);
      String minOSGILevel = systemPreferences
          .get("minOSGILevel", null);
      String ignoredPrefixes = systemPreferences
          .get("ignoredPrefixes", null);
      String detailedMessages = systemPreferences.get("detailedMessages", null);
     
      if (logDirectory != null && minOSGILevel != null) {       
        this.fileLogger = new LogToFile(logDirectory, Utilities.osgiLevelToJavaLevel(Integer.parseInt(minOSGILevel)));
      } else {
        this.fileLogger = null;
View Full Code Here

  private boolean getFullscreenStartup() {
    return preferences().getBoolean(FULLSCREEN_STARTUP, false);
  }

  private Preferences preferences() {
    Preferences preferences = Platform.getPreferencesService()
        .getRootNode().node(InstanceScope.SCOPE).node(ID);
    return preferences;
  }
View Full Code Here

        }
        catch (BackingStoreException e) {
            throw new ConfigurationException("none", "Internal error while validating configuration.");
        }
        for (int i = 0; i < nodes.length; i++) {
            Preferences node = m_prefs.node(nodes[i]);
            if (name.equalsIgnoreCase(node.get(RepositoryConstants.REPOSITORY_NAME, "")) && name.equalsIgnoreCase(node.get(RepositoryConstants.REPOSITORY_CUSTOMER, ""))) {
                throw new ConfigurationException("name and customer", "Name and customer combination already exists");
            }
        }

        Preferences node = m_prefs.node(pid);
        node.put(RepositoryConstants.REPOSITORY_NAME, name);
        node.put(RepositoryConstants.REPOSITORY_CUSTOMER, customer);

        Component service = m_instances.get(pid);
        if (service == null) {
            // new instance
            File dir = new File(m_baseDir, pid);
View Full Code Here

     * Helper method for login.
     */
    private Preferences getRepositoryPrefs(Preferences userPrefs, URL location, String customer, String name) {
        // Note: we can only use the getAuthority part of the URL for indexing, because the full URL will contain
        // in the protocol part.
        Preferences repoPref = userPrefs.node(location.getAuthority() + location.getPath());
        Preferences customerPref = repoPref.node(customer);
        return customerPref.node(name);
    }
View Full Code Here

            .setImplementation(repo)
            .add(m_manager.createServiceDependency()
                .setService(ConnectionFactory.class)
                .setRequired(true)));

        Preferences prefs = m_preferences.getUserPreferences(user.getName());
        Preferences repoPrefs = getRepositoryPrefs(prefs, rsd.m_location, rsd.m_customer, rsd.m_name);

        return new RepositorySet(m_changeNotifier, m_log, user, repoPrefs, repos, getCachedRepositoryFromPreferences(repo, repoPrefs), rsd.m_name, rsd.m_writeAccess);
    }
View Full Code Here

    /* ********
     * Preferences
     * ********/

    void savePreferences() {
        Preferences workingNode = m_prefs.node(PREFS_LOCAL_WORKING_STATE);
        try {
            workingNode.clear();
        }
        catch (BackingStoreException e) {
            // Something went wrong clearing the node... Too bad, this means we
            // cannot store the properties.
            m_log.log(LogService.LOG_WARNING, "Could not store all preferences for " + workingNode.absolutePath());
            e.printStackTrace();
        }
       
        for (Map.Entry<RepositoryObject, WorkingState> entry : m_workingState.entrySet()) {
            workingNode.node(entry.getKey().getDefinition()).put(PREFS_LOCAL_WORKING_STATE_VALUE, entry.getValue().toString());
        }

        m_prefs.putLong(PREFS_LOCAL_FILE_VERSION, m_repository.getMostRecentVersion());
    }
View Full Code Here

    /**
     * Only call this after the repository has been deserialized.
     */
    void loadPreferences() {
        Preferences workingNode = m_prefs.node(PREFS_LOCAL_WORKING_STATE);
        Map<String, WorkingState> entries = new HashMap<String, WorkingState>();
        // First, get all nodes and their workingstate.
        try {
            String defaultWorkingState = WorkingState.Unchanged.toString();

            for (String node : workingNode.childrenNames()) {
                String state = workingNode.node(node).get(PREFS_LOCAL_WORKING_STATE_VALUE, defaultWorkingState);
                entries.put(node, WorkingState.valueOf(state));
            }
        }
        catch (BackingStoreException e) {
            // Something went wrong reading from the store, just work with whatever we have in the map.
            m_log.log(LogService.LOG_WARNING, "Could not load all preferences for " + workingNode.absolutePath());
            e.printStackTrace();
        }
        // Then, go through all objects and check whether they match a definition we know.
        // This prevents calling getDefinition more than once per object.
        for (ObjectRepository<RepositoryObject> repo : m_repos) {
View Full Code Here

        }
    }
   
    protected void saveState() {
        try {
            Preferences prefs = preferences.getUserPreferences("FeaturesServiceState");
            saveSet(prefs.node("repositories"), repositories.keySet());
            saveMap(prefs.node("features"), installed);
            prefs.flush();
        } catch (Exception e) {
            LOGGER.error("Error persisting FeaturesService state", e);
        }
    }
View Full Code Here

        }
    }

    protected boolean loadState() {
        try {
            Preferences prefs = preferences.getUserPreferences("FeaturesServiceState");
            if (prefs.nodeExists("repositories")) {
                Set<URI> repositories = loadSet(prefs.node("repositories"));
                for (URI repo : repositories) {
                    internalAddRepository(repo);
                }
                installed = loadMap(prefs.node("features"));
                return true;
            }
        } catch (Exception e) {
            LOGGER.error("Error loading FeaturesService state", e);
        }
View Full Code Here

TOP

Related Classes of org.osgi.service.prefs.Preferences

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.