User: starksm 
  Date: 01/06/22 12:08:25

  Modified:    src/main/org/jnp/interfaces NamingContext.java
  Log:
  Handle empty provider url names
  Accept the name to use for the log4j category
  
  Revision  Changes    Path
  1.10      +18 -10    jnp/src/main/org/jnp/interfaces/NamingContext.java
  
  Index: NamingContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/interfaces/NamingContext.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NamingContext.java        2001/04/26 07:50:51     1.9
  +++ NamingContext.java        2001/06/22 19:08:25     1.10
  @@ -37,7 +37,7 @@
   
    *   @author oberg
    *   @author [EMAIL PROTECTED]
  - *   @version $Revision: 1.9 $
  + *   @version $Revision: 1.10 $
    */
   public class NamingContext
      implements Context, java.io.Serializable
  @@ -747,18 +747,26 @@
            int port = 1099;
            
            // Locate naming service
  -         if (env.get(Context.PROVIDER_URL) != null)
  +         String url = (String) env.get(Context.PROVIDER_URL);
  +         if( url != null && url.length() > 0 )
            {
  -            StringTokenizer tkn = new 
StringTokenizer((String)env.get(Context.PROVIDER_URL),":");
  -            host = tkn.nextToken();
  -            try
  +            int colon = url.indexOf(':');
  +            if( colon < 0 )
               {
  -               port = Integer.parseInt(tkn.nextToken());
  -            } catch (Exception ex)
  +               host = url;
  +            }
  +            else
               {
  -               // Use default;
  +               host = url.substring(0, colon);
  +               try
  +               {
  +                  port = Integer.parseInt(url.substring(colon+1));
  +               }
  +               catch (Exception ex)
  +               {
  +                  // Use default;
  +               }
               }
  -                             
                 // Get server from cache
                 naming = getServer(host, port);
            } else
  @@ -769,7 +777,7 @@
               if (naming == null)
               {
                  // Local, but no local JNDI provider found!
  -               throw new ConfigurationException("Provider URL missing");
  +               throw new ConfigurationException("No valid Context.PROVIDER_URL was 
found");
               }
            }
         }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to