use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class ParentConfigListenerTest method addHttpListenerTest.
@Test
public void addHttpListenerTest() throws TransactionFailure {
NetworkListenersContainer container = habitat.getService(NetworkListenersContainer.class);
ConfigSupport.apply(new SingleConfigCode<NetworkListeners>() {
public Object run(NetworkListeners param) throws TransactionFailure {
NetworkListener newListener = param.createChild(NetworkListener.class);
newListener.setName("Funky-Listener");
newListener.setPort("8078");
param.getNetworkListener().add(newListener);
return null;
}
}, container.httpService);
getHabitat().<Transactions>getService(Transactions.class).waitForDrain();
assertTrue(container.received);
ObservableBean bean = (ObservableBean) ConfigSupport.getImpl(container.httpService);
// let's check that my newly added listener is available in the habitat.
List<ServiceHandle<NetworkListener>> networkListeners = habitat.getAllServiceHandles(NetworkListener.class);
boolean found = false;
for (ServiceHandle<NetworkListener> nlSH : networkListeners) {
NetworkListener nl = (NetworkListener) nlSH.getService();
if (nl.getName().equals("Funky-Listener")) {
found = true;
}
}
Assert.assertTrue("Newly added listener not found", found);
// direct access.
NetworkListener nl = habitat.getService(NetworkListener.class, "Funky-Listener");
Assert.assertTrue("Direct access to newly added listener failed", nl != null);
bean.removeListener(container);
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class ParentTest method parents.
@Test
public void parents() {
NetworkListeners service = getHabitat().getService(NetworkListeners.class);
assertNotNull(service);
NetworkListener listener = service.getNetworkListener().get(0);
assertNotNull(listener);
ConfigBeanProxy parent = service.getParent();
assertNotNull(parent);
NetworkListeners myService = listener.getParent(NetworkListeners.class);
assertNotNull(myService);
assertNotNull(myService.getNetworkListener().get(0).getName());
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class Ssl2EnabledTest method sslEnabledTest.
@Test
public void sslEnabledTest() {
for (final NetworkListener listener : config.getNetworkListeners().getNetworkListener()) {
Ssl ssl = listener.findHttpProtocol().getSsl();
if (ssl != null) {
try {
logger.fine("SSL2 ENABLED = " + ssl.getSsl2Enabled());
assertFalse(Boolean.parseBoolean(ssl.getSsl2Enabled()));
assertFalse(Boolean.parseBoolean(ssl.getSsl3Enabled()));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class TransactionCallBackTest method doTest.
public void doTest() throws TransactionFailure {
ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(habitat.<NetworkListeners>getService(NetworkListeners.class));
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("name", "funky-listener");
ConfigSupport.createAndSet(serviceBean, NetworkListener.class, configChanges, new TransactionCallBack<WriteableView>() {
@SuppressWarnings({ "unchecked" })
public void performOn(WriteableView param) throws TransactionFailure {
// if you know the type...
NetworkListener listener = param.getProxy(NetworkListener.class);
listener.setName("Aleksey");
// if you don't know the type
Method m;
try {
m = param.getProxyType().getMethod("setAddress", String.class);
m.invoke(param.getProxy(param.getProxyType()), "localhost");
} catch (NoSuchMethodException e) {
throw new TransactionFailure("Cannot find getProperty method", e);
} catch (IllegalAccessException e) {
throw new TransactionFailure("Cannot call getProperty method", e);
} catch (InvocationTargetException e) {
throw new TransactionFailure("Cannot call getProperty method", e);
}
}
});
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class GrizzlyConfigSchemaMigrator method addAsadminProtocol.
private void addAsadminProtocol(NetworkConfig config) throws TransactionFailure {
ensureAdminThreadPool();
final Protocols protocols = getProtocols(config);
Protocol adminProtocol = protocols.findProtocol(ASADMIN_LISTENER);
if (adminProtocol == null) {
adminProtocol = (Protocol) ConfigSupport.apply(new SingleConfigCode<Protocols>() {
public Object run(Protocols param) throws TransactionFailure {
final Protocol protocol = param.createChild(Protocol.class);
param.getProtocol().add(protocol);
protocol.setName(ASADMIN_LISTENER);
Http http = protocol.createChild(Http.class);
http.setFileCache(http.createChild(FileCache.class));
protocol.setHttp(http);
http.setDefaultVirtualServer(ASADMIN_VIRTUAL_SERVER);
http.setMaxConnections("250");
return protocol;
}
}, protocols);
}
for (NetworkListener listener : adminProtocol.findNetworkListeners()) {
ConfigSupport.apply(new SingleConfigCode<NetworkListener>() {
@Override
public Object run(NetworkListener param) {
param.setThreadPool("admin-thread-pool");
return null;
}
}, listener);
}
}
Aggregations