01: /*
02: * Copyright 2006-2007 The Scriptella Project Team.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package scriptella.execution;
17:
18: import scriptella.core.Session;
19: import scriptella.interactive.ProgressCallback;
20: import scriptella.spi.DriverContext;
21: import scriptella.spi.ParametersCallback;
22: import scriptella.util.IOUtils;
23:
24: import java.net.MalformedURLException;
25: import java.net.URL;
26:
27: /**
28: * Execution context for script.
29: * <p/>
30: * This class contains global data for executed elements.
31: * <br><b>Note:</b> Execution context is not intended to change its state during sql elements
32: * execution as opposed to {@link scriptella.core.DynamicContext}.
33: *
34: * @author Fyodor Kupolov
35: * @version 1.0
36: */
37: public class EtlContext implements ParametersCallback, DriverContext {
38: private ProgressCallback progressCallback;
39: private ParametersCallback properties;
40: private URL baseURL;
41: private ExecutionStatisticsBuilder statisticsBuilder = new ExecutionStatisticsBuilder();
42: Session session; //Connections related stuff is here
43:
44: public Object getParameter(final String name) {
45: return properties.getParameter(name);
46: }
47:
48: public ProgressCallback getProgressCallback() {
49: return progressCallback;
50: }
51:
52: void setProgressCallback(final ProgressCallback progressCallback) {
53: this .progressCallback = progressCallback;
54: }
55:
56: /**
57: * Sets configuration properties for this context.
58: * @param properties configuration properties.
59: */
60: void setProperties(ParametersCallback properties) {
61: this .properties = properties;
62: }
63:
64: public URL getScriptFileURL() {
65: return baseURL;
66: }
67:
68: void setBaseURL(final URL baseURL) {
69: this .baseURL = baseURL;
70: }
71:
72: public URL resolve(final String uri) throws MalformedURLException {
73: return IOUtils.resolve(baseURL, uri);
74: }
75:
76: public ExecutionStatisticsBuilder getStatisticsBuilder() {
77: return statisticsBuilder;
78: }
79:
80: public Session getSession() {
81: return session;
82: }
83:
84: }
|