001 /* 002 * Copyright (c) 2007-2015 Concurrent, Inc. All Rights Reserved. 003 * 004 * Project and contact information: http://www.cascading.org/ 005 * 006 * This file is part of the Cascading project. 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020 021 package cascading.flow; 022 023 import cascading.management.CascadingServices; 024 025 /** 026 * FlowSession implementations provide a call-back interface into the current flow management system, if any. 027 * <p/> 028 * A FlowSession is effectively unique to the current {@link Flow}, where a {@link FlowProcess} is unique 029 * to each underlying 'job'. 030 * 031 * @see FlowProcess 032 */ 033 public class FlowSession 034 { 035 /** Field NULL is a noop implementation of FlowSession. */ 036 public static final FlowSession NULL = new FlowSession(); 037 038 protected CascadingServices cascadingServices; 039 040 /** Field currentProcess */ 041 private FlowProcess currentProcess = FlowProcess.NULL; // is set via accessor 042 043 public FlowSession() 044 { 045 } 046 047 public FlowSession( CascadingServices cascadingServices ) 048 { 049 this.cascadingServices = cascadingServices; 050 } 051 052 /** 053 * Method setCurrentProcess sets the currentProcess of this FlowSession object. 054 * 055 * @param currentProcess the currentProcess of this FlowSession object. 056 */ 057 public void setCurrentProcess( FlowProcess currentProcess ) 058 { 059 this.currentProcess = currentProcess; 060 } 061 062 /** 063 * Method getCurrentProcess returns the currentProcess of this FlowSession object. 064 * 065 * @return the currentProcess (type FlowProcess) of this FlowSession object. 066 */ 067 public FlowProcess getCurrentProcess() 068 { 069 return currentProcess; 070 } 071 072 public CascadingServices getCascadingServices() 073 { 074 return cascadingServices; 075 } 076 077 /** 078 * Method getID returns the parent {@link Flow} ID value. 079 * 080 * @return of type String 081 */ 082 public String getID() 083 { 084 return currentProcess.getStringProperty( Flow.CASCADING_FLOW_ID ); 085 } 086 }