Search in sources :

Example 6 with AutoCloseableApp

use of io.vertigo.app.AutoCloseableApp in project vertigo by KleeGroup.

the class AppConfigTest method HomeTest.

@Test
public void HomeTest() {
    final String locales = "fr_FR";
    final AppConfig appConfig = AppConfig.builder().beginBoot().withLocales(locales).addPlugin(ClassPathResourceResolverPlugin.class).addPlugin(XmlParamPlugin.class, Param.of("url", "io/vertigo/app/config/xml2/basic-app-config.xml")).endBoot().addModule(ModuleConfig.builder("bio").addComponent(BioManager.class, BioManagerImpl.class).addComponent(MathManager.class, MathManagerImpl.class, Param.of("start", "${math.test.start}")).addPlugin(MathPlugin.class, Param.of("factor", "20")).build()).build();
    try (AutoCloseableApp app = new AutoCloseableApp(appConfig)) {
        assertEquals(app, app);
        assertTrue(app.getComponentSpace().contains("bioManager"));
        final BioManager bioManager = app.getComponentSpace().resolve(BioManager.class);
        final int res = bioManager.add(1, 2, 3);
        assertEquals(366, res);
        assertTrue(bioManager.isActive());
    }
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) AppConfig(io.vertigo.app.config.AppConfig) BioManager(io.vertigo.core.spaces.component.data.BioManager) XmlParamPlugin(io.vertigo.core.plugins.param.xml.XmlParamPlugin) MathPlugin(io.vertigo.core.spaces.component.data.MathPlugin) BioManagerImpl(io.vertigo.core.spaces.component.data.BioManagerImpl) Test(org.junit.jupiter.api.Test)

Example 7 with AutoCloseableApp

use of io.vertigo.app.AutoCloseableApp in project vertigo by KleeGroup.

the class AppServletStarter method contextInitialized.

/**
 * Initialize and start Vertigo Home.
 * @param servletContext ServletContext
 */
public void contextInitialized(final ServletContext servletContext) {
    final long start = System.currentTimeMillis();
    try {
        // Initialisation du web context de l'application (porteur des singletons applicatifs)
        ServletResourceResolverPlugin.setServletContext(servletContext);
        // Création de l'état de l'application
        // Lecture des paramètres de configuration
        final Map<String, Param> webAppConf = createWebParams(servletContext);
        WebAppContextParamPlugin.setParams(webAppConf);
        // -----
        final Properties bootConf = createBootProperties(servletContext);
        Assertion.checkArgument(bootConf.containsKey("boot.applicationConfiguration"), "Param \"boot.applicationConfiguration\" is mandatory, check your .properties or web.xml.");
        final XMLAppConfigBuilder appConfigBuilder = new XMLAppConfigBuilder();
        appConfigBuilder.beginBoot();
        // si présent on récupère le paramétrage du fichier externe de paramétrage log4j
        if (bootConf.containsKey(LOG4J_CONFIGURATION_PARAM_NAME)) {
            final String logFileName = bootConf.getProperty(LOG4J_CONFIGURATION_PARAM_NAME);
            bootConf.remove(LOG4J_CONFIGURATION_PARAM_NAME);
            // -----
            appConfigBuilder.withLogConfig(new LogConfig(logFileName));
        }
        final String xmlModulesFileNames = bootConf.getProperty("boot.applicationConfiguration");
        final String[] xmlFileNamesSplit = xmlModulesFileNames.split(";");
        bootConf.remove("boot.applicationConfiguration");
        // -----
        appConfigBuilder.withModules(getClass(), bootConf, xmlFileNamesSplit);
        // Initialisation de l'état de l'application
        app = new AutoCloseableApp(appConfigBuilder.build());
        appServletListener.onServletStart(getClass().getName());
    } catch (final Exception e) {
        LOG.error(e.getMessage(), e);
        throw WrappedException.wrap(e, "Problème d'initialisation de l'application");
    } finally {
        if (LOG.isInfoEnabled()) {
            LOG.info("Temps d'initialisation du listener " + (System.currentTimeMillis() - start));
        }
    }
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) Param(io.vertigo.core.param.Param) Properties(java.util.Properties) IOException(java.io.IOException) WrappedException(io.vertigo.lang.WrappedException) XMLAppConfigBuilder(io.vertigo.app.config.xml.XMLAppConfigBuilder) LogConfig(io.vertigo.app.config.LogConfig)

Example 8 with AutoCloseableApp

use of io.vertigo.app.AutoCloseableApp in project vertigo by KleeGroup.

the class WebServiceHandler method main.

// Will serve all static file are under "/public" in classpath if the route isn't consumed by others routes.
// When using Maven, the "/public" folder is assumed to be in "/main/resources"
// Spark.externalStaticFileLocation("D:/@GitHub/vertigo/vertigo-vega-impl/src/test/resources/");
// Spark.before(new IE8CompatibilityFix("8"));
// Spark.before(new CorsAllower());
public static void main(final String[] args) {
    final AutoCloseableApp app = new AutoCloseableApp(MyAppConfig.config());
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            app.close();
        }
    });
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp)

Example 9 with AutoCloseableApp

use of io.vertigo.app.AutoCloseableApp in project vertigo by KleeGroup.

the class NameSpace2JavaTest method testGenerateMasterDataSql.

/**
 * Lancement du test.
 */
@Test
public void testGenerateMasterDataSql() {
    NameSpace2Java.main(new String[] { "data/testMasterData.properties" });
    try (AutoCloseableApp app = new AutoCloseableApp(SqlTestConfigurator.config())) {
        execSqlScript("target/databasegenMasterdata/crebas.sql", app);
        execSqlScript("target/databasegenMasterdata/init_masterdata.sql", app);
    }
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) Test(org.junit.Test)

Example 10 with AutoCloseableApp

use of io.vertigo.app.AutoCloseableApp in project vertigo by KleeGroup.

the class AuthenticationManagerTest method setUp.

@Before
public void setUp() {
    app = new AutoCloseableApp(MyAppConfig.config(redis));
    DIInjector.injectMembers(this, app.getComponentSpace());
    securityManager.startCurrentUserSession(securityManager.createUserSession());
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) Before(org.junit.Before)

Aggregations

AutoCloseableApp (io.vertigo.app.AutoCloseableApp)18 AppConfig (io.vertigo.app.config.AppConfig)11 Test (org.junit.jupiter.api.Test)8 LogConfig (io.vertigo.app.config.LogConfig)4 FunctionManager (io.vertigo.core.spaces.component.data.FunctionManager)4 Test (org.junit.Test)4 BioManager (io.vertigo.core.spaces.component.data.BioManager)3 MathPlugin (io.vertigo.core.spaces.component.data.MathPlugin)3 Domain (io.vertigo.dynamo.domain.metamodel.Domain)3 Before (org.junit.Before)3 BioManagerImpl (io.vertigo.core.spaces.component.data.BioManagerImpl)2 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)2 DynamoDefinitionProvider (io.vertigo.dynamo.plugins.environment.DynamoDefinitionProvider)2 XMLAppConfigBuilder (io.vertigo.app.config.xml.XMLAppConfigBuilder)1 RedisConnector (io.vertigo.commons.impl.connectors.redis.RedisConnector)1 Param (io.vertigo.core.param.Param)1 XmlParamPlugin (io.vertigo.core.plugins.param.xml.XmlParamPlugin)1 DummyPlugin (io.vertigo.core.spaces.component.data.DummyPlugin)1 StartedManager (io.vertigo.core.spaces.component.data.StartedManager)1 StartedManagerInitializer (io.vertigo.core.spaces.component.data.StartedManagerInitializer)1