Examples of CacheManager


Examples of org.apache.cocoon.forms.CacheManager

    public Convertor build(Element element) throws Exception {
        String config = DomHelper.getAttribute(element, "config");

        Source source = null;
        SourceResolver sourceResolver = null;
        CacheManager cacheManager = null;
        try {
            cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
            sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
            source = sourceResolver.resolveURI(config);

            String prefix = HtmlCleanerTemplate.class.getName();
            HtmlCleanerTemplate template = (HtmlCleanerTemplate)cacheManager.get(source, prefix);
            if (template == null) {
                HtmlCleanerFactory factory = new HtmlCleanerFactory();
                InputSource is = SourceUtil.getInputSource(source);
                template = factory.buildTemplate(is);
                cacheManager.set(template, source, prefix);
            }

            return new HtmlCleaningConvertor(template);
        } finally {
            if (source != null)
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

                         Cacheable c)
    throws StandardException
  {
    // get the other cache. if the entry we are setting in the cache is of
    // type oidtdcacheable then use the nametdcache
    CacheManager otherCache =
      (c instanceof OIDTDCacheable) ? nameTdCache : OIDTdCache;
    Object key;
    TDCacheable otherCacheEntry = null;

    if (otherCache == nameTdCache)
      key = new TableKey(td.getSchemaDescriptor().getUUID(), td.getName());
    else
      key = td.getUUID();

    try
    {
      // insert the entry into the the other cache.
      otherCacheEntry = (TDCacheable)otherCache.create(key, td);
    }
    catch (StandardException se)
    {
      // if the object already exists in cache then somebody beat us to it
      // otherwise throw the error.
      if (!(se.getMessageId().equals(SQLState.OBJECT_EXISTS_IN_CACHE)))
        throw se;
    }
    finally
    {
      if (otherCacheEntry != null)
        otherCache.release(otherCacheEntry);
    }
  }
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

    public static void SYSCS_EMPTY_STATEMENT_CACHE()
       throws SQLException
    {
       LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
      
       CacheManager statementCache =
           lcc.getLanguageConnectionFactory().getStatementCache();
      
       if (statementCache != null)
           statementCache.ageOut();
    }
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

    public static void SYSCS_EMPTY_STATEMENT_CACHE()
       throws SQLException
    {
       LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
      
       CacheManager statementCache =
           lcc.getLanguageConnectionFactory().getStatementCache();
      
       if (statementCache != null)
           statementCache.ageOut();
    }
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

  @exception StandardException thrown if lookup goes wrong.
  */ 
  public void removeStatement(Statement statement)
    throws StandardException {
       
        CacheManager statementCache =
            getLanguageConnectionFactory().getStatementCache();

    if (statementCache == null)
      return;
      Cacheable cachedItem = statementCache.findCached(statement);
      if (cachedItem != null)
        statementCache.remove(cachedItem);
  }
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

   if none was found.
   */
  public PreparedStatement lookupStatement(GenericStatement statement)
    throws StandardException {

        CacheManager statementCache =
            getLanguageConnectionFactory().getStatementCache();
           
    if (statementCache == null)
      return null;

    // statement caching disable when in DDL mode
    if (dataDictionaryInWriteMode()) {
      return null;
    }

    Cacheable cachedItem = statementCache.find(statement);

    CachedStatement cs = (CachedStatement) cachedItem;


    GenericPreparedStatement ps = cs.getPreparedStatement();

    synchronized (ps) {
      if (ps.upToDate()) {
        GeneratedClass ac = ps.getActivationClass();

        // Check to see if the statement was prepared before some change
        // in the class loading set. If this is the case then force it to be invalid
        int currentClasses =
            getLanguageConnectionFactory().getClassFactory().getClassLoaderVersion();

        if (ac.getClassLoaderVersion() != currentClasses) {
          ps.makeInvalid(DependencyManager.INTERNAL_RECOMPILE_REQUEST, this);
        }

        // note that the PreparedStatement is not kept in the cache. This is because
        // having items kept in the cache that ultimately are held onto by
        // user code is impossible to manage. E.g. an open ResultSet would hold onto
        // a PreparedStatement (through its activation) and the user can allow
        // this object to be garbage collected. Pushing a context stack is impossible
        // in garbage collection as it may deadlock with the open connection and
        // the context manager assumes a singel current thread per context stack
      }
    }

    statementCache.release(cachedItem);
    return ps;
  }
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

    @exception StandardException thrown if lookup goes wrong.
    */ 
    public void removeStatement(GenericStatement statement)
        throws StandardException {
       
        CacheManager statementCache =
            getLanguageConnectionFactory().getStatementCache();

        if (statementCache == null)
            return;
        Cacheable cachedItem = statementCache.findCached(statement);
        // No need to do anything if the statement is already removed
        if (cachedItem != null) {
            CachedStatement cs = (CachedStatement) cachedItem;
            if (statement.getPreparedStatement() != cs.getPreparedStatement()) {
                // DERBY-3786: Someone else has removed the statement from
                // the cache, probably because of the same error that brought
                // us here. In addition, someone else has recreated the
                // statement. Since the recreated statement is not the same
                // object as the one we are working on, we don't have the
                // proper guarding (through the synchronized flag
                // GenericStatement.preparedStmt.compilingStatement) to ensure
                // that we're the only ones calling CacheManager.remove() on
                // this statement. Therefore, just release the statement here
                // so that we don't get in the way for the other thread that
                // is trying to compile the same query.
                statementCache.release(cachedItem);
            } else {
                // The statement object that we were trying to compile is still
                // in the cache. Since the compilation failed, remove it.
                statementCache.remove(cachedItem);
            }
        }
    }
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

     if none was found.
     */
    public PreparedStatement lookupStatement(GenericStatement statement)
        throws StandardException {

        CacheManager statementCache =
            getLanguageConnectionFactory().getStatementCache();
           
        if (statementCache == null)
            return null;

        // statement caching disable when in DDL mode
        if (dataDictionaryInWriteMode()) {
            return null;
        }

        Cacheable cachedItem = statementCache.find(statement);

        CachedStatement cs = (CachedStatement) cachedItem;


        GenericPreparedStatement ps = cs.getPreparedStatement();

        synchronized (ps) {
            if (ps.upToDate()) {
                GeneratedClass ac = ps.getActivationClass();

                // Check to see if the statement was prepared before some change
                // in the class loading set. If this is the case then force it to be invalid
                int currentClasses =
                        getLanguageConnectionFactory().getClassFactory().getClassLoaderVersion();

                if (ac.getClassLoaderVersion() != currentClasses) {
                    ps.makeInvalid(DependencyManager.INTERNAL_RECOMPILE_REQUEST, this);
                }

                // note that the PreparedStatement is not kept in the cache. This is because
                // having items kept in the cache that ultimately are held onto by
                // user code is impossible to manage. E.g. an open ResultSet would hold onto
                // a PreparedStatement (through its activation) and the user can allow
                // this object to be garbage collected. Pushing a context stack is impossible
                // in garbage collection as it may deadlock with the open connection and
                // the context manager assumes a singel current thread per context stack
            }
        }

        statementCache.release(cachedItem);
        return ps;
    }
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

  public StatementCache() throws SQLException {

    LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
       
        CacheManager statementCache =
            lcc.getLanguageConnectionFactory().getStatementCache();

    if (statementCache != null) {
      final Collection values = statementCache.values();
      data = new Vector(values.size());
      for (Iterator i = values.iterator(); i.hasNext(); ) {
        final CachedStatement cs = (CachedStatement) i.next();
        final GenericPreparedStatement ps =
          (GenericPreparedStatement) cs.getPreparedStatement();
View Full Code Here

Examples of org.apache.derby.iapi.services.cache.CacheManager

                         Cacheable c)
    throws StandardException
  {
    // get the other cache. if the entry we are setting in the cache is of
    // type oidtdcacheable then use the nametdcache
    CacheManager otherCache =
      (c instanceof OIDTDCacheable) ? nameTdCache : OIDTdCache;
    Object key;
    TDCacheable otherCacheEntry = null;

    if (otherCache == nameTdCache)
      key = new TableKey(td.getSchemaDescriptor().getUUID(), td.getName());
    else
      key = td.getUUID();

    try
    {
      // insert the entry into the the other cache.
      otherCacheEntry = (TDCacheable)otherCache.create(key, td);
    }
    catch (StandardException se)
    {
      // if the object already exists in cache then somebody beat us to it
      // otherwise throw the error.
      if (!(se.getMessageId().equals(SQLState.OBJECT_EXISTS_IN_CACHE)))
        throw se;
    }
    finally
    {
      if (otherCacheEntry != null)
        otherCache.release(otherCacheEntry);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.