use of org.glassfish.grizzly.config.dom.FileCache in project Payara by payara.
the class CreateHttp method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the parameter names and the values the parameter
* values.
*
* @param context information
*/
public void execute(AdminCommandContext context) {
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
final ActionReport report = context.getActionReport();
// check for duplicates
Protocols protocols = config.getNetworkConfig().getProtocols();
Protocol protocol = null;
for (Protocol p : protocols.getProtocol()) {
if (protocolName.equals(p.getName())) {
protocol = p;
}
}
if (protocol == null) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_FAIL_PROTOCOL_NOT_FOUND), protocolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (protocol.getHttp() != null) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_FAIL_DUPLICATE), protocolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// Add to the <network-config>
try {
ConfigSupport.apply(new SingleConfigCode<Protocol>() {
public Object run(Protocol param) throws TransactionFailure {
Http http = param.createChild(Http.class);
final FileCache cache = http.createChild(FileCache.class);
cache.setEnabled("false");
http.setFileCache(cache);
http.setDefaultVirtualServer(defaultVirtualServer);
http.setDnsLookupEnabled(dnsLookupEnabled == null ? null : dnsLookupEnabled.toString());
http.setMaxConnections(maxConnections);
http.setRequestTimeoutSeconds(requestTimeoutSeconds);
http.setTimeoutSeconds(timeoutSeconds);
http.setXpoweredBy(xPoweredBy == null ? null : xPoweredBy.toString());
http.setServerHeader(serverHeader == null ? null : serverHeader.toString());
http.setXframeOptions(xFrameOptions == null ? null : xFrameOptions.toString());
http.setServerName(serverName);
// HTTP2 options
http.setHttp2Enabled(http2Enabled);
if (http2MaxConcurrentStreams != null) {
http.setHttp2MaxConcurrentStreams(http2MaxConcurrentStreams);
}
if (http2InitialWindowSizeInBytes != null) {
http.setHttp2InitialWindowSizeInBytes(http2InitialWindowSizeInBytes);
}
if (http2MaxFramePayloadSizeInBytes != null) {
http.setHttp2MaxFramePayloadSizeInBytes(http2MaxFramePayloadSizeInBytes);
}
if (http2MaxHeaderListSizeInBytes != null) {
http.setHttp2MaxHeaderListSizeInBytes(http2MaxHeaderListSizeInBytes);
}
if (http2StreamsHighWaterMark != null) {
http.setHttp2StreamsHighWaterMark(http2StreamsHighWaterMark.toString());
}
if (http2CleanPercentage != null) {
http.setHttp2CleanPercentage(http2CleanPercentage.toString());
}
if (http2CleanFrequencyCheck != null) {
http.setHttp2CleanFrequencyCheck(http2CleanFrequencyCheck);
}
if (http2DisableCipherCheck != null) {
http.setHttp2DisableCipherCheck(http2DisableCipherCheck);
}
if (http2PushEnabled != null) {
http.setHttp2PushEnabled(http2PushEnabled);
}
param.setHttp(http);
return http;
}
}, protocol);
} catch (TransactionFailure e) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_REDIRECT_FAIL), protocolName, e.getMessage() == null ? "No reason given." : e.getMessage()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.grizzly.config.dom.FileCache in project Payara by payara.
the class DynamicConfigListener method changed.
@Override
public synchronized UnprocessedChangeEvents changed(final PropertyChangeEvent[] events) {
return ConfigSupport.sortAndDispatch(events, new Changed() {
@Override
public <T extends ConfigBeanProxy> NotProcessed changed(TYPE type, Class<T> tClass, T t) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "NetworkConfig changed {0} {1} {2}", new Object[] { type, tClass, t });
}
if (tClass == NetworkListener.class && t instanceof NetworkListener) {
return processNetworkListener(type, (NetworkListener) t, events);
} else if (tClass == Http.class && t instanceof Http) {
return processProtocol(type, (Protocol) t.getParent(), events);
} else if (tClass == FileCache.class && t instanceof FileCache) {
return processProtocol(type, (Protocol) t.getParent().getParent(), null);
} else if (tClass == Ssl.class && t instanceof Ssl) {
/*
* Make sure the SSL parent is in fact a protocol. It could
* be a jmx-connector.
*/
final ConfigBeanProxy parent = t.getParent();
if (parent instanceof Protocol) {
return processProtocol(type, (Protocol) parent, null);
}
} else if (tClass == Protocol.class && t instanceof Protocol) {
return processProtocol(type, (Protocol) t, null);
} else if (tClass == ThreadPool.class && t instanceof ThreadPool) {
NotProcessed notProcessed = null;
ThreadPool threadPool = (ThreadPool) t;
for (NetworkListener listener : threadPool.findNetworkListeners()) {
notProcessed = processNetworkListener(type, listener, null);
}
// Throw an unprocessed event change if one hasn't already if HTTP or ThreadPool monitoring is enabled.
MonitoringService ms = config.getMonitoringService();
String threadPoolLevel = ms.getModuleMonitoringLevels().getThreadPool();
String httpServiceLevel = ms.getModuleMonitoringLevels().getHttpService();
if (((threadPoolLevel != null && !threadPoolLevel.equals(OFF)) || (httpServiceLevel != null && !httpServiceLevel.equals(OFF))) && notProcessed == null) {
notProcessed = new NotProcessed("Monitoring statistics will be incorrect for " + threadPool.getName() + " until restart due to changed attribute(s).");
}
return notProcessed;
} else if (tClass == Transport.class && t instanceof Transport) {
NotProcessed notProcessed = null;
for (NetworkListener listener : ((Transport) t).findNetworkListeners()) {
notProcessed = processNetworkListener(type, listener, null);
}
return notProcessed;
} else if (tClass == VirtualServer.class && t instanceof VirtualServer && !grizzlyService.hasMapperUpdateListener()) {
return processVirtualServer(type, (VirtualServer) t);
} else if (tClass == SystemProperty.class && t instanceof SystemProperty) {
NetworkConfig networkConfig = config.getNetworkConfig();
if ((networkConfig != null) && ((SystemProperty) t).getName().endsWith("LISTENER_PORT")) {
for (NetworkListener listener : networkConfig.getNetworkListeners().getNetworkListener()) {
if (listener.getPort().equals(((SystemProperty) t).getValue())) {
return processNetworkListener(Changed.TYPE.CHANGE, listener, events);
}
}
}
return null;
}
return null;
}
}, logger);
}
Aggregations