2 Replies Latest reply on Nov 28, 2007 9:01 AM by Jorge Morales

    Getting first non exception transition

    Jorge Morales Master

      Hi,
      We have an ActionHandler where we want to Transition to take the first possible transition that is not an Exception Path, this is, is not one of the possible transitions taken by an ExceptionHandler`s actions.
      We have this code now:

       private String getOutputTransition(ExecutionContext context)
       throws ActionHandlerConfigurationException {
       List<ExceptionHandler> exceptionsH = context.getToken().getNode()
       .getExceptionHandlers();
      
       Node node = context.getToken().getNode();
       exceptionNodes = new ArrayList<String>();
       outputTransitions = node.getLeavingTransitions();
       if (exceptionsH != null) {
       for (ExceptionHandler eh : exceptionsH) {
       Action action = (Action) eh.getActions().iterator().next();
       if (action != null) {
       if (action.getActionDelegation().getClassName().equals("x.ba.MiExceptionHandler")) {
       String tr = StringUtils.substringBetween(action
       .getActionDelegation().getConfiguration(),
       "<exceptionPathTransition>",
       "</exceptionPathTransition>");
       exceptionNodes.add(node.getLeavingTransition(tr)
       .getTo().getName());
       }
       }
       }
       }
       if (exceptionNodes.size() == 0) {
       return null;
       } else {
       for (Transition t : outputTransitions) {
       if (!exceptionNodes.contains(t.getTo().getName())) {
       return t.getName();
       }
       }
       }
       throw new ActionHandlerConfigurationException(
       "All next transitions exceptions. Set a normal path");
       }
      


      This code is working, but it takes long time to execute, compared with the rest of our ActionHandlers things.

      Is there a way to achieve same result, and not having to use Configuration class?

      Thanks.