[jboss-cvs] JBossAS SVN: r93551 - in projects/webbeans-ri-int/trunk/webtier: src/main/java/org/jboss/webbeans/integration/webtier/jsp and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 15 13:37:59 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-09-15 13:37:59 -0400 (Tue, 15 Sep 2009)
New Revision: 93551

Added:
   projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/ForwardingJspApplicationContextImpl.java
Modified:
   projects/webbeans-ri-int/trunk/webtier/pom.xml
   projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/JspInitializationListener.java
Log:
Add JSP expression factory wrapping

Modified: projects/webbeans-ri-int/trunk/webtier/pom.xml
===================================================================
--- projects/webbeans-ri-int/trunk/webtier/pom.xml	2009-09-15 17:22:36 UTC (rev 93550)
+++ projects/webbeans-ri-int/trunk/webtier/pom.xml	2009-09-15 17:37:59 UTC (rev 93551)
@@ -34,9 +34,13 @@
     <dependency>
       <groupId>javax.servlet.jsp</groupId>
       <artifactId>jsp-api</artifactId>
-      <optional>true</optional>
     </dependency>
     
+    <dependency>
+      <groupId>jboss.web</groupId>
+      <artifactId>jbossweb</artifactId>
+    </dependency>
+    
     <!-- Test dependencies -->
     <dependency>
       <groupId>org.jboss.test</groupId>

Added: projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/ForwardingJspApplicationContextImpl.java
===================================================================
--- projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/ForwardingJspApplicationContextImpl.java	                        (rev 0)
+++ projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/ForwardingJspApplicationContextImpl.java	2009-09-15 17:37:59 UTC (rev 93551)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.integration.webtier.jsp;
+
+import javax.el.ELContextListener;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.servlet.jsp.JspContext;
+
+import org.apache.jasper.el.ELContextImpl;
+import org.apache.jasper.runtime.JspApplicationContextImpl;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class ForwardingJspApplicationContextImpl extends JspApplicationContextImpl
+{
+   
+   protected abstract JspApplicationContextImpl delegate();
+   
+   @Override
+   public void addELContextListener(ELContextListener listener)
+   {
+      delegate().addELContextListener(listener);
+   }
+   
+   @Override
+   public void addELResolver(ELResolver resolver) throws IllegalStateException
+   {
+      delegate().addELResolver(resolver);
+   }
+   
+   @Override
+   public ELContextImpl createELContext(JspContext arg0)
+   {
+      return delegate().createELContext(arg0);
+   }
+   
+   @Override
+   public ExpressionFactory getExpressionFactory()
+   {
+      return delegate().getExpressionFactory();
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      return this == obj || delegate().equals(obj);
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      return delegate().hashCode();
+   }
+   
+   @Override
+   public String toString()
+   {
+      return delegate().toString();
+   }
+
+}


Property changes on: projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/ForwardingJspApplicationContextImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/JspInitializationListener.java
===================================================================
--- projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/JspInitializationListener.java	2009-09-15 17:22:36 UTC (rev 93550)
+++ projects/webbeans-ri-int/trunk/webtier/src/main/java/org/jboss/webbeans/integration/webtier/jsp/JspInitializationListener.java	2009-09-15 17:37:59 UTC (rev 93551)
@@ -23,12 +23,14 @@
 package org.jboss.webbeans.integration.webtier.jsp;
 
 import javax.el.ELContextListener;
+import javax.el.ExpressionFactory;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.inject.Inject;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.jsp.JspApplicationContext;
 import javax.servlet.jsp.JspFactory;
 
+import org.apache.jasper.runtime.JspApplicationContextImpl;
 import org.jboss.webbeans.integration.webtier.util.Reflections;
 import org.jboss.webbeans.servlet.api.helpers.AbstractServletListener;
 
@@ -42,6 +44,31 @@
 public class JspInitializationListener extends AbstractServletListener
 {
    
+   private static class WebBeansJspApplicationContextImpl extends ForwardingJspApplicationContextImpl
+   {
+      private final JspApplicationContextImpl delegate;
+      private final ExpressionFactory expressionFactory;
+      
+      public WebBeansJspApplicationContextImpl(JspApplicationContextImpl delegate, ExpressionFactory expressionFactory)
+      {
+         this.delegate = delegate;
+         this.expressionFactory = expressionFactory;
+      }
+
+      @Override
+      protected JspApplicationContextImpl delegate()
+      {
+         return delegate;
+      }
+      
+      @Override
+      public ExpressionFactory getExpressionFactory()
+      {
+         return expressionFactory;
+      }
+      
+   }
+   
    @Inject 
    private BeanManager beanManager;
    
@@ -59,6 +86,10 @@
          jspAppContext.addELResolver(beanManager.getELResolver());
    
          jspAppContext.addELContextListener(Reflections.<ELContextListener>newInstance("org.jboss.webbeans.el.WebBeansELContextListener"));
+         
+         // Hack into JBoss Web/Catalina to replace the ExpressionFactory
+         JspApplicationContextImpl wrappedJspApplicationContextImpl = new WebBeansJspApplicationContextImpl(JspApplicationContextImpl.getInstance(sce.getServletContext()), beanManager.wrapExpressionFactory(jspAppContext.getExpressionFactory()));
+         sce.getServletContext().setAttribute(JspApplicationContextImpl.class.getName(), wrappedJspApplicationContextImpl);
       }
       // otherwise something went wrong starting WB, so don't register with JSP
    }




More information about the jboss-cvs-commits mailing list