You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by rs...@apache.org on 2002/05/09 20:36:35 UTC
cvs commit: xml-axis/java/src/org/apache/axis/server JNDIAxisServerFactory.java
rsitze 02/05/09 11:36:35
Modified: java/src/org/apache/axis/server JNDIAxisServerFactory.java
Log:
Cleaned up logic flow, added javadoc comments.
Changed to be child of DefaultAxisServerFactory,
to insure proper 'default' behavior and reduce redundent code.
Remove NLS from log.debug entry/exit, as per logging guidelines.
Log ignored exceptions as (NLS enabled) warning, as per developer guidelines.
Revision Changes Path
1.6 +43 -85 xml-axis/java/src/org/apache/axis/server/JNDIAxisServerFactory.java
Index: JNDIAxisServerFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/JNDIAxisServerFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JNDIAxisServerFactory.java 5 Feb 2002 16:25:38 -0000 1.5
+++ JNDIAxisServerFactory.java 9 May 2002 18:36:34 -0000 1.6
@@ -56,7 +56,9 @@
package org.apache.axis.server;
import org.apache.axis.EngineConfiguration;
+import org.apache.axis.AxisEngine;
import org.apache.axis.AxisFault;
+import org.apache.axis.utils.JavaUtils;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -72,7 +74,7 @@
* @author Glen Daniels (gdaniels@macromedia.com)
*/
-public class JNDIAxisServerFactory implements AxisServerFactory {
+public class JNDIAxisServerFactory extends DefaultAxisServerFactory {
/**
* Obtain an AxisServer reference, using JNDI if possible, otherwise
@@ -82,15 +84,17 @@
*
* NOTE : REQUIRES SERVLET 2.3 FOR THE GetServletContextName() CALL!
*
- * @param name the JNDI name we're interested in
- * @param configProvider a EngineConfiguration which should be used
- * to configure any engine we end up creating, or
- * null to use the default configuration pattern.
+ * @param environment The following is used, in addition to
+ * the keys used by the parent class:
+ * AxisEngine.ENV_SERVLET_CONTEXT
+ * [required, else default/parent behavior]
+ * - Instance of ServletContext
*/
public AxisServer getServer(Map environment)
throws AxisFault
{
- AxisServer server = null;
+ log.debug("Enter: JNDIAxisServerFactory::getServer");
+
InitialContext context = null;
// First check to see if JNDI works
@@ -98,99 +102,53 @@
try {
context = new InitialContext();
} catch (NamingException e) {
+ log.warn(JavaUtils.getMessage("jndiNotFound00"), e);
}
- EngineConfiguration config = null;
+ ServletContext servletContext = null;
try {
- config = (EngineConfiguration)environment.
- get(EngineConfiguration.PROPERTY_NAME);
+ servletContext =
+ (ServletContext)environment.get(AxisEngine.ENV_SERVLET_CONTEXT);
} catch (ClassCastException e) {
- // Just in case, fall through here.
+ log.warn(JavaUtils.getMessage("servletContextWrongClass00"), e);
+ // Fall through
}
-
- if (context != null) {
- // Figure out the name by looking in the servlet context (for
- // now)
- ServletContext servletContext =
- (ServletContext)environment.get("servletContext");
- if (servletContext != null) {
+
+ AxisServer server = null;
+ if (context != null && servletContext != null) {
+ // Figure out the name by looking in the servlet context (for now)
- /**
- * !!! WARNING - THIS CLASS NEEDS TO FIGURE OUT THE CORRECT
- * NAMING SCHEME FOR GETTING/PUTTING SERVERS FROM/TO JNDI!
- *
- */
+ /**
+ * !!! WARNING - THIS CLASS NEEDS TO FIGURE OUT THE CORRECT
+ * NAMING SCHEME FOR GETTING/PUTTING SERVERS FROM/TO JNDI!
+ *
+ */
- // For servlet 2.3....?
- // String name = servletContext.getServletContextName();
+ // For servlet 2.3....?
+ // String name = servletContext.getServletContextName();
- // THIS IS NOT ACCEPTABLE JNDI NAMING...
- String name = servletContext.getRealPath("/WEB-INF/Server");
+ // THIS IS NOT ACCEPTABLE JNDI NAMING...
+ String name = servletContext.getRealPath("/WEB-INF/Server");
- // We've got JNDI, so try to find an AxisServer at the
- // specified name.
+ // We've got JNDI, so try to find an AxisServer at the
+ // specified name.
+ try {
+ server = (AxisServer)context.lookup(name);
+ } catch (NamingException e) {
+ // Didn't find it.
+ server = super.getServer(environment);
try {
- server = (AxisServer)context.lookup(name);
- } catch (NamingException e) {
- // Didn't find it.
- server = createNewServer(config);
- try {
- context.bind(name, server);
- } catch (NamingException e1) {
- // !!! Couldn't do it, what should we do here?
- }
+ context.bind(name, server);
+ } catch (NamingException e1) {
+ // !!! Couldn't do it, what should we do here?
}
- } else {
- server = createNewServer(config);
}
+ } else {
+ server = super.getServer(environment);
}
- return server;
- }
-
- /**
- * Do the actual work of creating a new AxisServer, using the passed
- * engine configuration, or going through the default configuration
- * steps if null is passed.
- *
- * @return a shiny new AxisServer, ready for use.
- */
- static private AxisServer createNewServer(EngineConfiguration config)
- {
- // Just use the passed config if there is one.
- if (config != null) {
- return new AxisServer(config);
- }
-
- // Default configuration steps...
- //
- // 1. Check for a system property telling us which Engine
- // Configuration to use. If we find it, try creating one.
- String configClass = System.getProperty("axis.engineConfigClass");
- if (configClass != null) {
- // Got one - so try to make it (which means it had better have
- // a default constructor - may make it possible later to pass in
- // some kind of environmental parameters...)
- try {
- Class cls = Class.forName(configClass);
- config = (EngineConfiguration)cls.newInstance();
- } catch (ClassNotFoundException e) {
- // Fall through???
- } catch (InstantiationException e) {
- // Fall through???
- } catch (IllegalAccessException e) {
- // Fall through???
- }
- }
+ log.debug("Exit: JNDIAxisServerFactory::getServer");
- // 2. If we couldn't make one above, use the default one.
- // !!! May want to add options here for getting another system
- // property which is the config file name...
- if (config == null) {
- return new AxisServer();
- } else {
- // 3. Create an AxisServer using the appropriate config
- return new AxisServer(config);
- }
+ return server;
}
}