Search in sources :

Example 1 with ModuleConfig

use of io.vertigo.app.config.ModuleConfig in project vertigo by KleeGroup.

the class ComponentLoader method registerAllComponentsAndAspects.

/**
 * Add all the components defined in the moduleConfigs into the componentSpace.
 * @param paramManagerOpt optional paramManager
 * @param moduleConfigs the config of the module to add.
 */
public void registerAllComponentsAndAspects(final Optional<ParamManager> paramManagerOpt, final List<ModuleConfig> moduleConfigs) {
    Assertion.checkNotNull(moduleConfigs);
    // -----
    for (final ModuleConfig moduleConfig : moduleConfigs) {
        registerComponents(paramManagerOpt, moduleConfig.getName(), moduleConfig.getComponentConfigs());
        registerAspects(moduleConfig.getAspectConfigs());
        registerProxyMethods(moduleConfig.getProxyMethodConfigs());
    }
}
Also used : ModuleConfig(io.vertigo.app.config.ModuleConfig)

Example 2 with ModuleConfig

use of io.vertigo.app.config.ModuleConfig in project vertigo by KleeGroup.

the class XMLModulesHandler method startElement.

@Override
public void startElement(final String namespaceURI, final String localName, final String qName, final Attributes attrs) {
    switch(TagName.valueOf(qName)) {
        case app:
            final String appName = attrs.getValue("name");
            final String nodeId = attrs.getValue("nodeId");
            final String endPoint = attrs.getValue("endPoint");
            appConfigBuilder.withNodeConfig(NodeConfig.builder().withAppName(appName).withNodeId(nodeId).withEndPoint(endPoint).build());
            break;
        case boot:
            current = TagName.boot;
            final String locales = attrs.getValue("locales");
            final String defaultZoneId = attrs.getValue("defaultZoneId");
            if (defaultZoneId == null) {
                bootConfigBuilder = appConfigBuilder.beginBoot().withLocales(locales);
            } else {
                bootConfigBuilder = appConfigBuilder.beginBoot().withLocalesAndDefaultZoneId(locales, defaultZoneId);
            }
            break;
        case module:
            current = TagName.module;
            final String moduleName = attrs.getValue("name");
            moduleConfigBuilder = ModuleConfig.builder(moduleName);
            break;
        case component:
            current = TagName.component;
            final String componentApi = attrs.getValue("api");
            final Class<? extends Component> componentImplClass = ClassUtil.classForName(attrs.getValue("class"), Component.class);
            componentConfigBuilder = ComponentConfig.builder().withImpl(componentImplClass);
            if (componentApi != null) {
                final Class<?> componentApiClass = resolveInterface(componentApi, componentImplClass);
                componentConfigBuilder.withApi((Class<? extends Component>) componentApiClass);
            }
            break;
        case initializer:
            final String initClass = attrs.getValue("class");
            if (initClass != null) {
                final Class componentInitialierClass = ClassUtil.classForName(initClass);
                appConfigBuilder.addInitializer(componentInitialierClass);
            }
            break;
        case plugin:
            current = TagName.plugin;
            final Class<? extends Plugin> pluginImplClass = ClassUtil.classForName(attrs.getValue("class"), Plugin.class);
            pluginConfigBuilder = PluginConfig.builder(pluginImplClass);
            break;
        case proxy:
            final Class<? extends Component> proxyApiClass = ClassUtil.classForName(attrs.getValue("api"), Component.class);
            moduleConfigBuilder.addProxy(proxyApiClass);
            break;
        case provider:
            current = TagName.provider;
            final String definitionProviderClassName = attrs.getValue("class");
            final Class<? extends DefinitionProvider> definitionProviderClass = ClassUtil.classForName(definitionProviderClassName, DefinitionProvider.class);
            definitionProviderConfigBuilder = DefinitionProviderConfig.builder(definitionProviderClass);
            break;
        case resource:
            final String resourceType = attrs.getValue("type");
            final String resourcePath = attrs.getValue("path");
            definitionProviderConfigBuilder.addDefinitionResource(resourceType, evalParamValue(resourcePath));
            break;
        case param:
            final String paramName = attrs.getValue("name");
            final String paramValue = evalParamValue(attrs.getValue("value"));
            final Param param = Param.of(paramName, paramValue);
            if (current == TagName.plugin) {
                pluginConfigBuilder.addParam(param);
            } else if (current == TagName.component) {
                componentConfigBuilder.addParam(param);
            } else if (current == TagName.provider) {
                definitionProviderConfigBuilder.addParam(param);
            }
            break;
        case aspect:
            final String aspectImplClassStr = attrs.getValue("class");
            final Class<? extends Aspect> aspectImplClass = ClassUtil.classForName(aspectImplClassStr, Aspect.class);
            moduleConfigBuilder.addAspect(aspectImplClass);
            break;
        case proxyMethod:
            final String proxyMethodImplClassStr = attrs.getValue("class");
            final Class<? extends ProxyMethod> proxyMethodClass = ClassUtil.classForName(proxyMethodImplClassStr, ProxyMethod.class);
            moduleConfigBuilder.addProxyMethod(proxyMethodClass);
            break;
        case feature:
            final String featureClassStr = attrs.getValue("class");
            final ModuleConfig moduleConfigByFeatures = ClassUtil.newInstance(featureClassStr, Features.class).build();
            appConfigBuilder.addModule(moduleConfigByFeatures);
            break;
        case definitions:
        case config:
        case init:
        // non géré
        default:
    }
}
Also used : Param(io.vertigo.core.param.Param) ModuleConfig(io.vertigo.app.config.ModuleConfig) Features(io.vertigo.app.config.Features)

Aggregations

ModuleConfig (io.vertigo.app.config.ModuleConfig)2 Features (io.vertigo.app.config.Features)1 Param (io.vertigo.core.param.Param)1