You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/02/20 21:34:37 UTC

cvs commit: cocoon-2.2/src/java/org/apache/cocoon Cocoon.java

cziegeler    2004/02/20 12:34:37

  Modified:    src/java/org/apache/cocoon/components/source/impl
                        SitemapSource.java
               src/java/org/apache/cocoon/components/container
                        ComponentContext.java
               src/java/org/apache/cocoon/environment/internal
                        EnvironmentHelper.java
               src/java/org/apache/cocoon Cocoon.java
  Removed:     src/java/org/apache/cocoon/environment/internal
                        EnvironmentContext.java
  Log:
  Remove EnvironmentContext completly and avoid storing something in the object model
  
  Revision  Changes    Path
  1.28      +9 -8      cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- SitemapSource.java	13 Feb 2004 16:03:14 -0000	1.27
  +++ SitemapSource.java	20 Feb 2004 20:34:37 -0000	1.28
  @@ -125,8 +125,8 @@
       /** Do I need a refresh ? */
       private boolean needsRefresh;
   
  -    /** The unique key for this processing */
  -    private Object processKey;
  +    /** Is start processing on the environment called? */
  +    private boolean processed;
       
       /** The used protocol */
       private String protocol;
  @@ -143,7 +143,7 @@
                            Logger         logger)
       throws MalformedURLException {
   
  -        Environment env = EnvironmentHelper.getCurrentEnvironmentContext().getEnvironment();
  +        Environment env = EnvironmentHelper.getCurrentEnvironment();
           if ( env == null ) {
               throw new MalformedURLException("The cocoon protocol can not be used outside an environment.");
           }
  @@ -303,7 +303,8 @@
       protected void init() {
           this.systemIdForCaching = this.systemId;
           try {
  -            this.processKey = EnvironmentHelper.startProcessing(this.environment);
  +            this.environment.startingProcessing();
  +            this.processed = true;
               this.pipelineDescription = this.processor.buildPipeline(this.environment);
               this.pipelineDescription.lastProcessor.getEnvironmentHelper().setContext(this.environment);
   
  @@ -409,9 +410,9 @@
               this.pipelineDescription.release();
               this.pipelineDescription = null;
           }
  -        if (this.processKey != null) {
  -            EnvironmentHelper.endProcessing(this.environment, this.processKey);
  -            this.processKey = null;
  +        if ( this.processed ) {
  +            this.processed = false;
  +            this.environment.finishingProcessing();
           }
           this.sourceValidity = null;
           if (this.redirectSource != null) {
  
  
  
  1.4       +8 -8      cocoon-2.2/src/java/org/apache/cocoon/components/container/ComponentContext.java
  
  Index: ComponentContext.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/container/ComponentContext.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ComponentContext.java	19 Jan 2004 10:38:32 -0000	1.3
  +++ ComponentContext.java	20 Feb 2004 20:34:37 -0000	1.4
  @@ -54,7 +54,7 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.cocoon.components.ContextHelper;
  -import org.apache.cocoon.environment.internal.EnvironmentContext;
  +import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.internal.EnvironmentHelper;
   
   import java.util.Map;
  @@ -119,20 +119,20 @@
       public Object get( final Object key )
       throws ContextException {
           if ( key.equals(ContextHelper.CONTEXT_OBJECT_MODEL)) {
  -            final EnvironmentContext envContext = EnvironmentHelper.getCurrentEnvironmentContext();
  -            if ( envContext == null ) {
  +            final Environment env = EnvironmentHelper.getCurrentEnvironment();
  +            if ( env == null ) {
                   throw new ContextException("Unable to locate " + key + " (No environment available)");
               }
  -            return envContext.getEnvironment().getObjectModel();
  +            return env.getObjectModel();
           }
           if ( key instanceof String ) {
               String stringKey = (String)key;
               if ( stringKey.startsWith(OBJECT_MODEL_KEY_PREFIX) ) {
  -                final EnvironmentContext envContext = EnvironmentHelper.getCurrentEnvironmentContext();
  -                if ( envContext == null ) {
  +                final Environment env = EnvironmentHelper.getCurrentEnvironment();
  +                if ( env == null ) {
                       throw new ContextException("Unable to locate " + key + " (No environment available)");
                   }
  -                final Map objectModel = envContext.getEnvironment().getObjectModel();
  +                final Map objectModel = env.getObjectModel();
                   String objectKey = stringKey.substring(OBJECT_MODEL_KEY_PREFIX.length());
   
                   Object o = objectModel.get( objectKey );
  
  
  
  1.11      +4 -52     cocoon-2.2/src/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java
  
  Index: EnvironmentHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- EnvironmentHelper.java	20 Feb 2004 19:06:21 -0000	1.10
  +++ EnvironmentHelper.java	20 Feb 2004 20:34:37 -0000	1.11
  @@ -85,10 +85,6 @@
   extends AbstractLogEnabled
   implements SourceResolver, Serviceable, Disposable {
   
  -    /** The key used to store the current environment context
  -     * in the object model */
  -    static protected final String PROCESS_KEY = EnvironmentHelper.class.getName();
  -
       /** The environment information */
       static protected final InheritableThreadLocal environmentStack = new CloningInheritableThreadLocal();
       
  @@ -421,61 +417,17 @@
       }
   
       /**
  -     * This hook has to be called before a request is processed.
  -     * The hook is called by the Cocoon component and by the
  -     * cocoon protocol implementation.
  -     * This method should never raise an exception, except when
  -     * the environment is not set.
  -     *
  -     * @return A unique key within this thread.
  -     */
  -    public static Object startProcessing(Environment env) 
  -    throws ProcessingException {
  -        if ( null == env) {
  -            throw new ProcessingException("EnvironmentHelper.startProcessing: environment must be set.");
  -        }
  -        final EnvironmentContext desc = new EnvironmentContext(env);
  -        env.getObjectModel().put(PROCESS_KEY, desc);
  -        env.startingProcessing();
  -        return desc;
  -    }
  -
  -    /**
  -     * Return the environment context
  -     * TODO: THIS WILL BE REMOVED SOON
  +     * Return the environment
        */
  -    public static EnvironmentContext getCurrentEnvironmentContext() {
  +    public static Environment getCurrentEnvironment() {
           final EnvironmentStack stack = (EnvironmentStack) environmentStack.get();
           if ( stack != null && !stack.empty() ) {
               final EnvironmentInfo info = stack.getCurrentInfo();
  -            final Map objectModel = info.environment.getObjectModel();
  -            return (EnvironmentContext)objectModel.get(PROCESS_KEY);
  +            return info.environment;
           }
           return null;
       }
       
  -    /**
  -     * Return the environment context
  -     * TODO: THIS WILL BE REMOVED SOON
  -     */
  -    public static EnvironmentContext getEnvironmentContext(Environment environment) {
  -        final Map objectModel = environment.getObjectModel();
  -        return (EnvironmentContext)objectModel.get(PROCESS_KEY);
  -    }
  -
  -    /**
  -     * This hook has to be called before a request is processed.
  -     * The hook is called by the Cocoon component and by the
  -     * cocoon protocol implementation.
  -     * @param key A unique key within this thread return by
  -     *         {@link #startProcessing(Environment)}.
  -     */
  -    public static void endProcessing(Environment env, Object key) {
  -        env.finishingProcessing();
  -        final EnvironmentContext desc = (EnvironmentContext)key;
  -        env.getObjectModel().remove(PROCESS_KEY);
  -    }
  -
       /**
        * Return the current processor
        */
  
  
  
  1.37      +5 -5      cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Cocoon.java	6 Feb 2004 11:42:46 -0000	1.36
  +++ Cocoon.java	20 Feb 2004 20:34:37 -0000	1.37
  @@ -371,7 +371,7 @@
               throw new IllegalStateException("You cannot process a Disposed Cocoon engine.");
           }
   
  -        Object key = EnvironmentHelper.startProcessing(environment);
  +        environment.startingProcessing();
           EnvironmentHelper.enterProcessor(this, this.serviceManager, environment);
           try {
               boolean result;
  @@ -399,7 +399,7 @@
               throw any;
           } finally {
               EnvironmentHelper.leaveProcessor();
  -            EnvironmentHelper.endProcessing(environment, key);
  +            environment.finishingProcessing();
               if (getLogger().isDebugEnabled()) {
                   --activeRequestCount;
               }
  @@ -470,7 +470,7 @@
       throws Exception {
           ProgramGenerator programGenerator = null;
           Source source = null;
  -        Object key = EnvironmentHelper.startProcessing(environment);
  +        environment.startingProcessing();
           EnvironmentHelper.enterProcessor(this, this.serviceManager, environment);
   
           try {
  @@ -489,7 +489,7 @@
               */
           } finally {
               EnvironmentHelper.leaveProcessor();
  -            EnvironmentHelper.endProcessing(environment, key);
  +            environment.finishingProcessing();
               this.sourceResolver.release(source);
               this.serviceManager.release(programGenerator);
           }