tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r1407596 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/core/NamingContextListener.java test/org/apache/catalina/core/TestNamingContextListener.java webapps/docs/changelog.xml
Date Sat, 10 Nov 2012 09:31:58 GMT
2012/11/9  <markt@apache.org>:
> Author: markt
> Date: Fri Nov  9 19:33:44 2012
> New Revision: 1407596
>
> URL: http://svn.apache.org/viewvc?rev=1407596&view=rev
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54096
> env-entry can use any type that has a String or char constructor
>

Does it change what types are allowed for the <Environment> element in
Context or in GlobalResources?

I mean the following documentation:
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Environment_Entries
http://tomcat.apache.org/tomcat-7.0-doc/config/globalresources.html#Environment_Entries

Best regards,
Konstantin Kolinko

> Modified:
>     tomcat/tc7.0.x/trunk/   (props changed)
>     tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/NamingContextListener.java
>     tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>
> Propchange: tomcat/tc7.0.x/trunk/
> ------------------------------------------------------------------------------
>   Merged /tomcat/trunk:r1407595
>
> Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/NamingContextListener.java
> URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/NamingContextListener.java?rev=1407596&r1=1407595&r2=1407596&view=diff
> ==============================================================================
> --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/NamingContextListener.java (original)
> +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/NamingContextListener.java Fri
Nov  9 19:33:44 2012
> @@ -21,6 +21,7 @@ package org.apache.catalina.core;
>
>  import java.beans.PropertyChangeEvent;
>  import java.beans.PropertyChangeListener;
> +import java.lang.reflect.Constructor;
>  import java.net.MalformedURLException;
>  import java.net.URL;
>  import java.util.Collection;
> @@ -863,7 +864,11 @@ public class NamingContextListener
>                      }
>                  }
>              } else {
> -                logger.error(sm.getString("naming.invalidEnvEntryType", env.getName()));
> +                value = constructEnvEntry(env.getType(), env.getValue());
> +                if (value == null) {
> +                    logger.error(sm.getString(
> +                            "naming.invalidEnvEntryType", env.getName()));
> +                }
>              }
>          } catch (NumberFormatException e) {
>              logger.error(sm.getString("naming.invalidEnvEntryValue", env.getName()));
> @@ -886,6 +891,33 @@ public class NamingContextListener
>      }
>
>
> +    private Object constructEnvEntry(String type, String value) {
> +        try {
> +            Class<?> clazz = Class.forName(type);
> +            Constructor<?> c = null;
> +            try {
> +                 c = clazz.getConstructor(String.class);
> +                 return c.newInstance(value);
> +            } catch (NoSuchMethodException e) {
> +                // Ignore
> +            }
> +
> +            if (value.length() != 1) {
> +                return null;
> +            }
> +
> +            try {
> +                c = clazz.getConstructor(char.class);
> +                return c.newInstance(Character.valueOf(value.charAt(0)));
> +            } catch (NoSuchMethodException e) {
> +                // Ignore
> +            }
> +        } catch (Exception e) {
> +            // Ignore
> +        }
> +        return null;
> +    }
> +
>      /**
>       * Set the specified local EJBs in the naming context.
>       */
>
> Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
> (...)

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


Mime
View raw message