tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy NamingResources.java
Date Thu, 08 Nov 2001 19:28:59 GMT
remm        01/11/08 11:28:59

  Added:       catalina/src/share/org/apache/catalina/deploy
                        NamingResources.java
  Log:
  - Add a new helper object to manage the deployment descriptor resources.
    That will allow to avoid duplicating the code for hash map declaration / modification
    in 3 different classes.
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/NamingResources.java
  
  Index: NamingResources.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/NamingResources.java,v
1.1 2001/11/08 19:28:59 remm Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/08 19:28:59 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    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", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    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"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  
  package org.apache.catalina.deploy;
  
  
  import java.util.HashMap;
  
  
  /**
   * Holds and manages the naming resources defined in the J2EE Enterprise 
   * Naming Context and their associated JNDI context.
   *
   * @author Remy Maucherat
   * @version $Revision: 1.1 $ $Date: 2001/11/08 19:28:59 $
   */
  
  public final class NamingResources {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Create a new NamingResources instance.
       */
      public NamingResources() {
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The EJB resource references for this web application, keyed by name.
       */
      private HashMap ejbs = new HashMap();
  
  
      /**
       * The environment entries for this web application, keyed by name.
       */
      private HashMap envs = new HashMap();
  
  
      /**
       * The local  EJB resource references for this web application, keyed by
       * name.
       */
      private HashMap localEjbs = new HashMap();
  
  
      /**
       * The resource environment references for this web application,
       * keyed by name.
       */
      private HashMap resourceEnvRefs = new HashMap();
  
  
      /**
       * The resource references for this web application, keyed by name.
       */
      private HashMap resources = new HashMap();
  
  
      /**
       * The resource links for this web application, keyed by name.
       */
      private HashMap resourceLinks = new HashMap();
  
  
      /**
       * The resource parameters for this web application, keyed by name.
       */
      private HashMap resourceParams = new HashMap();
  
  
      // --------------------------------------------------------------Properties
  
  
      /**
       * Add an EJB resource reference for this web application.
       *
       * @param ejb New EJB resource reference
       */
      public void addEjb(ContextEjb ejb) {
  
          synchronized (ejbs) {
              ejbs.put(ejb.getName(), ejb);
          }
  
      }
  
  
      /**
       * Add an environment entry for this web application.
       *
       * @param environment New environment entry
       */
      public void addEnvironment(ContextEnvironment environment) {
  
          synchronized (envs) {
              envs.put(environment.getName(), environment);
          }
  
      }
  
  
      /**
       * Add resource parameters for this web application.
       *
       * @param resourceParameters New resource parameters
       */
      public void addResourceParams(ResourceParams resourceParameters) {
  
          synchronized (resourceParams) {
              resourceParams.put(resourceParameters.getName(),
                                 resourceParameters);
          }
  
      }
  
  
      /**
       * Add a local EJB resource reference for this web application.
       *
       * @param ejb New EJB resource reference
       */
      public void addLocalEjb(ContextLocalEjb ejb) {
  
          synchronized (localEjbs) {
              localEjbs.put(ejb.getName(), ejb);
          }
  
      }
  
  
      /**
       * Add a resource reference for this web application.
       *
       * @param resource New resource reference
       */
      public void addResource(ContextResource resource) {
  
          synchronized (resources) {
              resources.put(resource.getName(), resource);
          }
  
      }
  
  
      /**
       * Add a resource environment reference for this web application.
       *
       * @param name The resource environment reference name
       * @param type The resource environment reference type
       */
      public void addResourceEnvRef(String name, String type) {
  
          synchronized (resourceEnvRefs) {
              resourceEnvRefs.put(name, type);
          }
  
      }
  
  
      /**
       * Add a resource link for this web application.
       *
       * @param resource New resource link
       */
      public void addResourceLink(ContextResourceLink resourceLink) {
  
          synchronized (resourceLinks) {
              resourceLinks.put(resourceLink.getName(), resourceLink);
          }
  
      }
  
  
      /**
       * Return the EJB resource reference with the specified name, if any;
       * otherwise, return <code>null</code>.
       *
       * @param name Name of the desired EJB resource reference
       */
      public ContextEjb findEjb(String name) {
  
          synchronized (ejbs) {
              return ((ContextEjb) ejbs.get(name));
          }
  
      }
  
  
      /**
       * Return the defined EJB resource references for this application.
       * If there are none, a zero-length array is returned.
       */
      public ContextEjb[] findEjbs() {
  
          synchronized (ejbs) {
              ContextEjb results[] = new ContextEjb[ejbs.size()];
              return ((ContextEjb[]) ejbs.values().toArray(results));
          }
  
      }
  
  
      /**
       * Return the environment entry with the specified name, if any;
       * otherwise, return <code>null</code>.
       *
       * @param name Name of the desired environment entry
       */
      public ContextEnvironment findEnvironment(String name) {
  
          synchronized (envs) {
              return ((ContextEnvironment) envs.get(name));
          }
  
      }
  
  
      /**
       * Return the set of defined environment entries for this web
       * application.  If none have been defined, a zero-length array
       * is returned.
       */
      public ContextEnvironment[] findEnvironments() {
  
          synchronized (envs) {
              ContextEnvironment results[] = new ContextEnvironment[envs.size()];
              return ((ContextEnvironment[]) envs.values().toArray(results));
          }
  
      }
  
  
      /**
       * Return the local EJB resource reference with the specified name, if any;
       * otherwise, return <code>null</code>.
       *
       * @param name Name of the desired EJB resource reference
       */
      public ContextLocalEjb findLocalEjb(String name) {
  
          synchronized (localEjbs) {
              return ((ContextLocalEjb) localEjbs.get(name));
          }
  
      }
  
  
      /**
       * Return the defined local EJB resource references for this application.
       * If there are none, a zero-length array is returned.
       */
      public ContextLocalEjb[] findLocalEjbs() {
  
          synchronized (localEjbs) {
              ContextLocalEjb results[] = new ContextLocalEjb[localEjbs.size()];
              return ((ContextLocalEjb[]) localEjbs.values().toArray(results));
          }
  
      }
  
  
      /**
       * Return the resource reference with the specified name, if any;
       * otherwise return <code>null</code>.
       *
       * @param name Name of the desired resource reference
       */
      public ContextResource findResource(String name) {
  
          synchronized (resources) {
              return ((ContextResource) resources.get(name));
          }
  
      }
  
  
      /**
       * Return the resource link with the specified name, if any;
       * otherwise return <code>null</code>.
       *
       * @param name Name of the desired resource link
       */
      public ContextResourceLink findResourceLink(String name) {
  
          synchronized (resourceLinks) {
              return ((ContextResourceLink) resourceLinks.get(name));
          }
  
      }
  
  
      /**
       * Return the defined resource links for this application.  If
       * none have been defined, a zero-length array is returned.
       */
      public ContextResourceLink[] findResourceLinks() {
  
          synchronized (resourceLinks) {
              ContextResourceLink results[] = 
                  new ContextResourceLink[resources.size()];
              return ((ContextResourceLink[]) resourceLinks.values()
                      .toArray(results));
          }
  
      }
  
  
      /**
       * Return the defined resource references for this application.  If
       * none have been defined, a zero-length array is returned.
       */
      public ContextResource[] findResources() {
  
          synchronized (resources) {
              ContextResource results[] = new ContextResource[resources.size()];
              return ((ContextResource[]) resources.values().toArray(results));
          }
  
      }
  
  
      /**
       * Return the resource environment reference type for the specified
       * name, if any; otherwise return <code>null</code>.
       *
       * @param name Name of the desired resource environment reference
       */
      public String findResourceEnvRef(String name) {
  
          synchronized (resourceEnvRefs) {
              return ((String) resourceEnvRefs.get(name));
          }
  
      }
  
  
      /**
       * Return the set of resource environment reference names for this
       * web application.  If none have been specified, a zero-length
       * array is returned.
       */
      public String[] findResourceEnvRefs() {
  
          synchronized (resourceEnvRefs) {
              String results[] = new String[resourceEnvRefs.size()];
              return ((String[]) resourceEnvRefs.keySet().toArray(results));
          }
  
      }
  
  
      /**
       * Return the resource parameters with the specified name, if any;
       * otherwise return <code>null</code>.
       *
       * @param name Name of the desired resource parameters
       */
      public ResourceParams findResourceParams(String name) {
  
          synchronized (resourceParams) {
              return ((ResourceParams) resourceParams.get(name));
          }
  
      }
  
  
      /**
       * Remove any EJB resource reference with the specified name.
       *
       * @param name Name of the EJB resource reference to remove
       */
      public void removeEjb(String name) {
  
          synchronized (ejbs) {
              ejbs.remove(name);
          }
  
      }
  
  
      /**
       * Remove any environment entry with the specified name.
       *
       * @param name Name of the environment entry to remove
       */
      public void removeEnvironment(String name) {
  
          synchronized (envs) {
              envs.remove(name);
          }
  
      }
  
  
      /**
       * Remove any local EJB resource reference with the specified name.
       *
       * @param name Name of the EJB resource reference to remove
       */
      public void removeLocalEjb(String name) {
  
          synchronized (localEjbs) {
              localEjbs.remove(name);
          }
  
      }
  
  
      /**
       * Remove any resource reference with the specified name.
       *
       * @param name Name of the resource reference to remove
       */
      public void removeResource(String name) {
  
          synchronized (resources) {
              resources.remove(name);
          }
  
      }
  
  
      /**
       * Remove any resource environment reference with the specified name.
       *
       * @param name Name of the resource environment reference to remove
       */
      public void removeResourceEnvRef(String name) {
  
          synchronized (resourceEnvRefs) {
              resourceEnvRefs.remove(name);
          }
  
      }
  
  
      /**
       * Remove any resource link with the specified name.
       *
       * @param name Name of the resource link to remove
       */
      public void removeResourceLink(String name) {
  
          synchronized (resourceLinks) {
              resourceLinks.remove(name);
          }
  
      }
  
  
      /**
       * Remove any resource parameters with the specified name.
       *
       * @param name Name of the resource parameters to remove
       */
      public void removeResourceParams(String name) {
  
          synchronized (resourceParams) {
              resourceParams.remove(name);
          }
  
      }
  
  
  }
  
  
  

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


Mime
View raw message