![JAR search and dependency download from the Maven repository](/logo.png)
io.sarl.sre.boot.internal.cli.JanusApplicationModule.sarl Maven / Gradle / Ivy
The newest version!
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2021 the original authors 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 io.sarl.sre.boot.internal.cli
import com.google.inject.AbstractModule
import com.google.inject.Module
import io.bootique.BQModule
import io.bootique.BQModuleProvider
import io.sarl.maven.bootiqueapp.utils.SystemProperties
import io.sarl.sre.boot.commands.RunSingleAgentCommand
import io.sarl.sre.boot.configs.SreConfig
import javax.inject.Provider
import javax.inject.Singleton
import org.arakhne.afc.bootique.applicationdata2.annotations.DefaultApplicationName
import org.arakhne.afc.bootique.synopsishelp.annotations.ApplicationArgumentSynopsis
import org.arakhne.afc.bootique.synopsishelp.annotations.ApplicationDetailedDescription
import static extension io.bootique.BQCoreModule.*
import java.text.MessageFormat
import io.sarl.lang.SARLVersion
/**
* Module for configuring the janus application information.
*
* @author Stéphane Galland
* @version io.janusproject.kernel 3.0.12.0 20210527-171007
* @mavengroupid io.janusproject
* @mavenartifactid io.janusproject.kernel
* @since 3.0.11.0
*/
class JanusApplicationModule extends AbstractModule {
protected override configure {
// Name of the application.
typeof(String).bind.annotatedWith(typeof(DefaultApplicationName)).toInstance(
SystemProperties::getValue(SreConfig::PREFIX + ".programName", SreConfig::DEFAULT_PROGRAM_NAME))
// Short description of the application.
binder.extend.applicationDescription = Messages::JanusApplicationModule_0
// Long description of the application.
typeof(String).bind.annotatedWith(typeof(ApplicationDetailedDescription)).toProvider(typeof(LongDescriptionProvider)).in(typeof(Singleton))
// Synopsis of the application's arguments.
typeof(String).bind.annotatedWith(typeof(ApplicationArgumentSynopsis)).toInstance(Messages.JanusApplicationModule_1)
// Default command
binder.extend.defaultCommand = typeof(RunSingleAgentCommand)
}
/** Provider of the long description of the application.
*
* @author Stéphane Galland
* @version io.janusproject.kernel 3.0.12.0 20210527-171007
* @mavengroupid io.janusproject
* @mavenartifactid io.janusproject.kernel
* @since 3.0.11.0
*/
private static class LongDescriptionProvider implements Provider {
override get : String {
val implementationJavaVersion = SARLVersion::MINIMAL_JDK_VERSION_FOR_SARL_COMPILATION_ENVIRONMENT
return MessageFormat::format(Messages.JanusApplicationModule_2, implementationJavaVersion)
}
}
}
/** Provider of the module for the janus application information.
*
* @author Stéphane Galland
* @version io.janusproject.kernel 3.0.12.0 20210527-171007
* @mavengroupid io.janusproject
* @mavenartifactid io.janusproject.kernel
* @since 3.0.11.0
*/
class JanusApplicationModuleProvider implements BQModuleProvider {
override module : Module {
return new JanusApplicationModule
}
override moduleBuilder : BQModule.Builder {
return BQModule::builder(module).overrides(overrides).providerName(name).configs(configs).description(
Messages::JanusApplicationModuleProvider_0)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy