Package org.strecks.builder

Source Code of org.strecks.builder.Bootstrapper

/*
* Copyright 2005-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package org.strecks.builder;

import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.strecks.constants.DefaultImplementations;
import org.strecks.util.ReflectHelper;

/**
* The job of the bootstrapper is simply to load the Strecks properties file and instantiate the <code>Builder</code>
* to handle any remaining configuration tasks
* @see org.strecks.builder.Builder
* @author Phil Zoio
*/
public class Bootstrapper
{

  private static Log log = LogFactory.getLog(Bootstrapper.class);

  private Builder builder;

  public void bootStrap()
  {
    Properties properties = new Properties();

    try
    {
      properties = ConfigUtils.loadProperties("/strecks.properties");
    }
    catch (Exception e)
    {
      log.info("Configuration file strecks.properties not loaded. Using default builder");
    }

    String builder = properties.getProperty("builder.impl");
    if (builder == null)
    {
      builder = DefaultImplementations.BUILDER;
    }

    this.builder = ReflectHelper.createInstance(builder, Builder.class);
  }

  public Builder getBuilder()
  {
    return builder;
  }

}
TOP

Related Classes of org.strecks.builder.Bootstrapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.