Search in sources :

Example 6 with JspApplicationContext

use of javax.servlet.jsp.JspApplicationContext in project wildfly by wildfly.

the class WeldJspExpressionFactoryWrapper method wrap.

@Override
public ExpressionFactory wrap(ExpressionFactory expressionFactory, ServletContext servletContext) {
    BeanManager beanManager = getBeanManager();
    if (beanManager == null) {
        // this should never happen
        return expressionFactory;
    }
    // get JspApplicationContext.
    JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext);
    // register compositeELResolver with Jakarta Server Pages
    jspAppContext.addELResolver(beanManager.getELResolver());
    jspAppContext.addELContextListener(Reflections.<ELContextListener>newInstance("org.jboss.weld.module.web.el.WeldELContextListener", getClass().getClassLoader()));
    return beanManager.wrapExpressionFactory(expressionFactory);
}
Also used : JspApplicationContext(javax.servlet.jsp.JspApplicationContext) BeanManager(javax.enterprise.inject.spi.BeanManager)

Example 7 with JspApplicationContext

use of javax.servlet.jsp.JspApplicationContext in project Payara by payara.

the class WeldContextListener method contextInitialized.

/**
 * Stash the Weld EL Resolver and Weld EL Context Listener so it is recognized by JSP.
 * @param servletContextEvent
 */
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
    if (beanManager != null) {
        JspApplicationContext jspAppContext = getJspApplicationContext(servletContextEvent);
        jspAppContext.addELResolver(beanManager.getELResolver());
        try {
            Class<?> weldClass = Class.forName("org.jboss.weld.module.web.el.WeldELContextListener");
            WeldELContextListener welcl = (WeldELContextListener) weldClass.newInstance();
            jspAppContext.addELContextListener(welcl);
        } catch (Exception e) {
            logger.log(Level.WARNING, CDILoggerInfo.CDI_COULD_NOT_CREATE_WELDELCONTEXTlISTENER, new Object[] { e });
        }
        ((JspApplicationContextImpl) jspAppContext).setExpressionFactory(beanManager.wrapExpressionFactory(jspAppContext.getExpressionFactory()));
    }
}
Also used : JspApplicationContext(javax.servlet.jsp.JspApplicationContext) JspApplicationContextImpl(org.apache.jasper.runtime.JspApplicationContextImpl) WeldELContextListener(org.jboss.weld.module.web.el.WeldELContextListener)

Example 8 with JspApplicationContext

use of javax.servlet.jsp.JspApplicationContext in project jfinal by jfinal.

the class ModelRecordElResolver method init.

public static synchronized void init(ServletContext servletContext) {
    JspApplicationContext jac = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext);
    if (jspApplicationContext != jac) {
        jspApplicationContext = jac;
        jspApplicationContext.addELResolver(new ModelRecordElResolver());
    }
}
Also used : JspApplicationContext(javax.servlet.jsp.JspApplicationContext)

Aggregations

JspApplicationContext (javax.servlet.jsp.JspApplicationContext)8 JspApplicationContextImpl (org.apache.jasper.runtime.JspApplicationContextImpl)2 WeldELContextListener (org.jboss.weld.module.web.el.WeldELContextListener)2 ObjectStreamException (java.io.ObjectStreamException)1 List (java.util.List)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 FilterRegistration (javax.servlet.FilterRegistration)1 ServletContext (javax.servlet.ServletContext)1 JspFactory (javax.servlet.jsp.JspFactory)1 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)1 ExpressionFactoryWrapper (org.jboss.as.web.common.ExpressionFactoryWrapper)1 WeldBootstrap (org.jboss.weld.bootstrap.WeldBootstrap)1 CDI11Bootstrap (org.jboss.weld.bootstrap.api.CDI11Bootstrap)1 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)1 CDI11Deployment (org.jboss.weld.bootstrap.spi.CDI11Deployment)1 ExternalConfigurationBuilder (org.jboss.weld.configuration.spi.helpers.ExternalConfigurationBuilder)1 ContainerInstance (org.jboss.weld.environment.ContainerInstance)1 ContainerInstanceFactory (org.jboss.weld.environment.ContainerInstanceFactory)1 WeldBeanDeploymentArchive (org.jboss.weld.environment.deployment.WeldBeanDeploymentArchive)1 GwtDevHostedModeContainer (org.jboss.weld.environment.gwtdev.GwtDevHostedModeContainer)1