Package org.apache.excalibur.store

Examples of org.apache.excalibur.store.Store


  {
    this.resolver = resolver;

    setFailSafe(parameters.getParameterAsBoolean("failsafe", false));

    Store store = null;
    try
    {
      this.grammar = src;

      this.grammarSource = resolver.resolveURI(this.grammar);

      // Retrieve the parser automaton from the transient store
      store = (Store)this.manager.lookup(Store.TRANSIENT_STORE);

      ParserAutomatonEntry entry = (ParserAutomatonEntry)store.get(this.grammarSource.getURI());

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

        //SAXConfigurationHandler confighandler = new SAXConfigurationHandler();
        if (this.grammarSource.getInputStream()==null)
          throw new ProcessingException("Source '"+this.grammarSource.getURI()+"' not found");

        GrammarFactory factory = new GrammarFactory();
        SourceUtil.toSAX(this.manager, this.grammarSource, null, factory);

        //Configuration config = confighandler.getConfiguration();
        //Grammar grammar = GrammarFactory.createGrammar(config);
        Grammar grammar = factory.getGrammar();

        if (grammar==null)
          throw new ProcessingException("Error while reading the grammar from "+src);

        ParserAutomatonBuilder builder =
          new ParserAutomatonBuilder(grammar  /*, new AvalonLogger(logger)*/);

        ParserAutomaton automaton = builder.getParserAutomaton();
        setParserAutomaton(builder.getParserAutomaton());

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


  public void setup(SourceResolver resolver, Map objectmodel, String src, 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()+"'");

        if (this.lexiconSource.getInputStream()==null)
          throw new ProcessingException("Source '"+this.lexiconSource.getURI()+"' not found");

        LexiconFactory factory = new LexiconFactory();
        SourceUtil.toSAX(this.manager, this.lexiconSource, null, factory);

        Lexicon lexicon = factory.getLexicon();

        LexicalAutomatonBuilder builder =
          new LexicalAutomatonBuilder(lexicon/*, new AvalonLogger(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

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

                while (keys.hasMoreElements()) {
                    Object k = keys.nextElement();
                    if ( k instanceof String ) {
                        currentKey = (String)k;
                        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(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                delete = delete.substring(1, delete.lastIndexOf(':') + 1);
                while (keys.hasMoreElements()) {
                    Object k = keys.nextElement();
                    if ( k instanceof String ) {
                        currentKey = (String)k;
                        if (currentKey.startsWith(delete)) {
                            store.remove(currentKey);
                        }
                    }
                }
            }
        }
View Full Code Here

  public void setup(SourceResolver resolver, Map objectmodel, String src, Parameters parameters)
    throws ProcessingException, SAXException, IOException
  {
    this.resolver = resolver;

    Store store = null;

    try
    {
      this.lexicon = src;

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

      // Retrieve the parser table from the transient store
      store = (Store)this.manager.lookup(Store.TRANSIENT_STORE);

      LexicalAutomatonEntry entry = (LexicalAutomatonEntry)store.get(this.lexiconSource.getURI());

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

        if (this.lexiconSource.getInputStream()==null)
          throw new ProcessingException("Source '"+this.lexiconSource.getURI()+"' not found");

        LexiconFactory factory = new LexiconFactory();
        SourceUtil.toSAX(this.manager, this.lexiconSource, null, factory);

        Lexicon lexicon = factory.getLexicon();

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

        LexicalAutomaton automaton = builder.getLexicalAutomaton();
        setLexicalAutomaton(automaton);

        this.logger.info("Store automaton into store for '"+this.lexiconSource.getURI()+"'");

        store.store(this.lexiconSource.getURI(),
                    new LexicalAutomatonEntry(automaton, this.lexiconSource.getValidity()));
      }
      else
      {
        this.logger.info("Getting automaton from store for '"+this.lexiconSource.getURI()+"'");
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

            startGroup(ch, "Store-Janitor");
   
            // For each element in StoreJanitor
            Iterator i = this.storejanitor.iterator();
            while (i.hasNext()) {
                Store store = (Store) i.next();
                startGroup(ch, store.getClass().getName()+" (hash = 0x"+Integer.toHexString(store.hashCode())+")" );
                int size = 0;
                int empty = 0;
                atts.clear();
                atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
                ch.startElement(namespace, "value", "value", atts);
                // For each element in Store
                Enumeration e = store.keys();
                atts.clear();
                while( e.hasMoreElements() ) {
                    size++;
                    Object key  = e.nextElement();
                    Object val  = store.get( key );
                    String line = null;
                    if (val == null) {
                        empty++;
                    } else {
                        line = key + " (class: " + val.getClass().getName() + ")";
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(PortalManagerImpl.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(PortalManagerImpl.BUILDTYPE_VALUE_BASIC) ||
                    type.equals(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL)) {
                    if (type.equals(PortalManagerImpl.BUILDTYPE_VALUE_BASIC)) {
                        deleteGlobal = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false).substring(1);
                    }
                    deleteRole = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                    deleteRole = deleteRole.substring(1, deleteRole.lastIndexOf(':')+1) + PortalManagerImpl.BUILDTYPE_VALUE_ROLE;
                    deleteUser = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                    deleteUser = deleteUser.substring(1, deleteUser.lastIndexOf(':')+1) + PortalManagerImpl.BUILDTYPE_VALUE_ID;
                } else { // role
                    deleteGlobal = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_ROLE, role, null, false).substring(1);
                    deleteUser = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_ID, role, "a", false);
                    deleteUser = deleteUser.substring(1, deleteUser.length()-1);
                }

                while (keys.hasMoreElements()) {
                    Object k = keys.nextElement();
                    if ( k instanceof String ) {
                        currentKey = (String)k;
                        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(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false);
                delete = delete.substring(1, delete.lastIndexOf(':') + 1);
                while (keys.hasMoreElements()) {
                    Object k = keys.nextElement();
                    if ( k instanceof String ) {
                        currentKey = (String)k;
                        if (currentKey.startsWith(delete)) {
                            store.remove(currentKey);
                        }
                    }
                }
            }
        }
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.