use of org.glassfish.grizzly.config.dom.NetworkListeners in project Payara by payara.
the class GrizzlyConfigSchemaMigrator method migrateThreadPools.
private void migrateThreadPools(ThreadPools threadPools) throws TransactionFailure {
final Config config = threadPools.getParent(Config.class);
final NetworkListeners networkListeners = config.getNetworkConfig().getNetworkListeners();
threadPools.getThreadPool().addAll(networkListeners.getThreadPool());
ConfigSupport.apply(new SingleConfigCode<NetworkListeners>() {
public Object run(NetworkListeners param) {
param.getThreadPool().clear();
return null;
}
}, networkListeners);
}
use of org.glassfish.grizzly.config.dom.NetworkListeners 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.NetworkListeners in project Payara by payara.
the class SecureAdminConfigUpgrade method createAdminNetworkListener.
private NetworkListener createAdminNetworkListener(final Transaction t, final NetworkConfig nc, final String adminListenerProtocolName) throws TransactionFailure {
final NetworkListeners nls_w = t.enroll(nc.getNetworkListeners());
final NetworkListener nl_w = nls_w.createChild(NetworkListener.class);
nls_w.getNetworkListener().add(nl_w);
nl_w.setName(ADMIN_LISTENER_NAME);
nl_w.setProtocol(adminListenerProtocolName);
nl_w.setPort(ASADMIN_LISTENER_PORT);
nl_w.setTransport(ASADMIN_LISTENER_TRANSPORT);
nl_w.setThreadPool(ASADMIN_LISTENER_THREADPOOL);
return nl_w;
}
use of org.glassfish.grizzly.config.dom.NetworkListeners in project Payara by payara.
the class DeleteNetworkListener method execute.
/**
* Executes the command with the command parameters passed as Properties where the keys are the paramter 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;
}
ActionReport report = context.getActionReport();
NetworkListeners networkListeners = config.getNetworkConfig().getNetworkListeners();
try {
if (findListener(networkListeners, report)) {
final Protocol httpProtocol = listenerToBeRemoved.findHttpProtocol();
final VirtualServer virtualServer = config.getHttpService().getVirtualServerByName(httpProtocol.getHttp().getDefaultVirtualServer());
ConfigSupport.apply(new ConfigCode() {
public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
final NetworkListeners listeners = (NetworkListeners) params[0];
final VirtualServer server = (VirtualServer) params[1];
listeners.getNetworkListener().remove(listenerToBeRemoved);
server.removeNetworkListener(listenerToBeRemoved.getName());
return listenerToBeRemoved;
}
}, networkListeners, virtualServer);
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (TransactionFailure e) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.DELETE_NETWORK_LISTENER_FAIL), networkListenerName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
}
use of org.glassfish.grizzly.config.dom.NetworkListeners in project Payara by payara.
the class InstanceReaderImpl method getListeners.
/**
* Enlists both http and https listeners of this server instance
* It will be form "http:<hostname>:<port> https:<hostname>:<port>"
*
* @return String Listener(s) info.
*/
@Override
public String getListeners() throws LbReaderException {
StringBuffer listenerStr = new StringBuffer();
Config config = _domain.getConfigNamed(_server.getConfigRef());
NetworkConfig networkConfig = config.getNetworkConfig();
Protocols protocols = networkConfig.getProtocols();
NetworkListeners nls = networkConfig.getNetworkListeners();
Iterator<NetworkListener> listenerIter = nls.getNetworkListener().iterator();
int i = 0;
PropertyResolver resolver = new PropertyResolver(_domain, _server.getName());
while (listenerIter.hasNext()) {
NetworkListener listener = listenerIter.next();
NetworkListener rawListener = GlassFishConfigBean.getRawView(listener);
if (rawListener.getName().equals(ADMIN_LISTENER)) {
continue;
}
String prot = rawListener.getProtocol();
Protocol protocol = protocols.findProtocol(prot);
if (i > 0) {
// space between listener names
listenerStr.append(' ');
}
i++;
if (Boolean.valueOf(protocol.getHttp().getJkEnabled())) {
listenerStr.append(AJP_PROTO);
} else {
if (Boolean.valueOf(protocol.getSecurityEnabled()).booleanValue()) {
listenerStr.append(HTTPS_PROTO);
} else {
listenerStr.append(HTTP_PROTO);
}
}
String hostName = getResolvedHostName(rawListener.getAddress());
listenerStr.append(hostName);
listenerStr.append(':');
// resolve the port name
String port = rawListener.getPort();
// If it is system variable, resolve it
if ((port != null) && (port.length() > 1) && (port.charAt(0) == '$') && (port.charAt(1) == '{') && (port.charAt(port.length() - 1) == '}')) {
String portVar = port.substring(2, port.length() - 1);
port = resolver.getPropertyValue(portVar);
if (port == null) {
throw new LbReaderException(LbLogUtil.getStringManager().getString("UnableToResolveSystemProperty", portVar, _server.getName()));
}
}
listenerStr.append(port);
}
return listenerStr.toString();
}
Aggregations