gdaniels 02/02/04 06:51:58
Modified: java/src/org/apache/axis Constants.java
java/src/org/apache/axis/handlers JWSProcessor.java
java/src/org/apache/axis/transport/http AxisServlet.java
SimpleAxisServer.java
Log:
Allow the system property "axis.jws.servletClassDir" to change the default
JWS output directory. For instance, if we set this to "WEB-INF/jwsClasses"
and we have a jws file at axis/Foo.jws, the resulting class file will be
axis/WEB-INF/jwsClasses/Foo.class
Note that I removed the code which changed the class name to match the
subdirectory structure (i.e. axis/jws/Foo.jws would be assumed to be a
class called "jws.Foo"), since this seemed just wrong. The classname
should come from the package statement, if any, and if we want to respect
packages, we should just do that right.
Individual tests seem to work, but functional tests are hanging at the moment
due to what appear to be network problems connecting to whitemesa. If
there are problems with this I'll fix them as soon as they're found.
Revision Changes Path
1.50 +2 -2 xml-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- Constants.java 1 Feb 2002 05:21:21 -0000 1.49
+++ Constants.java 4 Feb 2002 14:51:57 -0000 1.50
@@ -406,8 +406,8 @@
//////////////////////////////////////////////////////////////////////////
public static final String URI_DEBUG = "http://xml.apache.org/axis/debug";
- // Absolute path of our home directory (if we can determine one)
- public static final String MC_HOME_DIR = "homeDir" ;
+ // Where to put those pesky JWS classes
+ public static final String MC_JWS_CLASSDIR = "jws.classDir" ;
// Relative path of the request URL (ie. http://.../axis/a.jws = /a.jws
public static final String MC_RELATIVE_PATH = "path";
1.34 +36 -10 xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
Index: JWSProcessor.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- JWSProcessor.java 15 Jan 2002 17:23:00 -0000 1.33
+++ JWSProcessor.java 4 Feb 2002 14:51:57 -0000 1.34
@@ -117,12 +117,43 @@
/* placed there by another handler (ie. HTTPActionHandler) */
/***************************************************************/
Runtime rt = Runtime.getRuntime();
- String jwsFile = msgContext.getStrProp(Constants.MC_REALPATH);
+ String jwsFile = msgContext.getStrProp(Constants.MC_RELATIVE_PATH);
+
+ int lastSlash = jwsFile.lastIndexOf('/');
+ String dir = null;
+
+ if (lastSlash > 0) {
+ dir = jwsFile.substring(0, lastSlash);
+ }
+
+ String file = jwsFile.substring(lastSlash + 1);
+
+ String outdir = msgContext.getStrProp( Constants.MC_JWS_CLASSDIR );
+ if ( outdir == null ) outdir = "." ;
+
+ // Build matching directory structure under the output
+ // directory. In other words, if we have:
+ // /webroot/jws1/Foo.jws
+ //
+ // That will be compiled to:
+ // .../jwsOutputDirectory/jws1/Foo.class
+ if (dir != null) {
+ outdir = outdir + File.separator + dir;
+ }
+
+ // Confirm output directory exists. If not, create it IF we're
+ // allowed to.
+ // !!! TODO: add a switch to control this.
+ File outDirectory = new File(outdir);
+ if (!outDirectory.exists()) {
+ outDirectory.mkdirs();
+ }
+
if (category.isInfoEnabled())
category.info("jwsFile: " + jwsFile );
String jFile = jwsFile.substring(0, jwsFile.length()-3) +
"java" ;
- String cFile = jwsFile.substring(0, jwsFile.length()-3) +
+ String cFile = outdir + File.separator + file.substring(0,
file.length()-3) +
"class" ;
if (category.isInfoEnabled()) {
@@ -136,14 +167,14 @@
/* Get the class */
/*****************/
String clsName = null ;
- clsName = msgContext.getStrProp(Constants.MC_RELATIVE_PATH);
+ //clsName = msgContext.getStrProp(Constants.MC_RELATIVE_PATH);
if ( clsName == null ) clsName = f2.getName();
if ( clsName != null && clsName.charAt(0) == '/' )
clsName = clsName.substring(1);
clsName = clsName.substring( 0, clsName.length()-4 );
clsName = clsName.replace('/', '.');
-
+
if (category.isInfoEnabled())
category.info("ClsName: " + clsName );
@@ -171,19 +202,14 @@
// Process proc = rt.exec( "javac " + jFile );
// proc.waitFor();
Compiler compiler = CompilerFactory.getCompiler();
- String outdir = null ;
String[] args = null ;
- outdir = msgContext.getStrProp( Constants.MC_HOME_DIR );
- if ( outdir == null ) outdir = f1.getParent();
- if ( outdir == null ) outdir = "." ;
-
compiler.setClasspath(getDefaultClasspath(msgContext));
compiler.setDestination(outdir);
compiler.setFile(jFile);
boolean result = compiler.compile();
-
+
/* Delete the temporary *.java file and check return code */
/**********************************************************/
(new File(jFile)).delete();
1.73 +65 -31
xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
Index: AxisServlet.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- AxisServlet.java 30 Jan 2002 16:19:11 -0000 1.72
+++ AxisServlet.java 4 Feb 2002 14:51:58 -0000 1.73
@@ -112,13 +112,22 @@
private boolean isDebug= false;
+ // Cached path to our WEB-INF directory
+ private String webInfPath;
+ // Cached path to JWS output directory
+ private String jwsClassDir = null;
+
+ public AxisServlet() {
+ }
+
public void init() {
+ webInfPath = getServletContext().getRealPath("/WEB-INF");
+
isDebug= category.isDebugEnabled();
if(isDebug) category.debug("In servlet init");
String param = getInitParameter("transport.name");
ServletContext context = getServletConfig().getServletContext();
-
if (param == null)
param = context.getInitParameter("transport.name");
if (param != null)
@@ -133,6 +142,15 @@
if (!(param == null) && (param.equalsIgnoreCase("true"))) {
enableList = true;
}
+
+ // Allow system property to override our default placement of
+ // JWS class files.
+ param = System.getProperty("axis.jws.servletClassDir");
+ if (param != null) {
+ jwsClassDir = param;
+ } else {
+ jwsClassDir = context.getRealPath("/");
+ }
}
public AxisServer getEngine() throws AxisFault {
@@ -144,7 +162,8 @@
// (so the config files can't get snooped by a browser)
FileProvider provider = null ;
- if (!(new File(webInfPath, Constants.SERVER_CONFIG_FILE)).exists()){
+ if (!(new File(webInfPath,
+ Constants.SERVER_CONFIG_FILE)).exists()){
InputStream is = null ;
is = context.getResourceAsStream("/WEB-INF/"+
Constants.SERVER_CONFIG_FILE);
@@ -197,10 +216,11 @@
ServletContext context = getServletConfig().getServletContext();
MessageContext msgContext = new MessageContext(engine);
- msgContext.setProperty(Constants.MC_HOME_DIR, context.getRealPath("/"));
+ msgContext.setProperty(Constants.MC_JWS_CLASSDIR,
+ jwsClassDir);
String realpath = context.getRealPath(req.getServletPath());
- String configPath = context.getRealPath("/WEB-INF");
+ String configPath = webInfPath;
if (realpath != null) {
msgContext.setProperty(Constants.MC_REALPATH, realpath);
msgContext.setProperty(Constants.MC_CONFIGPATH, configPath);
@@ -209,15 +229,19 @@
/*********************/
msgContext.setTransportName(transportName);
- /* Save some HTTP specific info in the bag in case a handler needs it */
- /**********************************************************************/
+ /* Save some HTTP specific info in the bag in case we need it */
+ /**************************************************************/
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLET, this );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, res );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETLOCATION,
getServletContext().getRealPath("/WEB-INF") );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO,
req.getPathInfo() );
- msgContext.setProperty(HTTPConstants.HEADER_AUTHORIZATION,
req.getHeader(HTTPConstants.HEADER_AUTHORIZATION) );
- msgContext.setProperty(Constants.MC_REMOTE_ADDR, req.getRemoteAddr());
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req);
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, res);
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETLOCATION,
+ webInfPath);
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO,
+ req.getPathInfo() );
+ msgContext.setProperty(HTTPConstants.HEADER_AUTHORIZATION,
+ req.getHeader(HTTPConstants.HEADER_AUTHORIZATION));
+ msgContext.setProperty(Constants.MC_REMOTE_ADDR,
+ req.getRemoteAddr());
try {
String url = req.getScheme() + "://" +
@@ -262,7 +286,8 @@
writer.println("<h2>" +
JavaUtils.getMessage("error00") + "</h2>");
writer.println("<p>" +
- JavaUtils.getMessage("noDeploy00") + "</p>");
+ JavaUtils.getMessage("noDeploy00") +
+ "</p>");
}
} else {
res.setContentType("text/html");
@@ -287,9 +312,11 @@
}
}
if (method == null) {
- writer.println("<h2>" + JavaUtils.getMessage("error00") +
- ": " +
- JavaUtils.getMessage("invokeGet00") + "</h2>");
+ writer.println("<h2>" +
+ JavaUtils.getMessage("error00") +
+ ": " +
+ JavaUtils.getMessage("invokeGet00") +
+ "</h2>");
writer.println("<p>" +
JavaUtils.getMessage("noMethod01") + "</p>");
return;
@@ -311,7 +338,8 @@
Message respMsg = msgContext.getResponseMessage();
if (respMsg != null) {
writer.println("<p>" +
- JavaUtils.getMessage("gotResponse00") + "</p>");
+ JavaUtils.getMessage("gotResponse00") +
+ "</p>");
writer.println(respMsg.getSOAPPart().getAsString());
} else {
writer.println("<p>" +
@@ -326,7 +354,7 @@
"<p>" +
JavaUtils.getMessage("axisService00") + "</p>");
writer.println(
- "<i>" + JavaUtils.getMessage("perhaps00") + "</i>");
+ "<i>" + JavaUtils.getMessage("perhaps00") + "</i>");
}
} catch (AxisFault fault) {
res.setContentType("text/html");
@@ -384,7 +412,8 @@
if (engine == null) {
// !!! should return a SOAP fault...
- ServletException se= new
ServletException(JavaUtils.getMessage("noEngine00"));
+ ServletException se =
+ new ServletException(JavaUtils.getMessage("noEngine00"));
category.debug(se);
throw se;
}
@@ -403,9 +432,10 @@
if(isDebug) category.debug("HEADER_CONTENT_LOCATION:" +
req.getHeader( HTTPConstants.HEADER_CONTENT_LOCATION));
- Message msg = new Message( req.getInputStream(), false,
- req.getHeader( HTTPConstants.HEADER_CONTENT_TYPE),
- req.getHeader( HTTPConstants.HEADER_CONTENT_LOCATION));
+ Message msg = new Message( req.getInputStream(),
+ false,
+ req.getHeader( HTTPConstants.HEADER_CONTENT_TYPE),
+ req.getHeader( HTTPConstants.HEADER_CONTENT_LOCATION));
if(isDebug) category.debug("Message:" + msg);
/* Set the request(incoming) message field in the context */
@@ -416,16 +446,20 @@
/*********************/
msgContext.setTransportName(transportName);
- /* Save some HTTP specific info in the bag in case a handler needs it */
- /**********************************************************************/
- msgContext.setProperty(Constants.MC_HOME_DIR, context.getRealPath("/"));
- msgContext.setProperty(Constants.MC_RELATIVE_PATH, req.getServletPath());
+ /* Save some HTTP specific info in the bag in case someone needs it */
+ /********************************************************************/
+ msgContext.setProperty(Constants.MC_JWS_CLASSDIR, jwsClassDir);
+ msgContext.setProperty(Constants.MC_RELATIVE_PATH,
+ req.getServletPath());
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLET, this );
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req );
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, res );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETLOCATION,
getServletContext().getRealPath("/WEB-INF") );
- msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO,
req.getPathInfo() );
- msgContext.setProperty(HTTPConstants.HEADER_AUTHORIZATION,
req.getHeader(HTTPConstants.HEADER_AUTHORIZATION) );
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETLOCATION,
+ webInfPath );
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO,
+ req.getPathInfo() );
+ msgContext.setProperty(HTTPConstants.HEADER_AUTHORIZATION,
+ req.getHeader(HTTPConstants.HEADER_AUTHORIZATION) );
msgContext.setProperty(Constants.MC_REMOTE_ADDR, req.getRemoteAddr());
@@ -436,7 +470,7 @@
category.debug("Constants.MC_HOME_DIR:" + context.getRealPath("/"));
category.debug("Constants.MC_RELATIVE_PATH:"+req.getServletPath());
category.debug("HTTPConstants.MC_HTTP_SERVLETLOCATION:"+
- getServletContext().getRealPath("/WEB-INF") );
+ webInfPath );
category.debug("HTTPConstants.MC_HTTP_SERVLETPATHINFO:" +
req.getPathInfo() );
category.debug("HTTPConstants.HEADER_AUTHORIZATION:" +
req.getHeader(HTTPConstants.HEADER_AUTHORIZATION));
category.debug("Constants.MC_REMOTE_ADDR:"+req.getRemoteAddr());
@@ -486,7 +520,7 @@
if (realpath != null)
msgContext.setProperty(Constants.MC_REALPATH, realpath);
- String configPath = context.getRealPath("/WEB-INF");
+ String configPath = webInfPath;
if(isDebug) category.debug("configPath:" + configPath);
msgContext.setProperty(Constants.MC_CONFIGPATH, configPath);
1.44 +4 -0
xml-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java
Index: SimpleAxisServer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- SimpleAxisServer.java 15 Jan 2002 17:57:03 -0000 1.43
+++ SimpleAxisServer.java 4 Feb 2002 14:51:58 -0000 1.44
@@ -261,7 +261,11 @@
doWsdl = true;
}
+ // Real and relative paths are the same for the
+ // SimpleAxisServer
msgContext.setProperty(Constants.MC_REALPATH,
+ fileName.toString());
+ msgContext.setProperty(Constants.MC_RELATIVE_PATH,
fileName.toString());
// !!! Fix string concatenation