use of org.glassfish.web.deployment.runtime.WebProperty in project Payara by payara.
the class BasePersistenceStrategyBuilder method readWebAppParams.
public void readWebAppParams(Context ctx, SessionManager smBean) {
if (smBean != null) {
// The persistence-type controls what properties of the
// session manager can be configured
ManagerProperties mgrBean = smBean.getManagerProperties();
if ((mgrBean != null) && (mgrBean.sizeWebProperty() > 0)) {
for (WebProperty prop : mgrBean.getWebProperty()) {
String name = prop.getAttributeValue(WebProperty.NAME);
String value = prop.getAttributeValue(WebProperty.VALUE);
if (name.equalsIgnoreCase("reapIntervalSeconds")) {
try {
reapInterval = Integer.parseInt(value);
} catch (NumberFormatException e) {
// XXX need error message
}
} else if (name.equalsIgnoreCase("maxSessions")) {
try {
maxSessions = Integer.parseInt(value);
} catch (NumberFormatException e) {
// XXX need error message
}
} else /*else if (name.equalsIgnoreCase("maxIdleBackupSeconds")) {
try {
maxIdleBackup = Integer.parseInt(value);
} catch (NumberFormatException e) {
// XXX need error message
}
} */
if (name.equalsIgnoreCase("relaxCacheVersionSemantics")) {
relaxCacheVersionSemantics = Boolean.parseBoolean(value);
} else if (name.equalsIgnoreCase("sessionFilename")) {
sessionFilename = value;
} else if (name.equalsIgnoreCase("persistenceFrequency")) {
_persistenceFrequency = value;
} else {
if (_logger.isLoggable(Level.INFO)) {
Object[] params = { name };
_logger.log(Level.INFO, LogFacade.PROPERTY_NOT_YET_SUPPORTED, params);
}
}
}
}
StoreProperties storeBean = smBean.getStoreProperties();
if ((storeBean != null) && (storeBean.sizeWebProperty() > 0)) {
for (WebProperty prop : storeBean.getWebProperty()) {
String name = prop.getAttributeValue(WebProperty.NAME);
String value = prop.getAttributeValue(WebProperty.VALUE);
if (name.equalsIgnoreCase("reapIntervalSeconds")) {
try {
storeReapInterval = Integer.parseInt(value);
} catch (NumberFormatException e) {
// XXX need error message
}
} else if (name.equalsIgnoreCase("directory")) {
directory = value;
} else if (name.equalsIgnoreCase("persistenceScope")) {
_persistenceScope = value;
} else if (name.equalsIgnoreCase("cookieName")) {
persistentCookieName = value;
} else {
if (_logger.isLoggable(Level.INFO)) {
Object[] params = { name };
_logger.log(Level.INFO, LogFacade.PROPERTY_NOT_YET_SUPPORTED, params);
}
}
}
}
}
}
use of org.glassfish.web.deployment.runtime.WebProperty in project Payara by payara.
the class WebBundleRuntimeNode method addDescriptor.
/**
* Adds a new DOL descriptor instance to the descriptor instance associated with
* this XMLNode
*
* @param newDescriptor the new descriptor
*/
@Override
public void addDescriptor(Object newDescriptor) {
SunWebAppImpl sunWebApp = (SunWebAppImpl) descriptor.getSunDescriptor();
if (newDescriptor instanceof WebComponentDescriptor) {
WebComponentDescriptor servlet = (WebComponentDescriptor) newDescriptor;
// for backward compatibility with s1as schema2beans generated desc
Servlet s1descriptor = new Servlet();
s1descriptor.setServletName(servlet.getCanonicalName());
if (servlet.getRunAsIdentity() != null) {
s1descriptor.setPrincipalName(servlet.getRunAsIdentity().getPrincipal());
}
sunWebApp.addServlet(s1descriptor);
} else if (newDescriptor instanceof ServiceReferenceDescriptor) {
descriptor.addServiceReferenceDescriptor((ServiceReferenceDescriptor) newDescriptor);
} else if (newDescriptor instanceof SecurityRoleMapping) {
SecurityRoleMapping srm = (SecurityRoleMapping) newDescriptor;
sunWebApp.addSecurityRoleMapping(srm);
// store it in the application using pure DOL descriptors...
Application app = descriptor.getApplication();
if (app != null) {
Role role = new Role(srm.getRoleName());
SecurityRoleMapper rm = app.getRoleMapper();
if (rm != null) {
List<PrincipalNameDescriptor> principals = srm.getPrincipalNames();
for (int i = 0; i < principals.size(); i++) {
rm.assignRole(principals.get(i).getPrincipal(), role, descriptor);
}
List<String> groups = srm.getGroupNames();
for (int i = 0; i < groups.size(); i++) {
rm.assignRole(new Group(groups.get(i)), role, descriptor);
}
}
}
} else if (newDescriptor instanceof IdempotentUrlPattern) {
sunWebApp.addIdempotentUrlPattern((IdempotentUrlPattern) newDescriptor);
} else if (newDescriptor instanceof SessionConfig) {
sunWebApp.setSessionConfig((SessionConfig) newDescriptor);
} else if (newDescriptor instanceof Cache) {
sunWebApp.setCache((Cache) newDescriptor);
} else if (newDescriptor instanceof ClassLoader) {
sunWebApp.setClassLoader((ClassLoader) newDescriptor);
} else if (newDescriptor instanceof JspConfig) {
sunWebApp.setJspConfig((JspConfig) newDescriptor);
} else if (newDescriptor instanceof LocaleCharsetInfo) {
sunWebApp.setLocaleCharsetInfo((LocaleCharsetInfo) newDescriptor);
} else if (newDescriptor instanceof WebProperty) {
sunWebApp.addWebProperty((WebProperty) newDescriptor);
} else if (newDescriptor instanceof Valve) {
sunWebApp.addValve((Valve) newDescriptor);
} else
super.addDescriptor(descriptor);
}
use of org.glassfish.web.deployment.runtime.WebProperty in project Payara by payara.
the class JSPCompiler method configureJspc.
// //////////////////////////////////////////////////////////////////////////
/*
* Configures the given JspC instance with the jsp-config properties
* specified in the sun-web.xml of the web module represented by the
* given WebBundleDescriptor.
*
* @param jspc JspC instance to be configured
* @param wbd WebBundleDescriptor of the web module whose sun-web.xml
* is used to configure the given JspC instance
*/
private static void configureJspc(JspC jspc, WebBundleDescriptor wbd) {
SunWebAppImpl sunWebApp = (SunWebAppImpl) wbd.getSunDescriptor();
if (sunWebApp == null) {
return;
}
// START SJSAS 6384538
if (sunWebApp.sizeWebProperty() > 0) {
WebProperty[] props = sunWebApp.getWebProperty();
for (int i = 0; i < props.length; i++) {
String pName = props[i].getAttributeValue("name");
String pValue = props[i].getAttributeValue("value");
if (pName == null || pValue == null) {
throw new IllegalArgumentException("Missing sun-web-app property name or value");
}
if ("enableTldValidation".equals(pName)) {
jspc.setIsValidationEnabled(Boolean.valueOf(pValue).booleanValue());
}
}
}
// END SJSAS 6384538
// START SJSAS 6170435
/*
* Configure JspC with the init params of the JspServlet
*/
Set<WebComponentDescriptor> set = wbd.getWebComponentDescriptors();
if (!set.isEmpty()) {
Iterator<WebComponentDescriptor> iterator = set.iterator();
while (iterator.hasNext()) {
WebComponentDescriptor webComponentDesc = iterator.next();
if ("jsp".equals(webComponentDesc.getCanonicalName())) {
Enumeration<InitializationParameter> en = webComponentDesc.getInitializationParameters();
if (en != null) {
while (en.hasMoreElements()) {
InitializationParameter initP = en.nextElement();
configureJspc(jspc, initP.getName(), initP.getValue());
}
}
break;
}
}
}
// END SJSAS 6170435
/*
* Configure JspC with jsp-config properties from sun-web.xml,
* which override JspServlet init params of the same name.
*/
JspConfig jspConfig = sunWebApp.getJspConfig();
if (jspConfig == null) {
return;
}
WebProperty[] props = jspConfig.getWebProperty();
for (int i = 0; props != null && i < props.length; i++) {
configureJspc(jspc, props[i].getAttributeValue("name"), props[i].getAttributeValue("value"));
}
}
use of org.glassfish.web.deployment.runtime.WebProperty in project Payara by payara.
the class SessionManagerConfigurationHelper method getPersistenceScope.
/**
* Get the persistence scope for this web module
* (this is the value from sun-web.xml if defined
* @param smBean the session manager config bean
*/
protected String getPersistenceScope(SessionManager smBean) {
String persistenceScope = null;
StoreProperties storeBean = smBean.getStoreProperties();
if ((storeBean != null) && (storeBean.sizeWebProperty() > 0)) {
WebProperty[] props = storeBean.getWebProperty();
for (int i = 0; i < props.length; i++) {
String name = props[i].getAttributeValue(WebProperty.NAME);
String value = props[i].getAttributeValue(WebProperty.VALUE);
if (name.equalsIgnoreCase("persistenceScope")) {
persistenceScope = value;
}
}
}
return persistenceScope;
}
use of org.glassfish.web.deployment.runtime.WebProperty in project Payara by payara.
the class DynamicWebServletRegistrationImpl method addValve.
/**
* Constructs a <tt>Valve</tt> from the given <tt>valveDescriptor</tt>
* and adds it to the <tt>Pipeline</tt> of this WebModule.
* @param valveDescriptor the object containing the information to
* create the valve.
*/
protected void addValve(org.glassfish.web.deployment.runtime.Valve valveDescriptor) {
String valveName = valveDescriptor.getAttributeValue(org.glassfish.web.deployment.runtime.Valve.NAME);
String className = valveDescriptor.getAttributeValue(org.glassfish.web.deployment.runtime.Valve.CLASS_NAME);
if (valveName == null) {
logger.log(Level.WARNING, LogFacade.VALVE_MISSING_NAME, getName());
return;
}
if (className == null) {
logger.log(Level.WARNING, LogFacade.VALVE_MISSING_CLASS_NAME, new Object[] { valveName, getName() });
return;
}
Object valve = loadInstance(className);
if (valve == null) {
return;
}
if (!(valve instanceof GlassFishValve) && !(valve instanceof Valve)) {
logger.log(Level.WARNING, LogFacade.VALVE_CLASS_NAME_NO_VALVE, className);
return;
}
WebProperty[] props = valveDescriptor.getWebProperty();
if (props != null && props.length > 0) {
for (WebProperty property : props) {
String propName = getSetterName(property.getAttributeValue(WebProperty.NAME));
if (propName != null && propName.length() != 0) {
String value = property.getAttributeValue(WebProperty.VALUE);
try {
Method method = valve.getClass().getMethod(propName, String.class);
method.invoke(valve, value);
} catch (NoSuchMethodException ex) {
String msg = rb.getString(LogFacade.VALVE_SPECIFIED_METHOD_MISSING);
msg = MessageFormat.format(msg, new Object[] { propName, valveName, getName() });
logger.log(Level.SEVERE, msg, ex);
} catch (Throwable t) {
String msg = rb.getString(LogFacade.VALVE_SETTER_CAUSED_EXCEPTION);
msg = MessageFormat.format(msg, new Object[] { propName, valveName, getName() });
logger.log(Level.SEVERE, msg, t);
}
} else {
logger.log(Level.WARNING, LogFacade.VALVE_MISSING_PROPERTY_NAME, new Object[] { valveName, getName() });
return;
}
}
}
if (valve instanceof Valve) {
super.addValve((Valve) valve);
} else if (valve instanceof GlassFishValve) {
super.addValve((GlassFishValve) valve);
}
}
Aggregations