001 /**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements. See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.camel.bam;
019
020 import org.apache.camel.Exchange;
021 import org.apache.camel.bam.model.ProcessInstance;
022 import org.apache.camel.bam.model.ActivityState;
023
024 /**
025 * @version $Revision: 1.1 $
026 */
027 public class ProcessContext {
028 private Exchange exchange;
029
030 private ProcessRules processRules;
031 private ActivityRules activityRules;
032
033 private ProcessInstance processInstance;
034 private ActivityState activityState;
035
036 public ProcessContext(Exchange exchange, ActivityRules activityRules, ActivityState activityState) {
037 this.exchange = exchange;
038 this.activityRules = activityRules;
039 this.activityState = activityState;
040 this.processRules = activityRules.getProcess();
041 this.processInstance = activityState.getProcess();
042 }
043
044 public ActivityRules getActivity() {
045 return activityRules;
046 }
047
048 public void setActivity(ActivityRules activityRules) {
049 this.activityRules = activityRules;
050 }
051
052 public ActivityState getActivityState() {
053 return activityState;
054 }
055
056 public void setActivityState(ActivityState activityState) {
057 this.activityState = activityState;
058 }
059
060 public Exchange getExchange() {
061 return exchange;
062 }
063
064 public void setExchange(Exchange exchange) {
065 this.exchange = exchange;
066 }
067
068 public ProcessRules getProcessDefinition() {
069 return processRules;
070 }
071
072 public void setProcessDefinition(ProcessRules processRules) {
073 this.processRules = processRules;
074 }
075
076 public ProcessInstance getProcessInstance() {
077 return processInstance;
078 }
079
080 public void setProcessInstance(ProcessInstance processInstance) {
081 this.processInstance = processInstance;
082 }
083
084 public ActivityState getActivityState(ActivityRules activityRules) {
085 return getProcessInstance().getActivityState(activityRules);
086 }
087
088 /**
089 * Called when the activity is started which may end up creating some timers
090 * for dependent actions
091 */
092 public void onStarted(ActivityState activityState) {
093 /** TODO */
094 }
095
096 /**
097 * Called when the activity is completed which may end up creating some timers
098 * for dependent actions
099 */
100 public void onCompleted(ActivityState activityState) {
101 /** TODO */
102 }
103 }