Coverage Report - org.apache.camel.bam.ActivityRules
 
Classes in this File Line Coverage Branch Coverage Complexity
ActivityRules
0% 
0% 
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.bam;
 18  
 
 19  
 import org.apache.camel.bam.model.ActivityDefinition;
 20  
 import org.apache.camel.bam.model.ActivityState;
 21  
 import org.apache.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 
 24  
 import java.util.ArrayList;
 25  
 import java.util.List;
 26  
 
 27  
 /**
 28  
  * Represents a activity which is typically a system or could be an endpoint
 29  
  *
 30  
  * @version $Revision: $
 31  
  */
 32  
 public class ActivityRules {
 33  0
     private static final transient Log log = LogFactory.getLog(ActivityRules.class);
 34  0
     private int expectedMessages = 1;
 35  
     private ActivityDefinition activity;
 36  
     private ProcessRules process;
 37  0
     private List<TemporalRule> rules = new ArrayList<TemporalRule>();
 38  
     private String activityName;
 39  
 
 40  0
     public ActivityRules(ProcessRules process) {
 41  0
         this.process = process;
 42  0
         process.getActivities().add(this);
 43  0
     }
 44  
 
 45  
     public ActivityDefinition getActivity() {
 46  0
         return activity;
 47  
     }
 48  
 
 49  
     public void setActivity(ActivityDefinition activity) {
 50  0
         this.activity = activity;
 51  0
     }
 52  
 
 53  
     public int getExpectedMessages() {
 54  0
         return expectedMessages;
 55  
     }
 56  
 
 57  
     public void setExpectedMessages(int expectedMessages) {
 58  0
         this.expectedMessages = expectedMessages;
 59  0
     }
 60  
 
 61  
     public ProcessRules getProcess() {
 62  0
         return process;
 63  
     }
 64  
 
 65  
     /**
 66  
      * Perform any assertions after the state has been updated
 67  
      */
 68  
     public void processExchange(ActivityState activityState, ProcessContext context) {
 69  
 
 70  0
         log.info("Received state: " + activityState
 71  
                 + " message count " + activityState.getReceivedMessageCount()
 72  
                 + " started: " + activityState.getTimeStarted()
 73  
                 + " completed: " + activityState.getTimeCompleted());
 74  
 
 75  
 /*
 76  
         process.fireRules(activityState, context);
 77  
 
 78  
         for (TemporalRule rule : rules) {
 79  
             rule.evaluate(context, activityState);
 80  
         }
 81  
 */
 82  0
     }
 83  
 
 84  
     public void setActivityName(String activityName) {
 85  0
         this.activityName = activityName;
 86  0
     }
 87  
 
 88  
     public void addRule(TemporalRule rule) {
 89  0
         rules.add(rule);
 90  0
     }
 91  
 
 92  
     /**
 93  
      * Handles overdue activities
 94  
      */
 95  
     public void processExpired(ActivityState activityState) throws Exception {
 96  0
         for (TemporalRule rule : rules) {
 97  0
             rule.processExpired(activityState);
 98  0
         }
 99  0
     }
 100  
 }