CVS: plexus-components/activity/src/java/org/apache/plexus/summit/activity DefaultActionEventService.java,1.4,1.5
[email protected] Tue, 20 May 2003 18:44:31 -0500
| Newsgroups | gmane.comp.java.plexus.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/plexus/plexus-components/activity/src/java/org/apache/plexus/summit/activity
In directory eng.werken.com:/tmp/cvs-serv10308/activity/src/java/org/apache/plexus/summit/activity
Modified Files:
DefaultActionEventService.java
Log Message:
A bunch of updates to make the activity component work right.
(Note: I usually use a derivative of this service that integrates
security, so I make no promises about the stability of this service).
I am not happy with the way the activity system works. Looking
for ideas for improvement.
Index: DefaultActionEventService.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/activity/src/java/org/apache/plexus/summit/activity/DefaultActionEventService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- DefaultActionEventService.java 13 May 2003 18:01:28 -0000 1.4
+++ DefaultActionEventService.java 20 May 2003 23:44:29 -0000 1.5
@@ -188,17 +188,22 @@
String methodName = null;
try
{
- methodName = getMethodName( data );
+ methodName = getMethodName( data, DEFAULT_METHOD );
+
Class actionClass = getClass( action );
- Method method = getMethod( actionClass, methodName );
+ Method method = getMethod( actionClass, data.getClass(), methodName, DEFAULT_METHOD );
// The arguments to pass to the method to execute.
Object[] args = new Object[1];
args[0] = data;
-
- method.invoke( actionClass.newInstance(), args );
+
+ method.invoke( actionClass.newInstance(), args );
}
+ catch ( ClassNotFoundException e )
+ {
+ getLogger().debug( "Could not find the action.", e );
+ }
catch (InvocationTargetException ite)
{
// I have not seen this exception, in stacktraces generated
@@ -234,22 +239,23 @@
* @return Method
* @throws NoSuchMethodException
*/
- protected Method getMethod( Class actionClass, String methodName )
+ protected Method getMethod( Class actionClass,
+ Class rundataClass,
+ String methodName,
+ String defaultName )
throws NoSuchMethodException, ClassNotFoundException
{
// The arguments to the method to find.
Class[] classes = new Class[1];
- classes[0] = RunData.class;
-
+ classes[0] = rundataClass;
+
try
{
return actionClass.getMethod(methodName, classes);
}
- catch (NoSuchMethodException e)
+ catch ( NoSuchMethodException e )
{
- // If the method specified by the submit button isn't found
- // try the default method.
- return actionClass.getMethod(DEFAULT_METHOD, classes);
+ return actionClass.getMethod(defaultName, classes);
}
}
@@ -259,7 +265,7 @@
* @param data
* @return String
*/
- protected String getMethodName(RunData data) throws NoSuchMethodException
+ protected String getMethodName( RunData data, String defaultName )
{
for ( Iterator iter = data.getParameters().keys(); iter.hasNext(); )
{
@@ -270,8 +276,7 @@
}
}
- throw new NoSuchMethodException(
- "ActionEvent: The button was null");
+ return defaultName;
}
/**