01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.builder;
16:
17: import java.util.Properties;
18:
19: import org.apache.commons.logging.Log;
20: import org.apache.commons.logging.LogFactory;
21: import org.strecks.constants.DefaultImplementations;
22: import org.strecks.util.ReflectHelper;
23:
24: /**
25: * The job of the bootstrapper is simply to load the Strecks properties file and instantiate the <code>Builder</code>
26: * to handle any remaining configuration tasks
27: * @see org.strecks.builder.Builder
28: * @author Phil Zoio
29: */
30: public class Bootstrapper {
31:
32: private static Log log = LogFactory.getLog(Bootstrapper.class);
33:
34: private Builder builder;
35:
36: public void bootStrap() {
37: Properties properties = new Properties();
38:
39: try {
40: properties = ConfigUtils
41: .loadProperties("/strecks.properties");
42: } catch (Exception e) {
43: log
44: .info("Configuration file strecks.properties not loaded. Using default builder");
45: }
46:
47: String builder = properties.getProperty("builder.impl");
48: if (builder == null) {
49: builder = DefaultImplementations.BUILDER;
50: }
51:
52: this .builder = ReflectHelper.createInstance(builder,
53: Builder.class);
54: }
55:
56: public Builder getBuilder() {
57: return builder;
58: }
59:
60: }
|