You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/03/04 02:18:56 UTC
svn commit: r918807 - in
/myfaces/extensions/cdi/branches/branch_for_jsf_1_2: core/api/
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/
core/a...
Author: gpetracek
Date: Thu Mar 4 01:18:55 2010
New Revision: 918807
URL: http://svn.apache.org/viewvc?rev=918807&view=rev
Log:
EXTCDI-10 and EXTCDI-11 initial draft
Added:
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/ApplicationPhaseListener.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/View.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/DebugPhaseListener.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/javax.enterprise.inject.spi.Extension
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/PhaseId.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/AfterPhase.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/BeforePhase.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/JsfPhaseListener.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/AfterPhaseBinding.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/BeforePhaseBinding.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecyclePhaseListener.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java
Modified:
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/pom.xml
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/pom.xml
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/beans.xml
myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java
Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/pom.xml?rev=918807&r1=918806&r2=918807&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/pom.xml (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/pom.xml Thu Mar 4 01:18:55 2010
@@ -42,6 +42,13 @@
<version>1</version>
<scope>compile</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <version>1.0.0-beta</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<resources>
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/ApplicationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/ApplicationPhaseListener.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/ApplicationPhaseListener.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/ApplicationPhaseListener.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+@Stereotype
+
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface ApplicationPhaseListener
+{
+}
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/View.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/View.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/View.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/listener/phase/annotation/View.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation;
+
+import javax.interceptor.InterceptorBinding;
+import javax.enterprise.util.Nonbinding;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+@Documented
+public @interface View
+{
+ @Nonbinding
+ String[] value() default "*";
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.core.api.util;
+
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
+import java.net.URL;
+
+/**
+ * keep in sync with extval!
+ *
+ * @author Gerhard Petracek
+ */
+public class ClassUtils
+{
+ public static Class tryToLoadClassForName(String name)
+ {
+ try
+ {
+ return loadClassForName(name);
+ }
+ catch (ClassNotFoundException e)
+ {
+ //do nothing - it's just a try
+ return null;
+ }
+ }
+
+ public static Class loadClassForName(String name) throws ClassNotFoundException
+ {
+ try
+ {
+ // Try WebApp ClassLoader first
+ return Class.forName(name, false, // do not initialize for faster startup
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ // fallback: Try ClassLoader for ClassUtils (i.e. the myfaces.jar lib)
+ return Class.forName(name, false, // do not initialize for faster startup
+ ClassUtils.class.getClassLoader());
+ }
+ }
+
+ public static <T> T tryToInstantiateClass(Class<T> targetClass)
+ {
+ try
+ {
+ return targetClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ //do nothing - it was just a try
+ }
+ return null;
+ }
+
+ public static <T> T tryToInstantiateClass(Class targetClass, Class<T> type)
+ {
+ try
+ {
+ return (T)targetClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ //do nothing - it was just a try
+ }
+ return null;
+ }
+
+ public static Object tryToInstantiateClassForName(String className)
+ {
+ try
+ {
+ return instantiateClassForName(className);
+ }
+ catch (Throwable t)
+ {
+ //do nothing - it was just a try
+ }
+ return null;
+ }
+
+ public static Object instantiateClassForName(String className)
+ throws ClassNotFoundException, IllegalAccessException, InstantiationException
+ {
+ return loadClassForName(className).newInstance();
+ }
+
+ public static String getJarVersion(Class targetClass)
+ {
+ String classFilePath = targetClass.getCanonicalName().replace('.', '/') + ".class";
+ String manifestFilePath = "/META-INF/MANIFEST.MF";
+
+ String classLocation = targetClass.getResource(targetClass.getSimpleName() + ".class").toString();
+ String manifestFileLocation = classLocation
+ .substring(0, classLocation.indexOf(classFilePath) - 1) + manifestFilePath;
+
+ try
+ {
+ return new Manifest(new URL(manifestFileLocation).openStream())
+ .getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION);
+ }
+ catch (Throwable t)
+ {
+ return null;
+ }
+ }
+}
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/DebugPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/DebugPhaseListener.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/DebugPhaseListener.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/DebugPhaseListener.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.blank;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.JsfPhaseListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.event.PhaseListener;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+
+@JsfPhaseListener
+public class DebugPhaseListener implements PhaseListener
+{
+ private static final Log LOG = LogFactory.getLog(DebugPhaseListener.class);
+
+ private static final long serialVersionUID = -3128296286005877801L;
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ if(LOG.isDebugEnabled())
+ {
+ LOG.debug("before: " + phaseEvent.getPhaseId());
+ }
+ }
+
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ if(LOG.isDebugEnabled())
+ {
+ LOG.debug("after: " + phaseEvent.getPhaseId());
+ }
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+}
Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java?rev=918807&r1=918806&r2=918807&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java Thu Mar 4 01:18:55 2010
@@ -18,9 +18,15 @@
*/
package org.apache.myfaces.blank;
+import org.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation.View;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.AfterPhase;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.BeforePhase;
import org.apache.myfaces.extensions.cdi.javaee.jsf.api.project.stage.JsfProjectStage;
+import javax.enterprise.event.Observes;
import javax.enterprise.inject.Model;
+import javax.faces.event.PhaseEvent;
import javax.inject.Inject;
@Model
@@ -29,13 +35,50 @@
@Inject
private JsfProjectStage jsfProjectStage;
+ private String text;
+ private StringBuffer invokedListenerMethods = new StringBuffer();
+
+ public void preRenderView1(@Observes @BeforePhase(PhaseId.RENDER_RESPONSE) PhaseEvent event)
+ {
+ this.invokedListenerMethods.append("preRenderView1 in phase:").append(event.getPhaseId());
+ this.invokedListenerMethods.append(" | ");
+
+ this.text = "Hello MyFaces CODI";
+ }
+
+ @View("/helloMyFacesCodi.jsp")
+ public void preRenderView2(@Observes @BeforePhase(PhaseId.INVOKE_APPLICATION) PhaseEvent event)
+ {
+ this.invokedListenerMethods.append("preRenderView2 in phase:").append(event.getPhaseId());
+ this.invokedListenerMethods.append(" | ");
+ }
+
+ @View("/invalidPage.jsp")
+ public void preRenderView3(@Observes @AfterPhase(PhaseId.RESTORE_VIEW) PhaseEvent event)
+ {
+ this.invokedListenerMethods.append("preRenderView3 in phase:").append(event.getPhaseId());
+ this.invokedListenerMethods.append(" | ");
+ }
+
+ @View({"/invalidPage.jsp", "/helloMyFacesCodi.jsp"})
+ public void preRenderView4(@Observes @AfterPhase(PhaseId.RESTORE_VIEW) PhaseEvent event)
+ {
+ this.invokedListenerMethods.append("preRenderView4 in phase:").append(event.getPhaseId());
+ this.invokedListenerMethods.append(" | ");
+ }
+
public String getText()
{
- return "Hello MyFaces CODI";
+ return this.text;
}
public String getProjectStageName()
{
return this.jsfProjectStage.toString();
}
+
+ public String getInvokedListenerMethods()
+ {
+ return invokedListenerMethods.toString();
+ }
}
Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp?rev=918807&r1=918806&r2=918807&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp Thu Mar 4 01:18:55 2010
@@ -25,11 +25,16 @@
<f:view>
<h:form id="mainForm">
<h:panelGrid columns="2">
- <h:outputLabel value="Bean-value:"/>
- <h:outputText value="#{helloCodiBean.text}"/>
+ <h:outputLabel for="txtInfo" value="Bean-value:"/>
+ <h:outputText id="txtInfo" value="#{helloCodiBean.text}"/>
- <h:outputLabel value="Project stage:"/>
- <h:outputText value="#{helloCodiBean.projectStageName}"/>
+ <h:outputLabel for="txtProjctStage" value="Project stage:"/>
+ <h:outputText id="txtProjctStage" value="#{helloCodiBean.projectStageName}"/>
+
+ <h:outputLabel for="txtInvokedListenerMethods" value="Invoked:"/>
+ <h:outputText id="txtInvokedListenerMethods" value="#{helloCodiBean.invokedListenerMethods}"/>
+
+ <h:commandButton value="send"/>
</h:panelGrid>
</h:form>
</f:view>
Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/pom.xml?rev=918807&r1=918806&r2=918807&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/pom.xml (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/pom.xml Thu Mar 4 01:18:55 2010
@@ -41,6 +41,20 @@
<artifactId>myfaces-extcdi-core-api</artifactId>
<version>1.2.1-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <version>1.0.0-beta</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
@@ -53,6 +67,13 @@
<targetPath>/META-INF</targetPath>
</resource>
<resource>
+ <directory>src/main/config</directory>
+ <includes>
+ <include>javax.enterprise.inject.spi.Extension</include>
+ </includes>
+ <targetPath>/META-INF/services/</targetPath>
+ </resource>
+ <resource>
<directory>src/main/resources</directory>
<includes>
<include>LICENSE.txt</include>
Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/beans.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/beans.xml?rev=918807&r1=918806&r2=918807&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/beans.xml (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/beans.xml Thu Mar 4 01:18:55 2010
@@ -2,6 +2,11 @@
<beans xmlns="http://java.sun.com/xml/ns/javaee"
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/beans_1_0.xsd">
+
+ <interceptors>
+ <class>org.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase.ViewControllerInterceptor</class>
+ </interceptors>
+
<alternatives>
<class>org.apache.myfaces.extensions.cdi.javaee.jsf.impl.project.stage.JsfAwareProjectStageResolver</class>
</alternatives>
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/javax.enterprise.inject.spi.Extension
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/javax.enterprise.inject.spi.Extension?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/javax.enterprise.inject.spi.Extension (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/config/javax.enterprise.inject.spi.Extension Thu Mar 4 01:18:55 2010
@@ -0,0 +1,19 @@
+#####################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#####################################################################################
+org.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase.PhaseListenerExtension
\ No newline at end of file
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/PhaseId.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/PhaseId.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/PhaseId.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/PhaseId.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase;
+
+public enum PhaseId
+{
+ RESTORE_VIEW(javax.faces.event.PhaseId.RESTORE_VIEW),
+ APPLY_REQUEST_VALUES(javax.faces.event.PhaseId.APPLY_REQUEST_VALUES),
+ PROCESS_VALIDATIONS(javax.faces.event.PhaseId.PROCESS_VALIDATIONS),
+ UPDATE_MODEL_VALUES(javax.faces.event.PhaseId.UPDATE_MODEL_VALUES),
+ INVOKE_APPLICATION(javax.faces.event.PhaseId.INVOKE_APPLICATION),
+ RENDER_RESPONSE(javax.faces.event.PhaseId.RENDER_RESPONSE);
+
+ javax.faces.event.PhaseId phaseId;
+
+ PhaseId(javax.faces.event.PhaseId phaseId)
+ {
+ this.phaseId = phaseId;
+ }
+
+ public static PhaseId convert(javax.faces.event.PhaseId phaseId)
+ {
+ if(RESTORE_VIEW.getPhaseId().equals(phaseId))
+ {
+ return RESTORE_VIEW;
+ }
+
+ if(RENDER_RESPONSE.getPhaseId().equals(phaseId))
+ {
+ return RENDER_RESPONSE;
+ }
+
+ if(APPLY_REQUEST_VALUES.getPhaseId().equals(phaseId))
+ {
+ return APPLY_REQUEST_VALUES;
+ }
+
+ if(PROCESS_VALIDATIONS.getPhaseId().equals(phaseId))
+ {
+ return PROCESS_VALIDATIONS;
+ }
+
+ if(UPDATE_MODEL_VALUES.getPhaseId().equals(phaseId))
+ {
+ return UPDATE_MODEL_VALUES;
+ }
+
+ if(INVOKE_APPLICATION.getPhaseId().equals(phaseId))
+ {
+ return INVOKE_APPLICATION;
+ }
+
+ return null;
+ }
+
+ javax.faces.event.PhaseId getPhaseId()
+ {
+ return phaseId;
+ }
+}
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/AfterPhase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/AfterPhase.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/AfterPhase.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/AfterPhase.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.PARAMETER;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+@Target(PARAMETER)
+@Retention(RUNTIME)
+@Documented
+
+@Qualifier
+public @interface AfterPhase
+{
+ PhaseId value();
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/BeforePhase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/BeforePhase.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/BeforePhase.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/BeforePhase.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.PARAMETER;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+@Target(PARAMETER)
+@Retention(RUNTIME)
+@Documented
+
+@Qualifier
+public @interface BeforePhase
+{
+ PhaseId value();
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/JsfPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/JsfPhaseListener.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/JsfPhaseListener.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/annotation/JsfPhaseListener.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation;
+
+import org.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation.ApplicationPhaseListener;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+
+@Stereotype
+@ApplicationPhaseListener
+public @interface JsfPhaseListener
+{
+}
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/AfterPhaseBinding.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/AfterPhaseBinding.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/AfterPhaseBinding.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/AfterPhaseBinding.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.AfterPhase;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+abstract class AfterPhaseBinding extends AnnotationLiteral<AfterPhase> implements AfterPhase
+{
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/BeforePhaseBinding.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/BeforePhaseBinding.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/BeforePhaseBinding.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/BeforePhaseBinding.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.BeforePhase;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+abstract class BeforePhaseBinding extends AnnotationLiteral<BeforePhase> implements BeforePhase
+{
+}
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Event;
+import javax.faces.event.PhaseEvent;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.lang.annotation.Annotation;
+
+@ApplicationScoped
+@Named
+public class JsfRequestLifecycleBroadcaster
+{
+ static final String BEAN_NAME = "jsfRequestLifecycleBroadcaster";
+
+ @Inject
+ private Event<PhaseEvent> phaseEvent;
+
+ void broadcastBeforeEvent(PhaseEvent phaseEvent)
+ {
+ this.phaseEvent.select(createAnnotationLiteral(phaseEvent.getPhaseId(), true)).fire(phaseEvent);
+ }
+
+ void broadcastAfterEvent(PhaseEvent phaseEvent)
+ {
+ this.phaseEvent.select(createAnnotationLiteral(phaseEvent.getPhaseId(), false)).fire(phaseEvent);
+ }
+
+ private Annotation createAnnotationLiteral(javax.faces.event.PhaseId phaseId, boolean isBeforeEvent)
+ {
+ if(isBeforeEvent)
+ {
+ return createBeforeLiteral(phaseId);
+ }
+ return createAfterLiteral(phaseId);
+ }
+
+ private Annotation createBeforeLiteral(final javax.faces.event.PhaseId phaseId)
+ {
+ return new BeforePhaseBinding() {
+ private static final long serialVersionUID = 849645435335842723L;
+
+ public PhaseId value()
+ {
+ return PhaseId.convert(phaseId);
+ }
+ };
+ }
+
+ private Annotation createAfterLiteral(final javax.faces.event.PhaseId phaseId)
+ {
+ return new AfterPhaseBinding() {
+ private static final long serialVersionUID = 490037768660184656L;
+
+ public PhaseId value()
+ {
+ return PhaseId.convert(phaseId);
+ }
+ };
+ }
+}
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecyclePhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecyclePhaseListener.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecyclePhaseListener.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecyclePhaseListener.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.JsfPhaseListener;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+@JsfPhaseListener
+public class JsfRequestLifecyclePhaseListener implements PhaseListener
+{
+ private static final long serialVersionUID = -4351903831660165998L;
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ resolveBroadcaster().broadcastBeforeEvent(phaseEvent);
+ }
+
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ resolveBroadcaster().broadcastAfterEvent(phaseEvent);
+ }
+
+ private JsfRequestLifecycleBroadcaster resolveBroadcaster()
+ {
+ //cdi has to inject the event - TODO refactor it
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return (JsfRequestLifecycleBroadcaster) facesContext.getApplication().getELResolver()
+ .getValue(facesContext.getELContext(), null, JsfRequestLifecycleBroadcaster.BEAN_NAME);
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.JsfPhaseListener;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.JsfUtils;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.faces.event.PhaseListener;
+
+public class PhaseListenerExtension implements Extension
+{
+ public void filterJsfPhaseListeners(@Observes ProcessAnnotatedType processAnnotatedType)
+ {
+ if (processAnnotatedType.getAnnotatedType().isAnnotationPresent(JsfPhaseListener.class))
+ {
+ addPhaseListener(processAnnotatedType);
+
+ processAnnotatedType.veto();
+ }
+ }
+
+ private void addPhaseListener(ProcessAnnotatedType processAnnotatedType)
+ {
+ PhaseListener newPhaseListener = createPhaseListenerInstance(processAnnotatedType);
+ JsfUtils.registerPhaseListener(newPhaseListener);
+ }
+
+ private PhaseListener createPhaseListenerInstance(ProcessAnnotatedType processAnnotatedType)
+ {
+ return ClassUtils.tryToInstantiateClass(
+ processAnnotatedType.getAnnotatedType().getJavaClass(), PhaseListener.class);
+ }
+}
Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java?rev=918807&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java Thu Mar 4 01:18:55 2010
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation.View;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.faces.context.FacesContext;
+
+@View
+@Interceptor
+public class ViewControllerInterceptor
+{
+ @AroundInvoke
+ public Object filterPhaseListenerMethods(InvocationContext invocationContext) throws Exception
+ {
+ Object result = null;
+ try
+ {
+ if(invokeListenerMethod(invocationContext))
+ {
+ result = invocationContext.proceed();
+ }
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+
+ return result;
+ }
+
+ private boolean invokeListenerMethod(InvocationContext invocationContext)
+ {
+ if(!invocationContext.getMethod().isAnnotationPresent(View.class))
+ {
+ return true;
+ }
+
+ View view = getViewAnnotation(invocationContext);
+
+ if(view.value().length == 1 && "*".equals(view.value()[0]))
+ {
+ return true;
+ }
+
+ String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
+ return isMethodBoundToView(view.value(), viewId);
+ }
+
+ private View getViewAnnotation(InvocationContext invocationContext)
+ {
+ View view;
+ if(invocationContext.getMethod().isAnnotationPresent(View.class))
+ {
+ view = invocationContext.getMethod().getAnnotation(View.class);
+ }
+ else
+ {
+ view = invocationContext.getMethod().getDeclaringClass().getAnnotation(View.class);
+ }
+ return view;
+ }
+
+ private boolean isMethodBoundToView(String[] viewIds, String viewId)
+ {
+ for(String current : viewIds)
+ {
+ if(current.equals(viewId))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java?rev=918807&r1=918806&r2=918807&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java Thu Mar 4 01:18:55 2010
@@ -21,7 +21,17 @@
import org.apache.myfaces.extensions.cdi.javaee.jsf.api.WebXmlParameterNames;
import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.FactoryFinder;
+import java.util.Iterator;
+/**
+ * keep in sync with extval!
+ *
+ * @author Gerhard Petracek
+ */
public class JsfUtils
{
public static String getProjectStageName()
@@ -37,4 +47,19 @@
return null;
}
}
+
+ public static void registerPhaseListener(PhaseListener phaseListener)
+ {
+ LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+
+ String currentId;
+ Lifecycle currentLifecycle;
+ Iterator lifecycleIds = lifecycleFactory.getLifecycleIds();
+ while (lifecycleIds.hasNext())
+ {
+ currentId = (String) lifecycleIds.next();
+ currentLifecycle = lifecycleFactory.getLifecycle(currentId);
+ currentLifecycle.addPhaseListener(phaseListener);
+ }
+ }
}