Java Code Examples for org.apache.catalina.core.StandardContext#setTldValidation()

The following examples show how to use org.apache.catalina.core.StandardContext#setTldValidation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TomcatWebAppBuilder.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void configureStart(final LifecycleEvent event, final StandardContext standardContext) {
    final ContextTransaction contextTransaction = new ContextTransaction();
    contextTransaction.setProperty(org.apache.naming.factory.Constants.FACTORY, UserTransactionFactory.class.getName());
    standardContext.getNamingResources().setTransaction(contextTransaction);

    if (event != null) {
        // ensure NamingContext is available for eager usage (@Observes @Initialized(ApplicationScoped) for instance)
        standardContext.getNamingContextListener().lifecycleEvent(event);
    }

    TomcatHelper.configureJarScanner(standardContext);

    startInternal(standardContext);

    // clear a bit log for default case
    addMyFacesDefaultParameters(standardContext.getLoader().getClassLoader(), standardContext.getServletContext());

    // breaks cdi
    standardContext.setTldValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.tld.validation", "false")));
    // breaks jstl
    standardContext.setXmlValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.xml.validation", "false")));
}
 
Example 2
Source File: MBeanFactory.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new StandardContext.
 *
 * @param parent MBean Name of the associated parent component
 * @param path The context path for this Context
 * @param docBase Document base directory (or WAR) for this Context
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, 
                                    String path,
                                    String docBase,
                                    boolean xmlValidation,
                                    boolean xmlNamespaceAware,
                                    boolean tldValidation,
                                    boolean tldNamespaceAware)
    throws Exception {

    // Create a new StandardContext instance
    StandardContext context = new StandardContext();
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    context.setXmlValidation(xmlValidation);
    context.setXmlNamespaceAware(xmlNamespaceAware);
    context.setTldValidation(tldValidation);
    context.setTldNamespaceAware(tldNamespaceAware);
    
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ObjectName deployer = new ObjectName(pname.getDomain()+
                                         ":type=Deployer,host="+
                                         pname.getKeyProperty("host"));
    if(mserver.isRegistered(deployer)) {
        String contextName = context.getName();
        mserver.invoke(deployer, "addServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
        String configPath = (String)mserver.getAttribute(deployer,
                                                         "configBaseName");
        String baseName = context.getBaseName();
        File configFile = new File(new File(configPath), baseName+".xml");
        if (configFile.isFile()) {
            context.setConfigFile(configFile.toURI().toURL());
        }
        mserver.invoke(deployer, "manageApp",
                       new Object[] {context},
                       new String[] {"org.apache.catalina.Context"});
        mserver.invoke(deployer, "removeServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
    } else {
        log.warn("Deployer not found for "+pname.getKeyProperty("host"));
        Service service = getService(pname);
        Engine engine = (Engine) service.getContainer();
        Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
        host.addChild(context);
    }

    // Return the corresponding MBean name
    return context.getObjectName().toString();

}
 
Example 3
Source File: MBeanFactory.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new StandardContext.
 *
 * @param parent MBean Name of the associated parent component
 * @param path The context path for this Context
 * @param docBase Document base directory (or WAR) for this Context
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, 
                                    String path,
                                    String docBase,
                                    boolean xmlValidation,
                                    boolean xmlNamespaceAware,
                                    boolean tldValidation,
                                    boolean tldNamespaceAware)
    throws Exception {

    // Create a new StandardContext instance
    StandardContext context = new StandardContext();
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    context.setXmlValidation(xmlValidation);
    context.setXmlNamespaceAware(xmlNamespaceAware);
    context.setTldValidation(tldValidation);
    context.setTldNamespaceAware(tldNamespaceAware);
    
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ObjectName deployer = new ObjectName(pname.getDomain()+
                                         ":type=Deployer,host="+
                                         pname.getKeyProperty("host"));
    if(mserver.isRegistered(deployer)) {
        String contextName = context.getName();
        mserver.invoke(deployer, "addServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
        String configPath = (String)mserver.getAttribute(deployer,
                                                         "configBaseName");
        String baseName = context.getBaseName();
        File configFile = new File(new File(configPath), baseName+".xml");
        if (configFile.isFile()) {
            context.setConfigFile(configFile.toURI().toURL());
        }
        mserver.invoke(deployer, "manageApp",
                       new Object[] {context},
                       new String[] {"org.apache.catalina.Context"});
        mserver.invoke(deployer, "removeServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
    } else {
        log.warn("Deployer not found for "+pname.getKeyProperty("host"));
        Service service = getService(pname);
        Engine engine = (Engine) service.getContainer();
        Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
        host.addChild(context);
    }

    // Return the corresponding MBean name
    return context.getObjectName().toString();

}