You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-commits@ws.apache.org by sc...@apache.org on 2005/08/22 18:56:01 UTC

svn commit: r235751 - in /webservices/wsrf/trunk/src/java/org/apache/ws: resource/impl/ resource/properties/query/impl/ util/jndi/

Author: scamp
Date: Mon Aug 22 09:55:57 2005
New Revision: 235751

URL: http://svn.apache.org/viewcvs?rev=235751&view=rev
Log:
Removed Redundant JNDIUtils and NamingContext

Removed:
    webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java
    webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/NamingContext.java
Modified:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/properties/query/impl/QueryEngineImpl.java
    webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java
    webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanNamingContext.java

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java?rev=235751&r1=235750&r2=235751&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java Mon Aug 22 09:55:57 2005
@@ -44,10 +44,11 @@
 import org.apache.ws.util.NameUtils;
 import org.apache.ws.util.i18n.Messages;
 import org.apache.ws.util.jndi.Initializable;
-import org.apache.ws.util.jndi.JNDIUtils;
+import org.apache.ws.util.jndi.XmlBeanJndiUtils;
 import org.apache.ws.util.lock.Lock;
 import org.apache.ws.util.lock.LockManager;
 import org.apache.ws.util.platform.JaxRpcPlatform;
+
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -823,7 +824,7 @@
    {
       if ( m_cacheLocation != null )
       {
-         m_cache = (Cache) JNDIUtils.lookup( initialContext, m_cacheLocation, Cache.class );
+         m_cache = (Cache) XmlBeanJndiUtils.lookup( initialContext, m_cacheLocation, Cache.class );
       }
    }
 

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/properties/query/impl/QueryEngineImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/properties/query/impl/QueryEngineImpl.java?rev=235751&r1=235750&r2=235751&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/properties/query/impl/QueryEngineImpl.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/properties/query/impl/QueryEngineImpl.java Mon Aug 22 09:55:57 2005
@@ -30,7 +30,8 @@
 import org.apache.ws.resource.properties.query.UnknownQueryExpressionDialectException;
 import org.apache.ws.resource.properties.query.xpath.impl.XalanXPathExpressionEvaluator;
 import org.apache.ws.util.i18n.Messages;
-import org.apache.ws.util.jndi.JNDIUtils;
+import org.apache.ws.util.jndi.XmlBeanJndiUtils;
+
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NameClassPair;
@@ -133,7 +134,7 @@
             {
                NameClassPair       pair      = (NameClassPair) list.next(  );
                ExpressionEvaluator evaluator =
-                  (ExpressionEvaluator) JNDIUtils.lookup( initialContext,
+                  (ExpressionEvaluator) XmlBeanJndiUtils.lookup( initialContext,
                                                           QUERY_EVALUATOR_CONTEXT + "/" + pair.getName(  ),
                                                           ExpressionEvaluator.class );
                registerEvaluator( evaluator );

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java?rev=235751&r1=235750&r2=235751&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java Mon Aug 22 09:55:57 2005
@@ -51,6 +51,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.StringTokenizer;
 
 /**
  * LOG-DONE JNDI Utiltiy methods for use with an XmlBean-generated JNDI-Config file. This class handles the initial
@@ -659,4 +660,68 @@
    {
       checkValueIsNonEmpty( params, PROP_FACTORY );
    }
+
+    /**
+     * Create all intermediate subcontexts.
+     */
+    public static Context createSubcontexts( Context currentContext,
+                                             String  name )
+    throws NamingException
+    {
+       StringTokenizer tokenizer = new StringTokenizer( name, "/" );
+
+       while ( tokenizer.hasMoreTokens(  ) )
+       {
+          String token = tokenizer.nextToken(  );
+          if ( ( !token.equals( "" ) ) && ( tokenizer.hasMoreTokens(  ) ) )
+          {
+             try
+             {
+                currentContext = currentContext.createSubcontext( token );
+             }
+             catch ( NamingException e )
+             {
+                // Silent catch. Probably an object is already bound in
+                // the context.
+                currentContext = (Context) currentContext.lookup( token );
+             }
+          }
+       }
+
+       return currentContext;
+    }
+    /**
+     * Retrieves the named object on the specified context. The object returned must be of assignable from the type
+     * specified.
+     *
+     * @param context the context to perform lookup on
+     * @param name    the name of the object to lookup
+     * @param type    the expected type of the object returned
+     */
+    public static Object lookup( Context context,
+                                 String  name,
+                                 Class   type )
+    throws NamingException
+    {
+       if ( context == null )
+       {
+          throw new IllegalArgumentException( "nullArgument:context" );
+       }
+
+       if ( type == null )
+       {
+          throw new IllegalArgumentException( "nullArgument:type" );
+       }
+
+       Object tmp = context.lookup( name );
+       if ( type.isAssignableFrom( tmp.getClass(  ) ) )
+       {
+          return tmp;
+       }
+       else
+       {
+          throw new NamingException( "expectedType " + type.getName(  ) );
+       }
+    }
+
 }

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanNamingContext.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanNamingContext.java?rev=235751&r1=235750&r2=235751&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanNamingContext.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanNamingContext.java Mon Aug 22 09:55:57 2005
@@ -23,6 +23,7 @@
 import org.apache.ws.util.jndi.tools.Resource;
 import org.apache.ws.util.jndi.tools.ResourceLink;
 import org.apache.ws.util.jndi.tools.ResourceParameters;
+
 import javax.naming.Context;
 import javax.naming.LinkRef;
 import javax.naming.NamingException;
@@ -254,7 +255,7 @@
       Iterator             nameIterator;
       XmlBeanNamingContext newContext;
 
-      JNDIUtils.createSubcontexts( m_context, serviceName );
+      XmlBeanJndiUtils.createSubcontexts( m_context, serviceName );
 
       try
       {
@@ -368,6 +369,6 @@
    private void createSubcontexts( String name )
    throws NamingException
    {
-      JNDIUtils.createSubcontexts( this.m_context, name );
+      XmlBeanJndiUtils.createSubcontexts( this.m_context, name );
    }
 }