Examples of IJoinPoint


Examples of org.fireflow.kernel.IJoinPoint

        }
        IPersistenceService persistenceService = rtCtx.getPersistenceService();
        //保存到数据库
        persistenceService.saveOrUpdateToken(token);

        IJoinPoint resultJoinPoint = null;
        resultJoinPoint = new JoinPoint();
        resultJoinPoint.setProcessInstance(this);
        resultJoinPoint.setSynchronizerId(synchInst.getSynchronizer().getId());
        if (enterTransInstanceCount == 1) {
            // 生成一个不存储到数据库中的JoinPoint
            resultJoinPoint.addValue(token.getValue());

            if (token.isAlive()) {
                resultJoinPoint.setAlive(true);
                resultJoinPoint.setFromActivityId(token.getFromActivityId());
            }
            resultJoinPoint.setStepNumber(token.getStepNumber() + 1);

            return resultJoinPoint;
        } else {

            int stepNumber = 0;

            List<IToken> tokensList_0 = persistenceService.findTokensForProcessInstance(this.getId(), synchInst.getSynchronizer().getId());
            Map<String,IToken> tokensMap = new HashMap<String,IToken>();
            for (int i = 0; i < tokensList_0.size(); i++) {
                IToken tmpToken =   tokensList_0.get(i);
                String tmpFromActivityId = tmpToken.getFromActivityId();
                if (!tokensMap.containsKey(tmpFromActivityId)) {
                    tokensMap.put(tmpFromActivityId, tmpToken);
                } else {
                  //TODO  ====下面的代码有意义吗?===start===wmj2003
                    IToken tmpToken2 = tokensMap.get(tmpFromActivityId);
                    if (tmpToken2.getStepNumber() > tmpToken.getStepNumber()) {
                        tokensMap.put(tmpFromActivityId, tmpToken2);
                    }
                   //TODO  ====下面的代码有意义吗?===end===wmj2003
                }
            }

            List<IToken> tokensList = new ArrayList<IToken>(tokensMap.values());

            for (int i = 0; i < tokensList.size(); i++) {
                IToken _token = tokensList.get(i);
                resultJoinPoint.addValue(_token.getValue());
                if (_token.isAlive()) {//如果token的状态是alive
                    resultJoinPoint.setAlive(true);
                    String oldFromActivityId = resultJoinPoint.getFromActivityId();
                    if (oldFromActivityId == null || oldFromActivityId.trim().equals("")) {
                        resultJoinPoint.setFromActivityId(_token.getFromActivityId());
                    } else {
                        resultJoinPoint.setFromActivityId(oldFromActivityId + IToken.FROM_ACTIVITY_ID_SEPARATOR + _token.getFromActivityId());
                    }

                }
                if (token.getStepNumber() > stepNumber) {
                    stepNumber = token.getStepNumber();
                }
            }

            resultJoinPoint.setStepNumber(stepNumber + 1);

            return resultJoinPoint;
        }
  
    }
View Full Code Here

Examples of org.fireflow.kernel.IJoinPoint

    /* (non-Javadoc)
     * @see org.fireflow.kernel.INodeInstance#fire(org.fireflow.kernel.IToken)
     */
    public void fire(IToken tk) throws KernelException {
        //TODO 此处性能需要改善一下,20090312
        IJoinPoint joinPoint = null;
        synchronized (this) { //流程同步器需要处理并发的情况,而activity的节点不需要处理并发情况?同步器节点,可能被同时触发,activity节点不会被同时触发?
            tk.setNodeId(this.getSynchronizer().getId());
            log.debug("The weight of the Entering TransitionInstance is " + tk.getValue());
            // 触发TokenEntered事件
            NodeInstanceEvent event1 = new NodeInstanceEvent(this);
            event1.setToken(tk);
            event1.setEventType(NodeInstanceEvent.NODEINSTANCE_TOKEN_ENTERED);//token 进入
            fireNodeEvent(event1);

            //汇聚检查

            joinPoint = ((ProcessInstance) tk.getProcessInstance()).createJoinPoint(this, tk);// JoinPoint由谁生成比较好?
            int value = joinPoint.getValue();
            log.debug("The volume of " + this.toString() + " is " + volume);
            log.debug("The value of " + this.toString() + " is " + value);
            if (value > volume) {//如果value大于同步器容量,那说明出错了
                KernelException exception = new KernelException(tk.getProcessInstance(),
                        this.getSynchronizer(),
                        "Error:The token count of the synchronizer-instance can NOT be  greater than  it's volumn  ");
                throw exception;
            }
            if (value < volume) {// 如果Value小于容量则继续等待其他弧的汇聚。 (哪些状态为dead的token到此结束,不再向下传递)
                return
            }
        }
        //如果汇聚点的容量和同步器节点的容量相同
        IProcessInstance processInstance = tk.getProcessInstance();
        // Synchronize的fire条件应该只与joinPoint的value有关(value==volume),与alive无关
        NodeInstanceEvent event2 = new NodeInstanceEvent(this);
        event2.setToken(tk);
        event2.setEventType(NodeInstanceEvent.NODEINSTANCE_FIRED);
        fireNodeEvent(event2);

        //在此事件监听器中,删除原有的token
        NodeInstanceEvent event4 = new NodeInstanceEvent(this);
        event4.setToken(tk);
        event4.setEventType(NodeInstanceEvent.NODEINSTANCE_LEAVING);
        fireNodeEvent(event4);

        //首先必须检查是否有满足条件的循环,loop比transition有更高的优先级,
        //(只能够有一个loop的条件为true,流程定义的时候需要注意)
        boolean doLoop = false;//表示是否有满足条件的循环,false表示没有,true表示有。
        if (joinPoint.getAlive()) {
            IToken tokenForLoop = new Token(); // 产生新的token
            tokenForLoop.setAlive(joinPoint.getAlive());
            tokenForLoop.setProcessInstance(processInstance);
            tokenForLoop.setStepNumber(joinPoint.getStepNumber()-1);
            tokenForLoop.setFromActivityId(joinPoint.getFromActivityId());

            for (int i = 0; i < this.leavingLoopInstances.size(); i++) {
                ILoopInstance loopInstance = this.leavingLoopInstances.get(i);
                doLoop = loopInstance.take(tokenForLoop);
                if (doLoop) {
                    break;
                }
            }
        }
        if (!doLoop) {//如果没有循环,则执行transitionInstance
                //非顺序流转的需要生成新的token,
                boolean activiateDefaultCondition = true;
                ITransitionInstance defaultTransInst = null;
                for (int i = 0; leavingTransitionInstances != null && i < leavingTransitionInstances.size(); i++) {
                    ITransitionInstance transInst = leavingTransitionInstances.get(i);
                    String condition = transInst.getTransition().getCondition();
                    if (condition != null && condition.equals(ConditionConstant.DEFAULT)) {
                        defaultTransInst = transInst;
                        continue;
                    }

                    Token token = new Token(); // 产生新的token
                    token.setAlive(joinPoint.getAlive());
                    token.setProcessInstance(processInstance);
                    token.setStepNumber(joinPoint.getStepNumber());
                    token.setFromActivityId(joinPoint.getFromActivityId());
                    boolean alive = transInst.take(token);
                    if (alive) {
                        activiateDefaultCondition = false;
                    }

                }
                if (defaultTransInst != null) {
                    Token token = new Token();
                    token.setAlive(activiateDefaultCondition && joinPoint.getAlive());
                    token.setProcessInstance(processInstance);
                    token.setStepNumber(joinPoint.getStepNumber());
                    token.setFromActivityId(joinPoint.getFromActivityId())
                    defaultTransInst.take(token);
                }
           
        }

View Full Code Here

Examples of org.fireflow.kernel.IJoinPoint

     *
     * @see org.fireflow.kenel.IPTNetExecutor#fire(org.fireflow.kenel.RuntimeContext,
     *      org.fireflow.kenel.ITransitionInstance)
     */
    public void fire(IToken tk) throws KernelException {
      IJoinPoint joinPoint = null;
        synchronized (this) {
            tk.setNodeId(this.getSynchronizer().getId());
            log.debug("The weight of the Entering TransitionInstance is " + tk.getValue());
            // 触发TokenEntered事件
            NodeInstanceEvent event1 = new NodeInstanceEvent(this);
            event1.setToken(tk);
            event1.setEventType(NodeInstanceEvent.NODEINSTANCE_TOKEN_ENTERED);
            fireNodeEvent(event1);

            //汇聚检查
            joinPoint = ((ProcessInstance) tk.getProcessInstance()).createJoinPoint(this, tk);// JoinPoint由谁生成比较好?
            int value = joinPoint.getValue();

            log.debug("The volume of " + this.toString() + " is " + volume);
            log.debug("The value of " + this.toString() + " is " + value);
            if (value > volume) {
                KernelException exception = new KernelException(tk.getProcessInstance(),
                        this.getSynchronizer(),
                        "Error:The token count of the synchronizer-instance can NOT be  greater than  it's volumn  ");
                throw exception;
            }
            if (value < volume) {// 如果Value小于容量则继续等待其他弧的汇聚。
                return;
            }
        }

        IProcessInstance processInstance = tk.getProcessInstance();
        NodeInstanceEvent event2 = new NodeInstanceEvent(this);
        event2.setToken(tk);
        event2.setEventType(NodeInstanceEvent.NODEINSTANCE_FIRED);
        fireNodeEvent(event2);
       
        //在此事件监听器中,删除原有的token
        NodeInstanceEvent event4 = new NodeInstanceEvent(this);
        event4.setToken(tk);
        event4.setEventType(NodeInstanceEvent.NODEINSTANCE_LEAVING);
        fireNodeEvent(event4);
       
        //首先必须检查是否有满足条件的循环
        boolean doLoop = false;//表示是否有满足条件的循环,false表示没有,true表示有。

        if (joinPoint.getAlive()) {
            IToken tokenForLoop = null;

                tokenForLoop = new Token(); // 产生新的token
                tokenForLoop.setAlive(joinPoint.getAlive());
                tokenForLoop.setProcessInstance(processInstance);
                tokenForLoop.setStepNumber(joinPoint.getStepNumber()-1);
                tokenForLoop.setFromActivityId(joinPoint.getFromActivityId());

            for (int i = 0; i < this.leavingLoopInstances.size(); i++) {
             
                ILoopInstance loopInstance = this.leavingLoopInstances.get(i);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.