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/08/12 15:48:56 UTC
svn commit: r984774 - in /myfaces/extensions/cdi/trunk:
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/
examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/view/
jee-modules/jsf-mo...
Author: gpetracek
Date: Thu Aug 12 13:48:55 2010
New Revision: 984774
URL: http://svn.apache.org/viewvc?rev=984774&view=rev
Log:
cleanup + draft for new optional events + page-bean annotation for view definitions
Added:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/CreateWindowContextEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/EndConversationEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestartConversationEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/StartConversationEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContextEvent.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/view/definition/PageBean.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/PreRenderViewBeanLoader.java
Modified:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanAccessEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ScopeBeanEvent.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/UnscopeBeanEvent.java
myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/view/DemoPages.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.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
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ExceptionUtils.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/ViewDefinitionEntry.java
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanAccessEvent.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/BeanAccessEvent.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanAccessEvent.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanAccessEvent.java Thu Aug 12 13:48:55 2010
@@ -23,7 +23,7 @@ import java.io.Serializable;
/**
* @author Gerhard Petracek
*/
-public final class BeanAccessEvent extends ConversationEvent
+public final class BeanAccessEvent extends BeanEvent
{
public BeanAccessEvent(Serializable bean)
{
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanEvent.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/BeanEvent.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanEvent.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/BeanEvent.java Thu Aug 12 13:48:55 2010
@@ -0,0 +1,39 @@
+/*
+ * 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 java.io.Serializable;
+
+/**
+ * @author Gerhard Petracek
+ */
+public abstract class BeanEvent
+{
+ private final Serializable bean;
+
+ public BeanEvent(Serializable bean)
+ {
+ this.bean = bean;
+ }
+
+ public final Serializable getBeanInstance()
+ {
+ return bean;
+ }
+}
\ No newline at end of file
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationEvent.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/ConversationEvent.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationEvent.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationEvent.java Thu Aug 12 13:48:55 2010
@@ -18,22 +18,20 @@
*/
package org.apache.myfaces.extensions.cdi.core.api.scope.conversation;
-import java.io.Serializable;
-
/**
* @author Gerhard Petracek
*/
public abstract class ConversationEvent
{
- private final Serializable bean;
+ private final Conversation conversation;
- public ConversationEvent(Serializable bean)
+ public ConversationEvent(Conversation conversation)
{
- this.bean = bean;
+ this.conversation = conversation;
}
- public final Serializable getBeanInstance()
+ public final Conversation getConversation()
{
- return bean;
+ return conversation;
}
}
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/CreateWindowContextEvent.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/CreateWindowContextEvent.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/CreateWindowContextEvent.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/CreateWindowContextEvent.java Thu Aug 12 13:48:55 2010
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * @author Gerhard Petracek
+ */
+public final class CreateWindowContextEvent extends WindowContextEvent
+{
+ public CreateWindowContextEvent(String windowContextId)
+ {
+ super(windowContextId);
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/EndConversationEvent.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/EndConversationEvent.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/EndConversationEvent.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/EndConversationEvent.java Thu Aug 12 13:48:55 2010
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * @author Gerhard Petracek
+ */
+public final class EndConversationEvent extends ConversationEvent
+{
+ public EndConversationEvent(Conversation conversation)
+ {
+ super(conversation);
+ }
+}
\ 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/RestartConversationEvent.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/RestartConversationEvent.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestartConversationEvent.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/RestartConversationEvent.java Thu Aug 12 13:48:55 2010
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * @author Gerhard Petracek
+ */
+public final class RestartConversationEvent extends ConversationEvent
+{
+ public RestartConversationEvent(Conversation conversation)
+ {
+ super(conversation);
+ }
+}
\ No newline at end of file
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ScopeBeanEvent.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/ScopeBeanEvent.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ScopeBeanEvent.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ScopeBeanEvent.java Thu Aug 12 13:48:55 2010
@@ -23,7 +23,7 @@ import java.io.Serializable;
/**
* @author Gerhard Petracek
*/
-public final class ScopeBeanEvent extends ConversationEvent
+public final class ScopeBeanEvent extends BeanEvent
{
public ScopeBeanEvent(Serializable bean)
{
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/StartConversationEvent.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/StartConversationEvent.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/StartConversationEvent.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/StartConversationEvent.java Thu Aug 12 13:48:55 2010
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * @author Gerhard Petracek
+ */
+public final class StartConversationEvent extends ConversationEvent
+{
+ public StartConversationEvent(Conversation conversation)
+ {
+ super(conversation);
+ }
+}
\ No newline at end of file
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/UnscopeBeanEvent.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/UnscopeBeanEvent.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/UnscopeBeanEvent.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/UnscopeBeanEvent.java Thu Aug 12 13:48:55 2010
@@ -23,7 +23,7 @@ import java.io.Serializable;
/**
* @author Gerhard Petracek
*/
-public final class UnscopeBeanEvent extends ConversationEvent
+public final class UnscopeBeanEvent extends BeanEvent
{
public UnscopeBeanEvent(Serializable bean)
{
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContextEvent.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/WindowContextEvent.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContextEvent.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContextEvent.java Thu Aug 12 13:48:55 2010
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ * @author Gerhard Petracek
+ */
+public abstract class WindowContextEvent
+{
+ private final String windowContextId;
+
+ public WindowContextEvent(String windowContextId)
+ {
+ this.windowContextId = windowContextId;
+ }
+
+ public final String getWindowContextId()
+ {
+ return windowContextId;
+ }
+}
\ No newline at end of file
Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/view/DemoPages.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/view/DemoPages.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/view/DemoPages.java (original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/view/DemoPages.java Thu Aug 12 13:48:55 2010
@@ -22,6 +22,8 @@ import org.apache.myfaces.extensions.cdi
import org.apache.myfaces.extensions.cdi.javaee.jsf.api.view.definition.JsfViewExtension;
import org.apache.myfaces.extensions.cdi.javaee.jsf.api.view.definition.NavigationMode;
import org.apache.myfaces.extensions.cdi.javaee.jsf.api.view.definition.Page;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.view.definition.PageBean;
+import org.apache.myfaces.blank.conversation.grouped.ConversationDemoBean1;
/**
* @author Gerhard Petracek
@@ -30,6 +32,7 @@ import org.apache.myfaces.extensions.cdi
navigation = NavigationMode.REDIRECT, extension = JsfViewExtension.JSP)
public abstract class DemoPages implements ViewDefinition
{
+ @PageBean(ConversationDemoBean1.class) //triggers e.g. @PostConstruct before the rendering process (if needed)
@Page(basePath = ".")
//means that DemoPages$HelloMyFacesCodi gets /demoPages/helloMyFacesCodi.jsp if parent-base-path isn't overridden
//in this case: helloMyFacesCodi.jsp
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/view/definition/PageBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/view/definition/PageBean.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/view/definition/PageBean.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/view/definition/PageBean.java Thu Aug 12 13:48:55 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.api.view.definition;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Stereotype
+
+//don't use @Inherited
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface PageBean
+{
+ Class value();
+
+ String name() default "";
+
+ @Target(TYPE)
+ @Retention(RUNTIME)
+ @Documented
+ public static @interface List
+ {
+ PageBean[] value();
+ }
+}
\ 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/DefaultWindowContextManager.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/DefaultWindowContextManager.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.java Thu Aug 12 13:48:55 2010
@@ -25,7 +25,7 @@ import org.apache.myfaces.extensions.cdi
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ConversationUtils;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.JsfUtils;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.RequestCache;
-import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ExceptionUtils.windowContextNotEditable;
+import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ExceptionUtils.windowContextNotEditableException;
import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ConversationUtils.*;
import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ConversationUtils.resolveWindowContextId;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.spi.EditableWindowContext;
@@ -314,7 +314,7 @@ public class DefaultWindowContextManager
{
if(!(windowContext instanceof EditableWindowContext))
{
- throw windowContextNotEditable(windowContext);
+ throw windowContextNotEditableException(windowContext);
}
return (EditableWindowContext)windowContext;
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=984774&r1=984773&r2=984774&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 Thu Aug 12 13:48:55 2010
@@ -28,7 +28,8 @@ import org.apache.myfaces.extensions.cdi
import static org.apache.myfaces.extensions.cdi.core.impl.utils.CodiUtils.getOrCreateScopedInstanceOfBeanByClass;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ConversationUtils;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.RequestCache;
-import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ExceptionUtils.windowContextManagerNotEditable;
+import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ExceptionUtils
+ .windowContextManagerNotEditableException;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.spi.EditableWindowContext;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.spi.JsfAwareWindowContextConfig;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.spi.EditableWindowContextManager;
@@ -78,7 +79,7 @@ class GroupedConversationContextAdapter
{
if(!(windowContextManager instanceof EditableWindowContextManager))
{
- throw windowContextManagerNotEditable(windowContextManager);
+ throw windowContextManagerNotEditableException(windowContextManager);
}
Class<?> beanClass = beanDescriptor.getBeanClass();
@@ -93,7 +94,7 @@ class GroupedConversationContextAdapter
{
if(!(windowContextManager instanceof EditableWindowContextManager))
{
- throw windowContextManagerNotEditable(windowContextManager);
+ throw windowContextManagerNotEditableException(windowContextManager);
}
Bean<?> bean = beanEntry.getBean();
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.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/JsfWindowContext.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java Thu Aug 12 13:48:55 2010
@@ -27,7 +27,7 @@ import org.apache.myfaces.extensions.cdi
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.spi.JsfAwareWindowContextConfig;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.RequestCache;
import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.JsfUtils;
-import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ExceptionUtils.conversationNotEditable;
+import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.ExceptionUtils.conversationNotEditableException;
import javax.enterprise.inject.Typed;
import java.util.Date;
@@ -137,7 +137,7 @@ public class JsfWindowContext implements
if(!(conversation instanceof EditableConversation))
{
- throw conversationNotEditable(conversation);
+ throw conversationNotEditableException(conversation);
}
return endAndRemoveConversation(conversationKey, (EditableConversation)conversation, true);
}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ExceptionUtils.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/util/ExceptionUtils.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ExceptionUtils.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ExceptionUtils.java Thu Aug 12 13:48:55 2010
@@ -37,21 +37,26 @@ public class ExceptionUtils
+ windowContextTimeoutInMinutes + " minutes.");
}
- public static RuntimeException windowContextManagerNotEditable(WindowContextManager windowContextManager)
+ public static RuntimeException windowContextManagerNotEditableException(WindowContextManager windowContextManager)
{
return new RuntimeException(windowContextManager.getClass().getName() + " has to implement "
+ EditableWindowContextManager.class.getName());
}
- public static RuntimeException windowContextNotEditable(WindowContext windowContext)
+ public static RuntimeException windowContextNotEditableException(WindowContext windowContext)
{
return new RuntimeException(windowContext.getClass().getName() + " has to implement "
+ EditableWindowContext.class.getName());
}
- public static RuntimeException conversationNotEditable(Conversation conversation)
+ public static RuntimeException conversationNotEditableException(Conversation conversation)
{
return new RuntimeException(conversation.getClass().getName() + " has to implement "
+ EditableConversation.class.getName());
}
+
+ public static RuntimeException invalidViewException(String viewId)
+ {
+ return new RuntimeException("View-ID: " + viewId + " doesn't exist.");
+ }
}
Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/PreRenderViewBeanLoader.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/view/PreRenderViewBeanLoader.java?rev=984774&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/PreRenderViewBeanLoader.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/PreRenderViewBeanLoader.java Thu Aug 12 13:48: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.view;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.BeforePhase;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+import org.apache.myfaces.extensions.cdi.core.impl.utils.CodiUtils;
+
+import javax.enterprise.event.Observes;
+import javax.faces.event.PhaseEvent;
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ */
+final class PreRenderViewBeanLoader
+{
+ protected void initBeans(@Observes @BeforePhase(PhaseId.RENDER_RESPONSE) PhaseEvent event)
+ {
+ String viewId = event.getFacesContext().getViewRoot().getViewId();
+
+ ViewDefinitionEntry viewDefinitionEntry = ViewDefinitionCache.getViewDefinition(viewId);
+
+ if(viewDefinitionEntry == null)
+ {
+ return;
+ }
+
+ List<String> beanNames = viewDefinitionEntry.getBeanNames();
+
+ for(String beanName : beanNames)
+ {
+ //resolve bean to trigger @PostConstruct if it isn't scoped
+ CodiUtils.getOrCreateScopedInstanceOfBeanByName(beanName, Object.class);
+ }
+ }
+}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/ViewDefinitionEntry.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/view/ViewDefinitionEntry.java?rev=984774&r1=984773&r2=984774&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/ViewDefinitionEntry.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/view/ViewDefinitionEntry.java Thu Aug 12 13:48:55 2010
@@ -20,6 +20,13 @@ package org.apache.myfaces.extensions.cd
import org.apache.myfaces.extensions.cdi.core.api.view.definition.ViewDefinition;
import org.apache.myfaces.extensions.cdi.javaee.jsf.api.view.definition.NavigationMode;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.view.definition.PageBean;
+
+import javax.inject.Named;
+import java.util.List;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.beans.Introspector;
/**
* @author Gerhard Petracek
@@ -29,6 +36,7 @@ public class ViewDefinitionEntry
private final String viewId;
private final Class<? extends ViewDefinition> viewDefinitionClass;
private final NavigationMode navigationMode;
+ private final List<String> beanNames;
public ViewDefinitionEntry(String viewId,
Class<? extends ViewDefinition> viewDefinitionClass,
@@ -37,7 +45,9 @@ public class ViewDefinitionEntry
this.viewId = viewId;
this.viewDefinitionClass = viewDefinitionClass;
this.navigationMode = navigationMode;
- //TODO validate view-di
+
+ beanNames = Collections.unmodifiableList(findBeanNames(viewDefinitionClass));
+ //TODO validate view-id
}
public String getViewId()
@@ -55,6 +65,66 @@ public class ViewDefinitionEntry
return navigationMode;
}
+ public List<String> getBeanNames()
+ {
+ return beanNames;
+ }
+
+ private List<String> findBeanNames(Class<? extends ViewDefinition> viewDefinitionClass)
+ {
+ if(!viewDefinitionClass.isAnnotationPresent(PageBean.class) &&
+ !viewDefinitionClass.isAnnotationPresent(PageBean.List.class))
+ {
+ return Collections.emptyList();
+ }
+
+ List<String> result = new ArrayList<String>();
+
+ if(viewDefinitionClass.isAnnotationPresent(PageBean.class))
+ {
+ result.add(extractBeanName(viewDefinitionClass.getAnnotation(PageBean.class)));
+ }
+
+ if(viewDefinitionClass.isAnnotationPresent(PageBean.List.class))
+ {
+ result.addAll(extractBeanNames(viewDefinitionClass.getAnnotation(PageBean.List.class)));
+ }
+
+ return result;
+ }
+
+ private List<String> extractBeanNames(PageBean.List pageBeanList)
+ {
+ List<String> result = new ArrayList<String>();
+ for(PageBean pageBean : pageBeanList.value())
+ {
+ result.add(extractBeanName(pageBean));
+ }
+ return result;
+ }
+
+ private String extractBeanName(PageBean pageBean)
+ {
+ if(!"".equals(pageBean.name()))
+ {
+ return pageBean.name();
+ }
+
+ Class<?> pageBeanClass = pageBean.value();
+
+ if(pageBeanClass.isAnnotationPresent(Named.class))
+ {
+ String beanName = pageBeanClass.getAnnotation(Named.class).value();
+
+ if(!"".equals(beanName))
+ {
+ return beanName;
+ }
+ }
+
+ return Introspector.decapitalize(pageBeanClass.getSimpleName());
+ }
+
@Override
public boolean equals(Object o)
{