[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Wed Oct 25 19:32:54 UTC 2006
kawas
Wed Oct 25 15:32:54 EDT 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms
In directory dev.open-bio.org:/tmp/cvs-serv14113/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms
Modified Files:
CallableServicesServlet.java
Log Message:
made service testing code more modular and fixed a thread (cleanup) issue
moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms CallableServicesServlet.java,1.5,1.6
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/CallableServicesServlet.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/client/ui/graphical/servlet/forms/CallableServicesServlet.java 2006/10/18 22:31:06 1.5
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/CallableServicesServlet.java 2006/10/25 19:32:54 1.6
@@ -6,11 +6,6 @@
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -18,14 +13,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.discovery.tools.DiscoverSingleton;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.biomoby.client.CentralImpl;
-import org.biomoby.client.ui.graphical.servlet.utilities.ContextLoader;
-import org.biomoby.client.ui.graphical.servlet.utilities.ServiceTester;
-import org.biomoby.shared.MobyException;
-import org.biomoby.shared.MobyService;
+import org.biomoby.client.ui.graphical.servlet.utilities.ServiceTesterRunner;
/**
* @author Eddie Kawas This class was created to call out to all registered
@@ -43,31 +33,10 @@
// some useful variables
private final String newline = System.getProperty("line.separator");
- ServiceTesterRunner scheduler = null;
+
- public void init(ServletConfig arg0) throws ServletException {
- super.init(arg0);
-
- ContextLoader cLoader = null;
- try {
- cLoader = (ContextLoader) DiscoverSingleton.find(Class
- .forName((String) ContextLoader.class.getCanonicalName()), Class.forName(
- (String) ContextLoader.class.getCanonicalName()).getName());
- log
- .warn((cLoader == null ? "ContextLoader is null and is therefore not loaded. This is BAD!"
- : "ContextLoader has loaded successfully."));
- } catch (Exception e) {
- log.warn("ContextLoader is null and is therefore not loaded. This is BAD!"
- + System.getProperty("line.separator") + e.getStackTrace());
- }
-
- log.info("initializing CallableServiceServlet");
- scheduler = new ServiceTesterRunner();
- Timer timer = new Timer();
- Calendar calendar = Calendar.getInstance();
- Date time = calendar.getTime();
- log.info("Scheduling on going task.");
- timer.scheduleAtFixedRate(scheduler, time, 1000 * 60 * 60);
+ public void init(ServletConfig conf) throws ServletException {
+ super.init(conf);
}
/*
@@ -79,7 +48,9 @@
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// set the content type
-
+
+ ServiceTesterRunner scheduler = (ServiceTesterRunner) getServletContext().getAttribute("tester");
+
String authority = filter(request.getParameter("authority"));
String servicename = filter(request.getParameter("service"));
String getStats = filter(request.getParameter("getStats"));
@@ -163,11 +134,6 @@
}
- public void init() throws ServletException {
- super.init();
-
- }
-
private static String filter(String input) {
if (input == null)
return null;
@@ -201,63 +167,5 @@
doGet(arg0, arg1);
}
- public final class ServiceTesterRunner extends TimerTask {
- /*
- *
- */
-
- protected ServiceTester t = null;
-
- public ServiceTesterRunner() {
- try {
- t = new ServiceTester(
- System.getProperty("MOBY_SERVER") == null ? CentralImpl.DEFAULT_ENDPOINT
- : System.getProperty("MOBY_SERVER"),
- System.getProperty("MOBY_URI") == null ? CentralImpl.DEFAULT_NAMESPACE
- : System.getProperty("MOBY_URI"));
- } catch (MobyException e) {
- log.error("Couldn't instantiate a ServiceTester object", e);
- }
- // run();
- }
-
- /*
- * Implements TimerTask's abstract run method.
- */
- public void run() {
- if (t == null) {
- try {
- t = new ServiceTester(
- System.getProperty("MOBY_SERVER") == null ? CentralImpl.DEFAULT_ENDPOINT
- : System.getProperty("MOBY_SERVER"),
- System.getProperty("MOBY_URI") == null ? CentralImpl.DEFAULT_NAMESPACE
- : System.getProperty("MOBY_URI"));
- } catch (MobyException e) {
- log.error("Couldn't instantiate a ServiceTester object", e);
- return;
- }
- }
- // implement this method to contain whatever it is you want to do
- log.info("re-querying services...");
- MobyService[] services = t.getServices();
- if (services != null && services.length > 0) {
- Map map = t.testServices(services);
- if (map != null && !map.isEmpty())
- t.setResultMap(map);
- }
- services = null;
- log.info("service checking complete!");
- // log stats every hour
- t.logStats();
- }
-
- public ServiceTester getServiceTester() {
- return t;
- }
-
- // expressed in milliseconds
- private final static long ONCE_PER_DAY = 1000 * 60 * 60 * 24;
-
- }
}
More information about the MOBY-guts
mailing list