Package org.drools.jpdl.core

Examples of org.drools.jpdl.core.JpdlConnection


                    String transitionName = transition.getName();
                    if (transitionName == null) {
                        transitionName = Node.CONNECTION_DEFAULT_TYPE;
                    }
                    // TODO: transition condition, events and exception handlers
                    JpdlConnection connection = new JpdlConnection(from, transitionName, to, Node.CONNECTION_DEFAULT_TYPE);
                    Map<String, Event> events = transition.getEvents();
                    if (events != null) {
                        for (Event event : events.values()) {
                            connection.addEvent(event);
                        }
                    }
                    List<ExceptionHandler> exceptionHandlers = transition.getExceptionHandlers();
                    if (exceptionHandlers != null) {
                        for (ExceptionHandler exceptionHandler : exceptionHandlers) {
                            connection.addExceptionHandler(exceptionHandler);
                        }
                    }
                    connection.setCondition(transition.getCondition());
                }
            }
        }
    }
View Full Code Here


        "Could not find default leave transition: " + this);
    }
  }

  public void leave(String type) {
    JpdlConnection connection = (JpdlConnection)
        getJpdlNode().getOutgoingConnection(type);
    if (connection == null) {
      throw new JbpmException("transition '" + type
        + "' is not a leaving transition of node '" + this + "'");
    }
    removeEventListeners();
    fireEvent(Event.EVENTTYPE_NODE_LEAVE);
        ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
        Event event = connection.getEvent(Event.EVENTTYPE_TRANSITION);
        if (event != null) {
            List<Action> actions = event.getActions();
            if (actions != null) {
                for (Action action: actions) {
                    try {
                        action.execute(new JpdlExecutionContext());
                    } catch (Exception exception) {
                        boolean handled = false;
                        List<ExceptionHandler> exceptionHandlers = connection.getExceptionHandlers();
                        try {
                            for (ExceptionHandler exceptionHandler: exceptionHandlers) {
                                if (exceptionHandler.matches(exception)) {
                                    exceptionHandler.handleException(null, new JpdlExecutionContext());
                                    handled = true;
                                }
                            }
                        } catch (Exception e) {
                            exception = e;
                        }
                        if (!handled) {
                            if (exception instanceof JbpmException) {
                                throw (JbpmException) exception;
                            } else {
                                throw new DelegationException(exception, null);
                            }
                        }
                    }
                }
            }
        }
        String condition = connection.getCondition();
        if (condition != null) {
            Object result = JbpmExpressionEvaluator.evaluate(
                condition, new JpdlExecutionContext());
            if (result == null) {
                throw new JbpmException("connection condition " + condition
                        + " evaluated to null");
            } else if (!(result instanceof Boolean)) {
                throw new JbpmException("connection condition " + condition
                        + " evaluated to non-boolean: "
                        + result.getClass().getName());
            } else if (!((Boolean) result).booleanValue()) {
                throw new JbpmException("connection condition " + condition
                        + " evaluated to 'false'");
            }
        }
        ((NodeInstanceContainer) getNodeInstanceContainer())
          .getNodeInstance(connection.getTo()).trigger(this, connection.getToType());
  }
View Full Code Here

TOP

Related Classes of org.drools.jpdl.core.JpdlConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.