jakarta-slide-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pne...@apache.org
Subject cvs commit: jakarta-slide/src/share/org/apache/slide/common EmbeddedDomain.java Domain.java
Date Mon, 20 Jan 2003 11:52:01 GMT
pnever      2003/01/20 03:52:00

  Modified:    src/wrappers/wrappers/catalina SlideServerListener.java
               src/share/org/apache/slide/common EmbeddedDomain.java
                        Domain.java
  Log:
  Problem with the loading of parameters in EmbeddedDomain.
  Thanks to Unico Hommes [Unico@hippo.nl] for this fix.
  
  Revision  Changes    Path
  1.2       +29 -32    jakarta-slide/src/wrappers/wrappers/catalina/SlideServerListener.java
  
  Index: SlideServerListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/wrappers/wrappers/catalina/SlideServerListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SlideServerListener.java	15 Jan 2003 12:43:43 -0000	1.1
  +++ SlideServerListener.java	20 Jan 2003 11:51:59 -0000	1.2
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -15,7 +15,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -23,15 +23,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Slide", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written 
  + *    from this software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package wrappers.catalina;
  @@ -67,38 +67,26 @@
   
   import java.io.File;
   import java.io.FileInputStream;
  -import java.io.InputStream;
   import java.io.IOException;
   import java.util.Enumeration;
  -
  -import javax.xml.parsers.SAXParser;
  -import javax.xml.parsers.SAXParserFactory;
  +import java.util.Hashtable;
   import javax.xml.parsers.FactoryConfigurationError;
   import javax.xml.parsers.ParserConfigurationException;
  -
  -import org.xml.sax.*;
  -import org.xml.sax.helpers.*;
  -
  -import org.apache.catalina.Container;
  -import org.apache.catalina.Host;
  +import javax.xml.parsers.SAXParser;
  +import javax.xml.parsers.SAXParserFactory;
   import org.apache.catalina.Lifecycle;
   import org.apache.catalina.LifecycleEvent;
   import org.apache.catalina.LifecycleException;
   import org.apache.catalina.LifecycleListener;
   import org.apache.catalina.Server;
  -import org.apache.catalina.Service;
   import org.apache.catalina.logger.FileLogger;
  -
   import org.apache.slide.common.Domain;
   import org.apache.slide.common.EmbeddedDomain;
  -import org.apache.slide.common.Namespace;
  -import org.apache.slide.common.NamespaceAccessToken;
   import org.apache.slide.util.conf.Configuration;
   import org.apache.slide.util.conf.ConfigurationElement;
  -import org.apache.slide.util.conf.ConfigurationException;
   import org.apache.slide.util.conf.Populate;
  -import org.apache.slide.util.logger.SimpleLogger;
  -
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
   import wrappers.jmx.SlideJMX;
   
   
  @@ -265,7 +253,7 @@
        * Get configuration object from a file.
        */
       protected Configuration getConfiguration(File file)
  -        throws IOException, SAXException, ParserConfigurationException, 
  +        throws IOException, SAXException, ParserConfigurationException,
           FactoryConfigurationError {
   
           // Get XML parser
  @@ -287,12 +275,12 @@
        * Setup domain.
        */
       protected void initializeDomain()
  -        throws IOException, SAXException, FactoryConfigurationError, 
  +        throws IOException, SAXException, FactoryConfigurationError,
           ParserConfigurationException {
   
           File domainConfigFile = new File(configFileName);
           if (!domainConfigFile.isAbsolute()) {
  -            domainConfigFile = new File(System.getProperty("catalina.home"), 
  +            domainConfigFile = new File(System.getProperty("catalina.home"),
                                           configFileName);
           }
   
  @@ -309,6 +297,15 @@
                             (Configuration) namespaceDefinitions.nextElement());
           }
   
  +        // Loading domain parameters
  +        Enumeration parametersEnum =
  +            slideConfiguration.getConfigurations("parameter");
  +        Hashtable parameters = new Hashtable();
  +        while( parametersEnum.hasMoreElements() ) {
  +            Configuration p = (Configuration)parametersEnum.nextElement();
  +            parameters.put( p.getAttribute("name"), p.getValue() );
  +        }
  +        domain.setParameters( parameters );
       }
   
   
  @@ -322,7 +319,7 @@
           String name = xmlFragment.getAttribute("name");
   
           Configuration definition = xmlFragment.getConfiguration("definition");
  -        Configuration configuration = 
  +        Configuration configuration =
               xmlFragment.getConfiguration("configuration");
           Configuration baseData = xmlFragment.getConfiguration("data");
   
  @@ -359,7 +356,7 @@
           nsLogger.setLogger(catalinaLogger);
           nsLogger.setLoggerLevel(logLevel);
   
  -        domain.addNamespace(name, nsLogger, definition, 
  +        domain.addNamespace(name, nsLogger, definition,
                               configuration, baseData);
           try {
               slideJMXWrapper.addNamespace(name);
  
  
  
  1.8       +26 -17    jakarta-slide/src/share/org/apache/slide/common/EmbeddedDomain.java
  
  Index: EmbeddedDomain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/EmbeddedDomain.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- EmbeddedDomain.java	25 Apr 2002 21:12:27 -0000	1.7
  +++ EmbeddedDomain.java	20 Jan 2003 11:52:00 -0000	1.8
  @@ -87,11 +87,11 @@
        * Default constructor.
        */
       public EmbeddedDomain() {
  -
  +        
           // Compatibility with the static domain
           if (!Domain.isInitialized())
               Domain.setDomain(this);
  -
  +        
       }
       
       
  @@ -151,7 +151,7 @@
       
       /**
        * Set the default namespace of this domain.
  -     * 
  +     *
        * @param defaultNamespace New default namespace name
        */
       public void setDefaultNamespace(String defaultNamespace) {
  @@ -206,7 +206,7 @@
       
       /**
        * Add a namespace to this domain.
  -     * 
  +     *
        * @param name Namespace name
        * @param logger Namespace logger
        * @param definition Input stream to the namepace definition
  @@ -217,13 +217,13 @@
                                     Configuration definition,
                                     Configuration configuration,
                                     Configuration baseData) {
  -
  +        
           // FIXME: Check parameters
  -
  +        
           Namespace namespace = new Namespace();
           namespace.setName(name);
           namespace.setLogger(logger);
  -
  +        
           try {
               namespace.loadDefinition(definition);
               namespace.loadParameters(configuration);
  @@ -236,11 +236,11 @@
               e.printStackTrace();
               return null;
           }
  -
  +        
           namespaces.put(name, namespace);
  -
  +        
           return namespace;
  -
  +        
       }
       
       
  @@ -250,16 +250,16 @@
        * @param name Name of the namespace
        */
       public Namespace removeNamespace(String name) {
  -
  +        
           // FIXME: Check parameters
  -
  +        
           try {
               Namespace namespace = (Namespace) namespaces.get(name);
               namespace.disconnectServices();
           } catch(Exception e) {
           }
           return (Namespace) namespaces.remove(name);
  -
  +        
       }
       
       
  @@ -273,6 +273,15 @@
           return (Namespace) namespaces.get(name);
       }
       
  +    /**
  +     * Set the specified parameters
  +     *
  +     * @param    parameters          the parameters
  +     *
  +     */
  +    public void setParameters( Hashtable parameters ) {
  +        Domain.setParameters( parameters );
  +    }
       
       /**
        * Start domain (doesn't do anything yet).
  
  
  
  1.39      +24 -15    jakarta-slide/src/share/org/apache/slide/common/Domain.java
  
  Index: Domain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Domain.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Domain.java	30 Oct 2002 09:59:51 -0000	1.38
  +++ Domain.java	20 Jan 2003 11:52:00 -0000	1.39
  @@ -127,7 +127,7 @@
    *   <ul>
    *     <li>
    *       {@link #accessNamespace Domain.accessNamespace(SecurityToken
  -          securityObject, String namespace)}
  + securityObject, String namespace)}
    *       <br>
    *       Used to access a specific namespace. This method returns a
    *       <code>NamespaceAccessToken</code>, which thereafter must be used by
  @@ -136,7 +136,7 @@
    *     </li>
    *     <li>
    *       {@link #accessDomain Domain.accessDomain(SecurityToken
  -          securityObject)}
  + securityObject)}
    *       <br>
    *       Enumerates the registered namespaces with this domain. This allows
    *       application to browse the list of available namespaces.
  @@ -156,8 +156,8 @@
    * @version $Revision$
    */
   public final class Domain {
  -
  -
  +    
  +    
       // -------------------------------------------------------------- Constants
       
       
  @@ -228,7 +228,7 @@
        * Set the domain as having been initialized before.
        */
       public static void setInitialized(boolean initialized) {
  -
  +        
           if( namespaces == null ) namespaces = new Hashtable();
           if( activeNamespaces == null ) activeNamespaces = new Hashtable();
           if( parameters == null ) parameters = new Hashtable();
  @@ -407,7 +407,7 @@
           Populate pop = new Populate();
           Configuration slideConfiguration =
               new ConfigurationElement(pop.load(new InputSource
  -                (configurationInputStream), parser.getXMLReader()));
  +                                                  (configurationInputStream), parser.getXMLReader()));
           
           Domain.init(slideConfiguration);
           
  @@ -711,6 +711,15 @@
           return result;
       }
       
  +    /**
  +     * Set the specified parameters
  +     *
  +     * @param    parameters          the parameters
  +     *
  +     */
  +    static void setParameters( Hashtable parameters ) {
  +        Domain.parameters = parameters;
  +    }
       
       /**
        * Set the logger to be used by Slide.
  @@ -826,11 +835,11 @@
                       namespaceLogger =
                           (Logger) (Class.forName(loggerClass).newInstance());
                       namespaceLogger.setLoggerLevel(configuration.getAttributeAsInt
  -                                                   ("logger-level", Logger.INFO));
  +                                                       ("logger-level", Logger.INFO));
                   } catch (Exception e) {
                       error(e);
                   }
  -        }
  +            }
               
               Namespace namespace = new Namespace();
               namespace.setName(configuration.getAttribute("name"));
  @@ -840,10 +849,10 @@
                   configuration.getConfiguration("configuration");
               namespace.loadParameters(namespaceConfigurationDefinition);
               
  -         Configuration namespaceDefinition =
  +            Configuration namespaceDefinition =
                   configuration.getConfiguration("definition");
  -         namespace.loadDefinition(namespaceDefinition);
  -         addNamespace(namespace);
  +            namespace.loadDefinition(namespaceDefinition);
  +            addNamespace(namespace);
               try {
                   Configuration namespaceBaseDataDefinition =
                       configuration.getConfiguration("data");
  
  
  

--
To unsubscribe, e-mail:   <mailto:slide-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:slide-dev-help@jakarta.apache.org>


Mime
View raw message