@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 JSP jspAppContext.addELResolver(beanManager.getELResolver()); jspAppContext.addELContextListener(Reflections.<ELContextListener>newInstance("org.jboss.weld.module.web.el.WeldELContextListener", getClass().getClassLoader())); return beanManager.wrapExpressionFactory(expressionFactory); }
/** * Stash the Weld EL Resolver and Weld EL Context Listener so it is recognized by JSP. */ public void contextInitialized(ServletContextEvent servletContextEvent) { if (null != beanManager) { 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())); } }
@Override protected void initContainerIntegration( ServletContext servletContext, ExternalContext externalContext) { JspApplicationContext appCtx = getJspFactory().getJspApplicationContext(servletContext); appCtx.addELContextListener(new FacesELContextListener()); RuntimeConfig runtimeConfig = buildConfiguration(servletContext, externalContext, appCtx.getExpressionFactory()); // configure the el resolver for jsp configureResolverForJSP(appCtx, runtimeConfig); }
private HttpJspBase loadJsp(String forwardedUrl, File compilationDir) throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException, ServletException { String jspClassName = toJspClassName(forwardedUrl); URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { compilationDir.toURI().toURL() }); Class<?> cls = Class.forName(jspClassName, true, classLoader); HttpJspBase instance = (HttpJspBase) cls.newInstance(); MockServletConfig servletConfig = new MockServletConfig(new MockServletContext()); servletConfig.getServletContext().setAttribute(InstanceManager.class.getName(), new InstanceManagerImplementation()); JspApplicationContext jspApplicationContext = JspFactory.getDefaultFactory().getJspApplicationContext( servletConfig.getServletContext()); // Register the ELResolver with JSP jspApplicationContext.addELResolver(manager.getELResolver()); // Register ELContextListener with JSP jspApplicationContext.addELContextListener(Reflections .<ELContextListener> newInstance("org.jboss.weld.el.WeldELContextListener")); // Push the wrapped expression factory into the servlet context so that // Tomcat or Jetty can hook it in using a container code servletConfig.getServletContext().setAttribute(EXPRESSION_FACTORY_NAME, manager.wrapExpressionFactory(jspApplicationContext.getExpressionFactory())); instance.init(servletConfig); JspFactory.setDefaultFactory(new org.apache.jasper.runtime.JspFactoryImpl()); instance._jspInit(); return instance; }
@Override public void requestInitialized(ServletRequestEvent sre) { if (!installed && beanManager!= null && JspFactory.getDefaultFactory() != null) { synchronized (this) { if (!installed) { installed = true; // get JspApplicationContext. JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext( sre.getServletContext()); // register compositeELResolver with JSP jspAppContext.addELResolver(beanManager.getELResolver()); jspAppContext.addELContextListener(Reflections.<ELContextListener> newInstance( "org.jboss.weld.el.WeldELContextListener", getClass().getClassLoader())); // Hack into JBoss Web/Catalina to replace the ExpressionFactory JspApplicationContextImpl wrappedJspApplicationContextImpl = new WeldJspApplicationContextImpl( JspApplicationContextImpl.getInstance(sre.getServletContext()), beanManager .wrapExpressionFactory(jspAppContext.getExpressionFactory())); sre.getServletContext().setAttribute(JspApplicationContextImpl.class.getName(), wrappedJspApplicationContextImpl); } } } // otherwise something went wrong starting Weld, so don't register with JSP }
jspApplicationContext.addELContextListener(Reflections.<ELContextListener> newInstance("org.jboss.weld.el.WeldELContextListener"));
@Override protected void initContainerIntegration( ServletContext servletContext, ExternalContext externalContext) { JspApplicationContext appCtx = getJspFactory().getJspApplicationContext(servletContext); appCtx.addELContextListener(new FacesELContextListener()); // check for user-specified ExpressionFactory ExpressionFactory expressionFactory = getUserDefinedExpressionFactory(externalContext); if (expressionFactory == null) { expressionFactory = appCtx.getExpressionFactory(); } RuntimeConfig runtimeConfig = buildConfiguration(servletContext, externalContext, expressionFactory); // configure the el resolver for jsp configureResolverForJSP(appCtx, runtimeConfig); }
@Override protected void initContainerIntegration( ServletContext servletContext, ExternalContext externalContext) { JspApplicationContext appCtx = getJspFactory().getJspApplicationContext(servletContext); appCtx.addELContextListener(new FacesELContextListener()); // check for user-specified ExpressionFactory ExpressionFactory expressionFactory = getUserDefinedExpressionFactory(externalContext); if (expressionFactory == null) { expressionFactory = appCtx.getExpressionFactory(); } RuntimeConfig runtimeConfig = buildConfiguration(servletContext, externalContext, expressionFactory); // configure the el resolver for jsp configureResolverForJSP(appCtx, runtimeConfig); }
@Override protected void initContainerIntegration( ServletContext servletContext, ExternalContext externalContext) { JspApplicationContext appCtx = getJspFactory().getJspApplicationContext(servletContext); appCtx.addELContextListener(new FacesELContextListener()); // check for user-specified ExpressionFactory ExpressionFactory expressionFactory = getUserDefinedExpressionFactory(externalContext); if (expressionFactory == null) { expressionFactory = appCtx.getExpressionFactory(); } RuntimeConfig runtimeConfig = buildConfiguration(servletContext, externalContext, expressionFactory); // configure the el resolver for jsp configureResolverForJSP(appCtx, runtimeConfig); }
jspApplicationContext.addELContextListener(new WeldELContextListener()); } catch (Exception e) { throw WeldServletLogger.LOG.errorLoadingWeldELContextListener(e);
jspApplicationContext.addELContextListener(new WeldELContextListener()); } catch (Exception e) { throw WeldServletLogger.LOG.errorLoadingWeldELContextListener(e);
jspApplicationContext.addELContextListener(new WeldELContextListener()); } catch (Exception e) { throw WeldServletLogger.LOG.errorLoadingWeldELContextListener(e);
jspAppContext.addELContextListener(elContextListener);
jspAppContext.addELContextListener(elContextListener);
jspAppContext.addELContextListener(elContextListener);
jspAppContext.addELContextListener(elContextListener);
jspAppContext.addELContextListener(elContextListener);