cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript JSCocoon.java
Date Mon, 03 Mar 2003 18:39:37 GMT
cziegeler    2003/03/03 10:39:37

  Modified:    src/java/org/apache/cocoon Cocoon.java
               src/java/org/apache/cocoon/environment/wrapper
                        EnvironmentWrapper.java
               src/java/org/apache/cocoon/components/flow
                        AbstractInterpreter.java
               src/java/org/apache/cocoon/components
                        CocoonComponentManager.java
               src/java/org/apache/cocoon/components/source/impl
                        SitemapSource.java
               src/java/org/apache/cocoon/environment
                        AbstractEnvironment.java Environment.java
               src/java/org/apache/cocoon/components/treeprocessor/sitemap
                        CallFunctionNode.java ContinueNode.java
               src/java/org/apache/cocoon/components/treeprocessor
                        TreeProcessor.java
               src/deprecated/java/org/apache/cocoon/components/source
                        SitemapSource.java
               src/java/org/apache/cocoon/components/flow/javascript
                        JSCocoon.java
  Log:
  Refactoring internal component manager handling. This removes
  most hacks and cleans-up the environment interface. The 
  remaining part is to remove the setComponents() method.
  This change might break sub-sitemap handling and the cocoon protocol;
  so please be patient if you experience any problems (this is real alpha stuff :) )
  
  Revision  Changes    Path
  1.53      +2 -2      xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- Cocoon.java	28 Feb 2003 00:22:49 -0000	1.52
  +++ Cocoon.java	3 Mar 2003 18:39:35 -0000	1.53
  @@ -588,7 +588,7 @@
           Object key = CocoonComponentManager.startProcessing(environment);
           try {
               CocoonComponentManager.enterEnvironment(environment,
  -                                                    environment.getObjectModel(),
  +                                                    this.componentManager,
                                                       this);
               boolean result;
               if (this.getLogger().isDebugEnabled()) {
  
  
  
  1.28      +13 -21    xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
  
  Index: EnvironmentWrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- EnvironmentWrapper.java	6 Feb 2003 15:13:22 -0000	1.27
  +++ EnvironmentWrapper.java	3 Mar 2003 18:39:35 -0000	1.28
  @@ -149,7 +149,6 @@
           this.setComponents(env.getSourceResolver(), env.getXMLizer());
           this.enableLogging(logger);
           this.environment = env;
  -        this.manager = manager;
   
           this.context = env.getContext();
           this.prefix = new StringBuffer(env.getURIPrefix());
  @@ -202,18 +201,6 @@
       }
   
       /**
  -     * The treeprocessor sets up new managers per sitemap. Set the
  -     * "current" one for this environment.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        super.setComponentManager( manager );
  -        // HACK: As processing enters sitemap, capture current processor.
  -        // If pipeline is successfully assembled, this will contain proper processor.
  -        // Used by cocoon protocol.
  -        this.processor = CocoonComponentManager.getCurrentProcessor();
  -    }
  -
  -    /**
        * Get the output stream
        */
       public OutputStream getOutputStream()
  @@ -223,13 +210,12 @@
           : this.outputStream;
       }
   
  -  public OutputStream getOutputStream(int bufferSize)
  -    throws IOException
  -  {
  -    return this.outputStream == null
  -      ? this.environment.getOutputStream()
  -      : this.outputStream;
  -  }
  +    public OutputStream getOutputStream(int bufferSize)
  +    throws IOException {
  +        return this.outputStream == null
  +                ? this.environment.getOutputStream()
  +                : this.outputStream;
  +    }
   
       /**
        * Set the output stream for this environment. It hides the one of the
  @@ -337,6 +323,12 @@
   
       public void changeContext(String prefix, String context)
       throws MalformedURLException {
  +		// HACK: As processing enters sitemap, capture current processor.
  +		// If pipeline is successfully assembled, this will contain proper processor.
  +		// Used by cocoon protocol.
  +		// FIXME (CZ) : Is this the right place? This was before
  +		//               in the setComponentManager method!
  +		this.processor = CocoonComponentManager.getCurrentProcessor();
           super.changeContext(prefix, context);
           this.lastContext = this.context;
           this.lastPrefix  = this.prefix.toString();
  
  
  
  1.13      +1 -1      xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java
  
  Index: AbstractInterpreter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AbstractInterpreter.java	26 Feb 2003 17:15:40 -0000	1.12
  +++ AbstractInterpreter.java	3 Mar 2003 18:39:35 -0000	1.13
  @@ -194,7 +194,7 @@
           processor = (Processor)this.manager.lookup(Processor.ROLE);
   
           // Enter the environment
  -        CocoonComponentManager.enterEnvironment(wrapper, wrapper.getObjectModel(), processor);
  +        CocoonComponentManager.enterEnvironment(wrapper, this.manager, processor);
   
           // Process the subrequest
           result = processor.process(wrapper);
  
  
  
  1.48      +26 -18    xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- CocoonComponentManager.java	3 Mar 2003 18:08:53 -0000	1.47
  +++ CocoonComponentManager.java	3 Mar 2003 18:39:36 -0000	1.48
  @@ -105,41 +105,45 @@
       /** The {@link RoleManager} */
       private RoleManager roleManager;
   
  +    /** The root component manager */
  +    private static ComponentManager rootManager;
  +    
       /** Create the ComponentManager */
  -    public CocoonComponentManager()
  -    {
  +    public CocoonComponentManager(){
           super( null, Thread.currentThread().getContextClassLoader() );
  +        if ( null == rootManager ) rootManager = this;
       }
   
       /** Create the ComponentManager with a Classloader */
  -    public CocoonComponentManager( final ClassLoader loader )
  -    {
  +    public CocoonComponentManager( final ClassLoader loader ) {
           super( null, loader );
  +		if ( null == rootManager ) rootManager = this;
       }
   
       /** Create the ComponentManager with a Classloader and parent ComponentManager */
  -    public CocoonComponentManager( final ComponentManager manager, final ClassLoader loader
)
  -    {
  +    public CocoonComponentManager( final ComponentManager manager, final ClassLoader loader
) {
           super(manager, loader);
  +		if ( null == rootManager ) rootManager = this;
       }
   
       /** Create the ComponentManager with a parent ComponentManager */
  -    public CocoonComponentManager(final ComponentManager manager)
  -    {
  +    public CocoonComponentManager(final ComponentManager manager) {
           super(manager);
  +		if ( null == rootManager ) rootManager = this;
       }
   
       /**
        * This hook must be called by the sitemap each time a sitemap is entered
        */
  -    public static void enterEnvironment(Environment env,
  -                                          Map         objectModel,
  -                                          Processor   processor) {
  +    public static void enterEnvironment(Environment      env,
  +                                          ComponentManager manager,
  +                                          Processor        processor) {
  +        final Map objectModel = env.getObjectModel();
           if (environmentStack.get() == null) {
               environmentStack.set(new EnvironmentStack());
           }
           final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
  -        stack.push(new Object[] {env, processor});
  +        stack.push(new Object[] {env, processor, manager});
           
           EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
           if ( null != desc ) {
  @@ -223,11 +227,15 @@
        * FIXME: Do we really want to expose this?
        */
       static public ComponentManager getSitemapComponentManager() {
  -        Environment env = getCurrentEnvironment();
  -        if ( null != env ) {
  -        	return env.getComponentManager();
  -        }
  -        return null;
  +		final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
  +
  +		if ( null != stack && !stack.empty()) {
  +			Object[] o = (Object[])stack.peek();
  +			return (ComponentManager)o[2];
  +		}
  +
  +        // if we don't have an environment yet, just return the root manager
  +        return rootManager;
       }
       
       /**
  
  
  
  1.39      +4 -4      xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- SitemapSource.java	31 Jan 2003 22:51:34 -0000	1.38
  +++ SitemapSource.java	3 Mar 2003 18:39:36 -0000	1.39
  @@ -267,7 +267,7 @@
               this.environment.setOutputStream(os);
               try {
                   CocoonComponentManager.enterEnvironment(this.environment,
  -                                                        this.environment.getObjectModel(),
  +                                                        this.manager,
                                                           this.pipelineProcessor);
                   this.processingPipeline.process(this.environment);
               } finally {
  @@ -352,7 +352,7 @@
                   int currentOffset = envStack.getOffset();
                   try {
                       CocoonComponentManager.enterEnvironment(this.environment,
  -                                                            this.environment.getObjectModel(),
  +                                                            this.manager,
                                                               this.pipelineProcessor);
                       this.processingPipeline.prepareInternal(this.environment);
                       this.sourceValidity = this.processingPipeline.getValidityForEventPipeline();
  @@ -408,7 +408,7 @@
                   int currentOffset = envStack.getOffset();
                   try {
                       CocoonComponentManager.enterEnvironment(this.environment,
  -                                                            this.environment.getObjectModel(),
  +                                                            this.manager,
                                                               this.pipelineProcessor);
                       this.processingPipeline.process(this.environment, new EnvironmentChanger(consumer,
envStack));
                   } finally {
  
  
  
  1.44      +1 -21     xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java
  
  Index: AbstractEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- AbstractEnvironment.java	3 Mar 2003 18:08:54 -0000	1.43
  +++ AbstractEnvironment.java	3 Mar 2003 18:39:36 -0000	1.44
  @@ -52,7 +52,6 @@
   
   import org.apache.commons.collections.IteratorEnumeration;
   
  -import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   
   import org.apache.cocoon.ProcessingException;
  @@ -114,30 +113,11 @@
       /** The attributes */
       private Map attributes = new HashMap();
   
  -    /** The current manager */
  -    protected ComponentManager manager;
  -
       /** The secure Output Stream */
       protected BufferedOutputStream secureOutputStream;
   
       /** The real output stream */
       protected OutputStream outputStream;
  -
  -    /**
  -     * The sitemap processor sets up new managers per sitemap. Get the
  -     * "current" one for this environment.
  -     */
  -    public ComponentManager getComponentManager(){
  -        return this.manager;
  -    }
  -
  -    /**
  -     * The sitemap processor sets up new managers per sitemap. Set the
  -     * "current" one for this environment.
  -     */
  -    public void setComponentManager(ComponentManager manager){
  -        this.manager = manager;
  -    }
   
       /**
        * Constructs the abstract environment
  
  
  
  1.20      +3 -16     xml-cocoon2/src/java/org/apache/cocoon/environment/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/Environment.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Environment.java	26 Feb 2003 13:28:19 -0000	1.19
  +++ Environment.java	3 Mar 2003 18:39:36 -0000	1.20
  @@ -50,14 +50,14 @@
   */
   package org.apache.cocoon.environment;
   
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.excalibur.xmlizer.XMLizer;
   import java.io.IOException;
   import java.io.OutputStream;
   import java.net.URL;
   import java.util.Enumeration;
   import java.util.Map;
   
  +import org.apache.excalibur.xmlizer.XMLizer;
  +
   /**
    * Base interface for an environment abstraction
    *
  @@ -70,12 +70,6 @@
       extends SourceResolver {
   
       /**
  -     * Get the <code>ComponentManager</code> for the current request.
  -     * This is an internal method, use it at your own risk!
  -     */
  -    ComponentManager getComponentManager();
  -
  -    /**
        * Set the <code>SourceResolver</code> and the <code>XMLizer</code>
        * This is an internal method, use it at your own risk!
        */
  @@ -189,13 +183,6 @@
        *         environment is not able to test it
        */
       boolean isResponseModified(long lastModified);
  -
  -    /**
  -     * Set the <code>ComponentManager</code> for the current request.
  -     * This is an internal method, use it at your own risk!
  -     */
  -    void setComponentManager(ComponentManager manager);
  -
   
       /**
        * Mark the response as not modified.
  
  
  
  1.10      +0 -2      xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
  
  Index: CallFunctionNode.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CallFunctionNode.java	31 Jan 2003 22:51:37 -0000	1.9
  +++ CallFunctionNode.java	3 Mar 2003 18:39:36 -0000	1.10
  @@ -158,8 +158,6 @@
     {
       List params = null;
   
  -    env.setComponentManager(manager);
  -
       // Resolve parameters
       if (parameters != null)
         params = resolveList(parameters, manager, context,
  
  
  
  1.10      +0 -1      xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ContinueNode.java
  
  Index: ContinueNode.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ContinueNode.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ContinueNode.java	31 Jan 2003 22:51:37 -0000	1.9
  +++ ContinueNode.java	3 Mar 2003 18:39:36 -0000	1.10
  @@ -141,7 +141,6 @@
           // Obtain the redirector
           // Redirector redirector = PipelinesNode.getRedirector(env);
   
  -        env.setComponentManager(this.manager);
           try {
               interpreter.handleContinuation(contId, params, env /*, redirector*/);
           } finally {
  
  
  
  1.27      +3 -4      xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
  
  Index: TreeProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- TreeProcessor.java	3 Mar 2003 18:08:54 -0000	1.26
  +++ TreeProcessor.java	3 Mar 2003 18:39:36 -0000	1.27
  @@ -312,7 +312,7 @@
           }
   
           // and now process
  -        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel(),
this);
  +        CocoonComponentManager.enterEnvironment(environment, this.manager, this);
           try {
               return this.rootNode.invoke(environment, context);
           } finally {
  @@ -331,8 +331,7 @@
   
           context.enableLogging(getLogger());
   
  -        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel(),
this);
  -        environment.setComponentManager(this.manager);
  +        CocoonComponentManager.enterEnvironment(environment, this.manager, this);
           try {
               if ( process(environment, context) ) {
                   return context.getProcessingPipeline();
  
  
  
  1.4       +3 -3      xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/SitemapSource.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SitemapSource.java	26 Feb 2003 15:02:34 -0000	1.3
  +++ SitemapSource.java	3 Mar 2003 18:39:37 -0000	1.4
  @@ -242,7 +242,7 @@
               this.environment.setOutputStream(os);
               try {
                   CocoonComponentManager.enterEnvironment(this.environment,
  -                                                        this.environment.getObjectModel(),
  +                                                        this.manager,
                                                           this.pipelineProcessor);
                   this.processingPipeline.process(this.environment);
               } finally {
  @@ -338,7 +338,7 @@
                   Object fragment;
                   try {
                       CocoonComponentManager.enterEnvironment(this.environment,
  -                                                            this.environment.getObjectModel(),
  +                                                            this.manager,
                                                               this.pipelineProcessor);
                       this.processingPipeline.process(this.environment, xmls);
                       fragment = xmls.getSAXFragment();
  
  
  
  1.18      +6 -5      xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java
  
  Index: JSCocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JSCocoon.java	26 Feb 2003 17:15:41 -0000	1.17
  +++ JSCocoon.java	3 Mar 2003 18:39:37 -0000	1.18
  @@ -66,6 +66,7 @@
   import org.apache.cocoon.environment.Context;
   import org.apache.cocoon.components.modules.output.OutputModule;
   import org.apache.cocoon.components.modules.input.InputModule;
  +import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.flow.ContinuationsManagerImpl;
   import org.apache.cocoon.components.flow.ContinuationsManager;
   import org.apache.cocoon.components.flow.WebContinuation;
  @@ -331,7 +332,7 @@
         Redirector redirector = new SitemapRedirector(this.environment);
         SourceResolver resolver = (SourceResolver)this.environment.getObjectModel()
             .get(OBJECT_SOURCE_RESOLVER);
  -      ComponentManager sitemapManager = this.environment.getComponentManager();
  +      ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
         ComponentSelector actionSelector
             = (ComponentSelector)sitemapManager.lookup(Action.ROLE + "Selector");
         Action action = (Action)actionSelector.select(type);
  @@ -373,7 +374,7 @@
       {
         // since no new components can be declared on sitemap we could
         // very well use the 'other' one here. Anyway, since it's there...
  -      ComponentManager sitemapManager = this.environment.getComponentManager();
  +      ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
         ComponentSelector inputSelector = (ComponentSelector)sitemapManager
             .lookup(InputModule.ROLE + "Selector");
         InputModule input = (InputModule) inputSelector.select(type);
  @@ -394,7 +395,7 @@
       {
         // since no new components can be declared on sitemap we could
         // very well use the 'other' one here. Anyway, since it's there...
  -      ComponentManager sitemapManager = this.environment.getComponentManager();
  +      ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
         ComponentSelector outputSelector = (ComponentSelector)sitemapManager
             .lookup(OutputModule.ROLE + "Selector");
         OutputModule output = (OutputModule) outputSelector.select(type);
  @@ -412,7 +413,7 @@
       {
         // since no new components can be declared on sitemap we could
         // very well use the 'other' one here. Anyway, since it's there...
  -      ComponentManager sitemapManager = this.environment.getComponentManager();
  +      ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
         ComponentSelector outputSelector = (ComponentSelector)sitemapManager
             .lookup(OutputModule.ROLE + "Selector");
         OutputModule output = (OutputModule) outputSelector.select(type);
  @@ -429,7 +430,7 @@
       {
         // since no new components can be declared on sitemap we could
         // very well use the 'other' one here. Anyway, since it's there...
  -      ComponentManager sitemapManager = this.environment.getComponentManager();
  +      ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
         ComponentSelector outputSelector = (ComponentSelector)sitemapManager
             .lookup(OutputModule.ROLE + "Selector");
         OutputModule output = (OutputModule) outputSelector.select(type);
  
  
  

Mime
View raw message