Search in sources :

Example 1 with Configuration

use of org.apache.ofbiz.base.container.ContainerConfig.Configuration in project ofbiz-framework by apache.

the class EntityDataLoadContainer method init.

@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
    this.name = name;
    // get the data-load properties passed by the user in the command line
    Map<String, String> loadDataProps = ofbizCommands.stream().filter(command -> command.getName().equals(StartupCommandUtil.StartupOption.LOAD_DATA.getName())).map(command -> command.getProperties()).findFirst().get();
    /* disable job scheduler, JMS listener and startup services
         * FIXME: This is not thread-safe. */
    ServiceDispatcher.enableJM(false);
    ServiceDispatcher.enableJMS(false);
    ServiceDispatcher.enableSvcs(false);
    Configuration configuration = ContainerConfig.getConfiguration(name, configFile);
    Property delegatorNameProp = configuration.getProperty("delegator-name");
    String overrideDelegator = loadDataProps.get(DELEGATOR_NAME);
    if ("all-tenants".equals(overrideDelegator)) {
        // load data for all tenants
        for (GenericValue tenant : getTenantList(delegatorNameProp)) {
            String tenantDelegator = delegatorNameProp.value + "#" + tenant.getString("tenantId");
            loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, tenantDelegator);
        }
    } else {
        // load data for a single delegator
        loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, overrideDelegator);
    }
}
Also used : EntityCondition(org.apache.ofbiz.entity.condition.EntityCondition) Arrays(java.util.Arrays) ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) EntityDataLoader(org.apache.ofbiz.entity.util.EntityDataLoader) URL(java.net.URL) EntityQuery(org.apache.ofbiz.entity.util.EntityQuery) UtilURL(org.apache.ofbiz.base.util.UtilURL) ContainerException(org.apache.ofbiz.base.container.ContainerException) UtilValidate(org.apache.ofbiz.base.util.UtilValidate) EntityExpr(org.apache.ofbiz.entity.condition.EntityExpr) DelegatorFactory(org.apache.ofbiz.entity.DelegatorFactory) NumberFormat(java.text.NumberFormat) TreeSet(java.util.TreeSet) StartupCommandUtil(org.apache.ofbiz.base.start.StartupCommandUtil) ArrayList(java.util.ArrayList) ContainerConfig(org.apache.ofbiz.base.container.ContainerConfig) EntityOperator(org.apache.ofbiz.entity.condition.EntityOperator) Locale(java.util.Locale) Map(java.util.Map) ServiceDispatcher(org.apache.ofbiz.service.ServiceDispatcher) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) Delegator(org.apache.ofbiz.entity.Delegator) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) EntityUtil(org.apache.ofbiz.entity.util.EntityUtil) DatabaseUtil(org.apache.ofbiz.entity.jdbc.DatabaseUtil) StartupCommand(org.apache.ofbiz.base.start.StartupCommand) GenericValue(org.apache.ofbiz.entity.GenericValue) GenericHelperInfo(org.apache.ofbiz.entity.datasource.GenericHelperInfo) Collection(java.util.Collection) StringUtil(org.apache.ofbiz.base.util.StringUtil) ModelEntity(org.apache.ofbiz.entity.model.ModelEntity) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) Debug(org.apache.ofbiz.base.util.Debug) GenericEntityException(org.apache.ofbiz.entity.GenericEntityException) Optional(java.util.Optional) Container(org.apache.ofbiz.base.container.Container) GenericValue(org.apache.ofbiz.entity.GenericValue) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property)

Example 2 with Configuration

use of org.apache.ofbiz.base.container.ContainerConfig.Configuration in project ofbiz-framework by apache.

the class CatalinaContainer method init.

@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
    this.name = name;
    ContainerConfig.Configuration configuration = ContainerConfig.getConfiguration(name, configFile);
    Property engineConfig = retrieveTomcatEngineConfig(configuration);
    // tomcat setup
    tomcat = prepareTomcatServer(configuration, engineConfig);
    Engine engine = prepareTomcatEngine(tomcat, engineConfig);
    Host host = prepareHost(tomcat, null);
    // add realm and valve for Tomcat SSO
    if (EntityUtilProperties.propertyValueEquals("security", "security.login.tomcat.sso", "true")) {
        boolean useEncryption = EntityUtilProperties.propertyValueEquals("security", "password.encrypt", "true");
        OFBizRealm ofBizRealm = new OFBizRealm();
        if (useEncryption) {
            ofBizRealm.setCredentialHandler(new HashedCredentialHandler());
        } else {
            ofBizRealm.setCredentialHandler(new SimpleCredentialHandler());
        }
        host.setRealm(ofBizRealm);
        ((StandardHost) host).addValve(new SingleSignOn());
    }
    // clustering, valves and connectors setup
    Property clusterProps = prepareTomcatClustering(host, engineConfig);
    prepareTomcatEngineValves(engineConfig).forEach(valve -> ((StandardEngine) engine).addValve(valve));
    prepareTomcatConnectors(configuration).forEach(connector -> tomcat.getService().addConnector(connector));
    loadWebapps(tomcat, configuration, clusterProps);
}
Also used : ContainerConfig(org.apache.ofbiz.base.container.ContainerConfig) StandardHost(org.apache.catalina.core.StandardHost) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) Host(org.apache.catalina.Host) StandardHost(org.apache.catalina.core.StandardHost) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine) SingleSignOn(org.apache.catalina.authenticator.SingleSignOn)

Aggregations

ContainerConfig (org.apache.ofbiz.base.container.ContainerConfig)2 Configuration (org.apache.ofbiz.base.container.ContainerConfig.Configuration)2 Property (org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property)2 File (java.io.File)1 URL (java.net.URL)1 NumberFormat (java.text.NumberFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Optional (java.util.Optional)1 TreeSet (java.util.TreeSet)1 Collectors (java.util.stream.Collectors)1 Engine (org.apache.catalina.Engine)1 Host (org.apache.catalina.Host)1 SingleSignOn (org.apache.catalina.authenticator.SingleSignOn)1 StandardEngine (org.apache.catalina.core.StandardEngine)1 StandardHost (org.apache.catalina.core.StandardHost)1