[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Mon Mar 12 16:57:30 UTC 2007
gordonp
Mon Mar 12 12:57:30 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service
In directory dev.open-bio.org:/tmp/cvs-serv4195/src/main/org/biomoby/service
Modified Files:
MobyServlet.java
Log Message:
Updates to base service for better extensibility
moby-live/Java/src/main/org/biomoby/service MobyServlet.java,1.5,1.6
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java 2007/02/08 16:59:58 1.5
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java 2007/03/12 16:57:30 1.6
@@ -77,7 +77,7 @@
protected boolean isDebug = false;
public void doGet(HttpServletRequest request,
- HttpServletResponse response)
+ HttpServletResponse response)
throws ServletException, java.io.IOException{
if(thisService == null){
try{
@@ -1142,9 +1142,10 @@
}
MobyServlet servlet = new MobyServlet();
+ ClassLoader classLoader = servlet.getClass().getClassLoader();
try{
// This line can throw many different exception if you didn't get the class right!
- Class servletClass = servlet.getClass().getClassLoader().loadClass(args[0]);
+ Class servletClass = classLoader.loadClass(args[0]);
if(servletClass == null){
System.err.println("The Class to test (" + args[0] + ") was not found");
System.err.println("Assuming you don't want to run a servlet test, executing main() method from subclass");
@@ -1189,7 +1190,14 @@
MobyContentInstance testResults = new MobyContentInstance();
// Configure the service, minimally, to check the input data
- servlet.init(new TestServletConfig(args[0], new TestServletContext()));
+ java.net.URL webXMLURL = classLoader.getResource("WEB-INF/web.xml");
+ if(webXMLURL == null){
+ System.err.println("No WEB-INF/web.xml, assuming you don't need any of its settings for the servlet to work!");
+ servlet.init(new TestServletConfig(args[0], new TestServletContext()));
+ }
+ else{
+ servlet.init(new TestServletConfig(new TestServletContext(), webXMLURL));
+ }
servlet.thisService = servlet.createServiceFromConfig(null);
// It should populate the testResults
@@ -1210,7 +1218,7 @@
for(ServiceException se: testResults.getExceptions()){
se.printStackTrace();
}
- throw new Exception("Executing service " + args[0] + " cause exceptions");
+ throw new Exception("Executing service " + args[0] + " caused exceptions");
}
else{
System.out.println(testResults.toString());
More information about the MOBY-guts
mailing list