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