[jboss-cvs] jboss-seam/src/main/org/jboss/seam/interceptors ...
Gavin King
gavin.king at jboss.com
Fri Sep 29 18:48:50 EDT 2006
User: gavin
Date: 06/09/29 18:48:50
Modified: src/main/org/jboss/seam/interceptors
BusinessProcessInterceptor.java
Log:
JBSEAM-28 context events
Revision Changes Path
1.41 +8 -111 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.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- BusinessProcessInterceptor.java 6 Sep 2006 23:55:47 -0000 1.40
+++ BusinessProcessInterceptor.java 29 Sep 2006 22:48:50 -0000 1.41
@@ -11,7 +11,6 @@
import java.lang.reflect.Method;
import java.util.Map;
-import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
@@ -25,15 +24,12 @@
import org.jboss.seam.annotations.ResumeProcess;
import org.jboss.seam.annotations.StartTask;
import org.jboss.seam.core.BusinessProcess;
-import org.jboss.seam.core.FacesMessages;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.taskmgmt.exe.TaskInstance;
/**
* Interceptor which handles interpretation of jBPM-related annotations.
*
* @author <a href="mailto:steve at hibernate.org">Steve Ebersole </a>
- * @version $Revision: 1.40 $
+ * @version $Revision: 1.41 $
*/
@Interceptor(around={ValidationInterceptor.class, BijectionInterceptor.class, OutcomeInterceptor.class})
public class BusinessProcessInterceptor extends AbstractInterceptor
@@ -69,22 +65,25 @@
if ( method.isAnnotationPresent( StartTask.class ) ) {
log.trace( "encountered @StartTask" );
StartTask tag = method.getAnnotation( StartTask.class );
- return initTask( tag.taskIdParameter() );
+ Long taskId = getRequestParamValueAsLong( tag.taskIdParameter() );
+ return BusinessProcess.instance().initTask(taskId);
}
else if ( method.isAnnotationPresent( BeginTask.class ) ) {
log.trace( "encountered @BeginTask" );
BeginTask tag = method.getAnnotation( BeginTask.class );
- return initTask( tag.taskIdParameter() );
+ Long taskId = getRequestParamValueAsLong( tag.taskIdParameter() );
+ return BusinessProcess.instance().initTask(taskId);
}
else if ( method.isAnnotationPresent( ResumeProcess.class ) ) {
log.trace( "encountered @ResumeProcess" );
ResumeProcess tag = method.getAnnotation( ResumeProcess.class );
- return initProcess( tag.processIdParameter() );
+ Long processId = getRequestParamValueAsLong( tag.processIdParameter() );
+ return BusinessProcess.instance().initProcess(processId);
}
if ( method.isAnnotationPresent(EndTask.class) )
{
log.trace( "encountered @EndTask" );
- return checkTask();
+ return BusinessProcess.instance().checkTask();
}
else
{
@@ -92,108 +91,6 @@
}
}
- private boolean checkTask()
- {
- TaskInstance task = org.jboss.seam.core.TaskInstance.instance();
- Long taskId = BusinessProcess.instance().getTaskId();
- if ( task==null )
- {
- taskNotFound(taskId);
- return false;
- }
- else if ( task.hasEnded() )
- {
- taskEnded(taskId);
- return false;
- }
- else
- {
- return true;
- }
- }
-
- private boolean initTask(String taskIdParameter) {
- BusinessProcess process = BusinessProcess.instance();
- Long taskId = getRequestParamValueAsLong(taskIdParameter);
- process.setTaskId(taskId);
- TaskInstance taskInstance = org.jboss.seam.core.TaskInstance.instance();
- if (taskInstance==null)
- {
- taskNotFound(taskId);
- return false;
- }
- else if ( taskInstance.hasEnded() )
- {
- taskEnded(taskId);
- return false;
- }
- else
- {
- process.setProcessId( taskInstance.getTaskMgmtInstance().getProcessInstance().getId() );
- return true;
- }
- }
-
- private boolean initProcess(String processIdParameter) {
- Long processId = getRequestParamValueAsLong(processIdParameter);
- BusinessProcess.instance().setProcessId(processId);
- ProcessInstance process = org.jboss.seam.core.ProcessInstance.instance();
- if ( process==null )
- {
- processNotFound(processId);
- return false;
- }
- else if ( process.hasEnded() )
- {
- processEnded(processId);
- return false;
- }
- else
- {
- return true;
- }
- }
-
- private void taskNotFound(Long taskId)
- {
- FacesMessages.instance().addFromResourceBundle(
- FacesMessage.SEVERITY_WARN,
- "org.jboss.seam.TaskNotFound",
- "Task #0 not found",
- taskId
- );
- }
-
- private void taskEnded(Long taskId)
- {
- FacesMessages.instance().addFromResourceBundle(
- FacesMessage.SEVERITY_WARN,
- "org.jboss.seam.TaskEnded",
- "Task #0 already ended",
- taskId
- );
- }
-
- private void processEnded(Long processId)
- {
- FacesMessages.instance().addFromResourceBundle(
- FacesMessage.SEVERITY_WARN,
- "org.jboss.seam.ProcessEnded",
- "Process #0 already ended",
- processId
- );
- }
-
- private void processNotFound(Long processId)
- {
- FacesMessages.instance().addFromResourceBundle(
- FacesMessage.SEVERITY_WARN,
- "org.jboss.seam.ProcessNotFound",
- "Process #0 not found",
- processId
- );
- }
-
private Object afterInvocation(InvocationContext invocation, Object result)
{
Method method = invocation.getMethod();
More information about the jboss-cvs-commits
mailing list