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/11 21:23:29 UTC
svn commit: r963137 - in /myfaces/extensions/cdi/trunk:
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/tools/annotate/
core/impl/src/main/java/org/...
Author: gpetracek
Date: Sun Jul 11 19:23:29 2010
New Revision: 963137
URL: http://svn.apache.org/viewvc?rev=963137&view=rev
Log:
EXTCDI-1, EXTCDI-2 and EXTCDI-3 @ViewAccessScoped and @WindowScoped as stereotypes
Added:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ViewAccessScoped.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowScoped.java
myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/MixedConversationDemoBean.java
- copied, changed from r963097, myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java
Modified:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/tools/annotate/DefaultAnnotation.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java
myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/BeanStorage.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ViewAccessScoped.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/ViewAccessScoped.java?rev=963137&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ViewAccessScoped.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ViewAccessScoped.java Sun Jul 11 19:23:29 2010
@@ -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.core.api.scope.conversation;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Stereotype
+
+@Target({TYPE, METHOD, FIELD})
+@Retention(RUNTIME)
+@Documented
+
+@ConversationScoped(ViewAccessGroup.class)
+public @interface ViewAccessScoped
+{
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowScoped.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/WindowScoped.java?rev=963137&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowScoped.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowScoped.java Sun Jul 11 19:23:29 2010
@@ -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.core.api.scope.conversation;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Stereotype
+
+@Target({TYPE, METHOD, FIELD})
+@Retention(RUNTIME)
+@Documented
+
+@ConversationScoped(WindowGroup.class)
+public @interface WindowScoped
+{
+}
\ No newline at end of file
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/tools/annotate/DefaultAnnotation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/tools/annotate/DefaultAnnotation.java?rev=963137&r1=963136&r2=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/tools/annotate/DefaultAnnotation.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/tools/annotate/DefaultAnnotation.java Sun Jul 11 19:23:29 2010
@@ -56,7 +56,7 @@ public class DefaultAnnotation implement
static volatile Map<Class<? extends Annotation>, Annotation> annotationCache
= new ConcurrentHashMap<Class<? extends Annotation>, Annotation>();
- public static Annotation of(Class<? extends Annotation> annotationClass)
+ public static <T extends Annotation> T of(Class<T> annotationClass)
{
Annotation annotation = annotationCache.get(annotationClass);
@@ -78,7 +78,7 @@ public class DefaultAnnotation implement
}
}
- return annotation;
+ return (T)annotation;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
@@ -102,4 +102,32 @@ public class DefaultAnnotation implement
return method.getDefaultValue();
}
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (!(o instanceof DefaultAnnotation))
+ {
+ return false;
+ }
+
+ DefaultAnnotation that = (DefaultAnnotation) o;
+
+ if (!annotationClass.equals(that.annotationClass))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return annotationClass.hashCode();
+ }
}
Modified: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java?rev=963137&r1=963136&r2=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java (original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java Sun Jul 11 19:23:29 2010
@@ -27,5 +27,5 @@ public interface EditableConversation
void deactivate();
- <T> void addBean(Class<?> beanClass, BeanEntry<T> beanInstance);
+ <T> void addBean(BeanEntry<T> beanInstance);
}
Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java?rev=963137&r1=963136&r2=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java (original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java Sun Jul 11 19:23:29 2010
@@ -48,6 +48,14 @@ public class ConversationDemoBean4 imple
@Qualifier2
private ConversationDemoBeanWithQualifier bean2;
+ @Inject
+ @Qualifier1
+ private MixedConversationDemoBean mixedBean1;
+
+ @Inject
+ @Qualifier2
+ private MixedConversationDemoBean mixedBean2;
+
@PostConstruct
public void init()
{
@@ -58,7 +66,12 @@ public class ConversationDemoBean4 imple
public String getValue()
{
- return value + " bean1: " + this.bean1.getValue() + " bean2: " + this.bean2.getValue() + " "
- + createdAt.toLocaleString();
+ return value +
+ createdAt.toLocaleString() +
+ " injected beans: " +
+ this.bean1.getValue() + " " +
+ this.bean2.getValue() + " " +
+ this.mixedBean1.getValue() + " " +
+ this.mixedBean2.getValue();
}
}
\ No newline at end of file
Copied: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/MixedConversationDemoBean.java (from r963097, myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/MixedConversationDemoBean.java?p2=myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/MixedConversationDemoBean.java&p1=myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java&r1=963097&r2=963137&rev=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean4.java (original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/MixedConversationDemoBean.java Sun Jul 11 19:23:29 2010
@@ -18,47 +18,54 @@
*/
package org.apache.myfaces.blank.conversation.grouped;
-import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped;
-import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessGroup;
+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.blank.conversation.grouped.qualifier.Qualifier1;
import org.apache.myfaces.blank.conversation.grouped.qualifier.Qualifier2;
-import javax.inject.Named;
-import javax.inject.Inject;
-import javax.annotation.PostConstruct;
+import javax.enterprise.inject.Produces;
import java.io.Serializable;
import java.util.Date;
/**
* @author Gerhard Petracek
*/
-@Named
-@ConversationScoped(ViewAccessGroup.class)
-public class ConversationDemoBean4 implements Serializable
+public class MixedConversationDemoBean implements Serializable
{
- private String value = "Hello view access scoped! ";
- private Date createdAt;
private static final long serialVersionUID = -4238520498463300564L;
- @Inject
- @Qualifier1
- private ConversationDemoBeanWithQualifier bean1;
+ private String value;
- @Inject
- @Qualifier2
- private ConversationDemoBeanWithQualifier bean2;
+ private Date createdAt;
- @PostConstruct
- public void init()
+ protected MixedConversationDemoBean()
{
+ }
+
+ private MixedConversationDemoBean(String value)
+ {
+ this.value = value;
this.createdAt = new Date();
- this.bean1.getValue();
- this.bean2.getValue();
+ }
+
+ @Produces
+ @Qualifier1
+ @WindowScoped
+ public MixedConversationDemoBean createWindowScopedBean()
+ {
+ return new MixedConversationDemoBean("Q1@WindowScoped ");
+ }
+
+ @Produces
+ @Qualifier2
+ @ViewAccessScoped
+ public MixedConversationDemoBean createViewAccessScopedBean()
+ {
+ return new MixedConversationDemoBean("Q2@ViewAccessScoped ");
}
public String getValue()
{
- return value + " bean1: " + this.bean1.getValue() + " bean2: " + this.bean2.getValue() + " "
- + createdAt.toLocaleString();
+ return value + createdAt.toLocaleString();
}
}
\ No newline at end of file
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/BeanStorage.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/scope/conversation/BeanStorage.java?rev=963137&r1=963136&r2=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/BeanStorage.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/BeanStorage.java Sun Jul 11 19:23:29 2010
@@ -52,22 +52,22 @@ class BeanStorage implements Serializabl
}
//don't use something like Bean#touch here to ensure that the correct ViewId is used as well
- return addBean(beanClass, this.beanMap, beanEntry);
+ return addBean(this.beanMap, beanEntry);
}
}
- public BeanEntry addBean(Class beanClass, BeanEntry<Serializable> beanHolder)
+ public BeanEntry addBean(BeanEntry<Serializable> beanEntry)
{
synchronized (this)
{
- return addBean(beanClass, this.beanMap, beanHolder);
+ return addBean(this.beanMap, beanEntry);
}
}
- private BeanEntry addBean(
- Class beanClass, Map<Class, BeanEntry<Serializable>> beanMap, BeanEntry<Serializable> beanEntry)
+ private BeanEntry addBean(Map<Class, BeanEntry<Serializable>> beanMap, BeanEntry<Serializable> beanEntry)
{
//BeanEntryHolder newBean = new BeanEntryHolder(beanHolder);
+ Class beanClass = beanEntry.getBean().getBeanClass();
beanMap.remove(beanClass);
beanMap.put(beanClass, beanEntry);
//this.beanAccessedEventEvent.fire(new BeanAccessedEvent(bean.getBeanInstance()));
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.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/scope/conversation/DefaultConversation.java?rev=963137&r1=963136&r2=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java Sun Jul 11 19:23:29 2010
@@ -46,7 +46,7 @@ public class DefaultConversation impleme
private String lastViewId; //for access scope
- private final BeanStorage beanStorage;
+ private final BeanStorage beanStorage = new BeanStorage();
private final long conversationTimeoutInMs;
@@ -59,9 +59,8 @@ public class DefaultConversation impleme
this.conversationKey = conversationKey;
this.windowScoped = WindowGroup.class.isAssignableFrom(conversationKey.getConversationGroup());
- tryToProcessViewAccessScope(conversationKey.getConversationGroup());
+ tryToProcessViewAccessScope();
- this.beanStorage = new BeanStorage();
this.conversationTimeoutInMs = conversationTimeoutInMinutes * 60000;
}
@@ -110,16 +109,16 @@ public class DefaultConversation impleme
return (T) scopedBean.getBeanInstance();
}
- public <T> void addBean(Class<?> beanClass, BeanEntry<T> beanEntry)
+ public <T> void addBean(BeanEntry<T> beanEntry)
{
- tryToProcessViewAccessScope(beanClass);
+ tryToProcessViewAccessScope();
//TODO check if conversation is active
touchConversation(false);
//TODO
//noinspection unchecked
- this.beanStorage.addBean(beanClass, (BeanEntry<Serializable>) beanEntry);
+ this.beanStorage.addBean((BeanEntry<Serializable>) beanEntry);
}
/*
@@ -169,12 +168,19 @@ public class DefaultConversation impleme
return FacesContext.getCurrentInstance().getViewRoot().getViewId();
}
- private void tryToProcessViewAccessScope(Class<?> groupKey)
+ private void tryToProcessViewAccessScope()
{
+ Class<?> groupKey = this.conversationKey.getConversationGroup();
ConversationScoped conversationScoped = groupKey.getAnnotation(ConversationScoped.class);
if (conversationScoped != null && ViewAccessGroup.class.isAssignableFrom(conversationScoped.value()))
{
this.lastViewId = getCurrentViewId();
}
+ //workaround
+ else if(conversationScoped == null && this.conversationKey instanceof DefaultConversationKey &&
+ ((DefaultConversationKey)this.conversationKey).isViewAccessScopedAnnotationPresent())
+ {
+ this.lastViewId = getCurrentViewId();
+ }
}
}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.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/scope/conversation/DefaultConversationKey.java?rev=963137&r1=963136&r2=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java Sun Jul 11 19:23:29 2010
@@ -22,6 +22,7 @@ import org.apache.myfaces.extensions.cdi
import org.apache.myfaces.extensions.cdi.core.api.tools.annotate.DefaultAnnotation;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowGroup;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessGroup;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;
import javax.enterprise.inject.Default;
import java.lang.annotation.Annotation;
@@ -46,12 +47,24 @@ class DefaultConversationKey implements
private final Class<?> groupKey;
private final Set<Annotation> qualifiers = new HashSet<Annotation>();
+ private static final ViewAccessScoped VIEW_ACCESS_SCOPED = DefaultAnnotation.of(ViewAccessScoped.class);
+
+ //workaround
+ private boolean viewAccessScopedAnnotationPresent;
+
DefaultConversationKey(Class<?> groupKey, Annotation... qualifiers)
{
this.groupKey = groupKey;
this.qualifiers.addAll(Arrays.asList(qualifiers));
+ //TODO maybe we have to add a real qualifier instead
+ if(this.qualifiers.contains(VIEW_ACCESS_SCOPED))
+ {
+ this.qualifiers.remove(VIEW_ACCESS_SCOPED);
+ this.viewAccessScopedAnnotationPresent = true;
+ }
+
//for easier manual usage of the WindowContextManager
if(this.qualifiers.isEmpty())
{
@@ -76,6 +89,11 @@ class DefaultConversationKey implements
}
}
+ boolean isViewAccessScopedAnnotationPresent()
+ {
+ return viewAccessScopedAnnotationPresent;
+ }
+
private boolean isWindowScope()
{
return WindowGroup.class.isAssignableFrom(this.groupKey.getClass());
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.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/scope/conversation/GroupedConversationContextAdapter.java?rev=963137&r1=963136&r2=963137&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java Sun Jul 11 19:23:29 2010
@@ -23,6 +23,9 @@ import org.apache.myfaces.extensions.cdi
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.DefaultGroup;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowGroup;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessGroup;
+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.tools.annotate.DefaultAnnotation;
import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.AbstractConversationContextAdapter;
import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.BeanEntry;
import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.EditableConversation;
@@ -90,7 +93,7 @@ public class GroupedConversationContextA
Bean<?> bean = beanEntry.getBean();
Conversation foundConversation = getConversation(conversationManager, bean);
- ((EditableConversation) foundConversation).addBean(bean.getBeanClass(), beanEntry);
+ ((EditableConversation) foundConversation).addBean(beanEntry);
}
private Conversation getConversation(WindowContextManager conversationManager, Bean<?> bean)
@@ -98,6 +101,17 @@ public class GroupedConversationContextA
Class conversationGroup = getConversationGroup(bean);
Set<Annotation> qualifiers = bean.getQualifiers();
+
+ //workaround to keep the existing api
+ if(ViewAccessScoped.class.isAssignableFrom(conversationGroup))
+ {
+ if(bean.getStereotypes().contains(ViewAccessScoped.class))
+ {
+ //TODO maybe we have to add a real qualifier instead
+ qualifiers.add(DefaultAnnotation.of(ViewAccessScoped.class));
+ conversationGroup = bean.getBeanClass();
+ }
+ }
return conversationManager.getCurrentWindowContext()
.getConversation(conversationGroup, qualifiers.toArray(new Annotation[qualifiers.size()]));
}
@@ -106,13 +120,22 @@ public class GroupedConversationContextA
{
ConversationScoped conversationAnnotation = bean.getBeanClass().getAnnotation(ConversationScoped.class);
+ if(bean.getStereotypes().contains(WindowScoped.class))
+ {
+ return WindowGroup.class;
+ }
+
if(conversationAnnotation == null)
{
//in this case we have e.g. a producer method -> there is no official api to get the method
//-> it isn't possible to extract the group
//TODO if we keep the group approach we should perform a check via reflection here and throw an exception
//(if the user used a group) or we use a workaround (via reflection)
- return DefaultGroup.class;
+
+ //due to the target api we can't forward the stereotypes - we just have 2 supported stereotypes
+ //here we know that we have the 2nd supported stereotype
+ // (the rest is analyzed later on - see DefaultConversation)
+ return ViewAccessScoped.class;
}
Class groupClass = conversationAnnotation.value();