use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class ConfigListenerTest method removeListenerTest.
@Test
public void removeListenerTest() throws TransactionFailure {
Transactions transactions = getHabitat().getService(Transactions.class);
HttpListenerContainer container = registerAndCreateHttpListenerContainer(habitat);
ObservableBean bean = (ObservableBean) ConfigSupport.getImpl(container.httpListener);
bean.removeListener(container);
ConfigSupport.apply(new SingleConfigCode<NetworkListener>() {
@Override
public Object run(NetworkListener param) {
param.setPort("8989");
return null;
}
}, container.httpListener);
transactions.waitForDrain();
assertFalse(container.received);
// put back the right values in the domain to avoid test collisions
ConfigSupport.apply(new SingleConfigCode<NetworkListener>() {
@Override
public Object run(NetworkListener param) {
param.setPort("8080");
return null;
}
}, container.httpListener);
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class DirectAccessTest method doTest.
public void doTest() throws TransactionFailure {
NetworkConfig networkConfig = habitat.getService(NetworkConfig.class);
final NetworkListener listener = networkConfig.getNetworkListeners().getNetworkListener().get(0);
final Http http = listener.findHttpProtocol().getHttp();
ConfigBean config = (ConfigBean) ConfigBean.unwrap(http.getFileCache());
ConfigBean config2 = (ConfigBean) ConfigBean.unwrap(http);
Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("max-age-seconds", "12543");
configChanges.put("max-cache-size-bytes", "1200");
Map<String, String> config2Changes = new HashMap<String, String>();
config2Changes.put("http2-enabled", "false");
changes.put(config, configChanges);
changes.put(config2, config2Changes);
JavaConfig javaConfig = habitat.getService(JavaConfig.class);
ConfigBean javaConfigBean = (ConfigBean) ConfigBean.unwrap(javaConfig);
Map<String, String> javaConfigChanges = new HashMap<String, String>();
javaConfigChanges.put("jvm-options", "-XFooBar=false");
changes.put(javaConfigBean, javaConfigChanges);
getHabitat().<ConfigSupport>getService(ConfigSupport.class).apply(changes);
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class DirectRemovalTest method doTest.
public void doTest() throws TransactionFailure {
NetworkListeners listeners = habitat.getService(NetworkListeners.class);
ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(listeners);
for (NetworkListener listener : listeners.getNetworkListener()) {
if (listener.getName().endsWith("http-listener-1")) {
ConfigSupport.deleteChild(serviceBean, (ConfigBean) ConfigBean.unwrap(listener));
break;
}
}
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class HttpServiceTest method validTransaction.
@Test
public void validTransaction() throws TransactionFailure {
final String max = listener.findHttpProtocol().getHttp().getMaxConnections();
ConfigSupport.apply(new SingleConfigCode<NetworkListener>() {
public Object run(NetworkListener okToChange) throws TransactionFailure {
final Http http = okToChange.createChild(Http.class);
http.setMaxConnections("100");
http.setTimeoutSeconds("65");
http.setFileCache(http.createChild(FileCache.class));
ConfigSupport.apply(new SingleConfigCode<Protocol>() {
@Override
public Object run(Protocol param) {
param.setHttp(http);
return null;
}
}, okToChange.findHttpProtocol());
return http;
}
}, listener);
ConfigSupport.apply(new SingleConfigCode<Http>() {
@Override
public Object run(Http param) {
param.setMaxConnections(max);
return null;
}
}, listener.findHttpProtocol().getHttp());
try {
ConfigSupport.apply(new SingleConfigCode<Http>() {
public Object run(Http param) throws TransactionFailure {
param.setMaxConnections("7");
throw new TransactionFailure("Sorry, changed my mind", null);
}
}, listener.findHttpProtocol().getHttp());
} catch (TransactionFailure e) {
logger.fine("good, got my exception about changing my mind");
}
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class GetApplicationLaunchURLsCommand method getURLsForServer.
private List<URL> getURLsForServer(Server server, String appName, String contextRoot, Logger logger) {
List<URL> serverURLs = new ArrayList<URL>();
String virtualServers = server.getApplicationRef(appName).getVirtualServers();
if (virtualServers == null || virtualServers.trim().equals("")) {
return serverURLs;
}
String nodeName = server.getNodeRef();
String host = null;
if (nodeName != null) {
Node node = domain.getNodeNamed(nodeName);
host = node.getNodeHost();
}
if (host == null || host.trim().equals("") || host.trim().equalsIgnoreCase("localhost")) {
host = DeploymentCommandUtils.getLocalHostName();
}
List<String> vsList = StringUtils.parseStringList(virtualServers, " ,");
Config config = domain.getConfigNamed(server.getConfigRef());
HttpService httpService = config.getHttpService();
for (String vsName : vsList) {
VirtualServer vs = httpService.getVirtualServerByName(vsName);
String vsHttpListeners = vs.getNetworkListeners();
if (vsHttpListeners == null || vsHttpListeners.trim().equals("")) {
continue;
}
List<String> vsHttpListenerList = StringUtils.parseStringList(vsHttpListeners, " ,");
List<NetworkListener> httpListenerList = config.getNetworkConfig().getNetworkListeners().getNetworkListener();
for (String vsHttpListener : vsHttpListenerList) {
for (NetworkListener httpListener : httpListenerList) {
if (!httpListener.getName().equals(vsHttpListener)) {
continue;
}
if (!Boolean.valueOf(httpListener.getEnabled())) {
continue;
}
Protocol protocol = httpListener.findHttpProtocol();
// Do not include jk enabled listeners
if (Boolean.valueOf(protocol.getHttp().getJkEnabled())) {
continue;
}
boolean securityEnabled = Boolean.valueOf(protocol.getSecurityEnabled());
String proto = (securityEnabled ? "https" : "http");
String portStr = httpListener.getPort();
String redirPort = protocol.getHttp().getRedirectPort();
if (redirPort != null && !redirPort.trim().equals("")) {
portStr = redirPort;
}
// we need to resolve port for non-DAS instances
if (!DeploymentUtils.isDASTarget(server.getName())) {
PropertyResolver resolver = new PropertyResolver(domain, server.getName());
portStr = resolver.getPropertyValue(portStr);
}
try {
int port = Integer.parseInt(portStr);
URL url = new URL(proto, host, port, contextRoot);
serverURLs.add(url);
} catch (Exception ee) {
logger.log(Level.WARNING, ee.getMessage(), ee);
}
}
}
}
return serverURLs;
}
Aggregations