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/core NamingContextListener.java
Date Thu, 29 Nov 2001 02:36:05 GMT
remm        01/11/28 18:36:05

  Modified:    catalina/src/share/org/apache/catalina/core
                        NamingContextListener.java
  Log:
  - Implement the container listener, so that the naming context can be modified
    dynamically.
  
  Revision  Changes    Path
  1.4       +155 -24   jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java
  
  Index: NamingContextListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NamingContextListener.java	2001/11/10 00:31:04	1.3
  +++ NamingContextListener.java	2001/11/29 02:36:05	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
1.3 2001/11/10 00:31:04 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/11/10 00:31:04 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
1.4 2001/11/29 02:36:05 remm Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/11/29 02:36:05 $
    *
    * ====================================================================
    *
  @@ -116,7 +116,7 @@
    * with each context and server.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.3 $ $Date: 2001/11/10 00:31:04 $
  + * @version $Revision: 1.4 $ $Date: 2001/11/29 02:36:05 $
    */
   
   public class NamingContextListener
  @@ -355,33 +355,130 @@
           String type = event.getType();
   
           if (type.equals("addEjb")) {
  -            
  +
  +            String ejbName = (String) event.getData();
  +            if (ejbName != null) {
  +                ContextEjb ejb = namingResources.findEjb(ejbName);
  +                addEjb(ejb);
  +            }
  +
           } else if (type.equals("addEnvironment")) {
  -            
  -        } else if (type.equals("addResourceParams")) {
  -            
  +
  +            String environmentName = (String) event.getData();
  +            if (environmentName != null) {
  +                ContextEnvironment env = 
  +                    namingResources.findEnvironment(environmentName);
  +                addEnvironment(env);
  +            }
  +
  +        } else if ((type.equals("addResourceParams")) 
  +                   || (type.equals("removeResourceParams"))) {
  +
  +            String resourceParamsName = (String) event.getData();
  +            if (resourceParamsName != null) {
  +                ContextEjb ejb = namingResources.findEjb(resourceParamsName);
  +                if (ejb != null) {
  +                    removeEjb(resourceParamsName);
  +                    addEjb(ejb);
  +                }
  +                ContextResource resource = 
  +                    namingResources.findResource(resourceParamsName);
  +                if (resource != null) {
  +                    removeResource(resourceParamsName);
  +                    addResource(resource);
  +                }
  +                String resourceEnvRefValue = 
  +                    namingResources.findResourceEnvRef(resourceParamsName);
  +                if (resourceEnvRefValue != null) {
  +                    removeResourceEnvRef(resourceParamsName);
  +                    addResourceEnvRef(resourceParamsName, resourceEnvRefValue);
  +                }
  +                ContextResourceLink resourceLink = 
  +                    namingResources.findResourceLink(resourceParamsName);
  +                if (resourceLink != null) {
  +                    removeResourceLink(resourceParamsName);
  +                    addResourceLink(resourceLink);
  +                }
  +            }
  +
           } else if (type.equals("addLocalEjb")) {
  -            
  +
  +            String localEjbName = (String) event.getData();
  +            if (localEjbName != null) {
  +                ContextLocalEjb localEjb = 
  +                    namingResources.findLocalEjb(localEjbName);
  +                addLocalEjb(localEjb);
  +            }
  +
           } else if (type.equals("addResource")) {
  -            
  +
  +            String resourceName = (String) event.getData();
  +            if (resourceName != null) {
  +                ContextResource resource = 
  +                    namingResources.findResource(resourceName);
  +                addResource(resource);
  +            }
  +
           } else if (type.equals("addResourceLink")) {
  -            
  +
  +            String resourceLinkName = (String) event.getData();
  +            if (resourceLinkName != null) {
  +                ContextResourceLink resourceLink = 
  +                    namingResources.findResourceLink(resourceLinkName);
  +                addResourceLink(resourceLink);
  +            }
  +
           } else if (type.equals("addResourceEnvRef")) {
  -            
  +
  +            String resourceEnvRefName = (String) event.getData();
  +            if (resourceEnvRefName != null) {
  +                String resourceEnvRefValue = 
  +                    namingResources.findResourceEnvRef(resourceEnvRefName);
  +                addResourceEnvRef(resourceEnvRefName, resourceEnvRefValue);
  +            }
  +
           } else if (type.equals("removeEjb")) {
  -            
  +
  +            String ejbName = (String) event.getData();
  +            if (ejbName != null) {
  +                removeEjb(ejbName);
  +            }
  +
           } else if (type.equals("removeEnvironment")) {
  -            
  -        } else if (type.equals("removeResourceParams")) {
  -            
  +
  +            String environmentName = (String) event.getData();
  +            if (environmentName != null) {
  +                removeEnvironment(environmentName);
  +            }
  +
           } else if (type.equals("removeLocalEjb")) {
  -            
  +
  +            String localEjbName = (String) event.getData();
  +            if (localEjbName != null) {
  +                removeLocalEjb(localEjbName);
  +            }
  +
           } else if (type.equals("removeResource")) {
  -            
  +
  +            String resourceName = (String) event.getData();
  +            if (resourceName != null) {
  +                removeResource(resourceName);
  +            }
  +
           } else if (type.equals("removeResourceLink")) {
  -            
  +
  +            String resourceLinkName = (String) event.getData();
  +            if (resourceLinkName != null) {
  +                removeResourceLink(resourceLinkName);
  +            }
  +
           } else if (type.equals("removeResourceEnvRef")) {
  -            
  +
  +            String resourceEnvRefName = (String) event.getData();
  +            if (resourceEnvRefName != null) {
  +                removeResourceEnvRef(resourceEnvRefName);
  +            }
  +
           }
   
           // Setting the context in read only mode
  @@ -622,7 +719,11 @@
        */
       private void removeEjb(String name) {
   
  -
  +        try {
  +            envCtx.unbind(name);
  +        } catch (NamingException e) {
  +            log(sm.getString("naming.unbindFailed", e));
  +        }
   
       }
   
  @@ -632,7 +733,11 @@
        */
       private void removeEnvironment(String name) {
   
  -
  +        try {
  +            envCtx.unbind(name);
  +        } catch (NamingException e) {
  +            log(sm.getString("naming.unbindFailed", e));
  +        }
   
       }
   
  @@ -642,7 +747,11 @@
        */
       private void removeLocalEjb(String name) {
   
  -
  +        try {
  +            envCtx.unbind(name);
  +        } catch (NamingException e) {
  +            log(sm.getString("naming.unbindFailed", e));
  +        }
   
       }
   
  @@ -652,7 +761,11 @@
        */
       private void removeResource(String name) {
   
  -
  +        try {
  +            envCtx.unbind(name);
  +        } catch (NamingException e) {
  +            log(sm.getString("naming.unbindFailed", e));
  +        }
   
       }
   
  @@ -662,7 +775,25 @@
        */
       private void removeResourceEnvRef(String name) {
   
  +        try {
  +            envCtx.unbind(name);
  +        } catch (NamingException e) {
  +            log(sm.getString("naming.unbindFailed", e));
  +        }
  +
  +    }
   
  +
  +    /**
  +     * Set the specified resources in the naming context.
  +     */
  +    private void removeResourceLink(String name) {
  +
  +        try {
  +            envCtx.unbind(name);
  +        } catch (NamingException e) {
  +            log(sm.getString("naming.unbindFailed", e));
  +        }
   
       }
   
  
  
  

--
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