Package org.apache.excalibur.store

Examples of org.apache.excalibur.store.Store


    public void generate() throws SAXException {
        // Obtain the fragmentID  (which is simply the filename portion of the source)
        getLogger().debug("FragmentExtractorGenerator retrieving document " + source + ".");

        Store store = null;
        XMLDeserializer deserializer = null;
        Object fragment = null;
        try {
            store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
            fragment = store.get(source);

            if (fragment==null)
              throw new SAXException("Could not find frament with id " + source + " in store");

            deserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
View Full Code Here


        try {
            if (configuration != null && this.getIsAdminProfile(profileID) == false) {
                final String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
                if (storePrefix != null) {
                    final String key = profileID.substring(1);
                    final Store store = this.getProfileStore();
                    if (store.containsKey(key) == true) {
                        result = (Map)store.get(key);
                    }
                }
            }
        } catch (Exception local) {
            // local exceptions are ignored
View Full Code Here

        if (configuration != null
            && type != null
            && type.equals(PortalManager.BUILDTYPE_VALUE_ID) == false) {
            String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
            if (storePrefix != null) {
                Store store = this.getProfileStore();
                Enumeration keys = store.keys();
                String   currentKey;
                String  deleteGlobal = null;
                String  deleteRole = null;
                String  deleteUser = null;

                if (type.equals(PortalManager.BUILDTYPE_VALUE_BASIC) == true ||
                    type.equals(PortalManager.BUILDTYPE_VALUE_GLOBAL) == true) {
                    if (type.equals(PortalManager.BUILDTYPE_VALUE_BASIC) == true) {
                        deleteGlobal = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false).substring(1);
                    }
                    deleteRole = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                    deleteRole = deleteRole.substring(1, deleteRole.lastIndexOf(':')+1) + PortalManager.BUILDTYPE_VALUE_ROLE;
                    deleteUser = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                    deleteUser = deleteUser.substring(1, deleteUser.lastIndexOf(':')+1) + PortalManager.BUILDTYPE_VALUE_ID;
                } else { // role
                    deleteGlobal = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, false).substring(1);
                    deleteUser = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ID, role, "a", false);
                    deleteUser = deleteUser.substring(1, deleteUser.length()-1);
                }

                while (keys.hasMoreElements() == true) {
                    currentKey = (String)keys.nextElement();
                    if (deleteGlobal != null && currentKey.equals(deleteGlobal) == true) {
                        store.remove(currentKey);
                    } else if (deleteRole != null && currentKey.startsWith(deleteRole) == true) {
                        store.remove(currentKey);
                    } else if (deleteUser != null && currentKey.startsWith(deleteUser) == true) {
                        store.remove(currentKey);
                    }
                }
            }
        } else if (configuration != null && type == null) {
            // clean whole cache
            String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
            if (storePrefix != null) {
                Store store = this.getProfileStore();
                Enumeration keys = store.keys();
                String currentKey;
                String delete;

                delete = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                delete = delete.substring(1, delete.lastIndexOf(':') + 1);
                while (keys.hasMoreElements() == true) {
                    currentKey = (String)keys.nextElement();
                    if (currentKey.startsWith(delete) == true) {
                        store.remove(currentKey);
                    }
                }
            }
        }
View Full Code Here

                            (String)entry.getKey()
                        );
                    }
                    this.serializer.endDocument();

                    Store store = null;
                    String id = Long.toHexString((hashCode()^HashUtil.hash(requestURI))+fragmentID);
                    try {
                        store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);

                        store.store(id, this.serializer.getSAXFragment());
                    } catch (ComponentException ce) {
                        throw new SAXException("Could not lookup for transient store.", ce);
                    } catch (IOException ioe) {
                        throw new SAXException("Could not store fragment.", ioe);
                    } finally
View Full Code Here

     *@param  remove  The number of items to be removed.
     *@return         the remaining count of items, that could not be removed.
     *@since
     */
    private int reduceStoreBy(int remove) {
        Store store = (Store) storelist.get(index);
        int sizeBefore = countSize(store);
        for (int i = 0; i < sizeBefore & remove > 0; i++, remove--) {
            store.free();
        }
        int sizeAfter = countSize(store);
        debug("store index=" + index + ", size before=" + sizeBefore + ",  size after=" + sizeAfter + ", removed=" + (sizeBefore - sizeAfter));
        return remove;
    }
View Full Code Here

                      Parameters parameters)
                        throws ProcessingException, SAXException,
                               IOException {

        this.resolver = resolver;
        Store store = null;

        try {
            this.lexicon = src;

            this.lexiconSource = resolver.resolveURI(this.lexicon);

            // Retrieve the lexical automaton from the transient store
            store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
            LexicalAutomatonEntry entry = (LexicalAutomatonEntry) store.get(this.lexiconSource.getURI());

            // If the lexicon has changed, rebuild the lexical automaton
            if ((entry==null) || (entry.getValidity()==null) ||
                (entry.getValidity().isValid(this.lexiconSource.getValidity())<=
                 0)) {
                this.logger.info("(Re)building the automaton from '"+
                                 this.lexiconSource.getURI()+"'");

                SAXConfigurationHandler confighandler = new SAXConfigurationHandler();

                if (this.lexiconSource.getInputStream()==null) {
                    throw new ProcessingException("Source '"+
                                                  this.lexiconSource.getURI()+
                                                  "' not found");
                }
                SourceUtil.toSAX(this.manager, this.lexiconSource, null, confighandler);

                Configuration config = confighandler.getConfiguration();
                Lexicon lexicon = LexiconFactory.createLexicon(config);

                LexicalAutomatonBuilder builder = new LexicalAutomatonBuilder(lexicon,
                                                      this.logger);

                this.automaton = builder.getLexicalAutomaton();

                this.logger.info("Store automaton into store for '"+
                                 this.lexiconSource.getURI()+"'");
                store.store(this.lexiconSource.getURI(),
                            new LexicalAutomatonEntry(this.automaton,
                                                      this.lexiconSource.getValidity()));
            } else {
                this.logger.info("Getting automaton from store for '"+
                                 this.lexiconSource.getURI()+"'");
View Full Code Here

                }
                setIndex(0);
            }

            // Delete proportionate elements out of the store as configured.
            Store store = (Store)getStoreList().get(getIndex());
            int limit = calcToFree(store);
            if (getLogger().isDebugEnabled())
            {
                getLogger().debug("Freeing " + limit + " items from store N " + getIndex());
            }
            for (int i=0; i < limit; i++)
            {
                try
                {
                    store.free();
                }
                catch (OutOfMemoryError e)
                {
                    getLogger().error("OutOfMemoryError in freeMemory()");
                }
View Full Code Here

        try {
            if (configuration != null && !this.getIsAdminProfile(profileID)) {
                final String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
                if (storePrefix != null) {
                    final String key = profileID.substring(1);
                    final Store store = this.getProfileStore();
                    if (store.containsKey(key)) {
                        result = (Map)store.get(key);
                    }
                }
            }
        } catch (Exception local) {
            // local exceptions are ignored
View Full Code Here

        if (configuration != null
            && type != null
            && !type.equals(PortalManager.BUILDTYPE_VALUE_ID)) {
            String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
            if (storePrefix != null) {
                Store store = this.getProfileStore();
                Enumeration keys = store.keys();
                String   currentKey;
                String  deleteGlobal = null;
                String  deleteRole = null;
                String  deleteUser = null;

                if (type.equals(PortalManager.BUILDTYPE_VALUE_BASIC) ||
                    type.equals(PortalManager.BUILDTYPE_VALUE_GLOBAL)) {
                    if (type.equals(PortalManager.BUILDTYPE_VALUE_BASIC)) {
                        deleteGlobal = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false).substring(1);
                    }
                    deleteRole = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                    deleteRole = deleteRole.substring(1, deleteRole.lastIndexOf(':')+1) + PortalManager.BUILDTYPE_VALUE_ROLE;
                    deleteUser = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                    deleteUser = deleteUser.substring(1, deleteUser.lastIndexOf(':')+1) + PortalManager.BUILDTYPE_VALUE_ID;
                } else { // role
                    deleteGlobal = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, false).substring(1);
                    deleteUser = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ID, role, "a", false);
                    deleteUser = deleteUser.substring(1, deleteUser.length()-1);
                }

                while (keys.hasMoreElements()) {
                    currentKey = (String)keys.nextElement();
                    if (deleteGlobal != null && currentKey.equals(deleteGlobal)) {
                        store.remove(currentKey);
                    } else if (deleteRole != null && currentKey.startsWith(deleteRole)) {
                        store.remove(currentKey);
                    } else if (deleteUser != null && currentKey.startsWith(deleteUser)) {
                        store.remove(currentKey);
                    }
                }
            }
        } else if (configuration != null && type == null) {
            // clean whole cache
            String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
            if (storePrefix != null) {
                Store store = this.getProfileStore();
                Enumeration keys = store.keys();
                String currentKey;
                String delete;

                delete = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                delete = delete.substring(1, delete.lastIndexOf(':') + 1);
                while (keys.hasMoreElements()) {
                    currentKey = (String)keys.nextElement();
                    if (currentKey.startsWith(delete)) {
                        store.remove(currentKey);
                    }
                }
            }
        }
View Full Code Here

                            (String)entry.getKey()
                        );
                    }
                    this.serializer.endDocument();

                    Store store = null;
                    String id = Long.toHexString((hashCode()^HashUtil.hash(requestURI))+fragmentID);
                    try {
                        store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);

                        store.store(id, this.serializer.getSAXFragment());
                    } catch (ComponentException ce) {
                        throw new SAXException("Could not lookup for transient store.", ce);
                    } catch (IOException ioe) {
                        throw new SAXException("Could not store fragment.", ioe);
                    } finally
View Full Code Here

TOP

Related Classes of org.apache.excalibur.store.Store

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.