Package org.apache.felix.prefs

Examples of org.apache.felix.prefs.PreferencesImpl


    throws RepositoryException {
        this.readPreferences(prefs, session, node);
        final NodeIterator iterator = node.getNodes();
        while ( iterator.hasNext() ) {
            final Node current = iterator.nextNode();
            final PreferencesImpl impl = (PreferencesImpl)prefs.node(current.getName());
            this.readTree(impl, session, current);
        }
    }
View Full Code Here


    public PreferencesImpl load(BackingStoreManager manager, PreferencesDescription desc) throws BackingStoreException {
        final Session session = this.checkInitialized();
        try {
            final String path = this.getNodePath(desc);
            if ( session.itemExists(path) ) {
                final PreferencesImpl root = new PreferencesImpl(desc, manager);
                this.readTree(root, session, (Node)session.getItem(path));

                return root;
            }
        } catch (RepositoryException re) {
View Full Code Here

            // check for system preferences
            final PreferencesDescription systemDesc = new PreferencesDescription(bundleId, null);
            final String systemPath = this.getNodePath(systemDesc);
            if ( session.itemExists(systemPath) ) {
                final Node rootNode = (Node)session.getItem(systemPath);
                final PreferencesImpl root = new PreferencesImpl(systemDesc, manager);
                this.readTree(root, session, rootNode);
            }
            // user preferences
            final String userPath = this.rootNodePath + '/' + bundleId + '/' + "users";
            if ( session.itemExists(userPath) ) {
                final NodeIterator iterator = ((Node)session.getItem(userPath)).getNodes();
                while ( iterator.hasNext() ) {
                    final Node current = iterator.nextNode();
                    final PreferencesDescription desc = new PreferencesDescription(bundleId, current.getName());
                    final PreferencesImpl root = new PreferencesImpl(desc, manager);

                    this.readTree(root, session, current);

                    list.add(root);
                }
View Full Code Here

    protected void store(PreferencesImpl prefs, Session session)
    throws BackingStoreException, RepositoryException {
        // do we need to store at all?
        if ( prefs.getChangeSet().hasChanges() ) {
            // load existing data
            final PreferencesImpl savedData = this.load(prefs.getBackingStoreManager(), prefs.getDescription());
            if ( savedData != null ) {
                // merge with saved version
                final PreferencesImpl n = savedData.getOrCreateNode(prefs.absolutePath());
                n.applyChanges(prefs);
                prefs = n;
            }
            this.writePreferences(prefs, session);
        }
        // now process children
        @SuppressWarnings("unchecked")
        final Iterator<PreferencesImpl> i = prefs.getChildren().iterator();
        while ( i.hasNext() ) {
            final PreferencesImpl p = i.next();
            this.store(p, session);
        }

    }
View Full Code Here

    /**
     * @see org.apache.felix.prefs.BackingStore#update(org.apache.felix.prefs.PreferencesImpl)
     */
    public void update(PreferencesImpl prefs) throws BackingStoreException {
        final PreferencesImpl root = this.load(prefs.getBackingStoreManager(), prefs.getDescription());
        if ( root != null ) {
            // and now update
            if ( root.nodeExists(prefs.absolutePath()) ) {
                final PreferencesImpl updated = (PreferencesImpl)root.node(prefs.absolutePath());
                prefs.update(updated);
            }
        }
    }
View Full Code Here

    /**
     * @see org.osgi.service.prefs.PreferencesService#getSystemPreferences()
     */
    public synchronized Preferences getSystemPreferences() {
        if ( this.systemTree == null ) {
            this.systemTree = new PreferencesImpl(new PreferencesDescription(this.bundleId, null), this.storeManager);
        }
        // sync with latest version from store
        try {
            this.systemTree.sync();
        } catch (BackingStoreException ignore) {
View Full Code Here

    /**
     * @see org.osgi.service.prefs.PreferencesService#getUserPreferences(java.lang.String)
     */
    public synchronized Preferences getUserPreferences(String name) {
        PreferencesImpl result = (PreferencesImpl) this.trees.get(name);
        // if the tree does not exist yet, create it
        if (result == null || !result.isValid()) {
            result = new PreferencesImpl(new PreferencesDescription(this.bundleId, name), this.storeManager);
            this.trees.put(name, result);
        }
        // sync with latest version from store
        try {
            result.sync();
        } catch (BackingStoreException ignore) {
            // we ignore this
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.prefs.PreferencesImpl

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.