Search in sources :

Example 1 with Configuration

use of org.openksavi.sponge.config.Configuration in project sponge by softelnet.

the class DefaultConfigurationManager method setupXmlProperties.

private void setupXmlProperties() {
    for (Configuration configuration : rootConfig.getChildConfigurationsOf(ConfigurationConstants.TAG_PROPERTIES)) {
        String name = configuration.getAttribute(ConfigurationConstants.PROP_ATTRIBUTE_NAME, null);
        Object value = configuration.getValue();
        String systemProperty = System.getProperty(name);
        PropertyEntry entry = properties.get(name);
        if (systemProperty != null) {
            value = systemProperty;
        } else if (entry == null) {
            properties.put(name, new GenericPropertyEntry(value, isPropertyVariable(configuration), isPropertySystem(configuration)));
        } else {
            value = entry.getValue();
        }
        rootConfig.setVariable(name, value);
    }
}
Also used : XMLConfiguration(org.apache.commons.configuration2.XMLConfiguration) CommonsConfiguration(org.openksavi.sponge.core.config.CommonsConfiguration) Configuration(org.openksavi.sponge.config.Configuration) CombinedConfiguration(org.apache.commons.configuration2.CombinedConfiguration) PropertyEntry(org.openksavi.sponge.config.PropertyEntry)

Example 2 with Configuration

use of org.openksavi.sponge.config.Configuration in project sponge by softelnet.

the class BasePy4JPlugin method onConfigure.

@Override
public void onConfigure(Configuration configuration) {
    facadeInterfaceName = configuration.getString(TAG_FACADE_INTERFACE, facadeInterfaceName);
    javaPort = configuration.getInteger(TAG_JAVA_PORT, javaPort);
    pythonPort = configuration.getInteger(TAG_PYTHON_PORT, pythonPort);
    if (configuration.hasChildConfiguration(TAG_SECURITY)) {
        Configuration securityConfiguration = configuration.getChildConfiguration(TAG_SECURITY);
        SecurityConfiguration newSecurity = new SecurityConfiguration();
        newSecurity.setPassword(SpongeUtils.getRequiredConfigurationString(securityConfiguration, TAG_SECURITY_PASSWORD));
        newSecurity.setKeystore(SpongeUtils.getRequiredConfigurationString(securityConfiguration, TAG_SECURITY_KEYSTORE));
        newSecurity.setAlgorithm(securityConfiguration.getString(TAG_SECURITY_ALGORITHM, DEFAULT_SECURITY_ALGORITHM));
        security = newSecurity;
    }
}
Also used : Configuration(org.openksavi.sponge.config.Configuration)

Example 3 with Configuration

use of org.openksavi.sponge.config.Configuration in project sponge by softelnet.

the class DefaultKnowledgeBaseManager method createScriptKnowledgeBaseFromConfiguration.

protected DefaultScriptKnowledgeBase createScriptKnowledgeBaseFromConfiguration(String name, String typeCode, Configuration[] fileNodes) {
    List<KnowledgeBaseScript> scripts = new ArrayList<>();
    for (Configuration fileNode : fileNodes) {
        String fileName = fileNode.getValue();
        if (StringUtils.isEmpty(fileName)) {
            throw new SpongeException("Knowledge base file name must not be empty");
        }
        scripts.add(new FileKnowledgeBaseScript(fileName, fileNode.getAttribute(CFG_KB_FILE_ATTR_CHARSET, null), fileNode.getBooleanAttribute(CFG_KB_FILE_ATTR_REQUIRED, KnowledgeBaseScript.DEFAULT_REQUIRED)));
    }
    DefaultScriptKnowledgeBase knowledgeBase;
    if (scripts.isEmpty()) {
        if (StringUtils.isEmpty(typeCode)) {
            throw new SpongeException("Knowledge base type for script knowledge bases with no files must not be empty");
        }
        knowledgeBase = new DefaultScriptKnowledgeBase(name, getKnowledgeBaseInterpreterFactory(typeCode).getSupportedType());
    } else {
        KnowledgeBaseType inferredKnowledgeBaseType = inferKnowledgeBaseType(name, scripts);
        if (!StringUtils.isEmpty(typeCode) && !inferredKnowledgeBaseType.getTypeCode().equals(typeCode)) {
            throw new SpongeException("The inferred knowledge base type '" + inferredKnowledgeBaseType.getTypeCode() + "' is different that the specified '" + typeCode + "'");
        }
        knowledgeBase = new DefaultScriptKnowledgeBase(name, inferredKnowledgeBaseType);
    }
    scripts.forEach(script -> knowledgeBase.addScript(script));
    return knowledgeBase;
}
Also used : KnowledgeBaseType(org.openksavi.sponge.kb.KnowledgeBaseType) Configuration(org.openksavi.sponge.config.Configuration) DefaultScriptKnowledgeBase(org.openksavi.sponge.core.kb.DefaultScriptKnowledgeBase) SpongeException(org.openksavi.sponge.SpongeException) ArrayList(java.util.ArrayList) FileKnowledgeBaseScript(org.openksavi.sponge.core.kb.FileKnowledgeBaseScript) FileKnowledgeBaseScript(org.openksavi.sponge.core.kb.FileKnowledgeBaseScript) KnowledgeBaseScript(org.openksavi.sponge.kb.KnowledgeBaseScript)

Aggregations

Configuration (org.openksavi.sponge.config.Configuration)3 ArrayList (java.util.ArrayList)1 CombinedConfiguration (org.apache.commons.configuration2.CombinedConfiguration)1 XMLConfiguration (org.apache.commons.configuration2.XMLConfiguration)1 SpongeException (org.openksavi.sponge.SpongeException)1 PropertyEntry (org.openksavi.sponge.config.PropertyEntry)1 CommonsConfiguration (org.openksavi.sponge.core.config.CommonsConfiguration)1 DefaultScriptKnowledgeBase (org.openksavi.sponge.core.kb.DefaultScriptKnowledgeBase)1 FileKnowledgeBaseScript (org.openksavi.sponge.core.kb.FileKnowledgeBaseScript)1 KnowledgeBaseScript (org.openksavi.sponge.kb.KnowledgeBaseScript)1 KnowledgeBaseType (org.openksavi.sponge.kb.KnowledgeBaseType)1