Search in sources :

Example 1 with Property

use of org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property 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 Property

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

the class CatalinaContainer method prepareTomcatClustering.

private Property prepareTomcatClustering(Host host, Property engineConfig) throws ContainerException {
    Property clusterProp = null;
    List<Property> clusterProps = engineConfig.getPropertiesWithValue("cluster");
    if (clusterProps.size() > 1) {
        throw new ContainerException("Only one cluster configuration allowed per engine");
    }
    if (UtilValidate.isNotEmpty(clusterProps)) {
        clusterProp = clusterProps.get(0);
        GroupChannel channel = new GroupChannel();
        channel.setChannelReceiver(prepareChannelReceiver(clusterProp));
        channel.setChannelSender(prepareChannelSender(clusterProp));
        channel.setMembershipService(prepareChannelMcastService(clusterProp));
        SimpleTcpCluster cluster = new SimpleTcpCluster();
        cluster.setClusterName(clusterProp.name);
        cluster.setManagerTemplate(prepareClusterManager(clusterProp));
        cluster.setChannel(channel);
        cluster.addValve(prepareClusterValve(clusterProp));
        host.setCluster(cluster);
        Debug.logInfo("Catalina Cluster [" + cluster.getClusterName() + "] configured for host - " + host.getName(), module);
    }
    return clusterProp;
}
Also used : ContainerException(org.apache.ofbiz.base.container.ContainerException) SimpleTcpCluster(org.apache.catalina.ha.tcp.SimpleTcpCluster) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property)

Example 3 with Property

use of org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property 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)

Example 4 with Property

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

the class CatalinaContainer method prepareConnector.

private Connector prepareConnector(Property connectorProp) {
    Connector connector = new Connector(ContainerConfig.getPropertyValue(connectorProp, "protocol", "HTTP/1.1"));
    connector.setPort(ContainerConfig.getPropertyValue(connectorProp, "port", 0) + Start.getInstance().getConfig().portOffset);
    connectorProp.properties.values().stream().filter(prop -> !"protocol".equals(prop.name) && !"port".equals(prop.name)).forEach(prop -> {
        if (IntrospectionUtils.setProperty(connector, prop.name, prop.value)) {
            if (prop.name.indexOf("Pass") != -1) {
                // this property may be a password, do not include its value in the logs
                Debug.logInfo("Tomcat " + connector + ": set " + prop.name, module);
            } else {
                Debug.logInfo("Tomcat " + connector + ": set " + prop.name + "=" + prop.value, module);
            }
        } else {
            Debug.logWarning("Tomcat " + connector + ": ignored parameter " + prop.name, module);
        }
    });
    return connector;
}
Also used : URL(java.net.URL) FilterMap(org.apache.tomcat.util.descriptor.web.FilterMap) NamingException(javax.naming.NamingException) SingleSignOn(org.apache.catalina.authenticator.SingleSignOn) ContainerConfig(org.apache.ofbiz.base.container.ContainerConfig) Future(java.util.concurrent.Future) Host(org.apache.catalina.Host) Document(org.w3c.dom.Document) Map(java.util.Map) FlexibleLocation(org.apache.ofbiz.base.location.FlexibleLocation) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) RequestDumperFilter(org.apache.catalina.filters.RequestDumperFilter) InitialContext(javax.naming.InitialContext) LifecycleException(org.apache.catalina.LifecycleException) WebappLoader(org.apache.catalina.loader.WebappLoader) NioReceiver(org.apache.catalina.tribes.transport.nio.NioReceiver) Set(java.util.Set) StandardServer(org.apache.catalina.core.StandardServer) Collectors(java.util.stream.Collectors) ReplicationTransmitter(org.apache.catalina.tribes.transport.ReplicationTransmitter) ReplicationValve(org.apache.catalina.ha.tcp.ReplicationValve) Start(org.apache.ofbiz.base.start.Start) ServerInfo(org.apache.catalina.util.ServerInfo) List(java.util.List) StandardRoot(org.apache.catalina.webresources.StandardRoot) ContextConfig(org.apache.catalina.startup.ContextConfig) SAXException(org.xml.sax.SAXException) StandardContext(org.apache.catalina.core.StandardContext) SimpleTcpCluster(org.apache.catalina.ha.tcp.SimpleTcpCluster) MultiPointSender(org.apache.catalina.tribes.transport.MultiPointSender) StandardEngine(org.apache.catalina.core.StandardEngine) ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) Valve(org.apache.catalina.Valve) Callable(java.util.concurrent.Callable) Connector(org.apache.catalina.connector.Connector) ContainerException(org.apache.ofbiz.base.container.ContainerException) UtilValidate(org.apache.ofbiz.base.util.UtilValidate) Engine(org.apache.catalina.Engine) StandardHost(org.apache.catalina.core.StandardHost) IntrospectionUtils(org.apache.tomcat.util.IntrospectionUtils) ArrayList(java.util.ArrayList) JarScanner(org.apache.tomcat.JarScanner) HashSet(java.util.HashSet) ClusterManager(org.apache.catalina.ha.ClusterManager) AccessLogValve(org.apache.catalina.valves.AccessLogValve) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) EntityUtilProperties(org.apache.ofbiz.entity.util.EntityUtilProperties) StartupCommand(org.apache.ofbiz.base.start.StartupCommand) FilterDef(org.apache.tomcat.util.descriptor.web.FilterDef) Globals(org.apache.catalina.Globals) IOException(java.io.IOException) Context(org.apache.catalina.Context) File(java.io.File) ExecutionPool(org.apache.ofbiz.base.concurrent.ExecutionPool) UtilXml(org.apache.ofbiz.base.util.UtilXml) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) Tomcat(org.apache.catalina.startup.Tomcat) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) McastService(org.apache.catalina.tribes.membership.McastService) Debug(org.apache.ofbiz.base.util.Debug) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) Collections(java.util.Collections) Container(org.apache.ofbiz.base.container.Container) Connector(org.apache.catalina.connector.Connector)

Example 5 with Property

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

the class CatalinaContainer method prepareTomcatServer.

private Tomcat prepareTomcatServer(ContainerConfig.Configuration cc, ContainerConfig.Configuration.Property engineConfig) throws ContainerException {
    System.setProperty(Globals.CATALINA_HOME_PROP, System.getProperty("ofbiz.home") + "/" + ContainerConfig.getPropertyValue(cc, "catalina-runtime-home", "runtime/catalina"));
    System.setProperty(Globals.CATALINA_BASE_PROP, System.getProperty(Globals.CATALINA_HOME_PROP));
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir(System.getProperty("ofbiz.home"));
    Property defaultHostProp = engineConfig.getProperty("default-host");
    if (defaultHostProp == null) {
        throw new ContainerException("default-host element of server property is required for catalina!");
    }
    tomcat.setHostname(defaultHostProp.value);
    if (ContainerConfig.getPropertyValue(cc, "use-naming", false)) {
        tomcat.enableNaming();
    }
    StandardServer server = (StandardServer) tomcat.getServer();
    try {
        server.setGlobalNamingContext(new InitialContext());
    } catch (NamingException e) {
        throw new ContainerException(e);
    }
    return tomcat;
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) ContainerException(org.apache.ofbiz.base.container.ContainerException) StandardServer(org.apache.catalina.core.StandardServer) NamingException(javax.naming.NamingException) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) InitialContext(javax.naming.InitialContext)

Aggregations

Property (org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property)5 ContainerException (org.apache.ofbiz.base.container.ContainerException)4 ContainerConfig (org.apache.ofbiz.base.container.ContainerConfig)3 Configuration (org.apache.ofbiz.base.container.ContainerConfig.Configuration)3 File (java.io.File)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 Engine (org.apache.catalina.Engine)2 Host (org.apache.catalina.Host)2 SingleSignOn (org.apache.catalina.authenticator.SingleSignOn)2 StandardEngine (org.apache.catalina.core.StandardEngine)2 StandardHost (org.apache.catalina.core.StandardHost)2 StandardServer (org.apache.catalina.core.StandardServer)2 SimpleTcpCluster (org.apache.catalina.ha.tcp.SimpleTcpCluster)2 Tomcat (org.apache.catalina.startup.Tomcat)2