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/02 18:30:44 UTC

svn commit: r227033 [20/27] - in /webservices/wsrf/trunk: ./ src/java/org/apache/ws/ src/java/org/apache/ws/addressing/ src/java/org/apache/ws/addressing/v2003_03/ src/java/org/apache/ws/addressing/v2004_08_10/ src/java/org/apache/ws/resource/ src/java...

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/BeanFactory.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/BeanFactory.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/BeanFactory.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/BeanFactory.java Tue Aug  2 09:28:49 2005
@@ -17,7 +17,6 @@
 
 import org.apache.axis.AxisEngine;
 import org.apache.axis.MessageContext;
-
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NamingException;
@@ -32,116 +31,150 @@
  *
  * TODO (v1.1): remove Axis dependency from this class
  */
-public class BeanFactory extends BasicBeanFactory
+public class BeanFactory
+   extends BasicBeanFactory
 {
+   /**
+    * Create a new Bean instance. If <code>obj</code> is of type
+    * {@link ServiceResourceRef}, the bean will be
+    * created and initialized with security credentials associated
+    * with the current thread if the service associated with this bean
+    * has a security descriptor configured.
+    */
+   public Object getObjectInstance( Object    obj,
+                                    Name      name,
+                                    Context   nameCtx,
+                                    Hashtable environment )
+   throws NamingException
+   {
+      Subject        subject = null;
+      MessageContext msgCtx = null;
+
+      if ( obj instanceof ServiceResourceRef )
+      {
+         ServiceResourceRef resource    = (ServiceResourceRef) obj;
+         AxisEngine         engine      = resource.getAxisEngine(  );
+         String             serviceName = resource.getServiceName(  );
+         if ( engine == null )
+         {
+            throw new NamingException( "noServiceSet" );
+         }
+
+         if ( serviceName == null )
+         {
+            throw new NamingException( "noEngineSet" );
+         }
+      }
+
+      /* ServiceManager serviceManager =
+         ServiceManager.getServiceManager((AxisServer)engine);
+         SecurityManager securityManager =
+             SecurityManager.getManager();
+      
+                     try {
+                         msgCtx = serviceManager.createMessageContext(serviceName);
+                         ServiceSecurityConfig.initialize(msgCtx);
+                         subject = securityManager.getServiceSubject(serviceName);
+                     } catch (Exception e) {
+                         NamingException ne =
+                             new NamingException(i18n.getMessage("beanSecInitFailed"));
+                         ne.setRootCause(e);
+                         throw ne;
+                     }
+                 }*/
+      try
+      {
+         if ( subject == null )
+         {
+            return getInstance( msgCtx, obj, name, nameCtx, environment );
+         }
+         else
+         {
+            /*  GetInstanceAction action =
+               new GetInstanceAction(msgCtx, obj, name,
+                                     nameCtx, environment);
+               return JaasSubject.doAs(subject, action);*/
+         }
+      }
+      catch ( NamingException e )
+      {
+         throw e;
+      } /*catch (PrivilegedActionException e) {
+         Exception cause = e.getException();
+         if (cause instanceof NamingException) {
+             throw (NamingException)cause;
+         } else {
+             NamingException nm =
+                 new NamingException("beanInitFailed");
+             nm.setRootCause(cause);
+             throw nm;
+         }
+         } */
+      catch ( Exception e )
+      {
+         NamingException nm = new NamingException( "beanInitFailed" );
+         nm.setRootCause( e );
+         throw nm;
+      }
+
+      //todo fix this method
+      return null;
+   }
+
+   private Object getInstance( MessageContext msgCtx,
+                               Object         obj,
+                               Name           name,
+                               Context        nameCtx,
+                               Hashtable      environment )
+   throws NamingException
+   { //todo fix!
 
-    /**
-     * Create a new Bean instance. If <code>obj</code> is of type
-     * {@link ServiceResourceRef}, the bean will be
-     * created and initialized with security credentials associated 
-     * with the current thread if the service associated with this bean
-     * has a security descriptor configured.
-     */
-    public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-                                    Hashtable environment)
-        throws NamingException {
-        Subject subject = null;
-        MessageContext msgCtx = null;
-
-        if (obj instanceof ServiceResourceRef) {
-            ServiceResourceRef resource = (ServiceResourceRef)obj;
-            AxisEngine engine = resource.getAxisEngine();
-            String serviceName =  resource.getServiceName();
-            if (engine == null) {
-                throw new NamingException("noServiceSet");
-            }
-            if (serviceName == null) {
-                throw new NamingException("noEngineSet");
-            }}
-
-           /* ServiceManager serviceManager =
-                ServiceManager.getServiceManager((AxisServer)engine);
-            SecurityManager securityManager = 
-                SecurityManager.getManager();
-
-            try {
-                msgCtx = serviceManager.createMessageContext(serviceName);
-                ServiceSecurityConfig.initialize(msgCtx);
-                subject = securityManager.getServiceSubject(serviceName);
-            } catch (Exception e) {
-                NamingException ne = 
-                    new NamingException(i18n.getMessage("beanSecInitFailed"));
-                ne.setRootCause(e);
-                throw ne;
-            }
-        }*/
-
-        try {
-            if (subject == null) {
-                return getInstance(msgCtx, obj, name, nameCtx, environment);
-            } else {
-              /*  GetInstanceAction action =
-                    new GetInstanceAction(msgCtx, obj, name, 
-                                          nameCtx, environment);
-                return JaasSubject.doAs(subject, action);*/
-            } 
-        } catch (NamingException e) {
-            throw e;
-        } /*catch (PrivilegedActionException e) {
-            Exception cause = e.getException();
-            if (cause instanceof NamingException) {
-                throw (NamingException)cause;
-            } else {
-                NamingException nm = 
-                    new NamingException("beanInitFailed");
-                nm.setRootCause(cause);
-                throw nm;
-            }
-        } */catch (Exception e) {
-            NamingException nm = 
-                new NamingException("beanInitFailed");
-            nm.setRootCause(e);
-            throw nm;
-        }
-        //todo fix this method
-        return null;
-    }
-
-    private Object getInstance(MessageContext msgCtx, Object obj, Name name,
-                               Context nameCtx, Hashtable environment)
-        throws NamingException {      //todo fix!
-       // MessageContext oldCtx =
-        //    ServiceManager.HelperAxisEngine.getCurrentMessageContext();
+      // MessageContext oldCtx =
+      //    ServiceManager.HelperAxisEngine.getCurrentMessageContext();
       //  ServiceManager.HelperAxisEngine.setCurrentMessageContext(msgCtx);
-        try {
-            return super.getObjectInstance(obj, name, nameCtx, environment);
-        } finally {
-           // ServiceManager.HelperAxisEngine.setCurrentMessageContext(oldCtx);
-        }
-    }
-    
-    private class GetInstanceAction implements PrivilegedExceptionAction {
-
-        private MessageContext msgCtx;
-        private Object obj;
-        private Name name;
-        private Context nameCtx;
-        private Hashtable environment;
-
-        private GetInstanceAction(MessageContext msgCtx, Object obj, Name name,
-                                  Context nameCtx, Hashtable environment) {
-            this.msgCtx = msgCtx;
-            this.obj = obj;
-            this.name = name;
-            this.nameCtx = nameCtx;
-            this.environment = environment;
-        }
-
-        public Object run() throws Exception {
-            return getInstance(this.msgCtx, this.obj, this.name, 
-                               this.nameCtx, this.environment);
-        }
-    }
-    
-    
-}
+      try
+      {
+         return super.getObjectInstance( obj, name, nameCtx, environment );
+      }
+      finally
+      {
+         // ServiceManager.HelperAxisEngine.setCurrentMessageContext(oldCtx);
+      }
+   }
+
+   private class GetInstanceAction
+      implements PrivilegedExceptionAction
+   {
+      private MessageContext msgCtx;
+      private Object         obj;
+      private Name           name;
+      private Context        nameCtx;
+      private Hashtable      environment;
+
+      private GetInstanceAction( MessageContext msgCtx,
+                                 Object         obj,
+                                 Name           name,
+                                 Context        nameCtx,
+                                 Hashtable      environment )
+      {
+         this.msgCtx         = msgCtx;
+         this.obj            = obj;
+         this.name           = name;
+         this.nameCtx        = nameCtx;
+         this.environment    = environment;
+      }
+
+      /**
+       * DOCUMENT_ME
+       *
+       * @return DOCUMENT_ME
+       *
+       * @throws Exception DOCUMENT_ME
+       */
+      public Object run(  )
+      throws Exception
+      {
+         return getInstance( this.msgCtx, this.obj, this.name, this.nameCtx, this.environment );
+      }
+   }
+}
\ No newline at end of file

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java Tue Aug  2 09:28:49 2005
@@ -1,5 +1,21 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
 package org.apache.ws.util.jndi;
 
+
 /**
  * A bean to hold default values for Service config parameters.
  *
@@ -7,16 +23,25 @@
  */
 public class DefaultParameters
 {
-    private String m_defaultFactory = org.apache.ws.util.jndi.BeanFactory.class.getName();
-
-    public String getFactory()
-    {
-        return m_defaultFactory;
-    }
+   private String m_defaultFactory = org.apache.ws.util.jndi.BeanFactory.class.getName(  );
 
-    public void setFactory(String defaultFactory)
-    {
-        m_defaultFactory = defaultFactory;
-    }
+   /**
+    * DOCUMENT_ME
+    *
+    * @param defaultFactory DOCUMENT_ME
+    */
+   public void setFactory( String defaultFactory )
+   {
+      m_defaultFactory = defaultFactory;
+   }
 
-}
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String getFactory(  )
+   {
+      return m_defaultFactory;
+   }
+}
\ No newline at end of file

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/Initializable.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/Initializable.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/Initializable.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/Initializable.java Tue Aug  2 09:28:49 2005
@@ -15,6 +15,7 @@
  *=============================================================================*/
 package org.apache.ws.util.jndi;
 
+
 /**
  * Used with {@link BeanFactory}.
  * The init() method will be called if the bean implements this interface.

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java Tue Aug  2 09:28:49 2005
@@ -1,15 +1,29 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
 package org.apache.ws.util.jndi;
 
 import org.apache.axis.AxisEngine;
 import org.apache.axis.Constants;
 import org.apache.axis.MessageContext;
+import org.apache.commons.digester.Digester;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.commons.digester.Digester;
 import org.apache.naming.ContextBindings;
 import org.apache.ws.util.DeployConstants;
 import org.apache.ws.util.jndi.tools.JNDIConfigRuleSet;
-
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NameClassPair;
@@ -29,344 +43,368 @@
  */
 public abstract class JNDIUtils
 {
+   //TODO (low-priority): many of these methods should be made private
+   private static Log LOG = LogFactory.getLog( JNDIUtils.class.getName(  ) );
 
-    //TODO (low-priority): many of these methods should be made private
-    private static Log LOG =
-            LogFactory.getLog( JNDIUtils.class.getName() );
-    /**
-     * Apache JNDI URL Package Prefix
-     */
-    public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
-
-    /**
-     * Apache JNDI Initial Context Factory Prefix
-     */
-    public static final String APACHE_INITIAL_CONTEXT_FACTORY =
-            "org.apache.naming.java.javaURLContextFactory";
-
-    public static final String JNDI_CONFIG = "jndi-config.xml";
-
-    private static Context initialContext = null;
-
-    /**
-     * Configure JNDI with the Apache Tomcat naming service classes and create the comp and env contexts
-     *
-     * @return The initial context
-     *
-     * @throws Exception
-     */
-    public static Context initJNDI()
-            throws Exception
-    {
-        LOG.debug( "Initializing JNDI..." );
-        Context result = null;
-        Context compContext = null;
-
-        // set up naming
-
-        String value = APACHE_URL_PKG_PREFIX;
-        String oldValue =
-                System.getProperty( Context.URL_PKG_PREFIXES );
-
-        if ( oldValue != null )
-        {
-            if ( oldValue.startsWith( value + ":" ) )
-            {
-                value = oldValue;
-            }
-            else
-            {
-                value = value + ":" + oldValue;
-            }
-        }
-        LOG.debug( "Setting System Property " + Context.URL_PKG_PREFIXES + " to " + value );
-        System.setProperty( Context.URL_PKG_PREFIXES, value );
-
-        value = System.getProperty( Context.INITIAL_CONTEXT_FACTORY );
-
-        if ( value == null )
-        {
-            System.setProperty( Context.INITIAL_CONTEXT_FACTORY,
-                    APACHE_INITIAL_CONTEXT_FACTORY );
-            LOG.debug(
-                    "Setting System Property " + Context.INITIAL_CONTEXT_FACTORY + " to " +
-                    APACHE_INITIAL_CONTEXT_FACTORY );
-        }
-        else
-        {
-            LOG.debug( "System Property " + Context.INITIAL_CONTEXT_FACTORY + " is set to " + value );
-        }
-
-        result = new InitialContext();
-        if ( !ContextBindings.isClassLoaderBound() )
-        {
-            ContextBindings.bindContext( "wsrfContext", result );
-            ContextBindings.bindClassLoader( "wsrfContext" );
-        }
-
-        try
-        {
-            result.lookup( "java:comp/env" );
-        }
-        catch ( NameNotFoundException e )
-        {
-            compContext = result.createSubcontext( "comp" );
-            compContext.createSubcontext( "env" );
-        }
-        return result;
-    }
-
-
-    /**
-     * 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() );
-        }
-    }
-
-    private static class DirFilter implements FileFilter
-    {
-        public boolean accept( File path )
-        {
-            return path.isDirectory();
-        }
-    }
-
-    // multiple file configuration
-    public static synchronized Context initializeDir( MessageContext msgCtx )
-            throws Exception
-    {
-        if ( initialContext == null )
-        {
-            Context context = initJNDI();
-            String dir = (String) msgCtx.getProperty( Constants.MC_CONFIGPATH );
-            String configDir = ( dir == null ) ?
-                    DeployConstants.CONFIG_BASE_DIR :
-                    dir + File.separator + DeployConstants.CONFIG_BASE_DIR;
-
-            File fDir = new File( configDir );
-            File[] dirs = fDir.listFiles( new DirFilter() );
-            for ( int i = 0; i < dirs.length; i++ )
+   /**
+    * Apache JNDI URL Package Prefix
+    */
+   public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
+
+   /**
+    * Apache JNDI Initial Context Factory Prefix
+    */
+   public static final String APACHE_INITIAL_CONTEXT_FACTORY = "org.apache.naming.java.javaURLContextFactory";
+
+   /** DOCUMENT_ME */
+   public static final String JNDI_CONFIG = "jndi-config.xml";
+   private static Context     initialContext = null;
+
+   /**
+    * 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
             {
-                processJNDIFile( context, dirs[i],
-                        msgCtx.getAxisEngine(), JNDI_CONFIG );
+               currentContext = currentContext.createSubcontext( token );
             }
-            initialContext = context;
-        }
-        return initialContext;
-    }
-
-    private static void processJNDIFile( Context context,
-                                         File dir,
-                                         AxisEngine engine,
-                                         String configFile )
-            throws Exception
-    {
-        File file = new File( dir, configFile );
-        if ( !file.exists() )
-        {
-            return;
-        }
-
-        LOG.debug( "Loading jndi configuration from file: " + file );
-
-        InputStream in = null;
-        try
-        {
-            in = new FileInputStream( file );
-            parseJNDIConfig( context, in, engine );
-        }
-        finally
-        {
-            if ( in != null )
+            catch ( NamingException e )
             {
-                try
-                {
-                    in.close();
-                }
-                catch ( IOException e )
-                {
-                }
+               // Silent catch. Probably an object is already bound in
+               // the context.
+               currentContext = (Context) currentContext.lookup( token );
             }
-        }
-    }
+         }
+      }
 
-    // single file configuration
-    public static synchronized Context initializeFile( MessageContext msgCtx )
-            throws Exception
-    {
-        if ( initialContext == null )
-        {
-            Context context = initJNDI();
+      return currentContext;
+   }
 
-            InputStream configInput;
-            try
+   /**
+    * Configure JNDI with the Apache Tomcat naming service classes and create the comp and env contexts
+    *
+    * @return The initial context
+    *
+    * @throws Exception
+    */
+   public static Context initJNDI(  )
+   throws Exception
+   {
+      LOG.debug( "Initializing JNDI..." );
+      Context result      = null;
+      Context compContext = null;
+
+      // set up naming
+      String value    = APACHE_URL_PKG_PREFIX;
+      String oldValue = System.getProperty( Context.URL_PKG_PREFIXES );
+
+      if ( oldValue != null )
+      {
+         if ( oldValue.startsWith( value + ":" ) )
+         {
+            value = oldValue;
+         }
+         else
+         {
+            value = value + ":" + oldValue;
+         }
+      }
+
+      LOG.debug( "Setting System Property " + Context.URL_PKG_PREFIXES + " to " + value );
+      System.setProperty( Context.URL_PKG_PREFIXES, value );
+
+      value = System.getProperty( Context.INITIAL_CONTEXT_FACTORY );
+
+      if ( value == null )
+      {
+         System.setProperty( Context.INITIAL_CONTEXT_FACTORY, APACHE_INITIAL_CONTEXT_FACTORY );
+         LOG.debug( "Setting System Property " + Context.INITIAL_CONTEXT_FACTORY + " to "
+                    + APACHE_INITIAL_CONTEXT_FACTORY );
+      }
+      else
+      {
+         LOG.debug( "System Property " + Context.INITIAL_CONTEXT_FACTORY + " is set to " + value );
+      }
+
+      result = new InitialContext(  );
+      if ( !ContextBindings.isClassLoaderBound(  ) )
+      {
+         ContextBindings.bindContext( "wsrfContext", result );
+         ContextBindings.bindClassLoader( "wsrfContext" );
+      }
+
+      try
+      {
+         result.lookup( "java:comp/env" );
+      }
+      catch ( NameNotFoundException e )
+      {
+         compContext = result.createSubcontext( "comp" );
+         compContext.createSubcontext( "env" );
+      }
+
+      return result;
+   }
+
+   // multiple file configuration
+   public static synchronized Context initializeDir( MessageContext msgCtx )
+   throws Exception
+   {
+      if ( initialContext == null )
+      {
+         Context context   = initJNDI(  );
+         String  dir       = (String) msgCtx.getProperty( Constants.MC_CONFIGPATH );
+         String  configDir =
+            ( dir == null ) ? DeployConstants.CONFIG_BASE_DIR
+                            : ( dir + File.separator + DeployConstants.CONFIG_BASE_DIR );
+
+         File   fDir = new File( configDir );
+         File[] dirs = fDir.listFiles( new DirFilter(  ) );
+         for ( int i = 0; i < dirs.length; i++ )
+         {
+            processJNDIFile( context,
+                             dirs[i],
+                             msgCtx.getAxisEngine(  ),
+                             JNDI_CONFIG );
+         }
+
+         initialContext = context;
+      }
+
+      return initialContext;
+   }
+
+   // single file configuration
+   public static synchronized Context initializeFile( MessageContext msgCtx )
+   throws Exception
+   {
+      if ( initialContext == null )
+      {
+         Context     context = initJNDI(  );
+
+         InputStream configInput;
+         try
+         {
+            String cfgDir = null;
+            if ( msgCtx != null )
             {
-                String cfgDir = null;
-                if ( msgCtx != null )
-                {
-                    cfgDir = (String) msgCtx.getProperty( Constants.MC_CONFIGPATH );
-                }
-                if ( cfgDir == null )
-                {
-                    cfgDir = ".";
-                }
-                String file = cfgDir + File.separator + JNDI_CONFIG;
-                LOG.debug( "Trying to load JNDI configuration from file: " +
-                        file );
-
-                configInput = new FileInputStream( file );
+               cfgDir = (String) msgCtx.getProperty( Constants.MC_CONFIGPATH );
             }
-            catch ( FileNotFoundException e )
-            {
-                LOG.debug( "Trying to load JNDI configuration from resource stream: " + JNDI_CONFIG );
-
-                configInput =
-                        JNDIUtils.class.getClassLoader().getResourceAsStream( JNDI_CONFIG );
 
-                if ( configInput == null )
-                {
-                    throw new IOException( "jndiConfigNotFound" );
-                }
+            if ( cfgDir == null )
+            {
+               cfgDir = ".";
             }
 
-            parseJNDIConfig( context, configInput, msgCtx.getAxisEngine() );
+            String file = cfgDir + File.separator + JNDI_CONFIG;
+            LOG.debug( "Trying to load JNDI configuration from file: " + file );
 
-            initialContext = context;
-        }
+            configInput = new FileInputStream( file );
+         }
+         catch ( FileNotFoundException e )
+         {
+            LOG.debug( "Trying to load JNDI configuration from resource stream: " + JNDI_CONFIG );
 
-        return initialContext;
-    }
+            configInput = JNDIUtils.class.getClassLoader(  ).getResourceAsStream( JNDI_CONFIG );
 
-    public static String toString( Context ctx, String name )
-            throws NamingException
-    {
-        StringBuffer buf = new StringBuffer();
-        toString( buf, ctx, name, "" );
-        return buf.toString();
-    }
-
-    private static void toString( StringBuffer buf, Context ctx,
-                                  String name, String tab )
-            throws NamingException
-    {
-        buf.append( tab ).append( "context: " ).append( name ).append( "\n" );
-        NamingEnumeration list = ctx.list( name );
-        while ( list.hasMore() )
-        {
-            NameClassPair nc = (NameClassPair) list.next();
-            if ( nc.getClassName().equals( "org.apache.naming.NamingContext" ) )
+            if ( configInput == null )
             {
-                toString( buf, ctx, name + "/" + nc.getName(), tab + "  " );
+               throw new IOException( "jndiConfigNotFound" );
             }
-            else
+         }
+
+         parseJNDIConfig( context,
+                          configInput,
+                          msgCtx.getAxisEngine(  ) );
+
+         initialContext = context;
+      }
+
+      return initialContext;
+   }
+
+   /**
+    * 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(  ) );
+      }
+   }
+
+   /**
+    * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
+    *
+    * @param configInput The configuration stream to parse
+    *
+    * @throws Exception
+    */
+   public static void parseJNDIConfig( InputStream configInput )
+   throws Exception
+   {
+      parseJNDIConfig( new InitialContext(  ),
+                       configInput,
+                       null );
+   }
+
+   /**
+    * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
+    *
+    * @param configInput The configuration stream to parse
+    *
+    * @throws Exception
+    */
+   public static void parseJNDIConfig( Context     initContext,
+                                       InputStream configInput,
+                                       AxisEngine  engine )
+   throws Exception
+   {
+      if ( configInput == null )
+      {
+         throw new IllegalArgumentException( "config input stream was null." );
+      }
+
+      if ( initContext == null )
+      {
+         throw new IllegalArgumentException( "initial context was null." );
+      }
+
+      Context  envContext = (Context) initContext.lookup( "java:comp/env" );
+      Digester digester = new Digester(  );
+
+      digester.setNamespaceAware( true );
+      digester.setValidating( false ); // don't do any validation for now
+      digester.addRuleSet( new JNDIConfigRuleSet( "jndiConfig/" ) );
+
+      digester.push( new NamingContext( envContext, engine ) );
+      digester.parse( configInput );
+      digester.clear(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param ctx DOCUMENT_ME
+    * @param name DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    *
+    * @throws NamingException DOCUMENT_ME
+    */
+   public static String toString( Context ctx,
+                                  String  name )
+   throws NamingException
+   {
+      StringBuffer buf = new StringBuffer(  );
+      toString( buf, ctx, name, "" );
+      return buf.toString(  );
+   }
+
+   private static void processJNDIFile( Context    context,
+                                        File       dir,
+                                        AxisEngine engine,
+                                        String     configFile )
+   throws Exception
+   {
+      File file = new File( dir, configFile );
+      if ( !file.exists(  ) )
+      {
+         return;
+      }
+
+      LOG.debug( "Loading jndi configuration from file: " + file );
+
+      InputStream in = null;
+      try
+      {
+         in = new FileInputStream( file );
+         parseJNDIConfig( context, in, engine );
+      }
+      finally
+      {
+         if ( in != null )
+         {
+            try
             {
-                buf.append( tab ).append( " " ).append( nc ).append( "\n" );
+               in.close(  );
             }
-        }
-    }
-
-    /**
-     * 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() ) )
+            catch ( IOException e )
             {
-                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;
-    }
-
-    /**
-     * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
-     *
-     * @param configInput The configuration stream to parse
-     *
-     * @throws Exception
-     */
-    public static void parseJNDIConfig( InputStream configInput )
-            throws Exception
-    {
-        parseJNDIConfig( new InitialContext(), configInput, null );
-    }
-
-    /**
-     * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
-     *
-     * @param configInput The configuration stream to parse
-     *
-     * @throws Exception
-     */
-    public static void parseJNDIConfig( Context initContext,
-                                        InputStream configInput,
-                                        AxisEngine engine )
-            throws Exception
-    {
-
-        if ( configInput == null )
-        {
-            throw new IllegalArgumentException( "config input stream was null." );
-        }
-
-        if ( initContext == null )
-        {
-            throw new IllegalArgumentException( "initial context was null." );
-        }
-
-        Context envContext = (Context) initContext.lookup( "java:comp/env" );
-        Digester digester = new Digester();
-
-        digester.setNamespaceAware( true );
-        digester.setValidating( false );  // don't do any validation for now
-        digester.addRuleSet( new JNDIConfigRuleSet( "jndiConfig/" ) );
-
-        digester.push( new NamingContext( envContext, engine ) );
-        digester.parse( configInput );
-        digester.clear();
-    }
-
-}
+         }
+      }
+   }
+
+   private static void toString( StringBuffer buf,
+                                 Context      ctx,
+                                 String       name,
+                                 String       tab )
+   throws NamingException
+   {
+      buf.append( tab ).append( "context: " ).append( name ).append( "\n" );
+      NamingEnumeration list = ctx.list( name );
+      while ( list.hasMore(  ) )
+      {
+         NameClassPair nc = (NameClassPair) list.next(  );
+         if ( nc.getClassName(  ).equals( "org.apache.naming.NamingContext" ) )
+         {
+            toString( buf, ctx, name + "/" + nc.getName(  ), tab + "  " );
+         }
+         else
+         {
+            buf.append( tab ).append( " " ).append( nc ).append( "\n" );
+         }
+      }
+   }
+
+   private static class DirFilter
+      implements FileFilter
+   {
+      /**
+       * DOCUMENT_ME
+       *
+       * @param path DOCUMENT_ME
+       *
+       * @return DOCUMENT_ME
+       */
+      public boolean accept( File path )
+      {
+         return path.isDirectory(  );
+      }
+   }
+}
\ No newline at end of file

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/NamingContext.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/NamingContext.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/NamingContext.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/NamingContext.java Tue Aug  2 09:28:49 2005
@@ -24,7 +24,6 @@
 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.NameNotFoundException;
@@ -43,7 +42,7 @@
  */
 public class NamingContext
 {
-   private static Log LOG  = LogFactory.getLog( NamingContext.class.getName(  ) );
+   private static Log LOG     = LogFactory.getLog( NamingContext.class.getName(  ) );
    private Context    context;
    private AxisEngine engine;
 
@@ -77,7 +76,7 @@
       // Instantiate a new instance of the correct object type, and
       // initialize it.
       String type = environment.getType(  );
-      LOG.debug("Attempting to add environment for type: " + type);
+      LOG.debug( "Attempting to add environment for type: " + type );
       try
       {
          if ( type.equals( "java.lang.String" ) )

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=227033&r1=227032&r2=227033&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 Tue Aug  2 09:28:49 2005
@@ -18,15 +18,13 @@
 import org.apache.axis.components.logger.LogFactory;
 import org.apache.commons.logging.Log;
 import org.apache.ws.resource.JndiConstants;
-import org.apache.ws.resource.faults.FaultException;
+import org.apache.ws.util.XmlBeanUtils;
 import org.apache.ws.util.jndi.tools.ConfigContext;
 import org.apache.ws.util.jndi.tools.Environment;
 import org.apache.ws.util.jndi.tools.MetadataConfig;
 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 org.apache.ws.util.XmlBeanUtils;
-import org.apache.ws.Soap1_1Constants;
 import org.apache.wsfx.wsrf.jndi.config.EnvironmentDocument;
 import org.apache.wsfx.wsrf.jndi.config.GlobalDocument;
 import org.apache.wsfx.wsrf.jndi.config.JndiConfigDocument;
@@ -38,8 +36,6 @@
 import org.apache.wsfx.wsrf.jndi.config.ServiceDocument;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
-
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NameNotFoundException;
@@ -65,580 +61,602 @@
  */
 public class XmlBeanJndiUtils
 {
-    private static Log LOG = LogFactory.getLog(XmlBeanJndiUtils.class.getName());
-
-    /**
-     * Apache JNDI URL Package Prefix
-     */
-    public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
-
-    /**
-     * Apache JNDI Initial Context Factory Prefix
-     */
-    public static final String APACHE_INITIAL_CONTEXT_FACTORY =
-            "org.apache.naming.java.javaURLContextFactory";
-
-    /**
-     * The file name of the jndi-config file.
-     */
-    public static final String JNDI_CONFIG_FILENAME = "jndi-config.xml";
-    private static final String PROP_FACTORY = "factory";
-
-    private static boolean s_configLoaded;
-    private static boolean s_jndiInitialized;
-
-    private static DefaultParameters s_defaultParams;
-
-    /**
-     * Configure JNDI with the Apache Tomcat naming service classes and
-     * create the WSRF context.
-     *
-     * @return the WSRF context
-     * @throws Exception
-     */
-    public static synchronized Context initJNDI()
-            throws Exception
-    {
-        if (!s_jndiInitialized)
-        {
-            initJndiImpl();
-            initWsrfContext();
-            s_jndiInitialized = true;
-        }
-        return new InitialContext();
-    }
-
-    private static Context initWsrfContext()
-            throws NamingException
-    {
-        Context wsrfContext;
-        InitialContext initialContext = new InitialContext();
-        try
-        {
-            wsrfContext = (Context) initialContext.lookup(JndiConstants.CONTEXT_NAME_BASE);
-        }
-        catch (NameNotFoundException nnfe)
-        {
-            LOG.debug("Initializing WSRF JNDI context...");
-            LOG.debug("Creating JNDI subcontext: " + JndiConstants.CONTEXT_NAME_BASE + " ...");
-            wsrfContext = initialContext.createSubcontext(JndiConstants.CONTEXT_NAME_BASE);
-            LOG.debug("Creating JNDI subcontext: " + JndiConstants.CONTEXT_SERVICES_BASE + " ...");
-            wsrfContext.createSubcontext(JndiConstants.CONTEXT_SERVICES_BASE);
-            LOG.debug("Creating JNDI subcontext: " + JndiConstants.CONTEXT_GLOBAL_BASE + " ...");
-            wsrfContext.createSubcontext(JndiConstants.CONTEXT_GLOBAL_BASE);
-        }
-        return wsrfContext;
-    }
-
-    private static void initJndiImpl()
-    {
-        String apacheUrlPrefix = APACHE_URL_PKG_PREFIX;
-        String systemUrlPrefix = System.getProperty(Context.URL_PKG_PREFIXES);
-        String systemContextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
-
-        if (systemContextFactory == null && systemUrlPrefix == null)
-        {
-            System.setProperty(Context.URL_PKG_PREFIXES, apacheUrlPrefix);
-            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, APACHE_INITIAL_CONTEXT_FACTORY);
-        }
-    }
-
-    /**
-     * Initializes JNDI from a directory tree which contains the jndi-config.xml files....
-     *
-     * @param configDir
-     * @return
-     * @throws Exception
-     */
-    public static synchronized Context initFromDir(String configDir)
-            throws Exception
-    {
-
-        if (!s_configLoaded)
-        {
-            LOG.debug("Initializing JNDI from config directory: " + configDir + " ...");
-
-            initJNDI();
-
-            File fDir = new File(configDir);
-            File[] dirs =
-                    fDir.listFiles(new FileFilter()
-                    {
-                        public boolean accept(File path)
-                        {
-                            return path.isDirectory();
-                        }
-                    });
-
-            for (int i = 0; i < dirs.length; i++)
-            {
-                processJNDIFile(dirs[i], JNDI_CONFIG_FILENAME);
-            }
-            s_configLoaded = true;
-        }
-
+   private static Log LOG = LogFactory.getLog( XmlBeanJndiUtils.class.getName(  ) );
 
-        return new InitialContext();
-    }
-
-    /**
-     * Initializes JNDI given a File name which will attempt to be loaded.
-     *
-     * @param configFilename
-     * @return
-     * @throws Exception
-     */
-    public static synchronized Context initFromFile(String configFilename)
-            throws Exception
-    {
-        LOG.debug("Initializing JNDI from file: " + configFilename);
-        if (!s_configLoaded)
-        {
-            initJNDI();
-
-            InputStream configInput;
+   /**
+    * Apache JNDI URL Package Prefix
+    */
+   public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
+
+   /**
+    * Apache JNDI Initial Context Factory Prefix
+    */
+   public static final String APACHE_INITIAL_CONTEXT_FACTORY = "org.apache.naming.java.javaURLContextFactory";
+
+   /**
+    * The file name of the jndi-config file.
+    */
+   public static final String       JNDI_CONFIG_FILENAME = "jndi-config.xml";
+   private static final String      PROP_FACTORY = "factory";
+   private static boolean           s_configLoaded;
+   private static boolean           s_jndiInitialized;
+   private static DefaultParameters s_defaultParams;
+
+   /**
+    * Initializes JNDI from a directory tree which contains the jndi-config.xml files....
+    *
+    * @param configDir
+    * @return
+    * @throws Exception
+    */
+   public static synchronized Context initFromDir( String configDir )
+   throws Exception
+   {
+      if ( !s_configLoaded )
+      {
+         LOG.debug( "Initializing JNDI from config directory: " + configDir + " ..." );
+
+         initJNDI(  );
+
+         File   fDir = new File( configDir );
+         File[] dirs =
+            fDir.listFiles( new FileFilter(  )
+               {
+                  public boolean accept( File path )
+                  {
+                     return path.isDirectory(  );
+                  }
+               } );
+
+         for ( int i = 0; i < dirs.length; i++ )
+         {
+            processJNDIFile( dirs[i], JNDI_CONFIG_FILENAME );
+         }
+
+         s_configLoaded = true;
+      }
+
+      return new InitialContext(  );
+   }
+
+   /**
+    * Initializes JNDI given a File name which will attempt to be loaded.
+    *
+    * @param configFilename
+    * @return
+    * @throws Exception
+    */
+   public static synchronized Context initFromFile( String configFilename )
+   throws Exception
+   {
+      LOG.debug( "Initializing JNDI from file: " + configFilename );
+      if ( !s_configLoaded )
+      {
+         initJNDI(  );
+
+         InputStream configInput;
+         try
+         {
+            LOG.debug( "Trying to load JNDI configuration from file: " + configFilename );
+            configInput = new FileInputStream( configFilename );
+         }
+         catch ( FileNotFoundException fnfe )
+         {
+            LOG.debug( "Trying to load JNDI configuration from classloader resource: " + configFilename );
+            configInput = XmlBeanJndiUtils.class.getClassLoader(  ).getResourceAsStream( configFilename );
+            if ( configInput == null )
+            {
+               throw new IOException( "jndiConfigNotFound" );
+            }
+         }
+
+         Context context = new InitialContext(  );
+         parseJNDIConfig( context, configInput );
+         s_configLoaded = true;
+      }
+
+      return new InitialContext(  );
+   }
+
+   /**
+    * Initializes JNDI from a given InputStream to a jndi-config.xml file.
+    *
+    * @param inputStream
+    * @return JNDI Context
+    * @throws Exception
+    */
+   public static synchronized Context initFromInputStream( InputStream inputStream )
+   throws Exception
+   {
+      if ( !s_configLoaded )
+      {
+         initJNDI(  );
+         LOG.debug( "Trying to load JNDI configuration from inputstream" );
+         parseJNDIConfig( new InitialContext(  ),
+                          inputStream );
+         s_configLoaded = true;
+      }
+
+      return new InitialContext(  );
+   }
+
+   /**
+    * Configure JNDI with the Apache Tomcat naming service classes and
+    * create the WSRF context.
+    *
+    * @return the WSRF context
+    * @throws Exception
+    */
+   public static synchronized Context initJNDI(  )
+   throws Exception
+   {
+      if ( !s_jndiInitialized )
+      {
+         initJndiImpl(  );
+         initWsrfContext(  );
+         s_jndiInitialized = true;
+      }
+
+      return new InitialContext(  );
+   }
+
+   /**
+    * Called via parseJNDIConfig(InputStream)
+    * <p/>
+    * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
+    *
+    * @param configStream The configuration stream to parse
+    * @throws Exception
+    */
+   public static void parseJNDIConfig( Context     initContext,
+                                       InputStream configStream )
+   throws Exception
+   {
+      if ( configStream == null )
+      {
+         throw new IllegalArgumentException( "nullJNDIConfigInput" );
+      }
+
+      if ( initContext == null )
+      {
+         throw new IllegalArgumentException(  );
+      }
+
+      //get the global context
+      Context              envContext    = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_GLOBAL );
+      XmlBeanNamingContext namingContext = new XmlBeanNamingContext( envContext );
+
+      //load the config file
+      JndiConfigDocument jndiConfigDoc = (JndiConfigDocument) XmlObject.Factory.parse( configStream );
+      validateJndiConfig( jndiConfigDoc );
+      JndiConfigDocument.JndiConfig jndiConfig = jndiConfigDoc.getJndiConfig(  );
+      GlobalDocument.Global         global = jndiConfig.getGlobal(  );
+
+      //setup the global jndi elements
+      addGlobalElements( namingContext, global );
+
+      //get the service context
+      envContext       = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_SERVICES );
+      namingContext    = new XmlBeanNamingContext( envContext );
+
+      //setup the service jndi elements
+      ServiceDocument.Service[] serviceArray = jndiConfig.getServiceArray(  );
+      addServiceElements( namingContext, serviceArray );
+   }
+
+   private static void setDefaultParameterValues( ResourceParameters params )
+   {
+      if ( params.getParameter( PROP_FACTORY ) == null )
+      {
+         params.addParameter( PROP_FACTORY,
+                              s_defaultParams.getFactory(  ) );
+      }
+   }
+
+   private static DefaultParameters getDefaultProperties( GlobalDocument.Global global )
+   throws IllegalAccessException, 
+          InstantiationException, 
+          ClassNotFoundException
+   {
+      ResourceDocument.Resource   defaultConfig = null;
+      ResourceDocument.Resource[] resourceArray = global.getResourceArray(  );
+      for ( int i = 0; i < resourceArray.length; i++ )
+      {
+         ResourceDocument.Resource resource = resourceArray[i];
+         if ( DefaultParameters.class.getName(  ).equals( resource.getType(  ) ) )
+         {
+            defaultConfig = resource;
+            break;
+         }
+      }
+
+      return setupDefaultParams( defaultConfig );
+   }
+
+   private static Environment[] getEnvironmentArray( EnvironmentDocument.Environment[] environmentArray )
+   {
+      List envList = new ArrayList(  );
+
+      if ( environmentArray != null )
+      {
+         for ( int i = 0; i < environmentArray.length; i++ )
+         {
+            EnvironmentDocument.Environment environment = environmentArray[i];
+            Environment                     env = new Environment(  );
+            env.setDescription( environment.getDescription(  ) );
+            env.setName( environment.getName(  ) );
+            env.setType( environment.getType(  ) );
+            env.setValue( environment.getValue(  ) );
+            envList.add( env );
+         }
+      }
+
+      return (Environment[]) envList.toArray( new Environment[0] );
+   }
+
+   private static ResourceParameters getParameters( ResourceParamsDocument.ResourceParams resourceParams )
+   {
+      ResourceParameters params = new ResourceParameters(  );
+      if ( resourceParams != null )
+      {
+         ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray(  );
+         for ( int i = 0; i < parameterArray.length; i++ )
+         {
+            ParameterDocument.Parameter parameter = parameterArray[i];
+            params.addParameter( parameter.getName(  ),
+                                 parameter.getValue(  ) );
+         }
+      }
+
+      return params;
+   }
+
+   private static Resource[] getResourceArray( ResourceDocument.Resource[] resourceArray,
+                                               String                      name,
+                                               XmlBeanNamingContext        namingContext )
+   {
+      List resources = new ArrayList(  );
+      if ( resourceArray != null )
+      {
+         for ( int i = 0; i < resourceArray.length; i++ )
+         {
+            ResourceDocument.Resource resourceDoc = resourceArray[i];
+
+            //special type of resource....metatdata...handle differently....
+            MetadataConfigDocument.MetadataConfig metadataConfig = resourceDoc.getMetadataConfig(  );
+            if ( metadataConfig != null )
+            {
+               try
+               {
+                  Class          metaConfigClass = Class.forName( resourceDoc.getType(  ) );
+                  Constructor    constructor =
+                     metaConfigClass.getConstructor( new Class[]
+                                                     {
+                                                        MetadataConfigDocument.MetadataConfig.class
+                                                     } );
+                  MetadataConfig metaConfig  =
+                     (MetadataConfig) constructor.newInstance( new Object[]
+                                                               {
+                                                                  metadataConfig
+                                                               } );
+                  String         contextName = null;
+                  if ( name != null )
+                  {
+                     namingContext.getContext(  ).createSubcontext( name ); //add subcontext
+                     contextName = name + "/";
+                  }
+
+                  contextName = contextName + resourceDoc.getName(  );
+
+                  namingContext.bind( contextName, metaConfig );
+                  continue;
+               }
+               catch ( Exception e )
+               {
+                  LOG.error( "Unable to find constructor which takes: " + metadataConfig.getClass(  ).getName(  )
+                             + ", in MetadataConfig object: " + resourceDoc.getType(  )
+                             + ".  The metadata will be ignored!  Cause:" + e );
+               }
+            }
+
+            Resource resource = new Resource(  );
+            resource.setName( resourceDoc.getName(  ) );
+            resource.setAuth( resourceDoc.getAuth(  ) );
+            resource.setDescription( resourceDoc.getDescription(  ) );
+            resource.setType( resourceDoc.getType(  ) );
+            resource.setScope( resourceDoc.getScope(  ) );
+            resource.setParameters( getParameters( resourceDoc.getResourceParams(  ) ) );
+            resources.add( resource );
+         }
+      }
+
+      return (Resource[]) resources.toArray( new Resource[0] );
+   }
+
+   private static ResourceLink[] getResourceLinkArray( ResourceLinkDocument.ResourceLink[] resourceLinkArray )
+   {
+      List resourceLinks = new ArrayList(  );
+      if ( resourceLinkArray != null )
+      {
+         for ( int i = 0; i < resourceLinkArray.length; i++ )
+         {
+            ResourceLinkDocument.ResourceLink resourceLink = resourceLinkArray[i];
+            ResourceLink                      link = new ResourceLink(  );
+            link.setName( resourceLink.getName(  ) );
+            link.setTarget( resourceLink.getTarget(  ) );
+            resourceLinks.add( link );
+         }
+      }
+
+      return (ResourceLink[]) resourceLinks.toArray( new ResourceLink[0] );
+   }
+
+   private static ConfigContext[] getServiceArray( ServiceDocument.Service[] serviceArray,
+                                                   XmlBeanNamingContext      namingContext )
+   {
+      List services = new ArrayList(  );
+      if ( serviceArray != null )
+      {
+         for ( int i = 0; i < serviceArray.length; i++ )
+         {
+            ServiceDocument.Service service = serviceArray[i];
+            ConfigContext           context = new ConfigContext(  );
+            context.setName( service.getName(  ) );
+            Environment[] environmentArray = getEnvironmentArray( service.getEnvironmentArray(  ) );
+            for ( int j = 0; j < environmentArray.length; j++ )
+            {
+               context.addEnvironment( environmentArray[j] );
+            }
+
+            Resource[] resourceArray =
+               getResourceArray( service.getResourceArray(  ),
+                                 service.getName(  ),
+                                 namingContext );
+            for ( int j = 0; j < resourceArray.length; j++ )
+            {
+               Resource           resource = resourceArray[j];
+               ResourceParameters params = resource.getParameters(  );
+               setDefaultParameterValues( params );
+               validateParameterValues( params );
+            }
+
+            for ( int j = 0; j < resourceArray.length; j++ )
+            {
+               context.addResource( resourceArray[j] );
+            }
+
+            ResourceLink[] resourceLinkArray = getResourceLinkArray( service.getResourceLinkArray(  ) );
+            for ( int j = 0; j < resourceLinkArray.length; j++ )
+            {
+               context.addResourceLink( resourceLinkArray[j] );
+            }
+
+            services.add( context );
+         }
+      }
+
+      return (ConfigContext[]) services.toArray( new ConfigContext[0] );
+   }
+
+   private static ConfigContext[] getServiceSubContextArray( ConfigContext service )
+   {
+      List subContexts = new ArrayList(  );
+      if ( service != null )
+      {
+         Set      subContextNames = service.getSubContextNames(  );
+         Iterator iterator = subContextNames.iterator(  );
+
+         while ( iterator.hasNext(  ) )
+         {
+            subContexts.add( service.getSubContext( (String) iterator.next(  ) ) );
+         }
+      }
+
+      return (ConfigContext[]) subContexts.toArray( new ConfigContext[0] );
+   }
+
+   private static void addGlobalElements( XmlBeanNamingContext  namingContext,
+                                          GlobalDocument.Global global )
+   throws NamingException, 
+          IllegalAccessException, 
+          ClassNotFoundException, 
+          InstantiationException
+   {
+      if ( global != null )
+      {
+         s_defaultParams = getDefaultProperties( global );
+
+         Environment[] environmentArray = getEnvironmentArray( global.getEnvironmentArray(  ) );
+
+         for ( int i = 0; i < environmentArray.length; i++ )
+         {
+            namingContext.addEnvironment( environmentArray[i] );
+         }
+
+         ConfigContext[] subContext = getServiceArray( global.getServiceArray(  ),
+                                                       namingContext );
+         for ( int i = 0; i < subContext.length; i++ )
+         {
+            namingContext.addSubContext( subContext[i] );
+         }
+
+         Resource[] resourceArray = getResourceArray( global.getResourceArray(  ),
+                                                      null,
+                                                      namingContext );
+         for ( int i = 0; i < resourceArray.length; i++ )
+         {
+            namingContext.addResource( resourceArray[i] );
+         }
+
+         ResourceLink[] resourceLinkArray = getResourceLinkArray( global.getResourceLinkArray(  ) );
+         for ( int i = 0; i < resourceLinkArray.length; i++ )
+         {
+            namingContext.addResourceLink( resourceLinkArray[i] );
+         }
+      }
+   }
+
+   private static void addServiceElements( XmlBeanNamingContext      namingContext,
+                                           ServiceDocument.Service[] serviceArray )
+   throws NamingException
+   {
+      if ( serviceArray != null )
+      {
+         ConfigContext[] services = getServiceArray( serviceArray, namingContext );
+         for ( int i = 0; i < services.length; i++ )
+         {
+            ConfigContext service = services[i];
+            namingContext.addService( service );
+            ConfigContext[] serviceSubContextArray = getServiceSubContextArray( service );
+            for ( int j = 0; j < serviceSubContextArray.length; j++ )
+            { //todo not sure if defaults bubble down here...
+               namingContext.addSubContext( serviceSubContextArray[j] );
+            }
+         }
+      }
+   }
+
+   private static void checkValueIsNonEmpty( ResourceParameters params,
+                                             String             paramName )
+   {
+      String paramValue = params.getParameter( paramName );
+      if ( paramValue.trim(  ).equals( "" ) )
+      {
+         throw new RuntimeException( paramName + " parameter must have a non-empty value!" );
+      }
+   }
+
+   private static void initJndiImpl(  )
+   {
+      String apacheUrlPrefix      = APACHE_URL_PKG_PREFIX;
+      String systemUrlPrefix      = System.getProperty( Context.URL_PKG_PREFIXES );
+      String systemContextFactory = System.getProperty( Context.INITIAL_CONTEXT_FACTORY );
+
+      if ( ( systemContextFactory == null ) && ( systemUrlPrefix == null ) )
+      {
+         System.setProperty( Context.URL_PKG_PREFIXES, apacheUrlPrefix );
+         System.setProperty( Context.INITIAL_CONTEXT_FACTORY, APACHE_INITIAL_CONTEXT_FACTORY );
+      }
+   }
+
+   private static Context initWsrfContext(  )
+   throws NamingException
+   {
+      Context        wsrfContext;
+      InitialContext initialContext = new InitialContext(  );
+      try
+      {
+         wsrfContext = (Context) initialContext.lookup( JndiConstants.CONTEXT_NAME_BASE );
+      }
+      catch ( NameNotFoundException nnfe )
+      {
+         LOG.debug( "Initializing WSRF JNDI context..." );
+         LOG.debug( "Creating JNDI subcontext: " + JndiConstants.CONTEXT_NAME_BASE + " ..." );
+         wsrfContext = initialContext.createSubcontext( JndiConstants.CONTEXT_NAME_BASE );
+         LOG.debug( "Creating JNDI subcontext: " + JndiConstants.CONTEXT_SERVICES_BASE + " ..." );
+         wsrfContext.createSubcontext( JndiConstants.CONTEXT_SERVICES_BASE );
+         LOG.debug( "Creating JNDI subcontext: " + JndiConstants.CONTEXT_GLOBAL_BASE + " ..." );
+         wsrfContext.createSubcontext( JndiConstants.CONTEXT_GLOBAL_BASE );
+      }
+
+      return wsrfContext;
+   }
+
+   private static void processJNDIFile( File   dir,
+                                        String configFile )
+   throws Exception
+   {
+      Context context = new InitialContext(  );
+      File    file = new File( dir, configFile );
+      if ( !file.exists(  ) )
+      {
+         return;
+      }
+
+      LOG.debug( "Loading JNDI configuration from file: " + file + " ..." );
+
+      InputStream in = null;
+      try
+      {
+         in = new FileInputStream( file );
+         parseJNDIConfig( context, in );
+      }
+      finally
+      {
+         if ( in != null )
+         {
             try
             {
-                LOG.debug("Trying to load JNDI configuration from file: " + configFilename);
-                configInput = new FileInputStream(configFilename);
-            }
-            catch (FileNotFoundException fnfe)
-            {
-                LOG.debug("Trying to load JNDI configuration from classloader resource: " + configFilename);
-                configInput = XmlBeanJndiUtils.class.getClassLoader().getResourceAsStream(configFilename);
-                if (configInput == null)
-                {
-                    throw new IOException("jndiConfigNotFound");
-                }
-            }
-
-            Context context = new InitialContext();
-            parseJNDIConfig(context, configInput);
-            s_configLoaded = true;
-        }
-
-        return new InitialContext();
-    }
-
-    /**
-     * Initializes JNDI from a given InputStream to a jndi-config.xml file.
-     *
-     * @param inputStream
-     * @return JNDI Context
-     * @throws Exception
-     */
-    public static synchronized Context initFromInputStream(InputStream inputStream)
-            throws Exception
-    {
-        if (!s_configLoaded)
-        {
-            initJNDI();
-            LOG.debug("Trying to load JNDI configuration from inputstream");
-            parseJNDIConfig(new InitialContext(), inputStream);
-            s_configLoaded = true;
-        }
-
-        return new InitialContext();
-    }
-
-    /**
-     * Called via parseJNDIConfig(InputStream)
-     * <p/>
-     * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
-     *
-     * @param configStream The configuration stream to parse
-     * @throws Exception
-     */
-    public static void parseJNDIConfig(Context initContext,
-                                       InputStream configStream)
-            throws Exception
-    {
-        if (configStream == null)
-        {
-            throw new IllegalArgumentException("nullJNDIConfigInput");
-        }
-
-        if (initContext == null)
-        {
-            throw new IllegalArgumentException();
-        }
-
-        //get the global context
-        Context envContext = (Context) initContext.lookup(JndiConstants.CONTEXT_NAME_GLOBAL);
-        XmlBeanNamingContext namingContext = new XmlBeanNamingContext(envContext);
-
-        //load the config file
-        JndiConfigDocument jndiConfigDoc = (JndiConfigDocument) XmlObject.Factory.parse(configStream);
-        validateJndiConfig(jndiConfigDoc);
-        JndiConfigDocument.JndiConfig jndiConfig = jndiConfigDoc.getJndiConfig();
-        GlobalDocument.Global global = jndiConfig.getGlobal();
-
-        //setup the global jndi elements
-        addGlobalElements(namingContext, global);
-
-        //get the service context
-        envContext = (Context) initContext.lookup(JndiConstants.CONTEXT_NAME_SERVICES);
-        namingContext = new XmlBeanNamingContext(envContext);
-
-        //setup the service jndi elements
-        ServiceDocument.Service[] serviceArray = jndiConfig.getServiceArray();
-        addServiceElements(namingContext, serviceArray);
-    }
-    private static void validateJndiConfig( XmlObject requestXBean )
-    {
-            XmlOptions validateOptions = new XmlOptions();
-            List errorList = new ArrayList();
-            validateOptions.setErrorListener( errorList );
-            boolean isValid = requestXBean.validate( validateOptions );
-            if ( !isValid )
-            {
-                QName bodyElemName = XmlBeanUtils.getName( requestXBean );
-                StringBuffer strBuf = new StringBuffer( "jndi-config.xml  is not valid as per its schema: \n\n");
-                for ( int i = 0; i < errorList.size(); i++ )
-                {
-                    strBuf.append( "\t\t" );
-                    strBuf.append( i + 1 );
-                    strBuf.append( ") " );
-                    strBuf.append( errorList.get( i ) );
-                    strBuf.append( "\n" );
-                }
-                strBuf.append( "\n" );
-                LOG.fatal(strBuf.toString());
-            }
-    }
-
-    private static DefaultParameters getDefaultProperties(GlobalDocument.Global global)
-            throws IllegalAccessException,
-                   InstantiationException,
-                   ClassNotFoundException
-    {
-        ResourceDocument.Resource defaultConfig = null;
-        ResourceDocument.Resource[] resourceArray = global.getResourceArray();
-        for (int i = 0; i < resourceArray.length; i++)
-        {
-            ResourceDocument.Resource resource = resourceArray[i];
-            if (DefaultParameters.class.getName().equals(resource.getType()))
-            {
-                defaultConfig = resource;
-                break;
-            }
-        }
-
-        return setupDefaultParams(defaultConfig);
-    }
-
-    private static Environment[] getEnvironmentArray(EnvironmentDocument.Environment[] environmentArray)
-    {
-        List envList = new ArrayList();
-
-        if (environmentArray != null)
-        {
-            for (int i = 0; i < environmentArray.length; i++)
-            {
-                EnvironmentDocument.Environment environment = environmentArray[i];
-                Environment env = new Environment();
-                env.setDescription(environment.getDescription());
-                env.setName(environment.getName());
-                env.setType(environment.getType());
-                env.setValue(environment.getValue());
-                envList.add(env);
-            }
-        }
-
-        return (Environment[]) envList.toArray(new Environment[0]);
-    }
-
-    private static ResourceParameters getParameters(ResourceParamsDocument.ResourceParams resourceParams)
-    {
-        ResourceParameters params = new ResourceParameters();
-        if (resourceParams != null)
-        {
-            ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray();
-            for (int i = 0; i < parameterArray.length; i++)
-            {
-                ParameterDocument.Parameter parameter = parameterArray[i];
-                params.addParameter(parameter.getName(), parameter.getValue());
-            }
-        }
-        return params;
-    }
-
-    private static void validateParameterValues(ResourceParameters params)
-    {
-        checkValueIsNonEmpty(params, PROP_FACTORY);
-    }
-
-    private static void checkValueIsNonEmpty(ResourceParameters params, String paramName)
-    {
-        String paramValue = params.getParameter(paramName);
-        if (paramValue.trim().equals(""))
-        {
-            throw new RuntimeException(paramName + " parameter must have a non-empty value!");
-        }
-    }
-
-    private static void setDefaultParameterValues(ResourceParameters params)
-    {
-        if (params.getParameter(PROP_FACTORY) == null)
-        {
-            params.addParameter(PROP_FACTORY, s_defaultParams.getFactory());
-        }
-    }
-
-    private static Resource[] getResourceArray(ResourceDocument.Resource[] resourceArray, String name,
-                                               XmlBeanNamingContext namingContext)
-    {
-        List resources = new ArrayList();
-        if (resourceArray != null)
-        {
-            for (int i = 0; i < resourceArray.length; i++)
-            {
-                ResourceDocument.Resource resourceDoc = resourceArray[i];
-                //special type of resource....metatdata...handle differently....
-                MetadataConfigDocument.MetadataConfig metadataConfig = resourceDoc.getMetadataConfig();
-                if (metadataConfig != null)
-                {
-                    try
-                    {
-                        Class metaConfigClass = Class.forName(resourceDoc.getType());
-                        Constructor constructor = metaConfigClass.getConstructor(new Class[]{MetadataConfigDocument.MetadataConfig.class});
-                        MetadataConfig metaConfig = (MetadataConfig) constructor.newInstance(new Object[]{metadataConfig});
-                        String contextName = null;
-                        if (name != null)
-                        {
-                            namingContext.getContext().createSubcontext(name); //add subcontext
-                            contextName = name + "/";
-                        }
-                        contextName = contextName + resourceDoc.getName();
-
-                        namingContext.bind(contextName, metaConfig);
-                        continue;
-                    }
-                    catch (Exception e)
-                    {
-                        LOG.error("Unable to find constructor which takes: " + metadataConfig.getClass().getName() +
-                                  ", in MetadataConfig object: " +
-                                  resourceDoc.getType() +
-                                  ".  The metadata will be ignored!  Cause:" +
-                                  e);
-                    }
-
-                }
-                Resource resource = new Resource();
-                resource.setName(resourceDoc.getName());
-                resource.setAuth(resourceDoc.getAuth());
-                resource.setDescription(resourceDoc.getDescription());
-                resource.setType(resourceDoc.getType());
-                resource.setScope(resourceDoc.getScope());
-                resource.setParameters(getParameters(resourceDoc.getResourceParams()));
-                resources.add(resource);
+               in.close(  );
             }
-        }
-
-        return (Resource[]) resources.toArray(new Resource[0]);
-    }
-
-    private static ResourceLink[] getResourceLinkArray(ResourceLinkDocument.ResourceLink[] resourceLinkArray)
-    {
-        List resourceLinks = new ArrayList();
-        if (resourceLinkArray != null)
-        {
-            for (int i = 0; i < resourceLinkArray.length; i++)
+            catch ( IOException ioe )
             {
-                ResourceLinkDocument.ResourceLink resourceLink = resourceLinkArray[i];
-                ResourceLink link = new ResourceLink();
-                link.setName(resourceLink.getName());
-                link.setTarget(resourceLink.getTarget());
-                resourceLinks.add(link);
+               // ignore
             }
-        }
-        return (ResourceLink[]) resourceLinks.toArray(new ResourceLink[0]);
-    }
-
-    private static ConfigContext[] getServiceArray(ServiceDocument.Service[] serviceArray,
-                                                   XmlBeanNamingContext namingContext)
-    {
-        List services = new ArrayList();
-        if (serviceArray != null)
-        {
-            for (int i = 0; i < serviceArray.length; i++)
-            {
-                ServiceDocument.Service service = serviceArray[i];
-                ConfigContext context = new ConfigContext();
-                context.setName(service.getName());
-                Environment[] environmentArray = getEnvironmentArray(service.getEnvironmentArray());
-                for (int j = 0; j < environmentArray.length; j++)
-                {
-                    context.addEnvironment(environmentArray[j]);
-                }
-                Resource[] resourceArray = getResourceArray(service.getResourceArray(), service.getName(),
-                                                            namingContext);
-                for (int j = 0; j < resourceArray.length; j++)
-                {
-                    Resource resource = resourceArray[j];
-                    ResourceParameters params = resource.getParameters();
-                    setDefaultParameterValues(params);
-                    validateParameterValues(params);
-                }
-                for (int j = 0; j < resourceArray.length; j++)
-                {
-                    context.addResource(resourceArray[j]);
-                }
-
-                ResourceLink[] resourceLinkArray = getResourceLinkArray(service.getResourceLinkArray());
-                for (int j = 0; j < resourceLinkArray.length; j++)
-                {
-                    context.addResourceLink(resourceLinkArray[j]);
-                }
-
-                services.add(context);
-            }
-        }
-
-        return (ConfigContext[]) services.toArray(new ConfigContext[0]);
-    }
-
-    private static ConfigContext[] getServiceSubContextArray(ConfigContext service)
-    {
-        List subContexts = new ArrayList();
-        if (service != null)
-        {
-            Set subContextNames = service.getSubContextNames();
-            Iterator iterator = subContextNames.iterator();
-
-            while (iterator.hasNext())
-            {
-                subContexts.add(service.getSubContext((String) iterator.next()));
-            }
-        }
-
-        return (ConfigContext[]) subContexts.toArray(new ConfigContext[0]);
-    }
-
-    private static void addGlobalElements(XmlBeanNamingContext namingContext,
-                                          GlobalDocument.Global global)
-            throws NamingException,
-                   IllegalAccessException,
-                   ClassNotFoundException,
-                   InstantiationException
-    {
-        if (global != null)
-        {
-            s_defaultParams = getDefaultProperties(global);
-
-            Environment[] environmentArray = getEnvironmentArray(global.getEnvironmentArray());
-
-            for (int i = 0; i < environmentArray.length; i++)
-            {
-                namingContext.addEnvironment(environmentArray[i]);
-            }
-
-            ConfigContext[] subContext = getServiceArray(global.getServiceArray(), namingContext);
-            for (int i = 0; i < subContext.length; i++)
-            {
-                namingContext.addSubContext(subContext[i]);
-            }
-
-            Resource[] resourceArray = getResourceArray(global.getResourceArray(), null, namingContext);
-            for (int i = 0; i < resourceArray.length; i++)
-            {
-                namingContext.addResource(resourceArray[i]);
-            }
-
-            ResourceLink[] resourceLinkArray = getResourceLinkArray(global.getResourceLinkArray());
-            for (int i = 0; i < resourceLinkArray.length; i++)
-            {
-                namingContext.addResourceLink(resourceLinkArray[i]);
-            }
-        }
-    }
-
-    private static void addServiceElements(XmlBeanNamingContext namingContext,
-                                           ServiceDocument.Service[] serviceArray)
-            throws NamingException
-    {
-        if (serviceArray != null)
-        {
-            ConfigContext[] services = getServiceArray(serviceArray, namingContext);
-            for (int i = 0; i < services.length; i++)
-            {
-                ConfigContext service = services[i];
-                namingContext.addService(service);
-                ConfigContext[] serviceSubContextArray = getServiceSubContextArray(service);
-                for (int j = 0; j < serviceSubContextArray.length; j++)
-                { //todo not sure if defaults bubble down here...
-                    namingContext.addSubContext(serviceSubContextArray[j]);
-                }
-            }
-        }
-    }
-
-    private static void processJNDIFile(File dir,
-                                        String configFile)
-            throws Exception
-    {
-        Context context = new InitialContext();
-        File file = new File(dir, configFile);
-        if (!file.exists())
-        {
-            return;
-        }
-
-        LOG.debug("Loading JNDI configuration from file: " + file + " ...");
-
-        InputStream in = null;
-        try
-        {
-            in = new FileInputStream(file);
-            parseJNDIConfig(context, in);
-        }
-        finally
-        {
-            if (in != null)
-            {
-                try
-                {
-                    in.close();
-                }
-                catch (IOException ioe)
-                {
-                    // ignore
-                }
-            }
-        }
-    }
-
-    private static DefaultParameters setupDefaultParams(ResourceDocument.Resource defaultConfig)
-            throws ClassNotFoundException,
-                   IllegalAccessException,
-                   InstantiationException
-    {
-        DefaultParameters defaultParams = null;
-        if (defaultConfig != null)
-        {
-            Object defaultConf = Class.forName(defaultConfig.getType()).newInstance();
-            if (defaultConf instanceof DefaultParameters)
-            {
-                defaultParams = (DefaultParameters) defaultConf;
-                ResourceParamsDocument.ResourceParams resourceParams = defaultConfig.getResourceParams();
-                ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray();
-                for (int i = 0; i < parameterArray.length; i++)
-                {
-                    ParameterDocument.Parameter parameter = parameterArray[i];
-                    String name = parameter.getName();
-                    String value = parameter.getValue();
-
-                    if ((value != null) && !value.equals(""))
-                    {
-                        if (PROP_FACTORY.equals(name))
-                        {
-                            defaultParams.setFactory(value);
-                        }
-                    }
-                }
-            }
-        }
-        return defaultParams;
-    }
-
+         }
+      }
+   }
+
+   private static DefaultParameters setupDefaultParams( ResourceDocument.Resource defaultConfig )
+   throws ClassNotFoundException, 
+          IllegalAccessException, 
+          InstantiationException
+   {
+      DefaultParameters defaultParams = null;
+      if ( defaultConfig != null )
+      {
+         Object defaultConf = Class.forName( defaultConfig.getType(  ) ).newInstance(  );
+         if ( defaultConf instanceof DefaultParameters )
+         {
+            defaultParams = (DefaultParameters) defaultConf;
+            ResourceParamsDocument.ResourceParams resourceParams = defaultConfig.getResourceParams(  );
+            ParameterDocument.Parameter[]         parameterArray = resourceParams.getParameterArray(  );
+            for ( int i = 0; i < parameterArray.length; i++ )
+            {
+               ParameterDocument.Parameter parameter = parameterArray[i];
+               String                      name  = parameter.getName(  );
+               String                      value = parameter.getValue(  );
+
+               if ( ( value != null ) && !value.equals( "" ) )
+               {
+                  if ( PROP_FACTORY.equals( name ) )
+                  {
+                     defaultParams.setFactory( value );
+                  }
+               }
+            }
+         }
+      }
+
+      return defaultParams;
+   }
+
+   private static void validateJndiConfig( XmlObject requestXBean )
+   {
+      XmlOptions validateOptions = new XmlOptions(  );
+      List       errorList = new ArrayList(  );
+      validateOptions.setErrorListener( errorList );
+      boolean isValid = requestXBean.validate( validateOptions );
+      if ( !isValid )
+      {
+         QName        bodyElemName = XmlBeanUtils.getName( requestXBean );
+         StringBuffer strBuf = new StringBuffer( "jndi-config.xml  is not valid as per its schema: \n\n" );
+         for ( int i = 0; i < errorList.size(  ); i++ )
+         {
+            strBuf.append( "\t\t" );
+            strBuf.append( i + 1 );
+            strBuf.append( ") " );
+            strBuf.append( errorList.get( i ) );
+            strBuf.append( "\n" );
+         }
+
+         strBuf.append( "\n" );
+         LOG.fatal( strBuf.toString(  ) );
+      }
+   }
+
+   private static void validateParameterValues( ResourceParameters params )
+   {
+      checkValueIsNonEmpty( params, PROP_FACTORY );
+   }
 }