use of org.apache.cxf.transport.http_jetty.ThreadingParameters in project cxf by apache.
the class JettyHTTPServerEngineFactoryHolder method init.
public void init() {
try {
Element element = StaxUtils.read(new StringReader(parsedElement)).getDocumentElement();
JettyHTTPServerEngineFactoryConfigType config = getJaxbObject(element, JettyHTTPServerEngineFactoryConfigType.class);
Bus defaultBus = BusFactory.getDefaultBus();
factory = new JettyHTTPServerEngineFactory(defaultBus);
Map<String, ThreadingParameters> threadingParametersMap = new TreeMap<>();
if (config.getIdentifiedThreadingParameters() != null) {
for (ThreadingParametersIdentifiedType threads : config.getIdentifiedThreadingParameters()) {
ThreadingParameters rThreads = new ThreadingParameters();
String id = threads.getId();
if (threads.getThreadingParameters().getMaxThreads() != null) {
rThreads.setMaxThreads(threads.getThreadingParameters().getMaxThreads());
}
if (threads.getThreadingParameters().getMinThreads() != null) {
rThreads.setMinThreads(threads.getThreadingParameters().getMinThreads());
}
rThreads.setThreadNamePrefix(threads.getThreadingParameters().getThreadNamePrefix());
threadingParametersMap.put(id, rThreads);
}
factory.setThreadingParametersMap(threadingParametersMap);
}
// SSL
Map<String, TLSServerParameters> sslMap = new TreeMap<>();
if (config.getIdentifiedTLSServerParameters() != null) {
for (TLSServerParametersIdentifiedType t : config.getIdentifiedTLSServerParameters()) {
try {
TLSServerParameters parameter = new TLSServerParametersConfig(t.getTlsServerParameters());
sslMap.put(t.getId(), parameter);
} catch (Exception e) {
throw new RuntimeException("Could not configure TLS for id " + t.getId(), e);
}
}
factory.setTlsServerParametersMap(sslMap);
}
// Engines
List<JettyHTTPServerEngine> engineList = new ArrayList<>();
for (JettyHTTPServerEngineConfigType engine : config.getEngine()) {
JettyHTTPServerEngine eng = new JettyHTTPServerEngine(factory.getMBeanContainer(), engine.getHost(), engine.getPort());
if (engine.getConnector() != null && connectorMap != null) {
// we need to setup the Connector from the connectorMap
Connector connector = connectorMap.get(engine.getPort().toString());
if (connector != null) {
eng.setConnector(connector);
} else {
throw new RuntimeException("Could not find the connector instance for engine with port" + engine.getPort().toString());
}
}
if (engine.getHandlers() != null && handlersMap != null) {
List<Handler> handlers = handlersMap.get(engine.getPort().toString());
if (handlers != null) {
eng.setHandlers(handlers);
} else {
throw new RuntimeException("Could not find the handlers instance for engine with port" + engine.getPort().toString());
}
}
if (engine.isContinuationsEnabled() != null) {
eng.setContinuationsEnabled(engine.isContinuationsEnabled());
}
if (engine.isSendServerVersion() != null) {
eng.setSendServerVersion(engine.isSendServerVersion());
}
if (engine.getHost() != null && !StringUtils.isEmpty(engine.getHost())) {
eng.setHost(engine.getHost());
}
if (engine.getMaxIdleTime() != null) {
eng.setMaxIdleTime(engine.getMaxIdleTime());
}
if (engine.getPort() != null) {
eng.setPort(engine.getPort());
}
if (engine.isReuseAddress() != null) {
eng.setReuseAddress(engine.isReuseAddress());
}
if (engine.isSessionSupport() != null) {
eng.setSessionSupport(engine.isSessionSupport());
}
if (engine.getSessionTimeout() != null) {
eng.setSessionTimeout(engine.getSessionTimeout().intValue());
}
if (engine.getThreadingParameters() != null) {
ThreadingParametersType threads = engine.getThreadingParameters();
ThreadingParameters rThreads = new ThreadingParameters();
if (threads.getMaxThreads() != null) {
rThreads.setMaxThreads(threads.getMaxThreads());
}
if (threads.getMinThreads() != null) {
rThreads.setMinThreads(threads.getMinThreads());
}
eng.setThreadingParameters(rThreads);
}
// eng.setServer(engine.getTlsServerParameters());
if (engine.getTlsServerParameters() != null && (engine.getTlsServerParameters().getKeyManagers() != null || engine.getTlsServerParameters().getTrustManagers() != null)) {
try {
TLSServerParameters parameter = new TLSServerParametersConfig(engine.getTlsServerParameters());
eng.setTlsServerParameters(parameter);
} catch (Exception e) {
throw new RuntimeException("Could not configure TLS for engine on " + eng.getHost() + ":" + eng.getPort(), e);
}
}
eng.finalizeConfig();
engineList.add(eng);
}
factory.setEnginesList(engineList);
// Unravel this completely.
factory.initComplete();
} catch (Exception e) {
throw new RuntimeException("Could not process configuration.", e);
}
}
use of org.apache.cxf.transport.http_jetty.ThreadingParameters in project cxf by apache.
the class HTTPJettyTransportActivator method createThreadingParameters.
private ThreadingParameters createThreadingParameters(Dictionary<String, ?> d) {
Enumeration<String> keys = d.keys();
ThreadingParameters p = null;
while (keys.hasMoreElements()) {
String k = keys.nextElement();
if (k.startsWith("threadingParameters.")) {
if (p == null) {
p = new ThreadingParameters();
}
String v = (String) d.get(k);
k = k.substring("threadingParameters.".length());
if ("minThreads".equals(k)) {
p.setMinThreads(Integer.parseInt(v));
} else if ("maxThreads".equals(k)) {
p.setMaxThreads(Integer.parseInt(v));
} else if ("threadNamePrefix".equals(k)) {
p.setThreadNamePrefix(k);
}
}
}
return p;
}
use of org.apache.cxf.transport.http_jetty.ThreadingParameters in project cxf by apache.
the class HTTPJettyTransportActivator method configure.
private void configure(JettyHTTPServerEngine e, Dictionary<String, ?> properties) {
ThreadingParameters threading = createThreadingParameters(properties);
if (threading != null) {
e.setThreadingParameters(threading);
}
Enumeration<String> keys = properties.keys();
while (keys.hasMoreElements()) {
String k = keys.nextElement();
if ("sessionSupport".equals(k)) {
e.setSessionSupport(Boolean.parseBoolean((String) properties.get(k)));
} else if ("continuationsEnabled".equals(k)) {
e.setContinuationsEnabled(Boolean.parseBoolean((String) properties.get(k)));
} else if ("sendServerVersion".equals(k)) {
e.setSendServerVersion(Boolean.parseBoolean((String) properties.get(k)));
} else if ("reuseAddress".equals(k)) {
e.setReuseAddress(Boolean.parseBoolean((String) properties.get(k)));
} else if ("maxIdleTime".equals(k)) {
e.setMaxIdleTime(Integer.parseInt((String) properties.get(k)));
} else if ("sessionTimeout".equals(k)) {
e.setSessionTimeout(Integer.parseInt((String) properties.get(k)));
}
}
}
use of org.apache.cxf.transport.http_jetty.ThreadingParameters in project cxf by apache.
the class JettySpringTypesFactory method toThreadingParameters.
private static Map<String, ThreadingParameters> toThreadingParameters(List<ThreadingParametersIdentifiedType> list) {
Map<String, ThreadingParameters> map = new TreeMap<>();
for (ThreadingParametersIdentifiedType t : list) {
ThreadingParameters parameter = toThreadingParameters(t.getThreadingParameters());
map.put(t.getId(), parameter);
}
return map;
}
use of org.apache.cxf.transport.http_jetty.ThreadingParameters in project cxf by apache.
the class JettySpringTypesFactory method toThreadingParameters.
private static ThreadingParameters toThreadingParameters(ThreadingParametersType paramtype) {
ThreadingParameters params = new ThreadingParameters();
params.setMaxThreads(paramtype.getMaxThreads());
params.setMinThreads(paramtype.getMinThreads());
params.setThreadNamePrefix(paramtype.getThreadNamePrefix());
return params;
}
Aggregations