use of com.sun.enterprise.config.serverbeans.VirtualServer in project Payara by payara.
the class WarHandler method configureContextXmlAttribute.
protected void configureContextXmlAttribute(WebappClassLoader cloader, File base, DeploymentContext dc) throws XMLStreamException, IOException {
boolean consistent = true;
Boolean value = null;
File warContextXml = new File(base.getAbsolutePath(), WAR_CONTEXT_XML);
if (warContextXml.exists()) {
ContextXmlParser parser = new ContextXmlParser(warContextXml);
value = parser.getClearReferencesStatic();
}
if (value == null) {
Boolean domainCRS = null;
File defaultContextXml = new File(serverEnvironment.getInstanceRoot(), DEFAULT_CONTEXT_XML);
if (defaultContextXml.exists()) {
ContextXmlParser parser = new ContextXmlParser(defaultContextXml);
domainCRS = parser.getClearReferencesStatic();
}
List<Boolean> csrs = new ArrayList<Boolean>();
HttpService httpService = serverConfig.getHttpService();
DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
String vsIDs = params.virtualservers;
List<String> vsList = StringUtils.parseStringList(vsIDs, " ,");
if (httpService != null && vsList != null && !vsList.isEmpty()) {
for (VirtualServer vsBean : httpService.getVirtualServer()) {
if (vsList.contains(vsBean.getId())) {
Boolean csr = null;
Property prop = vsBean.getProperty("contextXmlDefault");
if (prop != null) {
File contextXml = new File(serverEnvironment.getInstanceRoot(), prop.getValue());
if (contextXml.exists()) {
// vs context.xml
ContextXmlParser parser = new ContextXmlParser(contextXml);
csr = parser.getClearReferencesStatic();
}
}
if (csr == null) {
csr = domainCRS;
}
csrs.add(csr);
}
}
// check that it is consistent
for (Boolean b : csrs) {
if (b != null) {
if (value != null && !b.equals(value)) {
consistent = false;
break;
}
value = b;
}
}
}
}
if (consistent) {
if (value != null) {
cloader.setClearReferencesStatic(value);
}
} else if (logger.isLoggable(Level.WARNING)) {
logger.log(Level.WARNING, LogFacade.INCONSISTENT_CLEAR_REFERENCE_STATIC);
}
}
use of com.sun.enterprise.config.serverbeans.VirtualServer in project Payara by payara.
the class CreateHttpListener 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) {
final ActionReport report = context.getActionReport();
if (!validateInputs(report)) {
return;
}
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
networkConfig = config.getNetworkConfig();
HttpService httpService = config.getHttpService();
if (!(verifyUniqueName(report, networkConfig) && verifyUniquePort(report, networkConfig) && verifyDefaultVirtualServer(report))) {
return;
}
VirtualServer vs = httpService.getVirtualServerByName(defaultVirtualServer);
boolean listener = false;
boolean protocol = false;
boolean transport = false;
try {
transport = createOrGetTransport(null);
protocol = createProtocol(context);
createHttp(context);
final ThreadPool threadPool = getThreadPool(networkConfig);
listener = createNetworkListener(networkConfig, transport, threadPool);
updateVirtualServer(vs);
} catch (TransactionFailure e) {
try {
if (listener) {
deleteListener(context);
}
if (protocol) {
deleteProtocol(context);
}
if (transport) {
deleteTransport(context);
}
} catch (Exception e1) {
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, e.getMessage(), e);
}
throw new RuntimeException(e.getMessage());
}
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, e.getMessage(), e);
}
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_LISTENER_FAIL), listenerId, e.getMessage()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of com.sun.enterprise.config.serverbeans.VirtualServer in project Payara by payara.
the class MapperListener method init.
/**
* Initialize associated mapper.
*/
public void init() {
if (webContainer == null) {
logger.log(Level.SEVERE, LogFacade.CANNOT_FIND_WEB_CONTAINER);
return;
}
try {
httpService = webContainer.getHttpService();
engine = webContainer.getEngine();
if (engine == null) {
logger.log(Level.SEVERE, LogFacade.CANNOT_FIND_ENGINE);
return;
}
if (defaultHost != null) {
mapper.setDefaultHostName(defaultHost);
}
for (VirtualServer vs : httpService.getVirtualServer()) {
Container host = engine.findChild(vs.getId());
if (host instanceof StandardHost) {
registerHost((StandardHost) host);
for (Container context : host.findChildren()) {
if (context instanceof StandardContext) {
registerContext((StandardContext) context);
for (Container wrapper : context.findChildren()) {
if (wrapper instanceof StandardWrapper) {
registerWrapper((StandardWrapper) wrapper);
}
}
}
}
}
}
} catch (Exception e) {
logger.log(Level.WARNING, LogFacade.ERROR_REGISTERING_CONTEXTS, e);
}
}
use of com.sun.enterprise.config.serverbeans.VirtualServer in project Payara by payara.
the class SecureAdminConfigUpgrade method createAdminVirtualServer.
private VirtualServer createAdminVirtualServer(final Transaction t, final Config config_w) throws TransactionFailure, PropertyVetoException {
final HttpService hs_w = t.enroll(config_w.getHttpService());
final VirtualServer vs_w = hs_w.createChild(VirtualServer.class);
hs_w.getVirtualServer().add(vs_w);
vs_w.setId(ASADMIN_VS_NAME);
vs_w.setNetworkListeners(ADMIN_LISTENER_NAME);
return vs_w;
}
use of com.sun.enterprise.config.serverbeans.VirtualServer in project Payara by payara.
the class GrizzlyService method createNetworkProxy.
/*
* Creates a new NetworkProxy for a particular HttpListner
* @param listener NetworkListener
* @param networkConfig HttpService
*/
public synchronized Future<Result<Thread>> createNetworkProxy(NetworkListener listener) {
if (!Boolean.valueOf(listener.getEnabled())) {
// in case the listener will be enabled
addChangeListener(listener);
LOGGER.log(Level.INFO, KernelLoggerInfo.grizzlyPortDisabled, new Object[] { listener.getName(), listener.getPort() });
return null;
}
// create the proxy for the port.
GrizzlyProxy proxy = new GrizzlyProxy(this, listener);
Future<Result<Thread>> future = null;
try {
proxy.initialize();
if (!isLightWeightListener(listener)) {
final NetworkConfig networkConfig = listener.getParent(NetworkListeners.class).getParent(NetworkConfig.class);
// attach all virtual servers to this port
for (VirtualServer vs : networkConfig.getParent(Config.class).getHttpService().getVirtualServer()) {
List<String> vsListeners = StringUtils.parseStringList(vs.getNetworkListeners(), " ,");
if (vsListeners == null || vsListeners.isEmpty() || vsListeners.contains(listener.getName())) {
if (!hosts.contains(vs.getId())) {
hosts.add(vs.getId());
}
}
}
addChangeListener(listener);
addChangeListener(listener.findThreadPool());
addChangeListener(listener.findTransport());
final Protocol protocol = listener.findHttpProtocol();
if (protocol != null) {
addChangeListener(protocol);
addChangeListener(protocol.getHttp());
addChangeListener(protocol.getHttp().getFileCache());
addChangeListener(protocol.getSsl());
}
}
future = proxy.start();
// add the new proxy to our list of proxies.
proxies.add(proxy);
} catch (Throwable e) {
final Future<Result<Thread>> errorFuture = Futures.createReadyFuture(new Result<Thread>(e));
future = errorFuture;
} finally {
if (future == null) {
final FutureImpl<Result<Thread>> errorFuture = Futures.<Result<Thread>>createUnsafeFuture();
errorFuture.result(new Result<Thread>(new IllegalStateException("Unexpected error")));
future = errorFuture;
}
futures.add(future);
}
return future;
}
Aggregations