[jboss-cvs] jboss-seam/src/main/org/jboss/seam/interceptors ...
Gavin King
gavin.king at jboss.com
Thu Mar 29 12:00:50 EDT 2007
User: gavin
Date: 07/03/29 12:00:50
Modified: src/main/org/jboss/seam/interceptors
BusinessProcessInterceptor.java
Log:
use EL to determine task/process id
Revision Changes Path
1.52 +34 -30 jboss-seam/src/main/org/jboss/seam/interceptors/BusinessProcessInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BusinessProcessInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/BusinessProcessInterceptor.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- BusinessProcessInterceptor.java 11 Feb 2007 19:48:12 -0000 1.51
+++ BusinessProcessInterceptor.java 29 Mar 2007 16:00:50 -0000 1.52
@@ -6,10 +6,7 @@
*/
package org.jboss.seam.interceptors;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
import java.lang.reflect.Method;
-import java.util.Map;
import javax.faces.context.FacesContext;
@@ -21,15 +18,17 @@
import org.jboss.seam.annotations.ResumeProcess;
import org.jboss.seam.annotations.StartTask;
import org.jboss.seam.core.BusinessProcess;
+import org.jboss.seam.core.Expressions;
import org.jboss.seam.intercept.InvocationContext;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
+import org.jboss.util.Strings;
/**
* Interceptor which handles interpretation of jBPM-related annotations.
*
* @author <a href="mailto:steve at hibernate.org">Steve Ebersole </a>
- * @version $Revision: 1.51 $
+ * @version $Revision: 1.52 $
*/
@Interceptor(stateless=true,
around={ValidationInterceptor.class, BijectionInterceptor.class})
@@ -57,19 +56,19 @@
if ( method.isAnnotationPresent( StartTask.class ) ) {
log.trace( "encountered @StartTask" );
StartTask tag = method.getAnnotation( StartTask.class );
- Long taskId = getRequestParamValueAsLong( tag.taskIdParameter() );
+ Long taskId = getRequestParamValueAsLong( tag.taskIdParameter(), tag.taskId() );
return BusinessProcess.instance().resumeTask(taskId);
}
else if ( method.isAnnotationPresent( BeginTask.class ) ) {
log.trace( "encountered @BeginTask" );
BeginTask tag = method.getAnnotation( BeginTask.class );
- Long taskId = getRequestParamValueAsLong( tag.taskIdParameter() );
+ Long taskId = getRequestParamValueAsLong( tag.taskIdParameter(), tag.taskId() );
return BusinessProcess.instance().resumeTask(taskId);
}
else if ( method.isAnnotationPresent( ResumeProcess.class ) ) {
log.trace( "encountered @ResumeProcess" );
ResumeProcess tag = method.getAnnotation( ResumeProcess.class );
- Long processId = getRequestParamValueAsLong( tag.processIdParameter() );
+ Long processId = getRequestParamValueAsLong( tag.processIdParameter(), tag.processId() );
return BusinessProcess.instance().resumeProcess(processId);
}
if ( method.isAnnotationPresent(EndTask.class) )
@@ -115,29 +114,34 @@
return result;
}
- private Long getRequestParamValueAsLong(String paramName)
+ private Long getRequestParamValueAsLong(String paramName, String el)
{
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Map paramMap = facesContext.getExternalContext()
- .getRequestParameterMap();
- String paramValue = (String) paramMap.get(paramName);
- if (paramValue==null)
+ Object id;
+ if ( Strings.isEmpty(paramName) )
{
- throw new IllegalStateException("no value for request parameter: " + paramName);
- //return null;
+ id = Expressions.instance().createValueBinding(el).getValue();
}
else
{
- PropertyEditor editor = PropertyEditorManager.findEditor(Long.class);
- if ( editor != null )
+ id = FacesContext.getCurrentInstance().getExternalContext()
+ .getRequestParameterMap().get(paramName);
+ }
+
+ if (id==null)
{
- editor.setAsText(paramValue);
- return (Long) editor.getValue();
+ throw new IllegalStateException("task/process id may not be null");
}
- else
+ else if (id instanceof Long)
{
- return Long.parseLong(paramValue);
+ return (Long) id;
}
+ else if (id instanceof String)
+ {
+ return new Long( (String) id );
+ }
+ else
+ {
+ throw new IllegalArgumentException("task/process id must be a string or long");
}
}
}
More information about the jboss-cvs-commits
mailing list