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/07/21 19:46:27 UTC
svn commit: r220151 - in
/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi: JNDIUtils.java
XmlBeanJndiUtils.java
Author: scamp
Date: Thu Jul 21 10:46:26 2005
New Revision: 220151
URL: http://svn.apache.org/viewcvs?rev=220151&view=rev
Log:
fixed bug in refactoring
Modified:
webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java
webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java
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=220151&r1=220150&r2=220151&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 Thu Jul 21 10:46:26 2005
@@ -155,7 +155,7 @@
Digester digester = new Digester();
// Don't do any validation for now
- // TODO: Need to write a real schema for this stuff
+ // TODO: look into getting rid of this stuff!
digester.setNamespaceAware( true );
digester.setValidating( false );
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=220151&r1=220150&r2=220151&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 Thu Jul 21 10:46:26 2005
@@ -60,7 +60,7 @@
public class XmlBeanJndiUtils
extends JNDIUtils
{
- private static Log LOG = LogFactory.getLog( XmlBeanJndiUtils.class.getName() );
+ private static Log LOG = LogFactory.getLog(XmlBeanJndiUtils.class.getName());
/**
* Apache JNDI URL Package Prefix
@@ -84,6 +84,9 @@
*/
private static Context s_wsrfContext;
+ private static boolean s_configLoaded;
+ private static boolean s_jndiInitialized;
+
private static DefaultParameters s_defaultParams;
/**
@@ -91,48 +94,51 @@
* create the WSRF context.
*
* @return the WSRF context
- *
* @throws Exception
*/
- public static Context initJNDI()
+ public static synchronized Context initJNDI()
throws Exception
{
- initJndiImpl();
- return initWsrfContext();
+ if (!s_jndiInitialized)
+ {
+ initJndiImpl();
+ initWsrfContext();
+ s_jndiInitialized = true;
+ }
+ return new InitialContext();
}
- private static Context initWsrfContext()
+ private static void initWsrfContext()
throws NamingException
{
- LOG.debug( "Initializing WSRF JNDI context..." );
+ LOG.debug("Initializing WSRF JNDI context...");
Context wsrfContext;
InitialContext initialContext = new InitialContext();
try
{
- wsrfContext = (Context)initialContext.lookup( JndiConstants.CONTEXT_NAME_SERVICES );
+ wsrfContext = (Context) initialContext.lookup(JndiConstants.CONTEXT_NAME_SERVICES);
}
- catch ( NameNotFoundException nnfe )
+ catch (NameNotFoundException nnfe)
{
- 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 );
+ 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 );
+ String systemUrlPrefix = System.getProperty(Context.URL_PKG_PREFIXES);
+ String systemContextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
- if ( systemContextFactory == null && systemUrlPrefix == null )
+ if (systemContextFactory == null && systemUrlPrefix == null)
{
- System.setProperty( Context.URL_PKG_PREFIXES, apacheUrlPrefix );
- System.setProperty( Context.INITIAL_CONTEXT_FACTORY, APACHE_INITIAL_CONTEXT_FACTORY );
+ System.setProperty(Context.URL_PKG_PREFIXES, apacheUrlPrefix);
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, APACHE_INITIAL_CONTEXT_FACTORY);
}
}
@@ -140,105 +146,101 @@
* 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 )
+ public static synchronized Context initFromDir(String configDir)
throws Exception
{
- LOG.debug( "Initializing JNDI from config directory: " + configDir + " ..." );
- if ( s_wsrfContext == null )
+
+ if (!s_configLoaded)
{
- Context context = initJNDI();
+ LOG.debug("Initializing JNDI from config directory: " + configDir + " ...");
+
+ initJNDI();
- File fDir = new File( configDir );
+ File fDir = new File(configDir);
File[] dirs =
- fDir.listFiles( new FileFilter()
+ fDir.listFiles(new FileFilter()
{
- public boolean accept( File path )
+ public boolean accept(File path)
{
return path.isDirectory();
}
- } );
+ });
- for ( int i = 0; i < dirs.length; i++ )
+ for (int i = 0; i < dirs.length; i++)
{
- processJNDIFile( context, dirs[i], JNDI_CONFIG_FILENAME );
+ processJNDIFile(dirs[i], JNDI_CONFIG_FILENAME);
}
-
- s_wsrfContext = context;
+ s_configLoaded = true;
}
- return s_wsrfContext;
+
+ 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 )
+ public static synchronized Context initFromFile(String configFilename)
throws Exception
{
- LOG.debug( "Initializing JNDI from file: " + configFilename );
- if ( s_wsrfContext == null )
+ LOG.debug("Initializing JNDI from file: " + configFilename);
+ if (!s_configLoaded)
{
- Context context = initJNDI();
+ initJNDI();
InputStream configInput;
try
{
- LOG.debug( "Trying to load JNDI configuration from file: " + configFilename );
+ LOG.debug("Trying to load JNDI configuration from file: " + configFilename);
- configInput = new FileInputStream( configFilename );
+ configInput = new FileInputStream(configFilename);
}
- catch ( FileNotFoundException fnfe )
+ catch (FileNotFoundException fnfe)
{
- LOG.debug( "Trying to load JNDI configuration from classloader resource: " + configFilename );
+ LOG.debug("Trying to load JNDI configuration from classloader resource: " + configFilename);
- configInput = JNDIUtils.class.getClassLoader().getResourceAsStream( configFilename );
+ configInput = JNDIUtils.class.getClassLoader().getResourceAsStream(configFilename);
- if ( configInput == null )
+ if (configInput == null)
{
- throw new IOException( "jndiConfigNotFound" );
+ throw new IOException("jndiConfigNotFound");
}
}
- parseJNDIConfig( context, configInput );
-
- s_wsrfContext = context;
+ Context context = new InitialContext();
+ parseJNDIConfig(context, configInput);
+ s_configLoaded = true;
}
- return s_wsrfContext;
+ 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 )
+ public static synchronized Context initFromInputStream(InputStream inputStream)
throws Exception
{
- if ( s_wsrfContext == null )
+ if (!s_configLoaded)
{
- Context context = initJNDI();
- LOG.debug( "Trying to load JNDI configuration from inputstream" );
- parseJNDIConfig( context, inputStream );
- s_wsrfContext = context;
+ initJNDI();
+ LOG.debug("Trying to load JNDI configuration from inputstream");
+ parseJNDIConfig(inputStream);
+ s_configLoaded = true;
}
- return s_wsrfContext;
+ return new InitialContext();
}
/**
@@ -247,342 +249,338 @@
* 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 )
+ public static void parseJNDIConfig(Context initContext,
+ InputStream configStream)
throws Exception
{
- if ( configStream == null )
+ if (configStream == null)
{
- throw new IllegalArgumentException( "nullJNDIConfigInput" );
+ throw new IllegalArgumentException("nullJNDIConfigInput");
}
- if ( initContext == null )
+ if (initContext == null)
{
throw new IllegalArgumentException();
}
//get the global context
- Context envContext = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_GLOBAL );
- XmlBeanNamingContext namingContext = new XmlBeanNamingContext( envContext );
+ 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 );
+ JndiConfigDocument jndiConfigDoc = (JndiConfigDocument) XmlObject.Factory.parse(configStream);
// TODO: validate the JNDI config XMLBean
JndiConfigDocument.JndiConfig jndiConfig = jndiConfigDoc.getJndiConfig();
GlobalDocument.Global global = jndiConfig.getGlobal();
//setup the global jndi elements
- addGlobalElements( namingContext, global );
+ addGlobalElements(namingContext, global);
//get the service context
- envContext = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_SERVICES );
- namingContext = new XmlBeanNamingContext( envContext );
+ 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 );
+ addServiceElements(namingContext, serviceArray);
}
- private static DefaultParameters getDefaultProperties( GlobalDocument.Global global )
+ private static DefaultParameters getDefaultProperties(GlobalDocument.Global global)
throws IllegalAccessException,
- InstantiationException,
- ClassNotFoundException
+ InstantiationException,
+ ClassNotFoundException
{
ResourceDocument.Resource defaultConfig = null;
ResourceDocument.Resource[] resourceArray = global.getResourceArray();
- for ( int i = 0; i < resourceArray.length; i++ )
+ for (int i = 0; i < resourceArray.length; i++)
{
ResourceDocument.Resource resource = resourceArray[i];
- if ( DefaultParameters.class.getName().equals( resource.getType() ) )
+ if (DefaultParameters.class.getName().equals(resource.getType()))
{
defaultConfig = resource;
break;
}
}
- return setupDefaultParams( defaultConfig );
+ return setupDefaultParams(defaultConfig);
}
- private static Environment[] getEnvironmentArray( EnvironmentDocument.Environment[] environmentArray )
+ private static Environment[] getEnvironmentArray(EnvironmentDocument.Environment[] environmentArray)
{
List envList = new ArrayList();
- if ( environmentArray != null )
+ if (environmentArray != null)
{
- for ( int i = 0; i < environmentArray.length; i++ )
+ 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 );
+ 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] );
+ return (Environment[]) envList.toArray(new Environment[0]);
}
- private static ResourceParameters getParameters( ResourceParamsDocument.ResourceParams resourceParams )
+ private static ResourceParameters getParameters(ResourceParamsDocument.ResourceParams resourceParams)
{
ResourceParameters params = new ResourceParameters();
- if ( resourceParams != null )
+ if (resourceParams != null)
{
ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray();
- for ( int i = 0; i < parameterArray.length; i++ )
+ for (int i = 0; i < parameterArray.length; i++)
{
ParameterDocument.Parameter parameter = parameterArray[i];
- params.addParameter( parameter.getName(), parameter.getValue() );
+ params.addParameter(parameter.getName(), parameter.getValue());
}
}
return params;
}
- private static void validateParameterValues( ResourceParameters params )
+ private static void validateParameterValues(ResourceParameters params)
{
- checkValueIsNonEmpty( params, PROP_FACTORY );
+ checkValueIsNonEmpty(params, PROP_FACTORY);
}
- private static void checkValueIsNonEmpty( ResourceParameters params, String paramName )
+ private static void checkValueIsNonEmpty(ResourceParameters params, String paramName)
{
- String paramValue = params.getParameter( paramName );
- if ( paramValue.trim().equals( "" ) )
+ String paramValue = params.getParameter(paramName);
+ if (paramValue.trim().equals(""))
{
- throw new RuntimeException( paramName + " parameter must have a non-empty value!" );
+ throw new RuntimeException(paramName + " parameter must have a non-empty value!");
}
}
- private static void setDefaultParameterValues( ResourceParameters params )
+ private static void setDefaultParameterValues(ResourceParameters params)
{
- if ( params.getParameter( PROP_FACTORY ) == null )
+ if (params.getParameter(PROP_FACTORY) == null)
{
- params.addParameter( PROP_FACTORY, s_defaultParams.getFactory() );
+ params.addParameter(PROP_FACTORY, s_defaultParams.getFactory());
}
}
- private static Resource[] getResourceArray( ResourceDocument.Resource[] resourceArray, String name,
- XmlBeanNamingContext namingContext )
+ private static Resource[] getResourceArray(ResourceDocument.Resource[] resourceArray, String name,
+ XmlBeanNamingContext namingContext)
{
List resources = new ArrayList();
- if ( resourceArray != null )
+ if (resourceArray != null)
{
- for ( int i = 0; i < resourceArray.length; i++ )
+ 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 )
+ if (metadataConfig != null)
{
try
{
- Class metaConfigClass = Class.forName( resourceDoc.getType() );
- Constructor constructor = metaConfigClass.getClass().getConstructor(
- new Class[]{metadataConfig.getClass()} );
- MetadataConfig metaConfig = (MetadataConfig) constructor.newInstance(
- new Object[]{metadataConfig} );
+ Class metaConfigClass = Class.forName(resourceDoc.getType());
+ Constructor constructor = metaConfigClass.getClass().getConstructor(new Class[]{metadataConfig.getClass()});
+ MetadataConfig metaConfig = (MetadataConfig) constructor.newInstance(new Object[]{metadataConfig});
String contextName = null;
- if ( name != null )
+ if (name != null)
{
- namingContext.getContext().createSubcontext( name ); //add subcontext
+ namingContext.getContext().createSubcontext(name); //add subcontext
contextName = name + "/";
}
contextName = contextName + resourceDoc.getName();
- namingContext.bind( contextName, metaConfig );
+ namingContext.bind(contextName, metaConfig);
continue;
}
- catch ( Exception e )
+ 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 );
+ 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 );
+ 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] );
+ return (Resource[]) resources.toArray(new Resource[0]);
}
- private static ResourceLink[] getResourceLinkArray( ResourceLinkDocument.ResourceLink[] resourceLinkArray )
+ private static ResourceLink[] getResourceLinkArray(ResourceLinkDocument.ResourceLink[] resourceLinkArray)
{
List resourceLinks = new ArrayList();
- if ( resourceLinkArray != null )
+ if (resourceLinkArray != null)
{
- for ( int i = 0; i < resourceLinkArray.length; i++ )
+ 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 );
+ link.setName(resourceLink.getName());
+ link.setTarget(resourceLink.getTarget());
+ resourceLinks.add(link);
}
}
- return (ResourceLink[]) resourceLinks.toArray( new ResourceLink[0] );
+ return (ResourceLink[]) resourceLinks.toArray(new ResourceLink[0]);
}
- private static ConfigContext[] getServiceArray( ServiceDocument.Service[] serviceArray,
- XmlBeanNamingContext namingContext )
+ private static ConfigContext[] getServiceArray(ServiceDocument.Service[] serviceArray,
+ XmlBeanNamingContext namingContext)
{
List services = new ArrayList();
- if ( serviceArray != null )
+ if (serviceArray != null)
{
- for ( int i = 0; i < serviceArray.length; i++ )
+ 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.setName(service.getName());
+ Environment[] environmentArray = getEnvironmentArray(service.getEnvironmentArray());
+ for (int j = 0; j < environmentArray.length; j++)
{
- context.addEnvironment( environmentArray[j] );
+ context.addEnvironment(environmentArray[j]);
}
- Resource[] resourceArray = getResourceArray( service.getResourceArray(), service.getName(),
- namingContext );
- for ( int j = 0; j < resourceArray.length; 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 );
+ setDefaultParameterValues(params);
+ validateParameterValues(params);
}
- for ( int j = 0; j < resourceArray.length; j++ )
+ for (int j = 0; j < resourceArray.length; j++)
{
- context.addResource( resourceArray[j] );
+ context.addResource(resourceArray[j]);
}
- ResourceLink[] resourceLinkArray = getResourceLinkArray( service.getResourceLinkArray() );
- for ( int j = 0; j < resourceLinkArray.length; j++ )
+ ResourceLink[] resourceLinkArray = getResourceLinkArray(service.getResourceLinkArray());
+ for (int j = 0; j < resourceLinkArray.length; j++)
{
- context.addResourceLink( resourceLinkArray[j] );
+ context.addResourceLink(resourceLinkArray[j]);
}
- services.add( context );
+ services.add(context);
}
}
- return (ConfigContext[]) services.toArray( new ConfigContext[0] );
+ return (ConfigContext[]) services.toArray(new ConfigContext[0]);
}
- private static ConfigContext[] getServiceSubContextArray( ConfigContext service )
+ private static ConfigContext[] getServiceSubContextArray(ConfigContext service)
{
List subContexts = new ArrayList();
- if ( service != null )
+ if (service != null)
{
Set subContextNames = service.getSubContextNames();
Iterator iterator = subContextNames.iterator();
- while ( iterator.hasNext() )
+ while (iterator.hasNext())
{
- subContexts.add( service.getSubContext( (String) iterator.next() ) );
+ subContexts.add(service.getSubContext((String) iterator.next()));
}
}
- return (ConfigContext[]) subContexts.toArray( new ConfigContext[0] );
+ return (ConfigContext[]) subContexts.toArray(new ConfigContext[0]);
}
- private static void addGlobalElements( XmlBeanNamingContext namingContext,
- GlobalDocument.Global global )
+ private static void addGlobalElements(XmlBeanNamingContext namingContext,
+ GlobalDocument.Global global)
throws NamingException,
- IllegalAccessException,
- ClassNotFoundException,
- InstantiationException
+ IllegalAccessException,
+ ClassNotFoundException,
+ InstantiationException
{
- if ( global != null )
+ if (global != null)
{
- s_defaultParams = getDefaultProperties( global );
+ s_defaultParams = getDefaultProperties(global);
- Environment[] environmentArray = getEnvironmentArray( global.getEnvironmentArray() );
+ Environment[] environmentArray = getEnvironmentArray(global.getEnvironmentArray());
- for ( int i = 0; i < environmentArray.length; i++ )
+ for (int i = 0; i < environmentArray.length; i++)
{
- namingContext.addEnvironment( environmentArray[i] );
+ namingContext.addEnvironment(environmentArray[i]);
}
- ConfigContext[] subContext = getServiceArray( global.getServiceArray(), namingContext );
- for ( int i = 0; i < subContext.length; i++ )
+ ConfigContext[] subContext = getServiceArray(global.getServiceArray(), namingContext);
+ for (int i = 0; i < subContext.length; i++)
{
- namingContext.addSubContext( subContext[i] );
+ namingContext.addSubContext(subContext[i]);
}
- Resource[] resourceArray = getResourceArray( global.getResourceArray(), null, namingContext );
- for ( int i = 0; i < resourceArray.length; i++ )
+ Resource[] resourceArray = getResourceArray(global.getResourceArray(), null, namingContext);
+ for (int i = 0; i < resourceArray.length; i++)
{
- namingContext.addResource( resourceArray[i] );
+ namingContext.addResource(resourceArray[i]);
}
- ResourceLink[] resourceLinkArray = getResourceLinkArray( global.getResourceLinkArray() );
- for ( int i = 0; i < resourceLinkArray.length; i++ )
+ ResourceLink[] resourceLinkArray = getResourceLinkArray(global.getResourceLinkArray());
+ for (int i = 0; i < resourceLinkArray.length; i++)
{
- namingContext.addResourceLink( resourceLinkArray[i] );
+ namingContext.addResourceLink(resourceLinkArray[i]);
}
}
}
- private static void addServiceElements( XmlBeanNamingContext namingContext,
- ServiceDocument.Service[] serviceArray )
+ private static void addServiceElements(XmlBeanNamingContext namingContext,
+ ServiceDocument.Service[] serviceArray)
throws NamingException
{
- if ( serviceArray != null )
+ if (serviceArray != null)
{
- ConfigContext[] services = getServiceArray( serviceArray, namingContext );
- for ( int i = 0; i < services.length; i++ )
+ 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++ )
+ 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] );
+ namingContext.addSubContext(serviceSubContextArray[j]);
}
}
}
}
- private static void processJNDIFile( Context context,
- File dir,
- String configFile )
+ private static void processJNDIFile(File dir,
+ String configFile)
throws Exception
{
- File file = new File( dir, configFile );
- if ( !file.exists() )
+ Context context = new InitialContext();
+ File file = new File(dir, configFile);
+ if (!file.exists())
{
return;
}
- LOG.debug( "Loading JNDI configuration from file: " + file + " ..." );
+ LOG.debug("Loading JNDI configuration from file: " + file + " ...");
InputStream in = null;
try
{
- in = new FileInputStream( file );
- parseJNDIConfig( context, in );
+ in = new FileInputStream(file);
+ parseJNDIConfig(context, in);
}
finally
{
- if ( in != null )
+ if (in != null)
{
try
{
in.close();
}
- catch ( IOException ioe )
+ catch (IOException ioe)
{
// ignore
}
@@ -590,31 +588,31 @@
}
}
- private static DefaultParameters setupDefaultParams( ResourceDocument.Resource defaultConfig )
+ private static DefaultParameters setupDefaultParams(ResourceDocument.Resource defaultConfig)
throws ClassNotFoundException,
- IllegalAccessException,
- InstantiationException
+ IllegalAccessException,
+ InstantiationException
{
DefaultParameters defaultParams = null;
- if ( defaultConfig != null )
+ if (defaultConfig != null)
{
- Object defaultConf = Class.forName( defaultConfig.getType() ).newInstance();
- if ( defaultConf instanceof DefaultParameters )
+ 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++ )
+ 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 ((value != null) && !value.equals(""))
{
- if ( PROP_FACTORY.equals( name ) )
+ if (PROP_FACTORY.equals(name))
{
- defaultParams.setFactory( value );
+ defaultParams.setFactory(value);
}
}
}