/gentoo-console-bootstrap/src/main/java/com/dowdandassociates/gentoo/console/bootstrap/Main.java
Java | 103 lines | 53 code | 18 blank | 32 comment | 3 complexity | 7e60c9aa34f4068ee9ddb7f091dacfb4 MD5 | raw file
- /*
- *
- * Main.java
- *
- *-----------------------------------------------------------------------------
- * Copyright 2013 Dowd and Associates
- *
- * 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 com.dowdandassociates.gentoo.console.bootstrap;
- import java.util.Properties;
- import com.google.inject.Guice;
- import com.google.inject.Injector;
- import com.netflix.blitz4j.LoggingConfiguration;
- import com.netflix.config.DynamicPropertyFactory;
- import com.netflix.config.DynamicStringProperty;
- import com.netflix.governator.guice.LifecycleInjector;
- import com.netflix.governator.lifecycle.LifecycleManager;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import com.dowdandassociates.gentoo.bootstrap.HvmBootstrapModule;
- import com.dowdandassociates.gentoo.bootstrap.Hvm1BootstrapModule;
- import com.dowdandassociates.gentoo.bootstrap.ParavirtualBootstrapModule;
- import com.dowdandassociates.gentoo.bootstrap.Bootstrapper;
- public class Main
- {
- private static Logger log = LoggerFactory.getLogger(Main.class);
- public static void main(String[] args)
- {
- /*
- Properties props = new Properties();
- props.setProperty("log4j.rootCategory", "DEBUG,stdout");
- props.setProperty("log4j.appender.stdout", "org.apache.log4j.ConsoleAppender");
- props.setProperty("log4j.appender.stdout.layout", "com.netflix.logging.log4jAdapter.NFPatternLayout");
- props.setProperty("log4j.appender.stdout.layout.ConversionPattern", "%d %-5p %C:%L [%t] [%M] %m%n");
- props.setProperty("log4j.logger.asyncAppenders", "DEBUG,stdout");
- LoggingConfiguration.getInstance().configure(props);
- */
- DynamicStringProperty virtualizationType = DynamicPropertyFactory.getInstance().getStringProperty("com.dowdandassociates.gentoo.bootstrap.Image.virtualizationType", "hvm");
- LoggingConfiguration.getInstance().configure();
- try
- {
- // Injector injector = Guice.createInjector(new Amd64MinimalBootstrapModule());
-
- // Injector injector = LifecycleInjector.builder().withBootstrapModule(new GentooBootstrapModule()).createInjector();
- Injector injector;
- if ("hvm".equals(virtualizationType.get()))
- {
- injector = LifecycleInjector.builder().withBootstrapModule(new HvmBootstrapModule()).createInjector();
- }
- else if ("hvm1".equals(virtualizationType.get()))
- {
- injector = LifecycleInjector.builder().withBootstrapModule(new Hvm1BootstrapModule()).createInjector();
- }
- else
- {
- injector = LifecycleInjector.builder().withBootstrapModule(new ParavirtualBootstrapModule()).createInjector();
- }
- LifecycleManager manager = injector.getInstance(LifecycleManager.class);
- manager.start();
- Bootstrapper bootstrapper = injector.getInstance(Bootstrapper.class);
- bootstrapper.execute();
- manager.close();
- }
- catch (Throwable t)
- {
- log.error(t.getMessage(), t);
- }
- finally
- {
- LoggingConfiguration.getInstance().stop();
- }
- }
- }