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);
}
}
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;
}
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);
}
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;
}
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;
}
Aggregations