Search in sources :

Example 1 with InitializationParameter

use of com.sun.enterprise.deployment.web.InitializationParameter 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[] webProperties = sunWebApp.getWebProperty();
        for (WebProperty prop : webProperties) {
            String pName = prop.getAttributeValue("name");
            String pValue = prop.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));
            }
        }
    }
    // END SJSAS 6384538
    // START SJSAS 6170435
    /*
             * Configure JspC with the init params of the JspServlet
             */
    Set<WebComponentDescriptor> webComponentDescriptors = wbd.getWebComponentDescriptors();
    if (!webComponentDescriptors.isEmpty()) {
        for (WebComponentDescriptor webComponentDesc : webComponentDescriptors) {
            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[] webProperties = jspConfig.getWebProperty();
    if (webProperties != null) {
        for (WebProperty prop : webProperties) {
            configureJspc(jspc, prop.getAttributeValue("name"), prop.getAttributeValue("value"));
        }
    }
}
Also used : SunWebAppImpl(org.glassfish.web.deployment.runtime.SunWebAppImpl) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) WebProperty(org.glassfish.web.deployment.runtime.WebProperty) JspConfig(org.glassfish.web.deployment.runtime.JspConfig) InitializationParameter(com.sun.enterprise.deployment.web.InitializationParameter)

Example 2 with InitializationParameter

use of com.sun.enterprise.deployment.web.InitializationParameter in project Payara by payara.

the class WebModuleListener method initIncludeJars.

private void initIncludeJars() {
    if (includeInitialized) {
        return;
    }
    String includeJarsString = null;
    ;
    for (WebComponentDescriptor wcd : wbd.getWebComponentDescriptors()) {
        if ("jsp".equals(wcd.getCanonicalName())) {
            InitializationParameter initp = wcd.getInitializationParameterByName("system-jar-includes");
            if (initp != null) {
                includeJarsString = initp.getValue();
                break;
            }
        }
    }
    includeInitialized = true;
    if (includeJarsString == null) {
        includeJars = null;
        return;
    }
    includeJars = new ArrayList<String>();
    StringTokenizer tokenizer = new StringTokenizer(includeJarsString);
    while (tokenizer.hasMoreElements()) {
        includeJars.add(tokenizer.nextToken());
    }
}
Also used : WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) StringTokenizer(java.util.StringTokenizer) InitializationParameter(com.sun.enterprise.deployment.web.InitializationParameter)

Example 3 with InitializationParameter

use of com.sun.enterprise.deployment.web.InitializationParameter in project Payara by payara.

the class WebComponentDescriptorImpl method add.

/**
 * this method will combine the information from this "other" // WebComponentDescriptor with current
 * WebComponentDescriptor // // when there are conflicts between the contents of the two, // the value from current
 * WebComponentDescriptor will override // the value in "other" // // Note: in the Set API, we only add value when such
 * value // is not existed in the Set already // // If combineUrlPatterns is false, then the first one take priority, //
 * otherwise take the second one. // // If combineConflict is true, it will combine the init parameter // conflict
 * information in #getConflictedInitParameterSet. // // And the conflict boolean will not be set.
 *
 * @param other
 * @param combineUrlPatterns
 * @param combineConflict
 */
@Override
public void add(WebComponentDescriptor other, boolean combineUrlPatterns, boolean combineConflict) {
    // components are different
    if (!getCanonicalName().equals(other.getCanonicalName())) {
        return;
    }
    // components are different
    if ((isServlet() && !other.isServlet()) || (!isServlet() && other.isServlet())) {
        return;
    }
    // for simple String types, we can rely on Set API
    if (combineUrlPatterns || getUrlPatternsSet().size() == 0) {
        getUrlPatternsSet().addAll(other.getUrlPatternsSet());
    }
    // name is not in the set yet
    if (conflictedInitParameterNames == null) {
        conflictedInitParameterNames = other.getConflictedInitParameterNames();
    } else {
        conflictedInitParameterNames.addAll(other.getConflictedInitParameterNames());
    }
    if (!combineConflict) {
        for (InitializationParameter initParam : getInitializationParameterSet()) {
            conflictedInitParameterNames.remove(initParam.getName());
        }
    }
    for (Iterator<InitializationParameter> initParamIter = other.getInitializationParameterSet().iterator(); initParamIter.hasNext(); ) {
        InitializationParameter initParam = initParamIter.next();
        InitializationParameter origInitParam = getInitializationParameterByName(initParam.getName());
        if (origInitParam == null) {
            getInitializationParameterSet().add(initParam);
        } else if (combineConflict && !origInitParam.getValue().equals(initParam.getValue())) {
            getConflictedInitParameterNames().add(initParam.getName());
        }
    }
    for (SecurityRoleReference secRoleRef : other.getSecurityRoleReferenceSet()) {
        if (getSecurityRoleReferenceByName(secRoleRef.getRoleName()) == null) {
            getSecurityRoleReferenceSet().add(secRoleRef);
        }
    }
    if (getLoadOnStartUp() == null) {
        setLoadOnStartUp(other.getLoadOnStartUp());
    }
    if (isAsyncSupported() == null) {
        setAsyncSupported(other.isAsyncSupported());
    }
    if (getRunAsIdentity() == null) {
        setRunAsIdentity(other.getRunAsIdentity());
    }
    if (getMultipartConfig() == null) {
        setMultipartConfig(other.getMultipartConfig());
    }
    if (getWebComponentImplementation() == null) {
        setWebComponentImplementation(other.getWebComponentImplementation());
    }
}
Also used : InitializationParameter(com.sun.enterprise.deployment.web.InitializationParameter) SecurityRoleReference(com.sun.enterprise.deployment.web.SecurityRoleReference)

Aggregations

InitializationParameter (com.sun.enterprise.deployment.web.InitializationParameter)3 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)2 SecurityRoleReference (com.sun.enterprise.deployment.web.SecurityRoleReference)1 StringTokenizer (java.util.StringTokenizer)1 JspConfig (org.glassfish.web.deployment.runtime.JspConfig)1 SunWebAppImpl (org.glassfish.web.deployment.runtime.SunWebAppImpl)1 WebProperty (org.glassfish.web.deployment.runtime.WebProperty)1