cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon Cocoon.java
Date Wed, 12 Mar 2003 15:04:18 GMT
bloritsch    2003/03/12 07:04:18

  Modified:    src/java/org/apache/cocoon Cocoon.java
  Log:
  many compilation fixes, as well as re-implementing my change to make cornerstone unnecessary
  
  Revision  Changes    Path
  1.2       +49 -18    cocoon-2.1/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Cocoon.java	9 Mar 2003 00:08:35 -0000	1.1
  +++ Cocoon.java	12 Mar 2003 15:04:18 -0000	1.2
  @@ -50,6 +50,14 @@
   */
   package org.apache.cocoon;
   
  +import java.io.BufferedInputStream;
  +import java.io.File;
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.net.URL;
  +import java.util.Enumeration;
  +import java.util.Map;
  +
   import org.apache.avalon.excalibur.component.DefaultRoleManager;
   import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
   import org.apache.avalon.excalibur.logger.LogKitManageable;
  @@ -62,10 +70,13 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
  +import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
  +import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.EnvironmentStack;
  @@ -79,26 +90,21 @@
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.util.ClassUtils;
  +import org.apache.excalibur.event.Queue;
  +import org.apache.excalibur.event.command.CommandManager;
  +import org.apache.excalibur.event.command.TPCThreadManager;
  +import org.apache.excalibur.event.command.ThreadManager;
   import org.apache.excalibur.instrument.InstrumentManageable;
   import org.apache.excalibur.instrument.InstrumentManager;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.impl.URLSource;
  -import org.apache.excalibur.xml.impl.XercesParser;
   import org.apache.excalibur.xml.sax.SAXParser;
   import org.xml.sax.InputSource;
   
  -import java.io.BufferedInputStream;
  -import java.io.File;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.net.URL;
  -import java.util.Enumeration;
  -import java.util.Map;
  -
   /**
    * The Cocoon Object is the main Kernel for the entire Cocoon system.
    *
  - * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a> (Apache
Software Foundation)
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
    * @version CVS $Id$
  @@ -157,6 +163,9 @@
   
       /** The XMLizer */
       private org.apache.excalibur.xmlizer.XMLizer xmlizer;
  +    
  +    private ThreadManager threadManager;
  +    private CommandManager commandManager;
   
       /**
        * Creates a new <code>Cocoon</code> instance.
  @@ -166,6 +175,23 @@
       public Cocoon() throws ConfigurationException {
           // Set the system properties needed by Xalan2.
           setSystemProperties();
  +        
  +        try
  +        {
  +            threadManager = new TPCThreadManager();
  +            Parameters params = new Parameters();
  +            params.setParameter("threads-per-processor", "1");
  +            params.setParameter("sleep-time", "100"); // 1/10 second
  +            ContainerUtil.parameterize(threadManager, params);
  +            ContainerUtil.initialize(threadManager);
  +            
  +            commandManager = new CommandManager();
  +            threadManager.register(commandManager);
  +        }
  +        catch(Exception e)
  +        {
  +            throw new ConfigurationException("Could not set up the event queue", e);
  +        }
       }
   
       /**
  @@ -186,14 +212,17 @@
        */
       public void contextualize(Context context) throws ContextException {
           if (this.context == null) {
  -            this.context = context;
  -            this.classpath = (String)context.get(Constants.CONTEXT_CLASSPATH);
  -            this.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
  +            this.context = new DefaultContext(context);
  +            ((DefaultContext)this.context).put(Queue.ROLE, commandManager.getCommandSink());
  +            ((DefaultContext)this.context).makeReadOnly();
  +
  +            this.classpath = (String)this.context.get(Constants.CONTEXT_CLASSPATH);
  +            this.workDir = (File)this.context.get(Constants.CONTEXT_WORK_DIR);
               try {
                   // FIXME : add a configuration option for the refresh delay.
                   // for now, hard-coded to 1 second.
                   URLSource urlSource = new URLSource();
  -                urlSource.init((URL)context.get(Constants.CONTEXT_CONFIG_URL), null);
  +                urlSource.init((URL)this.context.get(Constants.CONTEXT_CONFIG_URL), null);
                   this.configurationFile = new DelayedRefreshSourceWrapper(urlSource,
                       1000L
                   );
  @@ -254,7 +283,7 @@
           if ( !Constants.DEFAULT_PARSER.equals( parser ) ) {
               this.getLogger().warn("Deprecated property " +Constants.DEPRECATED_PARSER_PROPERTY+
" is used. Please use "+Constants.PARSER_PROPERTY+" instead.");
               if ( "org.apache.cocoon.components.parser.XercesParser".equals(parser) ) {
  -                parser = XercesParser.class.getName();
  +                parser = "org.apache.excalibur.xml.sax.XercesParser";
               } else {
                   this.getLogger().warn("Unknown value for deprecated property: " +
                                         Constants.DEPRECATED_PARSER_PROPERTY + ", value:
" + parser +
  @@ -462,13 +491,14 @@
        * Dispose this instance
        */
       public void dispose() {
  +        this.disposed = true;
           this.componentManager.release(this.threadSafeProcessor);
           this.componentManager.release(this.sourceResolver);
           this.componentManager.release((Component)this.xmlizer);
           this.sourceResolver = null;
           this.xmlizer = null;
           this.componentManager.dispose();
  -        this.disposed = true;
  +        ContainerUtil.dispose(this.threadManager);
       }
   
       /**
  @@ -585,10 +615,11 @@
               throw new IllegalStateException("You cannot process a Disposed Cocoon engine.");
           }
   
  +        environment.setComponents( this.sourceResolver, this.xmlizer );
           Object key = CocoonComponentManager.startProcessing(environment);
           try {
               CocoonComponentManager.enterEnvironment(environment,
  -                                                    this.componentManager,
  +                                                    environment.getObjectModel(),
                                                       this);
               boolean result;
               if (this.getLogger().isDebugEnabled()) {
  
  
  

Mime
View raw message