You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/10/10 15:25:57 UTC
svn commit: r1180947 - in /myfaces/extensions/cdi/trunk:
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/
jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/
jee-...
Author: struberg
Date: Mon Oct 10 13:25:56 2011
New Revision: 1180947
URL: http://svn.apache.org/viewvc?rev=1180947&view=rev
Log:
EXTCDI-232 introduce @RestScoped
--Thus line, and those below, will be ignored--
AM trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/RestScopedTestCase.java
M trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java
A trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped
AM trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/RestScopedBean.java
A trunk/test-modules/cargo-test-module/src/main/resources
A trunk/test-modules/cargo-test-module/src/main/resources/META-INF
AM trunk/test-modules/cargo-test-module/src/main/resources/META-INF/beans.xml
A trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped
AM trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/restScoped1.xhtml
M trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml
M trunk/test-modules/cargo-test-module/pom.xml
AM trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestScoped.java
AM trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestParameters.java
M trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java
M trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/JsfAwareConversationFactory.java
AM trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestConversationExpirationEvaluator.java
AM trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/JsfRestParameters.java
Added:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestScoped.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestConversationExpirationEvaluator.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestParameters.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/JsfRestParameters.java (with props)
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/RestScopedBean.java (with props)
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/META-INF/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/META-INF/beans.xml (with props)
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/restScoped1.xhtml (with props)
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/RestScopedTestCase.java (with props)
Modified:
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/JsfAwareConversationFactory.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestScoped.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestScoped.java?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestScoped.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestScoped.java Mon Oct 10 13:25:56 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.scope.conversation;
+
+import javax.enterprise.context.NormalScope;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * The scope is similar to @ConversationScoped but it will
+ * automatically end once the view get's invoked with a GET and the
+ * viewParams are different than on the previous invoke
+ */
+@Target({METHOD,TYPE,FIELD})
+@Retention(RUNTIME)
+@Inherited
+@Documented
+@NormalScope(passivating=true)
+public @interface RestScoped
+{
+}
Propchange: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestScoped.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java?rev=1180947&r1=1180946&r2=1180947&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java Mon Oct 10 13:25:56 2011
@@ -20,6 +20,7 @@ package org.apache.myfaces.extensions.cd
import org.apache.myfaces.extensions.cdi.core.api.activation.Deactivatable;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.RestScoped;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowScoped;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationGroup;
@@ -62,6 +63,7 @@ public class GroupedConversationContextE
event.addContext(new ConversationContextAdapter(WindowScoped.class, codiConversationContext, manager));
event.addContext(new ConversationContextAdapter(ConversationScoped.class, codiConversationContext, manager));
event.addContext(new ConversationContextAdapter(ViewAccessScoped.class, codiConversationContext, manager));
+ event.addContext(new ConversationContextAdapter(RestScoped.class, codiConversationContext, manager));
}
/**
@@ -87,7 +89,8 @@ public class GroupedConversationContextE
annotationType = qualifier.annotationType();
if(ConversationGroup.class.isAssignableFrom(annotationType) &&
- !ConversationScoped.class.isAssignableFrom(bean.getScope()))
+ !(ConversationScoped.class.isAssignableFrom(bean.getScope()) ||
+ RestScoped.class.isAssignableFrom(bean.getScope())))
{
String errorMessage = "Definition error in class: " + bean.getBeanClass().getName() +
"\nIt isn't allowed to use @" + ConversationGroup.class.getName() +
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/JsfAwareConversationFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/JsfAwareConversationFactory.java?rev=1180947&r1=1180946&r2=1180947&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/JsfAwareConversationFactory.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/JsfAwareConversationFactory.java Mon Oct 10 13:25:56 2011
@@ -18,6 +18,7 @@
*/
package org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.RestScoped;
import org.apache.myfaces.extensions.cdi.core.api.security.AccessDecisionVoterContext;
import org.apache.myfaces.extensions.cdi.core.impl.util.CodiUtils;
import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.ConversationFactory;
@@ -71,6 +72,16 @@ public class JsfAwareConversationFactory
return processCreatedConversation(conversation, configuration.isStartConversationEventEnabled());
}
+ if(RestScoped.class.isAssignableFrom(conversationKey.getScope()))
+ {
+ conversation = new DefaultConversation(conversationKey,
+ createAndRegisterRestConversationEvaluator(),
+ configuration,
+ this.beanManager);
+
+ return processCreatedConversation(conversation, configuration.isStartConversationEventEnabled());
+ }
+
conversation = new DefaultConversation(conversationKey,
new TimeoutConversationExpirationEvaluator(
configuration.getConversationTimeoutInMinutes()),
@@ -94,6 +105,17 @@ public class JsfAwareConversationFactory
return evaluator;
}
+ private RestConversationExpirationEvaluator createAndRegisterRestConversationEvaluator()
+ {
+ AccessDecisionVoterContext accessDecisionVoterContext =
+ CodiUtils.getContextualReferenceByClass(beanManager, AccessDecisionVoterContext.class, true);
+
+ RestConversationExpirationEvaluator evaluator =
+ new RestConversationExpirationEvaluator(beanManager, accessDecisionVoterContext);
+
+ return evaluator;
+ }
+
private EditableConversation processCreatedConversation(EditableConversation conversation,
boolean startConversationEventEnable)
{
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestConversationExpirationEvaluator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestConversationExpirationEvaluator.java?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestConversationExpirationEvaluator.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestConversationExpirationEvaluator.java Mon Oct 10 13:25:56 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.jsf.impl.scope.conversation;
+
+import org.apache.myfaces.extensions.cdi.core.api.security.AccessDecisionState;
+import org.apache.myfaces.extensions.cdi.core.api.security.AccessDecisionVoterContext;
+import org.apache.myfaces.extensions.cdi.core.impl.util.CodiUtils;
+
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * Evaluates when a @RestScoped Conversation context needs to get restarted.
+ */
+@Typed() // this is not a CDI bean
+class RestConversationExpirationEvaluator implements ConversationExpirationEvaluator
+{
+ private static final long serialVersionUID = 4586717766107967148L;
+
+ private AccessDecisionVoterContext accessDecisionVoterContext;
+
+ private RestParameters restParameters;
+
+ RestConversationExpirationEvaluator(BeanManager beanManager, AccessDecisionVoterContext accessDecisionVoterContext)
+ {
+ this.accessDecisionVoterContext = accessDecisionVoterContext;
+ this.restParameters = CodiUtils.getContextualReferenceByClass(beanManager, RestParameters.class);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isExpired()
+ {
+ // check for bean access via ViewConfig
+ if(this.accessDecisionVoterContext != null &&
+ AccessDecisionState.VOTE_IN_PROGRESS.equals(this.accessDecisionVoterContext.getState()))
+ {
+ return false;
+ }
+
+ // if the view params changed, then our Conversation must expire.
+ return restParameters.checkForNewViewParameters();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void touch()
+ {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void expire()
+ {
+ // do nothing
+ }
+
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestConversationExpirationEvaluator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestParameters.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestParameters.java?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestParameters.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestParameters.java Mon Oct 10 13:25:56 2011
@@ -0,0 +1,42 @@
+/*
+ * 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.jsf.impl.scope.conversation;
+
+import javax.enterprise.context.RequestScoped;
+import java.io.Serializable;
+
+
+/**
+ * This class holds information about the last used RestParameters for a given window.
+ */
+// this could be @WindowScoped, but due to a bug in OpenWebBeans 1.1.1 and below, we get passivation errors
+@RequestScoped
+public class RestParameters implements Serializable
+{
+ /**
+ * Check and update the view parameters of the given viewId.
+ *
+ * @return <code>true</code> if the viewParameters are now different than at the last invocation
+ */
+ public boolean checkForNewViewParameters()
+ {
+ return false;
+ }
+
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/RestParameters.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/JsfRestParameters.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/JsfRestParameters.java?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/JsfRestParameters.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/JsfRestParameters.java Mon Oct 10 13:25:56 2011
@@ -0,0 +1,116 @@
+/*
+ * 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.jsf2.impl.scope.conversation;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowScoped;
+import org.apache.myfaces.extensions.cdi.jsf.api.listener.phase.AfterPhase;
+import org.apache.myfaces.extensions.cdi.jsf.api.listener.phase.JsfPhaseId;
+import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.RestParameters;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Specializes;
+import javax.faces.component.UIViewParameter;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.view.ViewMetadata;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+
+/**
+ * This class holds information about the last used RestParameters for a given JSF view.
+ */
+@WindowScoped
+@Specializes
+public class JsfRestParameters extends RestParameters implements Serializable
+{
+ /**
+ * key= viewId
+ * value= concatenated viewParam names + values
+ *
+ * We use @WindowScoped to automatically include the windowId in a correct way.
+ *
+ * TODO we might change this to only store a hashKey.
+ */
+ private HashMap<String, String> viewParametersForViewId = new HashMap<String, String>();
+
+ /**
+ * Check and update the view parameters of the given viewId.
+ *
+ * @return <code>true</code> if the viewParameters are now different than at the last invocation
+ */
+ public boolean checkForNewViewParameters()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ if (facesContext == null)
+ {
+ // this might happen if we are outside the JSF-Servlet, e.g. in a ServletFilter.
+ return false;
+ }
+
+ String viewId = facesContext.getViewRoot().getViewId();
+
+ String currentViewParams = getViewParams(facesContext, viewId);
+ String oldViewParams = viewParametersForViewId.get(viewId);
+
+ if (!currentViewParams.equals(oldViewParams))
+ {
+ viewParametersForViewId.put(viewId, currentViewParams);
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @return the concatenated String of all viewParamName=viewParamValue of the given viewId
+ */
+ private String getViewParams(FacesContext facesContext, String viewId)
+ {
+ Collection<UIViewParameter> currentViewParams = ViewMetadata.getViewParameters(facesContext.getViewRoot());
+ StringBuilder sb = new StringBuilder();
+ for (UIViewParameter viewParameter : currentViewParams)
+ {
+ String viewParamName = viewParameter.getName();
+ String viewParamValue = facesContext.getExternalContext().getRequestParameterMap().get(viewParamName);
+ if (viewParamValue == null)
+ {
+ viewParamValue = "";
+ }
+
+ //X TODO it might be necessary to sort this first according to the viewParamNames.
+ sb.append(viewParamName).append("=").append(viewParamValue).append("+/+");
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * We need to store the view params after render response because
+ * we do not get them in the first initial view invocation when
+ * a new windowid got detected.
+ */
+ public void afterRenderResponse(@Observes @AfterPhase(JsfPhaseId.RENDER_RESPONSE) PhaseEvent phaseEvent)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ String viewId = facesContext.getViewRoot().getViewId();
+ viewParametersForViewId.put(viewId, getViewParams(facesContext, viewId));
+ }
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/JsfRestParameters.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml?rev=1180947&r1=1180946&r2=1180947&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml Mon Oct 10 13:25:56 2011
@@ -316,7 +316,7 @@
<artifactId>jetty-maven-plugin</artifactId>
<version>${maven.jetty.plugin.version}</version>
<configuration>
- <scanIntervalSeconds>10</scanIntervalSeconds>
+ <scanIntervalSeconds>5</scanIntervalSeconds>
<webAppConfig>
<contextPath>/${cargo.context}</contextPath>
</webAppConfig>
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java?rev=1180947&r1=1180946&r2=1180947&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java Mon Oct 10 13:25:56 2011
@@ -51,4 +51,13 @@ public interface Pages extends ViewConfi
{
}
}
+
+ public interface Restscoped extends Pages
+ {
+ @Page
+ public class RestScoped1 implements Restscoped
+ {
+ }
+ }
}
+
Added: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/RestScopedBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/RestScopedBean.java?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/RestScopedBean.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/RestScopedBean.java Mon Oct 10 13:25:56 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.test.cargo.view.restscoped;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.RestScoped;
+
+import javax.annotation.PostConstruct;
+import javax.faces.event.ComponentSystemEvent;
+import javax.inject.Named;
+import java.io.Serializable;
+
+/**
+ * This sample @RequestScoped page just increments an invocation counter,
+ * which starts at zero if a new instance got created.
+ *
+ * The {@link #param} parameter gets set via f:viewParam and defines the Rest parameter.
+ */
+@Named("restscoped")
+@RestScoped
+public class RestScopedBean implements Serializable
+{
+ private static final long serialVersionUID = -3165721387186644462L;
+
+ private int invocationCount;
+ private String param;
+
+
+ @PostConstruct
+ protected void init()
+ {
+ invocationCount = 0;
+ }
+
+ public void preRender(ComponentSystemEvent ev)
+ {
+ invocationCount++;
+ }
+
+ public int getInvocationCount()
+ {
+ return invocationCount;
+ }
+
+ public String getParam()
+ {
+ return param;
+ }
+
+ public void setParam(String param)
+ {
+ this.param = param;
+ }
+}
Propchange: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/restscoped/RestScopedBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/META-INF/beans.xml?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/META-INF/beans.xml (added)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/META-INF/beans.xml Mon Oct 10 13:25:56 2011
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<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">
+
+</beans>
\ No newline at end of file
Propchange: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/resources/META-INF/beans.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml?rev=1180947&r1=1180946&r2=1180947&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml Mon Oct 10 13:25:56 2011
@@ -28,7 +28,6 @@
<title>Apache MyFaces CODI Integration Tests for JSF 2.0</title>
</h:head>
<h:body>
-
<h1>Apache MyFaces CODI Integration Tests for JSF 2.0</h1>
<h:link value="Test Utils" outcome="utils.xhtml" />
@@ -37,8 +36,8 @@
<ul>
<li><h:link value="Conversation Test" outcome="pages/conversation/conversation1.xhtml" /></li>
+ <li><h:link value="RestScoped Test" outcome="pages/restscoped/restScoped1.xhtml" /></li>
</ul>
</h:body>
</html>
-
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/restScoped1.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/restScoped1.xhtml?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/restScoped1.xhtml (added)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/restScoped1.xhtml Mon Oct 10 13:25:56 2011
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<f:metadata>
+ <f:viewParam name="param" value="#{restscoped.param}"/>
+ <f:event type="javax.faces.event.PreRenderViewEvent" listener="#{restscoped.preRender}"/>
+</f:metadata>
+
+<h:head>
+ <title>Apache MyFaces CODI - RestScoped1</title>
+</h:head>
+<h:body>
+
+ <h2>RestScoped1</h2>
+
+ <h:form id="restscoped1">
+ <p>
+ Name from REST: <h:outputText value="#{restscoped.param}" />
+ </p>
+ <p>
+ Invocation Counter: <h:outputText value="#{restscoped.invocationCount}" />
+ </p>
+
+ <h:link id="nextPage" value="Same Page" outcome="restScoped1.xhtml">
+ <f:param name="param" value="#{restscoped.param}"/>
+ </h:link>
+ </h:form>
+
+</h:body>
+</html>
Propchange: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/restscoped/restScoped1.xhtml
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/RestScopedTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/RestScopedTestCase.java?rev=1180947&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/RestScopedTestCase.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/RestScopedTestCase.java Mon Oct 10 13:25:56 2011
@@ -0,0 +1,48 @@
+/*
+ * 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.test.cargo.conversation;
+
+import org.apache.myfaces.extensions.cdi.test.cargo.SimplePageInteraction;
+import org.apache.myfaces.extensions.cdi.test.cargo.view.config.Pages;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import javax.enterprise.inject.Typed;
+
+/**
+ */
+@RunWith(JUnit4.class)
+@Typed()
+public class RestScopedTestCase extends BaseConversationTest
+{
+
+ // NOTE that new @Test means new WebClient means new WindowContext
+
+ @Test
+ public void testSimpleRestScopedDialog() throws Exception
+ {
+ SimplePageInteraction pageInteraction = new SimplePageInteraction(getTestConfiguration())
+ .with(Pages.Restscoped.RestScoped1.class)
+ .start(Pages.Restscoped.RestScoped1.class)
+ .useForm("restscoped1");
+
+ }
+
+}
Propchange: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/RestScopedTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native