use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class CreateVirtualServer 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;
}
final ActionReport report = context.getActionReport();
if (networkListeners != null && httpListeners != null) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_VIRTUAL_SERVER_BOTH_HTTP_NETWORK), virtualServerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// use the listener parameter provided by the user.
if (networkListeners == null) {
networkListeners = httpListeners;
}
HttpService httpService = config.getHttpService();
// ensure we don't already have one of this name
for (VirtualServer virtualServer : httpService.getVirtualServer()) {
if (virtualServer.getId().equals(virtualServerId)) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_VIRTUAL_SERVER_DUPLICATE), virtualServerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
try {
ConfigSupport.apply(new SingleConfigCode<HttpService>() {
public Object run(HttpService param) throws PropertyVetoException, TransactionFailure {
// default
String docroot = "${com.sun.aas.instanceRoot}/docroot";
// default
String accessLog = "${com.sun.aas.instanceRoot}/logs/access";
VirtualServer newVirtualServer = param.createChild(VirtualServer.class);
newVirtualServer.setId(virtualServerId);
newVirtualServer.setHosts(hosts);
newVirtualServer.setNetworkListeners(networkListeners);
newVirtualServer.setDefaultWebModule(defaultWebModule);
newVirtualServer.setState(state);
newVirtualServer.setLogFile(logFile);
// values if the properties have not been specified.
if (properties != null) {
for (Map.Entry entry : properties.entrySet()) {
String pn = (String) entry.getKey();
String pv = (String) entry.getValue();
if ("docroot".equals(pn)) {
docroot = pv;
} else if ("accesslog".equals(pn)) {
accessLog = pv;
} else {
Property property = newVirtualServer.createChild(Property.class);
property.setName(pn);
property.setValue(pv);
newVirtualServer.getProperty().add(property);
}
}
}
newVirtualServer.setDocroot(docroot);
newVirtualServer.setAccessLog(accessLog);
param.getVirtualServer().add(newVirtualServer);
return newVirtualServer;
}
}, httpService);
} catch (TransactionFailure e) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_VIRTUAL_SERVER_FAIL), virtualServerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ServerConfigLookup method getWebContainerAvailabilityPropertyString.
/**
* Get the String value of the property under web-container-availability
* element from domain.xml whose name matches propName
* return defaultValue if not found
* @param propName
*/
protected String getWebContainerAvailabilityPropertyString(String propName, String defaultValue) {
WebContainerAvailability wcAvailabilityBean = getWebContainerAvailability();
if (wcAvailabilityBean == null) {
return defaultValue;
}
List<Property> props = wcAvailabilityBean.getProperty();
if (props == null) {
return defaultValue;
}
for (Property prop : props) {
String name = prop.getName();
String value = prop.getValue();
if (name.equalsIgnoreCase(propName)) {
return value;
}
}
return defaultValue;
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class VirtualServer method configure.
/**
* Configures this virtual server.
* @param vsID
* @param vsBean
* @param vsDocroot
* @param vsLogFile
* @param logServiceFile
* @param logLevel
*/
public void configure(String vsID, com.sun.enterprise.config.serverbeans.VirtualServer vsBean, String vsDocroot, String vsLogFile, MimeMap vsMimeMap, String logServiceFile, String logLevel) {
setDebug(debug);
setAppBase(vsDocroot);
setName(vsID);
setID(vsID);
setBean(vsBean);
setMimeMap(vsMimeMap);
String defaultContextXmlLocation = Constants.DEFAULT_CONTEXT_XML;
String defaultWebXmlLocation = Constants.DEFAULT_WEB_XML;
// Begin EE: 4920692 Make the default-web.xml be relocatable
Property prop = vsBean.getProperty("default-web-xml");
if (prop != null) {
defaultWebXmlLocation = prop.getValue();
}
// End EE: 4920692 Make the default-web.xml be relocatable
// allowLinking
boolean allowLinking = false;
prop = vsBean.getProperty("allowLinking");
if (prop != null) {
allowLinking = Boolean.parseBoolean(prop.getValue());
}
setAllowLinking(allowLinking);
prop = vsBean.getProperty("contextXmlDefault");
if (prop != null) {
defaultContextXmlLocation = prop.getValue();
}
setDefaultWebXmlLocation(defaultWebXmlLocation);
setDefaultContextXmlLocation(defaultContextXmlLocation);
// Set vs state
String state = vsBean.getState();
if (state == null) {
state = ON;
}
if (DISABLED.equalsIgnoreCase(state)) {
setIsActive(false);
} else {
setIsActive(Boolean.parseBoolean(state));
}
setLogFile(vsLogFile, logLevel, logServiceFile);
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class VirtualServer method configureAuthRealm.
/**
* Configures this virtual server with its authentication realm.
*
* Checks if this virtual server specifies any authRealm property, and
* if so, ensures that its value identifies a valid realm.
*
* @param securityService The security-service element from domain.xml
*/
void configureAuthRealm(SecurityService securityService) {
List<Property> properties = vsBean.getProperty();
if (properties != null && properties.size() > 0) {
for (Property p : properties) {
if (p != null && "authRealm".equals(p.getName())) {
authRealmName = p.getValue();
if (authRealmName != null) {
AuthRealm realm = null;
List<AuthRealm> rs = securityService.getAuthRealm();
if (rs != null && rs.size() > 0) {
for (AuthRealm r : rs) {
if (r != null && r.getName().equals(authRealmName)) {
realm = r;
break;
}
}
}
if (realm == null) {
_logger.log(Level.SEVERE, LogFacade.INVALID_AUTH_REALM, new Object[] { getID(), authRealmName });
}
}
break;
}
}
}
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class VirtualServer method configureCatalinaProperties.
/**
* Configures the valve_ and listener_ properties of this VirtualServer.
*/
protected void configureCatalinaProperties() {
List<Property> props = vsBean.getProperty();
if (props == null) {
return;
}
for (Property prop : props) {
String propName = prop.getName();
String propValue = prop.getValue();
if (propName == null || propValue == null) {
_logger.log(Level.WARNING, LogFacade.NULL_VIRTUAL_SERVER_PROPERTY, getName());
}
if (propName != null) {
if (propName.startsWith("valve_")) {
addValve(propValue);
} else if (propName.startsWith("listener_")) {
addListener(propValue);
} else if (propName.equals("securePagesWithPragma")) {
setSecurePagesWithPragma(Boolean.valueOf(propValue));
}
}
}
}
Aggregations