use of org.glassfish.grizzly.config.dom.Protocol 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>() {
@Override
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);
}
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class SecureAdminUpgradeHelper method ensureConfigReady.
private boolean ensureConfigReady(final Config c) throws TransactionFailure {
/*
* See if this config is already set up for secure admin.
*/
final NetworkConfig nc = c.getNetworkConfig();
if (nc == null) {
/*
* If there is no network config for this configuration then it is
* probably a test configuration of some sort. In any case, there
* is no lower-level network protocols to verify so declare this
* config to be OK.
*/
return true;
}
Protocol secAdminProtocol = nc.getProtocols().findProtocol(SecureAdminCommand.SEC_ADMIN_LISTENER_PROTOCOL_NAME);
if (secAdminProtocol != null) {
return true;
}
final EnableSecureAdminCommand enableCmd = new EnableSecureAdminCommand();
final Config c_w = transaction().enroll(c);
ConfigLevelContext configLevelContext = new ConfigLevelContext(topLevelContext(), c_w);
for (Iterator<Work<ConfigLevelContext>> it = enableCmd.perConfigSteps(); it.hasNext(); ) {
final Work<ConfigLevelContext> step = it.next();
if (!step.run(configLevelContext)) {
rollback();
return false;
}
}
return true;
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class WebContainerImpl method removeListener.
private void removeListener(String name) {
try {
NetworkListeners networkListeners = networkConfig.getNetworkListeners();
final NetworkListener listenerToBeRemoved = networkConfig.getNetworkListener(name);
final Protocols protocols = networkConfig.getProtocols();
final Protocol protocol = networkConfig.findProtocol(name);
if (listenerToBeRemoved == null) {
log.severe("Network Listener " + name + " doesn't exist");
} else {
final com.sun.enterprise.config.serverbeans.VirtualServer virtualServer = httpService.getVirtualServerByName(listenerToBeRemoved.findHttpProtocol().getHttp().getDefaultVirtualServer());
ConfigSupport.apply(new ConfigCode() {
public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
final NetworkListeners listeners = (NetworkListeners) params[0];
final com.sun.enterprise.config.serverbeans.VirtualServer server = (com.sun.enterprise.config.serverbeans.VirtualServer) params[1];
listeners.getNetworkListener().remove(listenerToBeRemoved);
server.removeNetworkListener(listenerToBeRemoved.getName());
return listenerToBeRemoved;
}
}, networkListeners, virtualServer);
ConfigSupport.apply(new ConfigCode() {
public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
final Protocols protocols = (Protocols) params[0];
final Protocol protocol = (Protocol) params[1];
protocols.getProtocol().remove(protocol);
return protocol;
}
}, protocols, protocol);
}
} catch (TransactionFailure e) {
log.severe("Remove listener " + name + " failed " + e.getMessage());
}
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class CreateNetworkListener method findVirtualServer.
private VirtualServer findVirtualServer(Protocol protocol) {
String name = null;
final Http http = protocol.getHttp();
if (http != null) {
name = http.getDefaultVirtualServer();
} else {
final List<ProtocolFinder> finders = protocol.getPortUnification().getProtocolFinder();
for (ProtocolFinder finder : finders) {
if (name == null) {
final Protocol p = finder.findProtocol();
if (p.getHttp() != null) {
name = p.getHttp().getDefaultVirtualServer();
}
}
}
}
return config.getHttpService().getVirtualServerByName(name);
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class CreateProtocolFilter method execute.
@Override
public void execute(AdminCommandContext context) {
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
report = context.getActionReport();
try {
final Protocols protocols = config.getNetworkConfig().getProtocols();
final Protocol protocol = protocols.findProtocol(protocolName);
validate(protocol, LogFacade.CREATE_HTTP_FAIL_PROTOCOL_NOT_FOUND, protocolName);
final Class<?> filterClass = Thread.currentThread().getContextClassLoader().loadClass(classname);
if (!org.glassfish.grizzly.filterchain.Filter.class.isAssignableFrom(filterClass)) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_PORTUNIF_FAIL_NOTFILTER), name, classname));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
ProtocolChainInstanceHandler handler = getHandler(protocol);
ProtocolChain chain = getChain(handler);
ConfigSupport.apply(new SingleConfigCode<ProtocolChain>() {
@Override
public Object run(ProtocolChain param) throws PropertyVetoException, TransactionFailure {
final List<ProtocolFilter> list = param.getProtocolFilter();
for (ProtocolFilter filter : list) {
if (name.equals(filter.getName())) {
throw new TransactionFailure(String.format("A protocol filter named %s already exists.", name));
}
}
final ProtocolFilter filter = param.createChild(ProtocolFilter.class);
filter.setName(name);
filter.setClassname(classname);
list.add(filter);
return null;
}
}, chain);
} catch (ValidationFailureException e) {
return;
} catch (Exception e) {
e.printStackTrace();
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_PORTUNIF_FAIL), name, e.getMessage() == null ? "No reason given" : e.getMessage()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
}
Aggregations