I am adding code to all my application-specific Turbine services to give them
the ability to describe their current status. For instance, I have a service
which performs a complex action on demand; it keeps track of the number of
successes and failures, and the average time the action takes to execute. I'm
going to make this information accessible to an admin of my app, and similar
information for my other application-specific Turbine services.
The following is a patch which adds a new method (public String getStatus()) to
the Service interface, so that it's easy to add this sort of capability to your
Turbine services. Simple implementations are provided for BaseService and
BaseUnicastRemoteObject; they display whether or not the service has
been initialized.
Let me know whether you think this feature would be generally useful in Turbine.
Index: BaseService.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/services/BaseService.java,v
retrieving revision 1.8
diff -u -r1.8 BaseService.java
--- BaseService.java 2001/05/05 13:26:55 1.8
+++ BaseService.java 2001/06/07 00:51:15
@@ -159,4 +159,14 @@
}
return configuration;
}
+
+ /**
+ * Returns the current status of this Service.
+ *
+ * @return The current status of this Service.
+ */
+ public String getStatus()
+ {
+ return (getInit() ? "Initialized." : "Uninitialized.");
+ }
}
Index: BaseUnicastRemoteService.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/services/BaseUnicastRemoteService.java,v
retrieving revision 1.2
diff -u -r1.2 BaseUnicastRemoteService.java
--- BaseUnicastRemoteService.java 2001/06/07 00:01:36 1.2
+++ BaseUnicastRemoteService.java 2001/06/07 00:51:15
@@ -123,6 +123,16 @@
return name;
}
+ /**
+ * Returns the current status of this Service.
+ *
+ * @return The current status of this Service.
+ */
+ public String getStatus()
+ {
+ return (getInit() ? "Initialized." : "Uninitialized.");
+ }
+
public ServiceBroker getServiceBroker()
{
return serviceBroker;
Index: Service.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/services/Service.java,v
retrieving revision 1.8
diff -u -r1.8 Service.java
--- Service.java 2001/06/07 00:03:46 1.8
+++ Service.java 2001/06/07 00:51:15
@@ -121,4 +121,11 @@
* @return The Configuration of this Service.
*/
public Configuration getConfiguration();
+
+ /**
+ * Returns the current status of this Service.
+ *
+ * @return The current status of this Service.
+ */
+ public String getStatus();
}
--
Leonard Richardson | CollabNet
[EMAIL PROTECTED] | http://collab.net/
"Duty now for the future"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]