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 to...@apache.org on 2005/01/06 08:27:20 UTC
cvs commit: ws-axis/java/webapps/axis i18nLib.jsp index.jsp happyaxis.jsp
toshi 2005/01/05 23:27:20
Modified: java/webapps/axis happyaxis.jsp
Added: java/webapps/axis i18nLib.jsp index.jsp
Log:
For i18n of Axis webapps.
Revision Changes Path
1.19 +92 -128 ws-axis/java/webapps/axis/happyaxis.jsp
Index: happyaxis.jsp
===================================================================
RCS file: /home/cvs/ws-axis/java/webapps/axis/happyaxis.jsp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- happyaxis.jsp 30 Dec 2004 02:01:19 -0000 1.18
+++ happyaxis.jsp 6 Jan 2005 07:27:20 -0000 1.19
@@ -1,13 +1,14 @@
<html>
-<%@ page import="java.io.InputStream,
+<%@ page contentType="text/html; charset=utf-8"
+ import="java.io.InputStream,
java.io.IOException,
javax.xml.parsers.SAXParser,
java.lang.reflect.*,
javax.xml.parsers.SAXParserFactory"
session="false" %>
- <%
- /*
- * Copyright 2002,2004 The Apache Software Foundation.
+<%
+/*
+ * Copyright 2002,2004,2005 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.
@@ -22,12 +23,8 @@
* limitations under the License.
*/
%>
-<head>
-<title>Axis Happiness Page</title>
-</head>
-<body bgcolor='#ffffff'>
-<%!
+<%!
/*
* Happiness tests for axis. These look at the classpath and warn if things
* are missing. Normally addng this much code in a JSP page is mad
@@ -38,20 +35,6 @@
* @author Brian Ewins
*/
-
- /**
- * Get a string providing install information.
- * TODO: make this platform aware and give specific hints
- */
- public String getInstallHints(HttpServletRequest request) {
-
- String hint=
- "<B><I>Note:</I></B> On Tomcat 4.x and Java1.4, you may need to put libraries that contain "
- +"java.* or javax.* packages into CATALINA_HOME/common/lib"
- +"<br>jaxrpc.jar and saaj.jar are two such libraries.";
- return hint;
- }
-
/**
* test for a class existing
* @param classname
@@ -106,39 +89,28 @@
if(clazz == null) {
String url="";
if(homePage!=null) {
- url="<br> See <a href="+homePage+">"+homePage+"</a>";
+ url=getMessage("seeHomepage",homePage,homePage);
}
- out.write("<p>"+category+": could not find class "+classname
- +" from file <b>"+jarFile
- +"</b><br> "+errorText
- +url
- +"<p>");
+ out.write(getMessage("couldNotFound",category,classname,jarFile,errorText,url));
return 1;
} else {
String location = getLocation(out, clazz);
+
if(location == null) {
- out.write("Found "+ description + " (" + classname + ")<br>");
+ out.write("<li>"+getMessage("foundClass00",description,classname)+"</li><br>");
}
else {
- out.write("Found "+ description + " (" + classname + ") at " + location + "<br>");
+ out.write("<li>"+getMessage("foundClass01",description,classname,location)+"</li><br>");
}
return 0;
}
} catch(NoClassDefFoundError ncdfe) {
String url="";
if(homePage!=null) {
- url="<br> See <a href="+homePage+">"+homePage+"</a>";
+ url=getMessage("seeHomepage",homePage,homePage);
}
- out.write("<p>"+category+": could not find a dependency"
- +" of class "+classname
- +" from file <b>"+jarFile
- +"</b><br> "+errorText
- +url
- +"<br>The root cause was: "+ncdfe.getMessage()
- +"<br>This can happen e.g. if "+classname+" is in"
- +" the 'common' classpath, but a dependency like "
- +" activation.jar is only in the webapp classpath."
- +"<p>");
+ out.write(getMessage("couldNotFoundDep",category, classname, errorText, url));
+ out.write(getMessage("theRootCause",ncdfe.getMessage(), classname));
return 1;
}
}
@@ -168,7 +140,7 @@
}
} catch (Throwable t){
}
- return "an unknown location";
+ return getMessage("classFoundError");
}
/**
@@ -188,7 +160,7 @@
String errorText,
String homePage) throws IOException {
return probeClass(out,
- "<b>Error</b>",
+ "<b>"+getMessage("error")+"</b>",
classname,
jarFile,
description,
@@ -213,7 +185,7 @@
String errorText,
String homePage) throws IOException {
return probeClass(out,
- "<b>Warning</b>",
+ "<b>"+getMessage("warning")+"</b>",
classname,
jarFile,
description,
@@ -222,28 +194,6 @@
}
/**
- * probe for a resource existing,
- * @param out
- * @param resource
- * @param errorText
- * @throws Exception
- */
- int wantResource(JspWriter out,
- String resource,
- String errorText) throws Exception {
- if(!resourceExists(resource)) {
- out.write("<p><b>Warning</b>: could not find resource "+resource
- +"<br>"
- +errorText);
- return 0;
- } else {
- out.write("found "+resource+"<br>");
- return 1;
- }
- }
-
-
- /**
* get servlet version string
*
*/
@@ -255,8 +205,6 @@
return Integer.toString(major) + '.' + Integer.toString(minor);
}
-
-
/**
* what parser are we using.
* @return the classname of the parser
@@ -264,7 +212,7 @@
private String getParserName() {
SAXParser saxParser = getSAXParser();
if (saxParser == null) {
- return "Could not create an XML Parser";
+ return getMessage("couldNotCreateParser");
}
// check to what is in the classname
@@ -323,15 +271,32 @@
}
return false;
}
-
%>
-<html><head><title>Axis Happiness Page</title></head>
-<body>
-<h1>Axis Happiness Page</h1>
-<h2>Examining webapp configuration</h2>
-<p>
-<h3>Needed Components</h3>
+<%@ include file="i18nLib.jsp" %>
+
+<%
+ // initialize a private HttpServletRequest
+ setRequest(request);
+%>
+
+<head>
+<title><%= getMessage("pageTitle") %></title>
+</head>
+<body bgcolor='#ffffff'>
+
+<%
+ out.print("<h1>"+ getMessage("pageTitle") +"</h1>");
+ out.print("<h2>"+ getMessage("pageRole") +"</h2><p/>");
+%>
+
+<%= getLocaleChoice() %>
+
+<%
+ out.print("<h3>"+ getMessage("neededComponents") +"</h3>");
+%>
+
+<UL>
<%
int needed=0,wanted=0;
@@ -347,44 +312,45 @@
needed = needClass(out, "javax.xml.soap.SOAPMessage",
"saaj.jar",
"SAAJ API",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
"http://ws.apache.org/axis/");
} else {
String location = getLocation(out, clazz);
- out.write("<b>Error:</b> Invalid version of SAAJ API found in " +
- location + ". Make sure that Axis' saaj.jar " +
- "precedes " + location + " in CLASSPATH.<br />" +
- "Axis will not work. See <a href=\"http://ws.apache.org/axis/java/install.html\">Axis installation instructions</a> for more information<br />");
+
+ out.print(getMessage("invalidSAAJ",location));
+ out.print(getMessage("criticalErrorMessage"));
+ out.print(getMessage("seeHomepage","http://ws.apache.org/axis/java/install.html",getMessage("axisInstallation")));
+ out.print("<br>");
}
needed+=needClass(out, "javax.xml.rpc.Service",
"jaxrpc.jar",
"JAX-RPC API",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
"http://ws.apache.org/axis/");
needed+=needClass(out, "org.apache.axis.transport.http.AxisServlet",
"axis.jar",
"Apache-Axis",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
"http://ws.apache.org/axis/");
needed+=needClass(out, "org.apache.commons.discovery.Resource",
"commons-discovery.jar",
"Jakarta-Commons Discovery",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
"http://jakarta.apache.org/commons/discovery/");
needed+=needClass(out, "org.apache.commons.logging.Log",
"commons-logging.jar",
"Jakarta-Commons Logging",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
"http://jakarta.apache.org/commons/logging/");
needed+=needClass(out, "org.apache.log4j.Layout",
"log4j-1.2.8.jar",
"Log4j",
- "Axis may not work",
+ getMessage("uncertainErrorMessage"),
"http://jakarta.apache.org/log4j");
//should we search for a javax.wsdl file here, to hint that it needs
@@ -392,22 +358,26 @@
needed+=needClass(out, "com.ibm.wsdl.factory.WSDLFactoryImpl",
"wsdl4j.jar",
"IBM's WSDL4Java",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
null);
needed+=needClass(out, "javax.xml.parsers.SAXParserFactory",
"xerces.jar",
"JAXP implementation",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
"http://xml.apache.org/xerces-j/");
needed+=needClass(out,"javax.activation.DataHandler",
"activation.jar",
"Activation API",
- "Axis will not work",
+ getMessage("criticalErrorMessage"),
"http://java.sun.com/products/javabeans/glasgow/jaf.html");
%>
-<h3>Optional Components</h3>
+</UL>
+<%
+ out.print("<h3>"+ getMessage("optionalComponents") +"</h3>");
+%>
+<UL>
<%
/*
* now the stuff we can live without
@@ -415,87 +385,81 @@
wanted+=wantClass(out,"javax.mail.internet.MimeMessage",
"mail.jar",
"Mail API",
- "Attachments will not work",
+ getMessage("attachmentsError"),
"http://java.sun.com/products/javamail/");
wanted+=wantClass(out,"org.apache.xml.security.Init",
"xmlsec.jar",
"XML Security API",
- "XML Security is not supported",
+ getMessage("xmlSecurityError"),
"http://xml.apache.org/security/");
wanted += wantClass(out, "javax.net.ssl.SSLSocketFactory",
"jsse.jar or java1.4+ runtime",
"Java Secure Socket Extension",
- "https is not supported",
+ getMessage("httpsError"),
"http://java.sun.com/products/jsse/");
/*
* resources on the classpath path
*/
- /* broken; this is a file, not a resource
- wantResource(out,"/server-config.wsdd",
- "There is no server configuration file;"
- +"run AdminClient to create one");
- */
/* add more libraries here */
+%>
+</UL>
+<%
out.write("<h3>");
//is everythng we need here
if(needed==0) {
//yes, be happy
- out.write("<i>The core axis libraries are present. </i>");
+ out.write(getMessage("happyResult00"));
} else {
//no, be very unhappy
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- out.write("<i>"
- +needed
- +" core axis librar"
- +(needed==1?"y is":"ies are")
- +" missing</i>");
+ out.write(getMessage("unhappyResult00",Integer.toString(needed)));
}
//now look at wanted stuff
if(wanted>0) {
- out.write("<i>"
- +wanted
- +" optional axis librar"
- +(wanted==1?"y is":"ies are")
- +" missing</i>");
+ out.write(getMessage("unhappyResult01",Integer.toString(wanted)));
} else {
- out.write("The optional components are present.");
+ out.write(getMessage("happyResult01"));
}
out.write("</h3>");
+%>
+<UL>
+<%
+
//hint if anything is missing
if(needed>0 || wanted>0 ) {
- out.write(getInstallHints(request));
+ out.write(getMessage("hintString"));
}
- %>
- <p>
- <B><I>Note:</I></B> Even if everything this page probes for is present, there is no guarantee your
- web service will work, because there are many configuration options that we do
- not check for. These tests are <i>necessary</i> but not <i>sufficient</i>
- <hr>
+ out.write(getMessage("noteString"));
+%>
+</UL>
- <h2>Examining Application Server</h2>
+ <h2><%= getMessage("apsExamining") %></h2>
+
+<UL>
<%
String servletVersion=getServletVersion();
String xmlParser=getParserName();
String xmlParserLocation = getParserLocation(out);
-
%>
- <table>
+ <table border="1" cellpadding="10">
<tr><td>Servlet version</td><td><%= servletVersion %></td></tr>
<tr><td>XML Parser</td><td><%= xmlParser %></td></tr>
<tr><td>XML ParserLocation</td><td><%= xmlParserLocation %></td></tr>
</table>
+</UL>
+
<% if(xmlParser.indexOf("crimson")>=0) { %>
<p>
- <b>We recommend <a href="http://xml.apache.org/xerces2-j/">Xerces 2</a>
- over Crimson as the XML parser for Axis</b>
+ <%= getMessage("recommendedParser") %>
</p>
<% } %>
- <h2>Examining System Properties</h2>
+ <h2><%= getMessage("sysExamining") %></h2>
+<UL>
<%
/**
* Dump the system properties
@@ -513,12 +477,12 @@
}
out.write("</pre><p>");
} else {
- out.write("System properties are not accessible<p>");
+ out.write(getMessage("sysPropError"));
}
%>
+</UL>
<hr>
- Platform: <%= getServletConfig().getServletContext().getServerInfo() %>
+ <%= getMessage("apsPlatform") %>:
+ <%= getServletConfig().getServletContext().getServerInfo() %>
</body>
</html>
-
-
1.1 ws-axis/java/webapps/axis/i18nLib.jsp
Index: i18nLib.jsp
===================================================================
<%@ page contentType="text/html; charset=utf-8" import="java.util.*" %>
<%
/*
* Copyright 2005 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.
*/
%>
<%!
/*
* A library file to produce i18n web applications. This can be easily
* reused from your jsp(s) - just include and call any methods.
* @author toshi
*/
// private variable
HttpServletRequest _req = null;
/**
* Set a HttpServletRequest to a private variable.
* @param request HttpServletRequest
*/
void setRequest(HttpServletRequest request) {
_req = request;
}
/**
* Get a ResourceBundle object.
* @return a ResourceBundle object
*/
ResourceBundle getRB() {
String strLocale = _req.getParameter("locale");
ResourceBundle objRb = null;
Locale objLcl = null;
if (strLocale!=null) {
objLcl=new Locale(strLocale,"");
} else {
objLcl=_req.getLocale();
}
Locale.setDefault(objLcl);
objRb = ResourceBundle.getBundle("i18n",objLcl);
return objRb;
}
/**
* Get a list of locale choice
* @return a list of supported locales
*/
String getLocaleChoice() {
String choice = getRB().getString("locales");
StringBuffer buf = new StringBuffer();
buf.append("<div align=\"right\">\n");
buf.append(getRB().getString("language"));
buf.append(": ");
StringTokenizer st = new StringTokenizer(choice);
String locale = null;
while (st.hasMoreTokens()) {
locale = st.nextToken();
buf.append("[<a href=\"?locale="+ locale +"\">"+ locale +"</a>] ");
}
buf.append("\n</div>\n");
return buf.toString();
}
/**
* Get a message from i18n.properties with several arguments.
* @param key The resource key
* @return The formatted message
*/
String getMessage(String key) {
return getMessage(key, null, null, null, null, null);
}
/**
* Get a message from i18n.properties with several arguments.
* @param key The resource key
* @param arg0 The argument to place in variable {0}
* @return The formatted message
*/
String getMessage(String key, String arg0) {
return getMessage(key, arg0, null, null, null, null);
}
/**
* Get a message from i18n.properties with several arguments.
* @param key The resource key
* @param arg0 The argument to place in variable {0}
* @param arg1 The argument to place in variable {1}
* @return The formatted message
*/
String getMessage(String key, String arg0, String arg1) {
return getMessage(key, arg0, arg1, null, null, null);
}
/**
* Get a message from i18n.properties with several arguments.
* @param key The resource key
* @param arg0 The argument to place in variable {0}
* @param arg1 The argument to place in variable {1}
* @param arg2 The argument to place in variable {2}
* @return The formatted message
*/
String getMessage(String key, String arg0, String arg1, String arg2) {
return getMessage(key, arg0, arg1, arg2, null, null);
}
/**
* Get a message from i18n.properties with several arguments.
* @param key The resource key
* @param arg0 The argument to place in variable {0}
* @param arg1 The argument to place in variable {1}
* @param arg2 The argument to place in variable {2}
* @param arg3 The argument to place in variable {3}
* @return The formatted message
*/
String getMessage(String key, String arg0, String arg1,
String arg2, String arg3) {
return getMessage(key, arg0, arg1, arg2, arg3, null);
}
/**
* Get a message from i18n.properties with several arguments.
* @param key The resource key
* @param arg0 The argument to place in variable {0}
* @param arg1 The argument to place in variable {1}
* @param arg2 The argument to place in variable {2}
* @param arg3 The argument to place in variable {3}
* @param arg4 The argument to place in variable {4}
* @return The formatted message
*/
String getMessage(String key, String arg0, String arg1,
String arg2, String arg3, String arg4) {
String strPattern = getRB().getString(key);
String [] params = { arg0, arg1, arg2, arg3, arg4 };
for (int i=0; i<5; i++) {
if (params[i]!=null) params[i]=params[i].replaceAll("\\\\","\\\\\\\\");
if (params[i]!=null) params[i]=params[i].replaceAll("%20"," ");
}
if (arg0!=null) strPattern = strPattern.replaceAll("\\{0\\}",params[0]);
if (arg1!=null) strPattern = strPattern.replaceAll("\\{1\\}",params[1]);
if (arg2!=null) strPattern = strPattern.replaceAll("\\{2\\}",params[2]);
if (arg3!=null) strPattern = strPattern.replaceAll("\\{3\\}",params[3]);
if (arg4!=null) strPattern = strPattern.replaceAll("\\{4\\}",params[4]);
return strPattern;
}
%>
1.1 ws-axis/java/webapps/axis/index.jsp
Index: index.jsp
===================================================================
<html>
<%@ page contentType="text/html; charset=utf-8" %>
<%
/*
* Copyright 2005 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.
*/
%>
<%@ include file="i18nLib.jsp" %>
<%
// initialize a private HttpServletRequest
setRequest(request);
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Apache-Axis</title>
</head>
<body bgcolor="#FFFFFF">
<h1 align="center">Apache-AXIS</h1>
<%= getLocaleChoice() %>
<%
out.print(getMessage("welcomeMessage")+"<p/>");
out.print(getMessage("operationType"));
%>
<ul>
<li>
<%
out.print("<a href=\""+ getMessage("validationURL") +"\">");
out.print(getMessage("validation") +"</a> - ");
out.print(getMessage("validationFootnote00") +"<br>");
out.print("<i>"+ getMessage("validationFootnote01") +"</i>");
%>
</li>
<li>
<%
out.print("<a href=\""+ getMessage("serviceListURL") +"\">");
out.print(getMessage("serviceList") +"</a> - ");
out.print(getMessage("serviceListFootnote"));
%>
</li>
<li>
<%
out.print("<a href=\""+ getMessage("callAnEndpointURL") +"\">");
out.print(getMessage("callAnEndpoint") +"</a> - ");
out.print(getMessage("callAnEndpointFootnote00") +" ");
out.print(getMessage("callAnEndpointFootnote01"));
%>
</li>
<li>
<%
out.print("<a href=\""+ getMessage("visitURL") +"\">");
out.print(getMessage("visit") +"</a> - ");
out.print(getMessage("visitFootnote"));
%>
</li>
<li>
<%
out.print("<a href=\""+ getMessage("adminURL") +"\">");
out.print(getMessage("admin") +"</a> - ");
out.print(getMessage("adminFootnote"));
%>
</li>
<li>
<%
out.print("<a href=\""+ getMessage("soapMonitorURL") +"\">");
out.print(getMessage("soapMonitor") +"</a> - ");
out.print(getMessage("soapMonitorFootnote"));
%>
</li>
</ul>
<%
out.print(getMessage("sideNote") +"<p/>");
%>
<%
out.print("<h3>"+ getMessage("validatingAxis") +"</h3>");
out.print(getMessage("validationNote00") +"<p/>");
out.print(getMessage("validationNote01"));
%>
</body>
</html>