You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by hl...@apache.org on 2004/07/26 00:43:06 UTC
cvs commit: jakarta-hivemind/examples/src/java/com/panorama/startup/impl ExecuteStatic.java
hlship 2004/07/25 15:43:06
Modified: . status.xml
framework/src/test/org/apache/hivemind/impl
TestErrorHandler.java
examples/src/java/com/panorama/startup/impl
ExecuteStatic.java
Added: framework/src/java/org/apache/hivemind/impl
StrictErrorHandler.java
Log:
Added StrictErrorHandler, an implementation of ErrorHandler that always throws an ApplicationRuntimeException.
Revision Changes Path
1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/StrictErrorHandler.java
Index: StrictErrorHandler.java
===================================================================
//Copyright 2004 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.
package org.apache.hivemind.impl;
import org.apache.commons.logging.Log;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.Location;
/**
* An implementation of {@link org.apache.hivemind.ErrorHandler} that
* throws an {@link org.apache.hivemind.ApplicationRuntimeException}
* <em>instead of</em> logging an error.
*
* @author Howard Lewis Ship
*/
public class StrictErrorHandler implements ErrorHandler
{
public void error(Log log, String message, Location location, Throwable cause)
{
String exceptionMessage =
location == null
? ImplMessages.unlocatedError(message)
: ImplMessages.locatedError(location, message);
throw new ApplicationRuntimeException(exceptionMessage, location, cause);
}
}
1.31 +3 -0 jakarta-hivemind/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/status.xml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- status.xml 24 Jul 2004 22:18:13 -0000 1.30
+++ status.xml 25 Jul 2004 22:43:05 -0000 1.31
@@ -79,6 +79,9 @@
<action type="update" dev="HLS">
Added more examples and examples documentation.
</action>
+ <action type="add" dev="HLS">
+ Added StrictErrorHandler, an implementation of ErrorHandler that always throws an ApplicationRuntimeException.
+ </action>
</release>
1.3 +37 -0 jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestErrorHandler.java
Index: TestErrorHandler.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestErrorHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestErrorHandler.java 21 Jun 2004 14:25:44 -0000 1.2
+++ TestErrorHandler.java 25 Jul 2004 22:43:05 -0000 1.3
@@ -17,6 +17,7 @@
import hivemind.test.FrameworkTestCase;
import org.apache.commons.logging.Log;
+import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.Location;
import org.apache.hivemind.Resource;
@@ -65,5 +66,41 @@
eh.error(log, "Bad frob value.", null, ex);
verifyControls();
+ }
+
+ public void testStrictErrorHandler()
+ {
+ ErrorHandler eh = new StrictErrorHandler();
+ Throwable cause = new NullPointerException();
+
+ try
+ {
+ eh.error(null, "An error message.", null, cause);
+ unreachable();
+ }
+ catch (ApplicationRuntimeException ex)
+ {
+ assertEquals("Error: An error message.", ex.getMessage());
+ assertSame(cause, ex.getRootCause());
+ }
+ }
+
+ public void testStrictErrorHandlerWithLocation()
+ {
+ ErrorHandler eh = new StrictErrorHandler();
+ Throwable cause = new NullPointerException();
+ Location l = fabricateLocation(21);
+
+ try
+ {
+ eh.error(null, "An error message.", l, cause);
+ unreachable();
+ }
+ catch (ApplicationRuntimeException ex)
+ {
+ assertEquals("Error at " + l + ": An error message.", ex.getMessage());
+ assertSame(l, ex.getLocation());
+ assertSame(cause, ex.getRootCause());
+ }
}
}
1.2 +8 -8 jakarta-hivemind/examples/src/java/com/panorama/startup/impl/ExecuteStatic.java
Index: ExecuteStatic.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/examples/src/java/com/panorama/startup/impl/ExecuteStatic.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExecuteStatic.java 20 Jul 2004 17:22:53 -0000 1.1
+++ ExecuteStatic.java 25 Jul 2004 22:43:06 -0000 1.2
@@ -37,19 +37,19 @@
m.invoke(null, null);
}
- /**
- * Sets the name of the method to invoke; if not set, the default is <code>init</code>.
- * The target class must have a public static method with that name taking no
- * parameters.
- */
+ /**
+ * Sets the name of the method to invoke; if not set, the default is <code>init</code>.
+ * The target class must have a public static method with that name taking no
+ * parameters.
+ */
public void setMethodName(String string)
{
_methodName = string;
}
- /**
- * Sets the class to invoke the method on.
- */
+ /**
+ * Sets the class to invoke the method on.
+ */
public void setTargetClass(Class targetClass)
{
_targetClass = targetClass;
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org