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/07/15 15:18:09 UTC
svn commit: r964415 - in /myfaces/extensions/cdi/trunk/jee-modules:
jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/
jsf-module/impl/src/main/resources/META-INF/
jsf20-module/impl/src/main/java/org/apache/...
Author: gpetracek
Date: Thu Jul 15 13:18:09 2010
New Revision: 964415
URL: http://svn.apache.org/viewvc?rev=964415&view=rev
Log:
EXTCDI-10 workaround as fallback
Added:
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleFactoryWrapper.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleWrapper.java
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleFactoryWrapper.java
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleWrapper.java
Modified:
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/faces-config.xml
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/beans.xml
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/faces-config.xml
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleFactoryWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleFactoryWrapper.java?rev=964415&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleFactoryWrapper.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleFactoryWrapper.java Thu Jul 15 13:18:09 2010
@@ -0,0 +1,51 @@
+/*
+ * 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 javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.lifecycle.Lifecycle;
+import java.util.Iterator;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class CodiLifecycleFactoryWrapper extends LifecycleFactory
+{
+ private final LifecycleFactory wrapped;
+
+ public CodiLifecycleFactoryWrapper(LifecycleFactory wrapped)
+ {
+ this.wrapped = wrapped;
+ }
+
+ public void addLifecycle(String s, Lifecycle lifecycle)
+ {
+ wrapped.addLifecycle(s, lifecycle);
+ }
+
+ public Lifecycle getLifecycle(String s)
+ {
+ return new CodiLifecycleWrapper(this.wrapped.getLifecycle(s), PhaseListenerExtension.consumePhaseListeners());
+ }
+
+ public Iterator<String> getLifecycleIds()
+ {
+ return wrapped.getLifecycleIds();
+ }
+}
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleWrapper.java?rev=964415&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleWrapper.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/CodiLifecycleWrapper.java Thu Jul 15 13:18:09 2010
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.faces.lifecycle.Lifecycle;
+import javax.faces.event.PhaseListener;
+import javax.faces.context.FacesContext;
+import javax.faces.FacesException;
+import java.util.List;
+
+/**
+ * intermediate workaround for
+ * {@link org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.JsfUtils#registerPhaseListener}
+ *
+ * @author Gerhard Petracek
+ */
+class CodiLifecycleWrapper extends Lifecycle
+{
+ private Lifecycle wrapped;
+
+ CodiLifecycleWrapper(Lifecycle wrapped, List<PhaseListener> phaseListeners)
+ {
+ this.wrapped = wrapped;
+
+ for(PhaseListener phaseListener : phaseListeners)
+ {
+ this.wrapped.addPhaseListener(phaseListener);
+ }
+ }
+
+ public void addPhaseListener(PhaseListener phaseListener)
+ {
+ wrapped.addPhaseListener(phaseListener);
+ }
+
+ public void execute(FacesContext facesContext)
+ throws FacesException
+ {
+ wrapped.execute(facesContext);
+ }
+
+ public PhaseListener[] getPhaseListeners()
+ {
+ return this.wrapped.getPhaseListeners();
+ }
+
+ public void removePhaseListener(PhaseListener phaseListener)
+ {
+ wrapped.removePhaseListener(phaseListener);
+ }
+
+ public void render(FacesContext facesContext)
+ throws FacesException
+ {
+ wrapped.render(facesContext);
+ }
+}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java?rev=964415&r1=964414&r2=964415&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/PhaseListenerExtension.java Thu Jul 15 13:18:09 2010
@@ -26,12 +26,17 @@ import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.faces.event.PhaseListener;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* @author Gerhard Petracek
*/
public class PhaseListenerExtension implements Extension
{
+ private static List<PhaseListener> phaseListeners = new CopyOnWriteArrayList<PhaseListener>();
+
public void filterJsfPhaseListeners(@Observes ProcessAnnotatedType processAnnotatedType)
{
if (processAnnotatedType.getAnnotatedType().isAnnotationPresent(JsfPhaseListener.class))
@@ -45,7 +50,16 @@ public class PhaseListenerExtension impl
private void addPhaseListener(ProcessAnnotatedType processAnnotatedType)
{
PhaseListener newPhaseListener = createPhaseListenerInstance(processAnnotatedType);
- JsfUtils.registerPhaseListener(newPhaseListener);
+
+ try
+ {
+ JsfUtils.registerPhaseListener(newPhaseListener);
+ }
+ catch (IllegalStateException e)
+ {
+ //current workaround some servers
+ phaseListeners.add(newPhaseListener);
+ }
}
private PhaseListener createPhaseListenerInstance(ProcessAnnotatedType processAnnotatedType)
@@ -53,4 +67,13 @@ public class PhaseListenerExtension impl
return ClassUtils.tryToInstantiateClass(
processAnnotatedType.getAnnotatedType().getJavaClass(), PhaseListener.class);
}
+
+ //current workaround some servers
+ public static List<PhaseListener> consumePhaseListeners()
+ {
+ List<PhaseListener> result = new ArrayList<PhaseListener>(phaseListeners.size());
+ result.addAll(phaseListeners);
+ phaseListeners.clear();
+ return result;
+ }
}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/faces-config.xml?rev=964415&r1=964414&r2=964415&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/faces-config.xml (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/faces-config.xml Thu Jul 15 13:18:09 2010
@@ -28,6 +28,7 @@
</application>
<factory>
+ <lifecycle-factory>org.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase.CodiLifecycleFactoryWrapper</lifecycle-factory>
<faces-context-factory>org.apache.myfaces.extensions.cdi.javaee.jsf.impl.request.CodiFacesContextFactory</faces-context-factory>
<render-kit-factory>org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.CodiRenderKitFactory</render-kit-factory>
</factory>
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleFactoryWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleFactoryWrapper.java?rev=964415&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleFactoryWrapper.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleFactoryWrapper.java Thu Jul 15 13:18:09 2010
@@ -0,0 +1,58 @@
+/*
+ * 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.jsf2.impl.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase.PhaseListenerExtension;
+
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.lifecycle.Lifecycle;
+import java.util.Iterator;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class CodiLifecycleFactoryWrapper extends LifecycleFactory
+{
+ private final LifecycleFactory wrapped;
+
+ public CodiLifecycleFactoryWrapper(LifecycleFactory wrapped)
+ {
+ this.wrapped = wrapped;
+ }
+
+ public void addLifecycle(String s, Lifecycle lifecycle)
+ {
+ wrapped.addLifecycle(s, lifecycle);
+ }
+
+ public Lifecycle getLifecycle(String s)
+ {
+ return new CodiLifecycleWrapper(this.wrapped.getLifecycle(s), PhaseListenerExtension.consumePhaseListeners());
+ }
+
+ public Iterator<String> getLifecycleIds()
+ {
+ return wrapped.getLifecycleIds();
+ }
+
+ public LifecycleFactory getWrapped()
+ {
+ return wrapped.getWrapped();
+ }
+}
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleWrapper.java?rev=964415&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleWrapper.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf2/impl/listener/phase/CodiLifecycleWrapper.java Thu Jul 15 13:18:09 2010
@@ -0,0 +1,73 @@
+/*
+ * 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.jsf2.impl.listener.phase;
+
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.event.PhaseListener;
+import javax.faces.context.FacesContext;
+import javax.faces.FacesException;
+import java.util.List;
+
+/**
+ * intermediate workaround for
+ * {@link org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.JsfUtils#registerPhaseListener}
+ *
+ * @author Gerhard Petracek
+ */
+class CodiLifecycleWrapper extends Lifecycle
+{
+ private Lifecycle wrapped;
+
+ CodiLifecycleWrapper(Lifecycle wrapped, List<PhaseListener> phaseListeners)
+ {
+ this.wrapped = wrapped;
+
+ for(PhaseListener phaseListener : phaseListeners)
+ {
+ this.wrapped.addPhaseListener(phaseListener);
+ }
+ }
+
+ public void addPhaseListener(PhaseListener phaseListener)
+ {
+ wrapped.addPhaseListener(phaseListener);
+ }
+
+ public void execute(FacesContext facesContext)
+ throws FacesException
+ {
+ wrapped.execute(facesContext);
+ }
+
+ public PhaseListener[] getPhaseListeners()
+ {
+ return wrapped.getPhaseListeners();
+ }
+
+ public void removePhaseListener(PhaseListener phaseListener)
+ {
+ wrapped.removePhaseListener(phaseListener);
+ }
+
+ public void render(FacesContext facesContext)
+ throws FacesException
+ {
+ wrapped.render(facesContext);
+ }
+}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/beans.xml?rev=964415&r1=964414&r2=964415&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/beans.xml (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/beans.xml Thu Jul 15 13:18:09 2010
@@ -4,6 +4,6 @@
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.jsf2.impl.listener.phase.ViewControllerInterceptor</class>
+ <class>org.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase.ViewControllerInterceptor</class>
</interceptors>
</beans>
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/faces-config.xml?rev=964415&r1=964414&r2=964415&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/faces-config.xml (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/resources/META-INF/faces-config.xml Thu Jul 15 13:18:09 2010
@@ -27,6 +27,7 @@
</application>
<factory>
+ <lifecycle-factory>org.apache.myfaces.extensions.cdi.javaee.jsf2.impl.listener.phase.CodiLifecycleFactoryWrapper</lifecycle-factory>
<faces-context-factory>org.apache.myfaces.extensions.cdi.javaee.jsf2.impl.request.CodiFacesContextFactory</faces-context-factory>
<render-kit-factory>org.apache.myfaces.extensions.cdi.javaee.jsf2.impl.scope.conversation.CodiRenderKitFactory</render-kit-factory>
</factory>