[webbeans-commits] Webbeans SVN: r3759 - in extensions/trunk: logger and 10 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Sep 23 07:17:06 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-09-23 07:17:06 -0400 (Wed, 23 Sep 2009)
New Revision: 3759
Added:
extensions/trunk/pom.xml
extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/
extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplication.java
extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplicationFactory.java
extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplication.java
extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplicationFactory.java
extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/ForwardingJspApplicationContextImpl.java
extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/JspInitialization.java
extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/util/
extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java
Modified:
extensions/trunk/logger/
extensions/trunk/servlet/build/pom.xml
extensions/trunk/servlet/int/pom.xml
extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java
extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Reflections.java
extensions/trunk/servlet/int/src/main/resources/META-INF/
extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml
extensions/trunk/servlet/pom.xml
extensions/trunk/servlet/support/pom.xml
extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/WebBeansLifecycleListener.java
Log:
add JSP and JSF support to servlet/tomcat
Property changes on: extensions/trunk/logger
___________________________________________________________________
Name: svn:ignore
- target
.project
.classpath
temp-testng-customsuite.xml
.settings
test-output
+
target
.project
.classpath
temp-testng-customsuite.xml
.settings
test-output
bin
Added: extensions/trunk/pom.xml
===================================================================
--- extensions/trunk/pom.xml (rev 0)
+++ extensions/trunk/pom.xml 2009-09-23 11:17:06 UTC (rev 3759)
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-extensions-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-version-matrix</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <name>Web Beans Extensions aggregator</name>
+ <url>http://www.seamframework.org/WebBeans</url>
+
+ <modules>
+ <module>servlet</module>
+ <module>se</module>
+ <module>logger</module>
+ <module>wicket</module>
+ </modules>
+
+</project>
Modified: extensions/trunk/servlet/build/pom.xml
===================================================================
--- extensions/trunk/servlet/build/pom.xml 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/build/pom.xml 2009-09-23 11:17:06 UTC (rev 3759)
@@ -67,6 +67,8 @@
<exclude>org.apache.tomcat:servlet-api</exclude>
<exclude>org.apache.tomcat:juli</exclude>
<exclude>org.apache.tomcat:annotations-api</exclude>
+ <exclude>javax.faces:jsf-api</exclude>
+ <exclude>javax.el:el-api</exclude>
</excludes>
</artifactSet>
</configuration>
Modified: extensions/trunk/servlet/int/pom.xml
===================================================================
--- extensions/trunk/servlet/int/pom.xml 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/int/pom.xml 2009-09-23 11:17:06 UTC (rev 3759)
@@ -57,6 +57,17 @@
</exclusions>
</dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
</project>
Modified: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -16,7 +16,10 @@
*/
package org.jboss.webbeans.environment.servlet;
+import javax.el.ELContextListener;
import javax.servlet.ServletContextEvent;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspFactory;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
import org.jboss.webbeans.bootstrap.api.Environments;
@@ -46,6 +49,7 @@
private static final String BOOTSTRAP_IMPL_CLASS_NAME = "org.jboss.webbeans.bootstrap.WebBeansBootstrap";
private static final String WEB_BEANS_LISTENER_CLASS_NAME = "org.jboss.webbeans.servlet.WebBeansListener";
private static final String APPLICATION_BEAN_STORE_ATTRIBUTE_NAME = Listener.class.getName() + ".applicationBeanStore";
+ private static final String EXPRESSION_FACTORY_NAME = "org.jboss.webbeans.el.ExpressionFactory";
private final transient Bootstrap bootstrap;
private final transient ServletListener webBeansListener;
@@ -55,17 +59,17 @@
{
try
{
- bootstrap = Reflections.newInstance(BOOTSTRAP_IMPL_CLASS_NAME, Bootstrap.class);
+ bootstrap = Reflections.newInstance(BOOTSTRAP_IMPL_CLASS_NAME);
}
- catch (Exception e)
+ catch (IllegalArgumentException e)
{
throw new IllegalStateException("Error loading Web Beans bootstrap, check that Web Beans is on the classpath", e);
}
try
{
- webBeansListener = Reflections.newInstance(WEB_BEANS_LISTENER_CLASS_NAME, ServletListener.class);
+ webBeansListener = Reflections.newInstance(WEB_BEANS_LISTENER_CLASS_NAME);
}
- catch (Exception e)
+ catch (IllegalArgumentException e)
{
throw new IllegalStateException("Error loading Web Beans listener, check that Web Beans is on the classpath", e);
}
@@ -105,25 +109,20 @@
boolean tomcat = true;
try
{
- Reflections.loadClass("org.apache.AnnotationProcessor", Object.class);
+ Reflections.classForName("org.apache.AnnotationProcessor");
}
- catch (ClassNotFoundException e)
+ catch (IllegalArgumentException e)
{
log.info("JSR-299 injection will not be available in Servlets, Filters etc. This facility is only available in Tomcat");
tomcat = false;
}
- catch (NoClassDefFoundError e)
- {
- log.info("JSR-299 injection will not be available in Servlets, Filters etc. This facility is only available in Tomcat");
- tomcat = false;
- }
if (tomcat)
{
// Try pushing a Tomcat AnnotationProcessor into the servlet context
try
{
- Class<?> clazz = Reflections.loadClass(WebBeansAnnotationProcessor.class.getName(), Object.class);
+ Class<?> clazz = Reflections.classForName(WebBeansAnnotationProcessor.class.getName());
Object annotationProcessor = clazz.getConstructor(WebBeansManager.class).newInstance(manager);
sce.getServletContext().setAttribute(WebBeansAnnotationProcessor.class.getName(), annotationProcessor);
}
@@ -133,7 +132,20 @@
}
}
+ // Push the manager into the servlet context so we can access in JSF
+ sce.getServletContext().setAttribute(WebBeansManager.class.getName(), manager);
+ JspApplicationContext jspApplicationContext = JspFactory.getDefaultFactory().getJspApplicationContext(sce.getServletContext());
+
+ // Register the ELResolver with JSP
+ jspApplicationContext.addELResolver(manager.getELResolver());
+
+ // Register ELContextListener with JSP
+ jspApplicationContext.addELContextListener(Reflections.<ELContextListener>newInstance("org.jboss.webbeans.el.WebBeansELContextListener"));
+
+ // Push the wrapped expression factory into the servlet context so that Tomcat or Jetty can hook it in using a container code
+ sce.getServletContext().setAttribute(EXPRESSION_FACTORY_NAME, manager.wrapExpressionFactory(jspApplicationContext.getExpressionFactory()));
+
bootstrap.deployBeans().validateBeans().endInitialization();
super.contextInitialized(sce);
}
Added: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplication.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplication.java (rev 0)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplication.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -0,0 +1,457 @@
+/*
+ * 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.environment.servlet.jsf;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import javax.el.ELContextListener;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.ProjectStage;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.Behavior;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.ActionListener;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import javax.faces.validator.Validator;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class ForwardingApplication extends Application
+{
+
+ protected abstract Application delegate();
+
+ public void addBehavior(String behaviorId, String behaviorClass)
+ {
+ delegate().addBehavior(behaviorId, behaviorClass);
+ }
+
+ public void addComponent(String componentType, String componentClass)
+ {
+ delegate().addComponent(componentType, componentClass);
+ }
+
+ public void addConverter(String converterId, String converterClass)
+ {
+ delegate().addConverter(converterId, converterClass);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void addConverter(Class targetClass, String converterClass)
+ {
+ delegate().addConverter(targetClass, converterClass);
+ }
+
+ @Override
+ public void addDefaultValidatorId(String validatorId)
+ {
+ delegate().addDefaultValidatorId(validatorId);
+ }
+
+ @Override
+ public void addELContextListener(ELContextListener listener)
+ {
+ delegate().addELContextListener(listener);
+ }
+
+ @Override
+ public void addELResolver(ELResolver resolver)
+ {
+ delegate().addELResolver(resolver);
+ }
+
+ @Override
+ public void addValidator(String validatorId, String validatorClass)
+ {
+ delegate().addValidator(validatorId, validatorClass);
+ }
+
+ @Override
+ public Behavior createBehavior(String behaviorId) throws FacesException
+ {
+ return delegate().createBehavior(behaviorId);
+ }
+
+ @Override
+ public UIComponent createComponent(FacesContext context, Resource componentResource)
+ {
+ return delegate().createComponent(context, componentResource);
+ }
+
+ @Override
+ public UIComponent createComponent(FacesContext context, String componentType, String rendererType)
+ {
+ return delegate().createComponent(context, componentType, rendererType);
+ }
+
+ @Override
+ public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType) throws FacesException
+ {
+ return delegate().createComponent(componentExpression, context, componentType);
+ }
+
+ @Override
+ public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType, String rendererType)
+ {
+ return delegate().createComponent(componentExpression, context, componentType, rendererType);
+ }
+
+ @Override
+ public UIComponent createComponent(String componentType) throws FacesException
+ {
+ return delegate().createComponent(componentType);
+ }
+
+ @Override
+ @Deprecated
+ public UIComponent createComponent(ValueBinding componentBinding, FacesContext context, String componentType) throws FacesException
+ {
+ return delegate().createComponent(componentBinding, context, componentType);
+ }
+
+ @Override
+ public Converter createConverter(String converterId)
+ {
+ return delegate().createConverter(converterId);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Converter createConverter(Class targetClass)
+ {
+ return delegate().createConverter(targetClass);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Deprecated
+ @Override
+ public MethodBinding createMethodBinding(String ref, Class[] params) throws ReferenceSyntaxException
+ {
+ return delegate().createMethodBinding(ref, params);
+ }
+
+ @Override
+ public Validator createValidator(String validatorId) throws FacesException
+ {
+ return delegate().createValidator(validatorId);
+ }
+
+ @Override
+ @Deprecated
+ public ValueBinding createValueBinding(String ref) throws ReferenceSyntaxException
+ {
+ return delegate().createValueBinding(ref);
+ }
+
+ @Override
+ public <T> T evaluateExpressionGet(FacesContext context, String expression, Class<? extends T> expectedType) throws ELException
+ {
+ return delegate().evaluateExpressionGet(context, expression, expectedType);
+ }
+
+ @Override
+ public ActionListener getActionListener()
+ {
+ return delegate().getActionListener();
+ }
+
+ @Override
+ public Iterator<String> getBehaviorIds()
+ {
+ return delegate().getBehaviorIds();
+ }
+
+
+
+ @Override
+ public Iterator<String> getComponentTypes()
+ {
+ return delegate().getComponentTypes();
+ }
+
+ @Override
+ public Iterator<String> getConverterIds()
+ {
+ return delegate().getConverterIds();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterator<Class<?>> getConverterTypes()
+ {
+ return delegate().getConverterTypes();
+ }
+
+ @Override
+ public Locale getDefaultLocale()
+ {
+ return delegate().getDefaultLocale();
+ }
+
+ @Override
+ public String getDefaultRenderKitId()
+ {
+ return delegate().getDefaultRenderKitId();
+ }
+
+ @Override
+ public Map<String, String> getDefaultValidatorInfo()
+ {
+ return delegate().getDefaultValidatorInfo();
+ }
+
+ @Override
+ public ELContextListener[] getELContextListeners()
+ {
+ return delegate().getELContextListeners();
+ }
+
+ @Override
+ public ELResolver getELResolver()
+ {
+ return delegate().getELResolver();
+ }
+
+ @Override
+ public ExpressionFactory getExpressionFactory()
+ {
+ return delegate().getExpressionFactory();
+ }
+
+ @Override
+ public String getMessageBundle()
+ {
+ return delegate().getMessageBundle();
+ }
+
+ @Override
+ public NavigationHandler getNavigationHandler()
+ {
+ return delegate().getNavigationHandler();
+ }
+
+ @Override
+ @Deprecated
+ public PropertyResolver getPropertyResolver()
+ {
+ return delegate().getPropertyResolver();
+ }
+
+ @Override
+ public ProjectStage getProjectStage()
+ {
+ return delegate().getProjectStage();
+ }
+
+ @Override
+ public ResourceBundle getResourceBundle(FacesContext ctx, String name)
+ {
+ return delegate().getResourceBundle(ctx, name);
+ }
+
+ @Override
+ public ResourceHandler getResourceHandler()
+ {
+ return delegate().getResourceHandler();
+ }
+
+ @Override
+ public StateManager getStateManager()
+ {
+ return delegate().getStateManager();
+ }
+
+ @Override
+ public Iterator<Locale> getSupportedLocales()
+ {
+ return delegate().getSupportedLocales();
+ }
+
+ @Override
+ public Iterator<String> getValidatorIds()
+ {
+ return delegate().getValidatorIds();
+ }
+
+ @Override
+ @Deprecated
+ public VariableResolver getVariableResolver()
+ {
+ return delegate().getVariableResolver();
+ }
+
+ @Override
+ public ViewHandler getViewHandler()
+ {
+ return delegate().getViewHandler();
+ }
+
+ @Override
+ public void publishEvent(FacesContext context, Class<? extends SystemEvent> systemEventClass, Class<?> sourceBaseType, Object source)
+ {
+ delegate().publishEvent(context, systemEventClass, sourceBaseType, source);
+ }
+
+ @Override
+ public void publishEvent(FacesContext context, Class<? extends SystemEvent> systemEventClass, Object source)
+ {
+ delegate().publishEvent(context, systemEventClass, source);
+ }
+
+ @Override
+ public void removeELContextListener(ELContextListener listener)
+ {
+ delegate().removeELContextListener(listener);
+ }
+
+ @Override
+ public void setActionListener(ActionListener listener)
+ {
+ delegate().setActionListener(listener);
+ }
+
+ @Override
+ public void setDefaultLocale(Locale locale)
+ {
+ delegate().setDefaultLocale(locale);
+ }
+
+ @Override
+ public void setDefaultRenderKitId(String renderKitId)
+ {
+ delegate().setDefaultRenderKitId(renderKitId);
+ }
+
+ @Override
+ public void setMessageBundle(String bundle)
+ {
+ delegate().setMessageBundle(bundle);
+ }
+
+ @Override
+ public void setNavigationHandler(NavigationHandler handler)
+ {
+ delegate().setNavigationHandler(handler);
+ }
+
+
+ @Override
+ @Deprecated
+ public void setPropertyResolver(PropertyResolver resolver)
+ {
+ delegate().setPropertyResolver(resolver);
+ }
+
+ @Override
+ public void setResourceHandler(ResourceHandler resourceHandler)
+ {
+ delegate().setResourceHandler(resourceHandler);
+ }
+
+ @Override
+ public void setStateManager(StateManager manager)
+ {
+ delegate().setStateManager(manager);
+ }
+
+ @Override
+ public void setSupportedLocales(Collection<Locale> locales)
+ {
+ delegate().setSupportedLocales(locales);
+
+ }
+
+ @Override
+ @Deprecated
+ public void setVariableResolver(VariableResolver resolver)
+ {
+ delegate().setVariableResolver(resolver);
+ }
+
+ @Override
+ public void setViewHandler(ViewHandler handler)
+ {
+ delegate().setViewHandler(handler);
+ }
+
+ @Override
+ public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass, Class<?> sourceClass, SystemEventListener listener)
+ {
+ delegate().subscribeToEvent(systemEventClass, sourceClass, listener);
+ }
+
+ @Override
+ public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass, SystemEventListener listener)
+ {
+ delegate().subscribeToEvent(systemEventClass, listener);
+ }
+
+ @Override
+ public void unsubscribeFromEvent(Class<? extends SystemEvent> systemEventClass, Class<?> sourceClass, SystemEventListener listener)
+ {
+ delegate().unsubscribeFromEvent(systemEventClass, sourceClass, listener);
+ }
+
+ @Override
+ public void unsubscribeFromEvent(Class<? extends SystemEvent> systemEventClass, SystemEventListener listener)
+ {
+ delegate().unsubscribeFromEvent(systemEventClass, listener);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate().equals(obj);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate().toString();
+ }
+
+}
Property changes on: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplication.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplicationFactory.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplicationFactory.java (rev 0)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplicationFactory.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -0,0 +1,61 @@
+/*
+ * 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.environment.servlet.jsf;
+
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class ForwardingApplicationFactory extends ApplicationFactory
+{
+
+ protected abstract ApplicationFactory delegate();
+
+ @Override
+ public Application getApplication()
+ {
+ return delegate().getApplication();
+ }
+
+ @Override
+ public void setApplication(Application application)
+ {
+ delegate().setApplication(application);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate().equals(obj);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate().toString();
+ }
+
+}
Property changes on: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/ForwardingApplicationFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplication.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplication.java (rev 0)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplication.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -0,0 +1,97 @@
+/*
+ * 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.environment.servlet.jsf;
+
+import javax.el.ELContextListener;
+import javax.el.ExpressionFactory;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+
+import org.jboss.webbeans.environment.servlet.util.Reflections;
+import org.jboss.webbeans.manager.api.WebBeansManager;
+
+/**
+ * @author pmuir
+ *
+ */
+public class WebBeansApplication extends ForwardingApplication
+{
+
+ private static final ELContextListener[] EMPTY_LISTENERS = {};
+
+ private final Application application;
+ private ExpressionFactory expressionFactory;
+
+ public WebBeansApplication(Application application)
+ {
+ this.application = application;
+ BeanManager beanManager = getBeanManager();
+ if (beanManager != null)
+ {
+ application.addELContextListener(Reflections.<ELContextListener>newInstance("org.jboss.webbeans.el.WebBeansELContextListener"));
+ application.addELResolver(beanManager.getELResolver());
+ }
+ }
+
+ @Override
+ protected Application delegate()
+ {
+ return application;
+ }
+
+ @Override
+ public ExpressionFactory getExpressionFactory()
+ {
+ // Application is multi-threaded, but no need to guard against races (re-
+ // creating the cached expression factory doesn't matter) or liveness
+ // (the value read by all threads will be the same)
+ // We have to do this lazily as Mojarra hasn't set the ExpressionFactory
+ // when the object is created
+ if (this.expressionFactory == null)
+ {
+ BeanManager beanManager = getBeanManager();
+ if (beanManager != null)
+ {
+ this.expressionFactory = beanManager.wrapExpressionFactory(delegate().getExpressionFactory());
+ }
+ else
+ {
+ // WB failed to initialize properly
+ this.expressionFactory = delegate().getExpressionFactory();
+ }
+ }
+ return expressionFactory;
+ }
+
+ private static WebBeansManager getBeanManager()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (!(facesContext.getExternalContext().getContext() instanceof ServletContext))
+ {
+ throw new IllegalStateException("Not in a servlet environment!");
+ }
+ ServletContext ctx = (ServletContext) facesContext.getExternalContext().getContext();
+ if (ctx.getAttribute(WebBeansManager.class.getName()) == null)
+ {
+ throw new IllegalStateException("BeanManager has not been pushed into the ServletContext");
+ }
+ return (WebBeansManager) ctx.getAttribute(WebBeansManager.class.getName());
+ }
+
+}
Property changes on: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplication.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplicationFactory.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplicationFactory.java (rev 0)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplicationFactory.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -0,0 +1,55 @@
+/*
+ * 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.environment.servlet.jsf;
+
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+
+
+/**
+ * @author pmuir
+ *
+ */
+public class WebBeansApplicationFactory extends ForwardingApplicationFactory
+{
+
+ private final ApplicationFactory applicationFactory;
+
+ private Application application;
+
+ public WebBeansApplicationFactory(ApplicationFactory applicationFactory)
+ {
+ this.applicationFactory = applicationFactory;
+ }
+
+ @Override
+ protected ApplicationFactory delegate()
+ {
+ return applicationFactory;
+ }
+
+ @Override
+ public Application getApplication()
+ {
+ if (application == null)
+ {
+ application = new WebBeansApplication(delegate().getApplication());
+ }
+ return application;
+ }
+
+}
Property changes on: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/jsf/WebBeansApplicationFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Reflections.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Reflections.java 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Reflections.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.environment.servlet.util;
+
/**
* Reflection utilities
*
@@ -27,24 +28,57 @@
private Reflections()
{
- // TODO Auto-generated constructor stub
}
- public static <T> T newInstance(String className, Class<T> expectedType) throws InstantiationException, IllegalAccessException, ClassNotFoundException
+ public static <T> T newInstance(String className)
{
- return loadClass(className, expectedType).newInstance();
+ try
+ {
+ return Reflections.<T>classForName(className).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new IllegalArgumentException("Cannot instantiate instance of " + className + " with no-argument constructor", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new IllegalArgumentException("Cannot instantiate instance of " + className + " with no-argument constructor", e);
+ }
}
- public static <T> Class<? extends T> loadClass(String className, Class<T> expectedType) throws ClassNotFoundException
+
+ public static <T> Class<T> classForName(String name)
{
- if (Thread.currentThread().getContextClassLoader() != null)
+
+ try
{
- return Thread.currentThread().getContextClassLoader().loadClass(className).asSubclass(expectedType);
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ Class<?> c = Thread.currentThread().getContextClassLoader().loadClass(name);
+
+ @SuppressWarnings("unchecked")
+ Class<T> clazz = (Class<T>) c;
+
+ return clazz;
+ }
+ else
+ {
+ Class<?> c = Class.forName(name);
+
+ @SuppressWarnings("unchecked")
+ Class<T> clazz = (Class<T>) c;
+
+ return clazz;
+ }
}
- else
+ catch (ClassNotFoundException e)
{
- return Class.forName(className).asSubclass(expectedType);
+ throw new IllegalArgumentException("Cannot load class for " + name, e);
}
+ catch (NoClassDefFoundError e)
+ {
+ throw new IllegalArgumentException("Cannot load class for " + name, e);
+ }
}
public static ClassLoader getClassLoader()
Property changes on: extensions/trunk/servlet/int/src/main/resources/META-INF
___________________________________________________________________
Name: svn:ignore
+ .faces-config.xml.jsfdia
Modified: extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml
===================================================================
--- extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml 2009-09-23 11:17:06 UTC (rev 3759)
@@ -4,12 +4,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+ <factory>
+ <application-factory>org.jboss.webbeans.environment.servlet.jsf.WebBeansApplicationFactory</application-factory>
+ </factory>
+
<application>
- <el-resolver>org.jboss.webbeans.el.WebBeansELResolver</el-resolver>
<view-handler>org.jboss.webbeans.jsf.ConversationAwareViewHandler</view-handler>
</application>
- <lifecycle>
- <phase-listener>org.jboss.webbeans.jsf.WebBeansPhaseListener</phase-listener>
- </lifecycle>
+
+ <lifecycle>
+ <phase-listener>org.jboss.webbeans.jsf.WebBeansPhaseListener</phase-listener>
+ </lifecycle>
</faces-config>
Modified: extensions/trunk/servlet/pom.xml
===================================================================
--- extensions/trunk/servlet/pom.xml 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/pom.xml 2009-09-23 11:17:06 UTC (rev 3759)
@@ -100,7 +100,11 @@
<dependencyManagement>
<dependencies>
-
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.0-RC</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Modified: extensions/trunk/servlet/support/pom.xml
===================================================================
--- extensions/trunk/servlet/support/pom.xml 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/support/pom.xml 2009-09-23 11:17:06 UTC (rev 3759)
@@ -43,7 +43,19 @@
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>jasper</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
Added: extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/ForwardingJspApplicationContextImpl.java
===================================================================
--- extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/ForwardingJspApplicationContextImpl.java (rev 0)
+++ extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/ForwardingJspApplicationContextImpl.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -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.environment.tomcat;
+
+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: extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/ForwardingJspApplicationContextImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/JspInitialization.java
===================================================================
--- extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/JspInitialization.java (rev 0)
+++ extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/JspInitialization.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -0,0 +1,86 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Use is subject to license terms.
+ *
+ * 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.environment.tomcat;
+
+import javax.el.ELContextListener;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.servlet.ServletContext;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspFactory;
+
+import org.apache.jasper.runtime.JspApplicationContextImpl;
+import org.jboss.webbeans.environment.tomcat.util.Reflections;
+
+/**
+ * The Web Beans JSP initialization listener
+ *
+ *
+ * @author Pete Muir
+ *
+ */
+public class JspInitialization
+{
+
+ private static final String EXPRESSION_FACTORY_NAME = "org.jboss.webbeans.el.ExpressionFactory";
+
+ 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;
+ }
+
+ }
+
+ public void initialize(ServletContext context)
+ {
+ // get JspApplicationContext.
+ JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext(context);
+
+ if (context.getAttribute(EXPRESSION_FACTORY_NAME) != null)
+ {
+ ExpressionFactory expressionFactory = (ExpressionFactory) context.getAttribute(EXPRESSION_FACTORY_NAME);
+ // Hack into JBoss Web/Catalina to replace the ExpressionFactory
+ JspApplicationContextImpl wrappedJspApplicationContextImpl = new WebBeansJspApplicationContextImpl(JspApplicationContextImpl.getInstance(context), expressionFactory);
+ context.setAttribute(JspApplicationContextImpl.class.getName(), wrappedJspApplicationContextImpl);
+ }
+ // otherwise something went wrong starting WB, so don't register with JSP
+ }
+}
Property changes on: extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/JspInitialization.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/WebBeansLifecycleListener.java
===================================================================
--- extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/WebBeansLifecycleListener.java 2009-09-23 11:12:01 UTC (rev 3758)
+++ extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/WebBeansLifecycleListener.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -30,6 +30,8 @@
{
StandardContext context = (StandardContext) event.getLifecycle();
final ServletContext servletContext = context.getServletContext();
+
+ // Initialize servlet injection
final AnnotationProcessor originalAnnotationProcessor = context.getAnnotationProcessor();
context.setAnnotationProcessor(new ForwardingAnnotationProcessor()
{
Added: extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java
===================================================================
--- extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java (rev 0)
+++ extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java 2009-09-23 11:17:06 UTC (rev 3759)
@@ -0,0 +1,79 @@
+/*
+ * 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.environment.tomcat.util;
+
+
+/**
+ * @author pmuir
+ *
+ */
+public class Reflections
+{
+
+
+ public static <T> T newInstance(String className)
+ {
+ try
+ {
+ return Reflections.<T>classForName(className).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new IllegalArgumentException("Cannot instantiate instance of " + className + " with no-argument constructor", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new IllegalArgumentException("Cannot instantiate instance of " + className + " with no-argument constructor", e);
+ }
+ }
+
+
+ public static <T> Class<T> classForName(String name)
+ {
+
+ try
+ {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ Class<?> c = Thread.currentThread().getContextClassLoader().loadClass(name);
+
+ @SuppressWarnings("unchecked")
+ Class<T> clazz = (Class<T>) c;
+
+ return clazz;
+ }
+ else
+ {
+ Class<?> c = Class.forName(name);
+
+ @SuppressWarnings("unchecked")
+ Class<T> clazz = (Class<T>) c;
+
+ return clazz;
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalArgumentException("Cannot load class for " + name, e);
+ }
+ catch (NoClassDefFoundError e)
+ {
+ throw new IllegalArgumentException("Cannot load class for " + name, e);
+ }
+ }
+
+}
Property changes on: extensions/trunk/servlet/support/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list