cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/acting AbstractComplementaryConfigurableAction.java
Date Sat, 06 Apr 2002 06:26:10 GMT
vgritsenko    02/04/05 22:26:10

  Modified:    src/java/org/apache/cocoon/acting
                        AbstractComplementaryConfigurableAction.java
  Log:
  1. Use resource resolver to resolve resources
  2. Check time stamp on !=
  3. Cache descriptors using system ID
  
  Revision  Changes    Path
  1.7       +30 -52    xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractComplementaryConfigurableAction.java
  
  Index: AbstractComplementaryConfigurableAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractComplementaryConfigurableAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractComplementaryConfigurableAction.java	22 Feb 2002 06:59:26 -0000	1.6
  +++ AbstractComplementaryConfigurableAction.java	6 Apr 2002 06:26:10 -0000	1.7
  @@ -50,15 +50,12 @@
   */
   package org.apache.cocoon.acting;
   
  -import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.components.source.SourceHandler;
   import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.environment.Environment;
   
   import java.util.HashMap;
   import java.util.Map;
  @@ -71,7 +68,7 @@
    * effective.  The name of the root configuration element is irrelevant.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Id: AbstractComplementaryConfigurableAction.java,v 1.6 2002/02/22 06:59:26
cziegeler Exp $
  + * @version CVS $Id: AbstractComplementaryConfigurableAction.java,v 1.7 2002/04/06 06:26:10
vgritsenko Exp $
    */
   public abstract class AbstractComplementaryConfigurableAction extends ConfigurableComposerAction
{
       private static Map configurations = new HashMap();
  @@ -85,10 +82,10 @@
        * Defaults to reload configuration file it has changed.
        */
       protected Configuration getConfiguration(String descriptor) throws ConfigurationException
{
  -    boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  -    if (this.settings.containsKey("reloadable"))
  -        reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  -    return this.getConfiguration(descriptor, null, reloadable);
  +        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  +        if (this.settings.containsKey("reloadable"))
  +            reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  +        return this.getConfiguration(descriptor, null, reloadable);
       }
   
       /**
  @@ -113,55 +110,36 @@
           }
   
           synchronized (AbstractComplementaryConfigurableAction.configurations) {
  -            conf = (ConfigurationHelper) AbstractComplementaryConfigurableAction.configurations.get(descriptor);
  +            Source resource = null;
  +            try {
  +                resource = resolver.resolve(descriptor);
  +                conf = (ConfigurationHelper) AbstractComplementaryConfigurableAction.configurations.get(resource.getSystemId());
  +                if (conf == null || (reloadable && conf.lastModified != resource.getLastModified()))
{
  +                    getLogger().debug("(Re)Loading " + descriptor);
   
  -            if (reloadable || conf == null) {
  -                SourceHandler sourceHandler = null;
  -                Source resource = null;
  -
  -                try {
  -                    sourceHandler = (SourceHandler) this.manager.lookup(SourceHandler.ROLE);
  -                    if (descriptor.startsWith("file:")) {
  -                        resource = sourceHandler.getSource((Environment)resolver,((Environment)resolver).getContext(),
descriptor.substring(5));
  -                    } else
  -                        resource = sourceHandler.getSource(null, descriptor);
  -
  -                    if (conf == null || conf.lastModified < resource.getLastModified())
{
  -                        getLogger().debug("(Re)Loading " + descriptor);
  -                        if (conf == null)
  -                            conf = new ConfigurationHelper();
  -
  -                        SAXConfigurationHandler builder = new SAXConfigurationHandler();
  -                        resource.toSAX(builder);
  -
  -                        conf.lastModified = resource.getLastModified();
  -                        conf.configuration = builder.getConfiguration();
  -
  -                        this.cacheConfiguration(descriptor, conf);
  -                    } else {
  -                        getLogger().debug("Using cached configuration for " + descriptor);
  +                    if (conf == null) {
  +                        conf = new ConfigurationHelper();
                       }
  -                } catch (Exception e) {
  -                    getLogger().error("Could not configure Database mapping environment",
e);
  -                    throw new ConfigurationException("Error trying to load configurations
for resource: " + (resource == null ? "null" : resource.getSystemId()));
  -                } finally {
  -                    if (resource != null) resource.recycle();
  -                    this.manager.release(sourceHandler);
  +
  +                    SAXConfigurationHandler builder = new SAXConfigurationHandler();
  +                    resource.toSAX(builder);
  +
  +                    conf.lastModified = resource.getLastModified();
  +                    conf.configuration = builder.getConfiguration();
  +
  +                    AbstractComplementaryConfigurableAction.configurations.put(resource.getSystemId(),
conf);
  +                } else {
  +                    getLogger().debug("Using cached configuration for " + descriptor);
                   }
  -        } else {
  -        getLogger().debug("Using fixed cached configuration for " + descriptor);
  -        }
  +            } catch (Exception e) {
  +                getLogger().error("Could not configure Database mapping environment", e);
  +                throw new ConfigurationException("Error trying to load configurations for
resource: "
  +                    + (resource == null ? "null" : resource.getSystemId()));
  +            } finally {
  +                if (resource != null) resource.recycle();
  +            }
           }
   
           return conf.configuration;
  -    }
  -
  -    /**
  -     * Cache the configuration so that we can use it later.
  -     */
  -    private void cacheConfiguration(String descriptor, ConfigurationHelper conf) {
  -        synchronized (AbstractComplementaryConfigurableAction.configurations) {
  -            AbstractComplementaryConfigurableAction.configurations.put(descriptor, conf);
  -        }
       }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message