myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1067579 - in /myfaces/extensions/cdi/trunk/jee-modules/jsf-module: api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/ impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ impl/src/main/java/org/a...
Date Sun, 06 Feb 2011 03:12:38 GMT
Author: gpetracek
Date: Sun Feb  6 03:12:37 2011
New Revision: 1067579

URL: http://svn.apache.org/viewvc?rev=1067579&view=rev
Log:
EXTCDI-125 inline view-configs (initial draft)

Added:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/InlineViewConfigRoot.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedInlineViewConfigDefinitionEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java
      - copied, changed from r1059626, myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/InlineViewConfigEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/BasefolderViewConfigRootMarker.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/RenamedBasefolderViewConfigRootMarker.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/SubfolderViewConfigRootMarker.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/OrderOverviewPage.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/SecuredPage.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/TestAccessDecisionVoter3.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/registration/
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/registration/RegistrationStep01PageBean.java
Removed:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigCacheStore.java
Modified:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigExtractor.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigCache.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ExceptionUtils.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/TestableViewConfigExtension.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/InlineViewConfigRoot.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/InlineViewConfigRoot.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/InlineViewConfigRoot.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/InlineViewConfigRoot.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.cdi.jsf.api.config.view;
+
+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
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+/**
+ * Only required for inline view-configs!
+ *
+ * Annotate a marker class or interface with this annotation for marking the package of the marker as base package.
+ *
+ * Simple example:
+ *
+ * Marker:
+ * my.customPackage.view.InlineViewConfigRootMarker //annotated with @InlineViewConfigRoot(pageBeanPostfix = "Page")
+ *
+ * PageBeans:
+ * my.customPackage.view.IndexPage //annotated with @Page and implements ViewConfig
+ * -> view-id: /index.xhtml
+ *
+ * my.customPackage.view.registration.RegistrationStep01 //annotated with @Page and implements ViewConfig
+ * -> view-id: /registration/registrationStep01.xhtml
+ */
+public @interface InlineViewConfigRoot
+{
+    String basePath() default ".";
+
+    String[] pageBeanPostfix() default "";
+}

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigExtractor.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/config/view/DefaultViewConfigExtractor.java?rev=1067579&r1=1067578&r2=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigExtractor.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigExtractor.java Sun Feb  6 03:12:37 2011
@@ -26,11 +26,14 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigEntry;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigExtractor;
 
+import javax.inject.Named;
 import java.lang.annotation.Annotation;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import static org.apache.myfaces.extensions.cdi.jsf.impl.util.ExceptionUtils.missingInlineViewConfigRootMarkerException;
+
 /**
  * @author Gerhard Petracek
  */
@@ -39,21 +42,53 @@ class DefaultViewConfigExtractor impleme
     public ViewConfigEntry extractViewConfig(Class<? extends ViewConfig> viewDefinitionClass)
     {
         //use the interface to make clear which information we really need
-        ViewConfigEntry scannedViewConfig = new DefaultViewConfigDefinitionEntry(viewDefinitionClass);
+        ViewConfigEntry viewConfigEntry = new ExtractedViewConfigDefinitionEntry(viewDefinitionClass);
+
+        return extractViewConfigEntry(viewDefinitionClass, viewConfigEntry);
+    }
+
+    public boolean isInlineViewConfig(Class<? extends ViewConfig> viewDefinitionClass)
+    {
+        return isResolvable(viewDefinitionClass, new ArrayList<Class<? extends Annotation>>());
+    }
+
+    public ViewConfigEntry extractInlineViewConfig(Class<? extends ViewConfig> viewDefinitionClass)
+    {
+        Class viewConfigRootMarker = ViewConfigCache.getInlineViewConfigRootMarker();
+
+        if(viewConfigRootMarker == null)
+        {
+            throw missingInlineViewConfigRootMarkerException(viewDefinitionClass);
+        }
+
+        int startIndex = viewConfigRootMarker.getPackage().getName().length() + 1;
+        String basePath = viewDefinitionClass.getName()
+                .substring(startIndex, viewDefinitionClass.getName().lastIndexOf("."));
+
+        basePath = basePath.replace(".", "/");
+
+        //use the interface to make clear which information we really need
+        ViewConfigEntry viewConfigEntry = new ExtractedInlineViewConfigDefinitionEntry(viewDefinitionClass, basePath);
+
+        return extractViewConfigEntry(viewDefinitionClass, viewConfigEntry);
+    }
 
-        scanViewConfigClass(viewDefinitionClass, (DefaultViewConfigDefinitionEntry)scannedViewConfig);
+    private ViewConfigEntry extractViewConfigEntry(Class<? extends ViewConfig> viewDefinitionClass,
+                                                   ViewConfigEntry viewConfigEntry)
+    {
+        scanViewConfigClass(viewDefinitionClass, (ExtractedViewConfigDefinitionEntry)viewConfigEntry);
 
-        return new DefaultViewConfigEntry(scannedViewConfig.getViewId(),
+        return new DefaultViewConfigEntry(viewConfigEntry.getViewId(),
                                           viewDefinitionClass,
-                                          scannedViewConfig.getNavigationMode(),
-                                          scannedViewConfig.getViewParameter(),
-                                          scannedViewConfig.getAccessDecisionVoters(),
-                                          scannedViewConfig.getErrorView(),
-                                          scannedViewConfig.getMetaData());
+                                          viewConfigEntry.getNavigationMode(),
+                                          viewConfigEntry.getViewParameter(),
+                                          viewConfigEntry.getAccessDecisionVoters(),
+                                          viewConfigEntry.getErrorView(),
+                                          viewConfigEntry.getMetaData());
     }
 
     private Collection<Annotation> extractViewMetaData(
-            Class<?> targetClass, DefaultViewConfigDefinitionEntry entry)
+            Class<?> targetClass, ExtractedViewConfigDefinitionEntry entry)
     {
         List<Annotation> result = new ArrayList<Annotation>();
 
@@ -78,11 +113,11 @@ class DefaultViewConfigExtractor impleme
         return result;
     }
 
-    private void scanViewConfigClass(Class<?> viewDefinitionClass, DefaultViewConfigDefinitionEntry scannedViewConfig)
+    private void scanViewConfigClass(Class<?> viewDefinitionClass, ExtractedViewConfigDefinitionEntry scannedViewConfig)
     {
-        String defaultExtension = DefaultViewConfigDefinitionEntry.DEFAULT_EXTENSION;
-        String defaultPageName = DefaultViewConfigDefinitionEntry.DEFAULT_PAGE_NAME;
-        String rootPath = DefaultViewConfigDefinitionEntry.ROOT_PATH;
+        String defaultExtension = ExtractedViewConfigDefinitionEntry.DEFAULT_EXTENSION;
+        String defaultPageName = ExtractedViewConfigDefinitionEntry.DEFAULT_PAGE_NAME;
+        String rootPath = ExtractedViewConfigDefinitionEntry.ROOT_PATH;
 
         String currentBasePath;
         Page pageAnnotation;
@@ -162,4 +197,40 @@ class DefaultViewConfigExtractor impleme
             currentClass = currentClass.getSuperclass();
         }
     }
+
+    /**
+     * @param annotated current class to scan
+     * @param scannedAnnotations simple cycle prevention
+     * @return true to signal that the class is resolvable via EL
+     */
+    private boolean isResolvable(Class annotated, List<Class<? extends Annotation>> scannedAnnotations)
+    {
+        if(annotated.isAnnotation())
+        {
+            scannedAnnotations.add(annotated);
+        }
+
+        Class<? extends Annotation> annotationClass;
+        for(Annotation annotation : annotated.getAnnotations())
+        {
+            annotationClass = annotation.annotationType();
+
+            if(scannedAnnotations.contains(annotationClass))
+            {
+                continue;
+            }
+
+            if(Named.class.equals(annotationClass) || "javax.faces.bean.ManagedBean".equals(annotationClass.getName()))
+            {
+                return true;
+            }
+
+            //to support stereotypes
+            if(isResolvable(annotationClass, scannedAnnotations))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
 }

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedInlineViewConfigDefinitionEntry.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/config/view/ExtractedInlineViewConfigDefinitionEntry.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedInlineViewConfigDefinitionEntry.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedInlineViewConfigDefinitionEntry.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,82 @@
+/*
+ * 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.config.view;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.InlineViewConfigRoot;
+
+/**
+ * @author Gerhard Petracek
+ */
+class ExtractedInlineViewConfigDefinitionEntry extends ExtractedViewConfigDefinitionEntry
+{
+    private static final long serialVersionUID = 4506644013820265055L;
+
+    public ExtractedInlineViewConfigDefinitionEntry(Class<? extends ViewConfig> viewDefinitionClass, String basePath)
+    {
+        super(viewDefinitionClass);
+        this.basePath = basePath + "/";
+    }
+
+    @Override
+    public void setBasePath(String currentBasePath)
+    {
+        //filtered
+    }
+
+    @Override
+    public String getViewId()
+    {
+        Class<?> viewConfigRootMarker = ViewConfigCache.getInlineViewConfigRootMarker();
+        InlineViewConfigRoot viewConfigRoot = viewConfigRootMarker.getAnnotation(InlineViewConfigRoot.class);
+
+        if(!viewConfigRoot.basePath().endsWith("/*") && !".".equals(viewConfigRoot.basePath()))
+        {
+            this.basePath = viewConfigRoot.basePath();
+        }
+
+        if(viewConfigRoot.basePath().endsWith("/*"))
+        {
+            String packageName = viewConfigRoot.basePath();
+            this.basePath = packageName.substring(0, packageName.length() - 2) + "/" + this.basePath;
+        }
+
+        if(".".equals(viewConfigRoot.basePath()))
+        {
+            String packageName = viewConfigRootMarker.getPackage().getName();
+            this.basePath = "/" + packageName.substring(packageName.lastIndexOf(".") + 1) + "/" + this.basePath;
+        }
+
+        if(DEFAULT_PAGE_NAME.equals(this.pageName))
+        {
+            this.pageName = createPageName(this.viewDefinitionClass.getSimpleName());
+
+            for(String postfix : viewConfigRoot.pageBeanPostfix())
+            {
+                if(this.pageName.endsWith(postfix))
+                {
+                    this.pageName = this.pageName.substring(0, this.pageName.length() - postfix.length());
+                    break;
+                }
+            }
+        }
+
+        return super.getViewId();
+    }
+}

Copied: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java (from r1059626, myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.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/config/view/ExtractedViewConfigDefinitionEntry.java?p2=myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java&p1=myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java&r1=1059626&r2=1067579&rev=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java Sun Feb  6 03:12:37 2011
@@ -35,7 +35,7 @@ import java.util.Collections;
 /**
  * @author Gerhard Petracek
  */
-class DefaultViewConfigDefinitionEntry implements ViewConfigEntry
+class ExtractedViewConfigDefinitionEntry implements ViewConfigEntry
 {
     private static final long serialVersionUID = -8387356240329549455L;
 
@@ -51,15 +51,15 @@ class DefaultViewConfigDefinitionEntry i
 
     List<Annotation> viewMetaDataList = new ArrayList<Annotation>();
 
-    private Class<? extends ViewConfig> viewDefinitionClass;
-    private String basePath = ROOT_PATH;
+    protected Class<? extends ViewConfig> viewDefinitionClass;
+    protected String basePath = ROOT_PATH;
     private Map<String, String> simpleClassNameToPathMapping = new HashMap<String, String>();
-    private String pageName = DEFAULT_PAGE_NAME;
+    protected String pageName = DEFAULT_PAGE_NAME;
     private String extension = DEFAULT_EXTENSION;
     private Page.NavigationMode navigationMode = null;
     private Page.ViewParameter viewParameter = null;
 
-    public DefaultViewConfigDefinitionEntry(Class<? extends ViewConfig> viewDefinitionClass)
+    public ExtractedViewConfigDefinitionEntry(Class<? extends ViewConfig> viewDefinitionClass)
     {
         this.viewDefinitionClass = viewDefinitionClass;
     }
@@ -179,7 +179,7 @@ class DefaultViewConfigDefinitionEntry i
             {
                 className = className.substring(className.lastIndexOf(".") + 1);
             }
-            className = className.substring(0, 1).toLowerCase() + className.substring(1);
+            className = createPageName(className);
             viewId.append(className);
         }
         //nested classes with manually defined page name and shared basePath
@@ -190,7 +190,7 @@ class DefaultViewConfigDefinitionEntry i
             this.basePath = "";
             className = className.substring(className.lastIndexOf(".") + 1);
             className = convertToPathSyntax(className, this.simpleClassNameToPathMapping);
-            className = className.substring(0, 1).toLowerCase() + className.substring(1);
+            className = createPageName(className);
             className = className.substring(0, className.lastIndexOf("/") + 1);
             className += this.pageName;
             viewId.append(className);
@@ -219,6 +219,12 @@ class DefaultViewConfigDefinitionEntry i
         return result;
     }
 
+    protected String createPageName(String className)
+    {
+        className = className.substring(0, 1).toLowerCase() + className.substring(1);
+        return className;
+    }
+
     /*
      * TODO refactor it!
      */

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/InlineViewConfigEntry.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/config/view/InlineViewConfigEntry.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/InlineViewConfigEntry.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/InlineViewConfigEntry.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.config.view;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigExtractor;
+
+/**
+ * @author Gerhard Petracek
+ */
+class InlineViewConfigEntry
+{
+    private final ViewConfigExtractor viewConfigExtractor;
+    private final Class<? extends ViewConfig> viewConfigDefinition;
+
+    InlineViewConfigEntry(ViewConfigExtractor viewConfigExtractor, Class<? extends ViewConfig> viewConfigDefinition)
+    {
+        this.viewConfigExtractor = viewConfigExtractor;
+        this.viewConfigDefinition = viewConfigDefinition;
+    }
+
+    ViewConfigExtractor getViewConfigExtractor()
+    {
+        return viewConfigExtractor;
+    }
+
+    Class<? extends ViewConfig> getViewConfigDefinition()
+    {
+        return viewConfigDefinition;
+    }
+}

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigCache.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/config/view/ViewConfigCache.java?rev=1067579&r1=1067578&r2=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigCache.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigCache.java Sun Feb  6 03:12:37 2011
@@ -19,15 +19,20 @@
 package org.apache.myfaces.extensions.cdi.jsf.impl.config.view;
 
 import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
-import org.apache.myfaces.extensions.cdi.core.api.config.view.DefaultErrorView;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigEntry;
+import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigExtractor;
 
-import static org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewConfigCacheStore.*;
-import static org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewConfigCacheStore.setDefaultErrorView;
+import org.apache.myfaces.extensions.cdi.core.api.config.view.DefaultErrorView;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.HashMap;
 import java.util.Collection;
 
+import static org.apache.myfaces.extensions.cdi.jsf.impl.util.ExceptionUtils.*;
+
 /**
  * TODO move exceptions to util class
  *
@@ -35,6 +40,28 @@ import java.util.Collection;
  */
 public class ViewConfigCache
 {
+    //we don't need a ConcurrentHashMap - write access is only allowed during the startup (by one thread)
+
+    private static Map<ClassLoader, Map<String, ViewConfigEntry>>
+            viewIdToViewDefinitionEntryMapping
+            = new HashMap<ClassLoader, Map<String, ViewConfigEntry>>();
+
+    private static Map<ClassLoader, Map<Class<? extends ViewConfig>, ViewConfigEntry>>
+            viewDefinitionToViewDefinitionEntryMapping =
+            new HashMap<ClassLoader, Map<Class<? extends ViewConfig>, ViewConfigEntry>>();
+
+    private static Map<ClassLoader, List<InlineViewConfigEntry>>
+            inlineViewDefinitionEntryList =
+            new HashMap<ClassLoader, List<InlineViewConfigEntry>>();
+
+    private static Map<ClassLoader, ViewConfigEntry>
+            defaultErrorView =
+            new HashMap<ClassLoader, ViewConfigEntry>();
+
+    private static Map<ClassLoader, Class>
+            inlineViewConfigRootMarker =
+            new HashMap<ClassLoader, Class>();
+
     static void addViewDefinition(String viewId, ViewConfigEntry viewDefinitionEntry)
     {
         storeViewDefinition(viewId, viewDefinitionEntry, false);
@@ -45,64 +72,210 @@ public class ViewConfigCache
         storeViewDefinition(viewId, viewDefinitionEntry, true);
     }
 
-    private static void storeViewDefinition(String viewId, ViewConfigEntry viewDefinitionEntry, boolean allowReplace)
+    public static ViewConfigEntry getViewDefinition(String viewId)
     {
-        tryToStorePageAsDefaultErrorPage(viewDefinitionEntry);
+        return getViewIdToViewDefinitionEntryMapping(true).get(viewId);
+    }
+
+    public static Collection<ViewConfigEntry> getViewConfigEntries()
+    {
+        Map<String, ViewConfigEntry> entryMap = getViewIdToViewDefinitionEntryMapping(true);
+
+        return entryMap.values();
+    }
+
+    public static ViewConfigEntry getViewDefinition(Class<? extends ViewConfig> viewDefinitionClass)
+    {
+        return getViewDefinitionToViewDefinitionEntryMapping(true).get(viewDefinitionClass);
+    }
+
+    public static ViewConfigEntry getDefaultErrorView()
+    {
+        lazyInlineViewConfigCompilation();
+        return defaultErrorView.get(getClassloader());
+    }
+
+    /**
+     * resets the whole cache - e.g. needed for junit tests
+     */
+    public static void reset()
+    {
+        getViewIdToViewDefinitionEntryMapping(false).clear();
+        getViewDefinitionToViewDefinitionEntryMapping(false).clear();
+        getInlineViewDefinitionToViewDefinitionEntryList().clear();
+
+        defaultErrorView.put(getClassloader(), null);
+        inlineViewConfigRootMarker.put(getClassloader(), null);
+    }
+
+    static void queueInlineViewConfig(ViewConfigExtractor viewConfigExtractor, Class<? extends ViewConfig> beanClass)
+    {
+        getInlineViewDefinitionToViewDefinitionEntryList()
+                .add(new InlineViewConfigEntry(viewConfigExtractor, beanClass));
+    }
+
+    static void setInlineViewConfigRootMarker(Class viewConfigRootClass)
+    {
+        Class storedPageClass = getInlineViewConfigRootMarker();
+
+        if(storedPageClass != null)
+        {
+            if(!storedPageClass.equals(viewConfigRootClass))
+            {
+                throw ambiguousViewConfigRootException(storedPageClass, viewConfigRootClass);
+            }
+        }
+        else
+        {
+            inlineViewConfigRootMarker.put(getClassloader(), viewConfigRootClass);
+        }
+    }
+
+    static Class getInlineViewConfigRootMarker()
+    {
+        return inlineViewConfigRootMarker.get(getClassloader());
+    }
 
-        if(getViewIdToViewDefinitionEntryMapping().containsKey(viewId) && !allowReplace)
+    static void storeViewDefinition(String viewId,
+                                    ViewConfigEntry viewDefinitionEntry,
+                                    boolean allowReplace,
+                                    boolean lazyInit)
+    {
+        if(getViewIdToViewDefinitionEntryMapping(lazyInit).containsKey(viewId) && !allowReplace)
         {
-            throw new IllegalArgumentException(viewId + " is already mapped to "
-                    + viewId + " via " + getViewIdToViewDefinitionEntryMapping().get(viewId).getViewDefinitionClass()
-                    + " -> a further view definition (" +
-                    viewDefinitionEntry.getViewDefinitionClass().getName() + ") is invalid");
+            throw ambiguousViewDefinitionException(
+                    viewId,
+                    viewDefinitionEntry.getViewDefinitionClass(),
+                    getViewIdToViewDefinitionEntryMapping(lazyInit).get(viewId).getViewDefinitionClass());
         }
-        getViewIdToViewDefinitionEntryMapping().put(viewId, viewDefinitionEntry);
-        getViewDefinitionToViewDefinitionEntryMapping()
+
+        tryToStorePageAsDefaultErrorPage(viewDefinitionEntry);
+
+        getViewIdToViewDefinitionEntryMapping(lazyInit).put(viewId, viewDefinitionEntry);
+        getViewDefinitionToViewDefinitionEntryMapping(lazyInit)
                 .put(viewDefinitionEntry.getViewDefinitionClass(), viewDefinitionEntry);
     }
 
+    static void storeViewDefinition(String viewId, ViewConfigEntry viewDefinitionEntry, boolean allowReplace)
+    {
+        storeViewDefinition(viewId, viewDefinitionEntry, allowReplace, true);
+    }
+
+    private static Map<String, ViewConfigEntry> getViewIdToViewDefinitionEntryMapping(boolean lazyInit)
+    {
+        if(lazyInit)
+        {
+            lazyInlineViewConfigCompilation();
+        }
+
+        Map<String, ViewConfigEntry> result = viewIdToViewDefinitionEntryMapping.get(getClassloader());
+
+        if(result == null)
+        {
+            result = new HashMap<String, ViewConfigEntry>();
+            viewIdToViewDefinitionEntryMapping.put(getClassloader(), result);
+        }
+
+        return result;
+    }
+
+    private static Map<Class<? extends ViewConfig>, ViewConfigEntry>
+        getViewDefinitionToViewDefinitionEntryMapping(boolean lazyInit)
+    {
+        if(lazyInit)
+        {
+            lazyInlineViewConfigCompilation();
+        }
+
+        Map<Class<? extends ViewConfig>, ViewConfigEntry> result =
+                viewDefinitionToViewDefinitionEntryMapping.get(getClassloader());
+
+        if(result == null)
+        {
+            result = new HashMap<Class<? extends ViewConfig>, ViewConfigEntry>();
+            viewDefinitionToViewDefinitionEntryMapping.put(getClassloader(), result);
+        }
+        return result;
+    }
+
+    private static List<InlineViewConfigEntry> getInlineViewDefinitionToViewDefinitionEntryList()
+    {
+        List<InlineViewConfigEntry> inlineViewConfigEntryList = inlineViewDefinitionEntryList.get(getClassloader());
+
+        if(inlineViewConfigEntryList == null)
+        {
+            inlineViewConfigEntryList = new ArrayList<InlineViewConfigEntry>();
+            inlineViewDefinitionEntryList.put(getClassloader(), inlineViewConfigEntryList);
+        }
+        return inlineViewConfigEntryList;
+    }
+
     private static void tryToStorePageAsDefaultErrorPage(ViewConfigEntry viewDefinitionEntry)
     {
         if(DefaultErrorView.class.isAssignableFrom(viewDefinitionEntry.getViewDefinitionClass()))
         {
-            if(getDefaultErrorViewForApplication() != null)
+            ViewConfigEntry defaultErrorView = getDefaultErrorView();
+            if(defaultErrorView != null)
             {
-                throw new IllegalStateException("multiple error pages found " +
-                        getDefaultErrorViewForApplication().getViewDefinitionClass().getClass().getName() + " and " +
-                        viewDefinitionEntry.getViewDefinitionClass().getName());
+                throw ambiguousDefaultErrorViewDefinitionException(viewDefinitionEntry.getViewDefinitionClass(),
+                                                                   defaultErrorView.getViewDefinitionClass());
             }
 
             setDefaultErrorView(viewDefinitionEntry);
         }
     }
 
-    public static ViewConfigEntry getViewDefinition(String viewId)
+    private static void setDefaultErrorView(ViewConfigEntry viewDefinitionEntry)
     {
-        return getViewIdToViewDefinitionEntryMapping().get(viewId);
+        //TODO
+        defaultErrorView.put(getClassloader(), viewDefinitionEntry);
     }
 
-    public static Collection<ViewConfigEntry> getViewConfigEntries()
+    private static ClassLoader getClassloader()
     {
-        Map<String, ViewConfigEntry> entryMap = getViewIdToViewDefinitionEntryMapping();
-
-        return entryMap.values();
+        return ClassUtils.getClassLoader(null);
     }
 
-    public static ViewConfigEntry getViewDefinition(Class<? extends ViewConfig> viewDefinitionClass)
+    private static void lazyInlineViewConfigCompilation()
     {
-        return getViewDefinitionToViewDefinitionEntryMapping().get(viewDefinitionClass);
-    }
+        List<InlineViewConfigEntry> inlineViewConfigEntryList =
+                inlineViewDefinitionEntryList.get(getClassloader());
 
-    public static ViewConfigEntry getDefaultErrorView()
-    {
-        return getDefaultErrorViewForApplication();
+        if(inlineViewConfigEntryList == null)
+        {
+            //there is no inline view config or it is already processed
+            return;
+        }
+
+        registerInlineViewConfigEntry();
     }
 
-    /**
-     * resets the whole cache - e.g. needed for junit tests
-     */
-    public static void reset()
+    private synchronized static void registerInlineViewConfigEntry()
     {
-        clear();
+        List<InlineViewConfigEntry> inlineViewConfigEntryList =
+                inlineViewDefinitionEntryList.get(getClassloader());
+
+        // switch into paranoia mode
+        if(inlineViewConfigEntryList == null)
+        {
+            return;
+        }
+
+        ViewConfigEntry viewConfigEntry;
+        for(InlineViewConfigEntry inlineViewConfigEntry : inlineViewConfigEntryList)
+        {
+            viewConfigEntry = inlineViewConfigEntry.getViewConfigExtractor()
+                    .extractInlineViewConfig(inlineViewConfigEntry.getViewConfigDefinition());
+
+            if(viewConfigEntry != null)
+            {
+                //activate view controller annotations
+                viewConfigEntry.addPageBean(viewConfigEntry.getViewDefinitionClass());
+
+                storeViewDefinition(viewConfigEntry.getViewId(), viewConfigEntry, false, false);
+            }
+        }
+
+        inlineViewDefinitionEntryList.put(getClassloader(), null);
     }
 }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.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/config/view/ViewConfigExtension.java?rev=1067579&r1=1067578&r2=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.java Sun Feb  6 03:12:37 2011
@@ -25,6 +25,7 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.core.api.Deactivatable;
 import org.apache.myfaces.extensions.cdi.core.impl.util.CodiUtils;
 import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.InlineViewConfigRoot;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.PageBeanConfigEntry;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigEntry;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigExtractor;
@@ -57,10 +58,30 @@ public class ViewConfigExtension impleme
 
         CodiStartupBroadcaster.broadcastStartup();
 
-        if (processAnnotatedType.getAnnotatedType().isAnnotationPresent(Page.class))
+        if(processAnnotatedType.getAnnotatedType().isAnnotationPresent(InlineViewConfigRoot.class))
         {
-            addPageDefinition(processAnnotatedType.getAnnotatedType().getJavaClass());
+            setInlineViewConfigRootMarker(processAnnotatedType.getAnnotatedType().getJavaClass());
             processAnnotatedType.veto();
+            return;
+        }
+
+        if (processAnnotatedType.getAnnotatedType().isAnnotationPresent(Page.class))
+        {
+            validateViewConfigDefinition(processAnnotatedType.getAnnotatedType().getJavaClass());
+
+            @SuppressWarnings({"unchecked"})
+            Class<? extends ViewConfig> beanClass = processAnnotatedType.getAnnotatedType().getJavaClass();
+
+            ViewConfigExtractor viewConfigExtractor = getViewConfigExtractor();
+            if(isInlineViewConfig(viewConfigExtractor, beanClass))
+            {
+                addInlinePageDefinition(viewConfigExtractor, beanClass);
+            }
+            else
+            {
+                addPageDefinition(beanClass);
+                processAnnotatedType.veto();
+            }
         }
 
         if (processAnnotatedType.getAnnotatedType().isAnnotationPresent(View.class) &&
@@ -74,7 +95,12 @@ public class ViewConfigExtension impleme
         }
     }
 
-    protected void addPageDefinition(Class pageDefinitionClass)
+    protected void setInlineViewConfigRootMarker(Class markerClass)
+    {
+        ViewConfigCache.setInlineViewConfigRootMarker(markerClass);
+    }
+
+    protected void addPageDefinition(Class<? extends ViewConfig> pageDefinitionClass)
     {
         ViewConfigEntry newEntry = createViewConfigEntry(pageDefinitionClass);
 
@@ -105,6 +131,26 @@ public class ViewConfigExtension impleme
         }
     }
 
+    protected boolean isInlineViewConfig(Class<? extends ViewConfig> beanClass)
+    {
+        return isInlineViewConfig(getViewConfigExtractor(), beanClass);
+    }
+
+    private boolean isInlineViewConfig(ViewConfigExtractor viewConfigExtractor, Class<? extends ViewConfig> beanClass)
+    {
+        return viewConfigExtractor.isInlineViewConfig(beanClass);
+    }
+
+    protected void addInlinePageDefinition(Class<? extends ViewConfig> beanClass)
+    {
+        addInlinePageDefinition(getViewConfigExtractor(), beanClass);
+    }
+
+    private void addInlinePageDefinition(ViewConfigExtractor viewConfigExtractor, Class<? extends ViewConfig> beanClass)
+    {
+        ViewConfigCache.queueInlineViewConfig(viewConfigExtractor, beanClass);
+    }
+
     /**
      * important: {@link org.apache.myfaces.extensions.cdi.core.api.config.view.View#inline()} isn't supported!
      *
@@ -150,18 +196,8 @@ public class ViewConfigExtension impleme
         }
     }
 
-    protected ViewConfigEntry createViewConfigEntry(Class pageDefinitionClass)
+    protected ViewConfigEntry createViewConfigEntry(Class<? extends ViewConfig> viewDefinitionClass)
     {
-        if(!ViewConfig.class.isAssignableFrom(pageDefinitionClass))
-        {
-            throw new IllegalArgumentException(
-                    "the page definition " + pageDefinitionClass.getName() + " has to implement "
-                            + ViewConfig.class.getName());
-        }
-
-        @SuppressWarnings({"unchecked"})
-        Class<? extends ViewConfig> viewDefinitionClass = (Class<? extends ViewConfig>)pageDefinitionClass;
-
         //we use abstract classes for nesting definitions
         //TODO log a warning in case of project-stage dev
         if(Modifier.isAbstract(viewDefinitionClass.getModifiers()))
@@ -169,17 +205,31 @@ public class ViewConfigExtension impleme
             return null;
         }
 
+        ViewConfigEntry result = getViewConfigExtractor().extractViewConfig(viewDefinitionClass);
+        return result;
+    }
+
+    private void validateViewConfigDefinition(Class beanClass)
+    {
+        if(!ViewConfig.class.isAssignableFrom(beanClass))
+        {
+            throw new IllegalArgumentException(
+                    "the page definition " + beanClass.getName() + " has to implement "
+                            + ViewConfig.class.getName());
+        }
+    }
+
+    private ViewConfigExtractor getViewConfigExtractor()
+    {
         ViewConfigExtractor viewConfigExtractor = CodiUtils.lookupFromEnvironment(VIEW_CONFIG_EXTRACTOR_PROPERTY_NAME,
-                                                                                  VIEW_CONFIG_EXTRACTOR_JNDI_NAME,
-                                                                                  ViewConfigExtractor.class);
-        
+                VIEW_CONFIG_EXTRACTOR_JNDI_NAME,
+                ViewConfigExtractor.class);
+
         if(viewConfigExtractor == null)
         {
             viewConfigExtractor = new DefaultViewConfigExtractor();
         }
-
-        ViewConfigEntry result = viewConfigExtractor.extractViewConfig(viewDefinitionClass);
-        return result;
+        return viewConfigExtractor;
     }
 
     public boolean isActivated()

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.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/config/view/spi/ViewConfigExtractor.java?rev=1067579&r1=1067578&r2=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.java Sun Feb  6 03:12:37 2011
@@ -26,4 +26,8 @@ import org.apache.myfaces.extensions.cdi
 public interface ViewConfigExtractor
 {
     ViewConfigEntry extractViewConfig(Class<? extends ViewConfig> viewDefinitionClass);
+
+    boolean isInlineViewConfig(Class<? extends ViewConfig> viewDefinitionClass);
+
+    ViewConfigEntry extractInlineViewConfig(Class<? extends ViewConfig> viewDefinitionClass);
 }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/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/jsf/impl/util/ExceptionUtils.java?rev=1067579&r1=1067578&r2=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ExceptionUtils.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ExceptionUtils.java Sun Feb  6 03:12:37 2011
@@ -18,9 +18,11 @@
  */
 package org.apache.myfaces.extensions.cdi.jsf.impl.util;
 
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
 import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext;
 import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
 import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.InlineViewConfigRoot;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContext;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContextManager;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableConversation;
@@ -88,4 +90,52 @@ public class ExceptionUtils
     {
         return new IllegalArgumentException("Cannot find conversation with key: " + conversationKey);
     }
+
+    public static IllegalStateException missingInlineViewConfigRootMarkerException(
+            Class<? extends ViewConfig> viewDefinitionClass)
+    {
+        StringBuilder message = new StringBuilder();
+
+        message.append(viewDefinitionClass.getName());
+        message.append(" is an inline view-config and no page-root marker has been found. ");
+        message.append("Please remove the @Page annotation ");
+        message.append("or add a marker class or interface in the root package of your page-beans ");
+        message.append("and annotate it with ");
+        message.append(InlineViewConfigRoot.class.getName());
+        message.append(" or refactor it to normal view-configs");
+        
+        throw new IllegalStateException(message.toString());
+    }
+
+    public static IllegalStateException ambiguousViewConfigRootException(
+            Class storedPageClass, Class viewConfigRootClass)
+    {
+        StringBuilder message = new StringBuilder();
+
+        message.append("Inline view-configs don't support multiple page-root markers in the same application.\n");
+        message.append("Refactor to normal view-configs or remove ");
+        message.append(storedPageClass.getName());
+        message.append(" or ");
+        message.append(viewConfigRootClass.getName());
+
+        throw new IllegalStateException(message.toString());
+    }
+
+    public static IllegalArgumentException ambiguousViewDefinitionException(String viewId,
+                                                                            Class<? extends ViewConfig> newDef,
+                                                                            Class<? extends ViewConfig> existingDef)
+    {
+        return new IllegalArgumentException(viewId + " is already mapped to "
+                + viewId + " via " + existingDef.getName()
+                + " -> a further view definition (" +
+                newDef.getName() + ") is invalid");
+    }
+
+    public static IllegalStateException ambiguousDefaultErrorViewDefinitionException(Class<? extends ViewConfig> newDef,
+                                                                         Class<? extends ViewConfig> existingDef)
+    {
+        return new IllegalStateException("multiple error pages found " +
+                        existingDef.getName() + " and " +
+                        newDef.getName());
+    }
 }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/TestableViewConfigExtension.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/TestableViewConfigExtension.java?rev=1067579&r1=1067578&r2=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/TestableViewConfigExtension.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/TestableViewConfigExtension.java Sun Feb  6 03:12:37 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view;
 
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewConfigExtension;
 
 /**
@@ -26,8 +27,26 @@ import org.apache.myfaces.extensions.cdi
 class TestableViewConfigExtension extends ViewConfigExtension
 {
     @Override
-    public void addPageDefinition(Class pageDefinitionClass)
+    public void addPageDefinition(Class<? extends ViewConfig> pageDefinitionClass)
     {
         super.addPageDefinition(pageDefinitionClass);
     }
+
+    @Override
+    public void setInlineViewConfigRootMarker(Class viewConfigRootMarker)
+    {
+        super.setInlineViewConfigRootMarker(viewConfigRootMarker);
+    }
+
+    @Override
+    public void addInlinePageDefinition(Class<? extends ViewConfig> beanClass)
+    {
+        super.addInlinePageDefinition(beanClass);
+    }
+
+    @Override
+    public boolean isInlineViewConfig(Class<? extends ViewConfig> beanClass)
+    {
+        return super.isInlineViewConfig(beanClass);
+    }
 }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java?rev=1067579&r1=1067578&r2=1067579&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java Sun Feb  6 03:12:37 2011
@@ -22,6 +22,12 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.PageBeanConfigEntry;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigEntry;
+import org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.BasefolderViewConfigRootMarker;
+import org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.RenamedBasefolderViewConfigRootMarker;
+import org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.SubfolderViewConfigRootMarker;
+import org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.order.OrderOverviewPage;
+import org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.registration.RegistrationStep01PageBean;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewConfigCache;
@@ -36,6 +42,12 @@ public class ViewConfigTest
 {
     private TestableViewConfigExtension viewConfigExtension = new TestableViewConfigExtension();
 
+    @BeforeMethod
+    public void resetCache()
+    {
+        ViewConfigCache.reset();
+    }
+
     @Test
     public void testSimpleCase()
     {
@@ -266,4 +278,119 @@ public class ViewConfigTest
                        pageBeanConfigEntry.getBeanClass().equals(TestPageBean3.class));
         }
     }
+
+    @Test
+    public void testBasefolderInlineViewConfig()
+    {
+        viewConfigExtension.setInlineViewConfigRootMarker(BasefolderViewConfigRootMarker.class);
+        viewConfigExtension.addInlinePageDefinition(OrderOverviewPage.class);
+        viewConfigExtension.addInlinePageDefinition(RegistrationStep01PageBean.class);
+
+        assertEquals(ViewConfigCache.getViewDefinition(
+                OrderOverviewPage.class).getViewId(),
+                "/pages/order/orderOverview.xhtml");
+        assertEquals(ViewConfigCache.getViewDefinition(
+                RegistrationStep01PageBean.class).getViewId(),
+                "/pages/registration/registrationStep01.xhtml");
+
+        assertEquals(ViewConfigCache.getViewDefinition(
+                OrderOverviewPage.class).getAccessDecisionVoters().iterator().next().getName(),
+                "org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.order.TestAccessDecisionVoter3");
+
+        PageBeanConfigEntry pageBeanConfigEntry = ViewConfigCache.getViewDefinition(RegistrationStep01PageBean.class)
+                .getPageBeanDefinitions().iterator().next();
+
+        assertEquals(pageBeanConfigEntry.getBeanClass(), RegistrationStep01PageBean.class);
+        assertEquals(pageBeanConfigEntry.getPreRenderViewMethods().size(), 1);
+    }
+
+    @Test
+    public void testRenamvedBasefolderInlineViewConfig()
+    {
+        viewConfigExtension.setInlineViewConfigRootMarker(RenamedBasefolderViewConfigRootMarker.class);
+        viewConfigExtension.addInlinePageDefinition(OrderOverviewPage.class);
+        viewConfigExtension.addInlinePageDefinition(RegistrationStep01PageBean.class);
+
+        assertEquals(ViewConfigCache.getViewDefinition(
+                OrderOverviewPage.class).getViewId(),
+                "/views/order/orderOverview.xhtml");
+        assertEquals(ViewConfigCache.getViewDefinition(
+                RegistrationStep01PageBean.class).getViewId(),
+                "/views/registration/registrationStep01.xhtml");
+
+        assertEquals(ViewConfigCache.getViewDefinition(
+                OrderOverviewPage.class).getAccessDecisionVoters().iterator().next().getName(),
+                "org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.order.TestAccessDecisionVoter3");
+
+        PageBeanConfigEntry pageBeanConfigEntry = ViewConfigCache.getViewDefinition(RegistrationStep01PageBean.class)
+                .getPageBeanDefinitions().iterator().next();
+
+        assertEquals(pageBeanConfigEntry.getBeanClass(), RegistrationStep01PageBean.class);
+        assertEquals(pageBeanConfigEntry.getPreRenderViewMethods().size(), 1);
+    }
+
+    @Test
+    public void testSubfolderInlineViewConfig()
+    {
+        viewConfigExtension.setInlineViewConfigRootMarker(SubfolderViewConfigRootMarker.class);
+        viewConfigExtension.addInlinePageDefinition(OrderOverviewPage.class);
+        viewConfigExtension.addInlinePageDefinition(RegistrationStep01PageBean.class);
+
+        assertEquals(ViewConfigCache.getViewDefinition(
+                OrderOverviewPage.class).getViewId(),
+                "/order/orderOverview.xhtml");
+        assertEquals(ViewConfigCache.getViewDefinition(
+                RegistrationStep01PageBean.class).getViewId(),
+                "/registration/registrationStep01.xhtml");
+
+        assertEquals(ViewConfigCache.getViewDefinition(
+                OrderOverviewPage.class).getAccessDecisionVoters().iterator().next().getName(),
+                "org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view.inline.pages.order.TestAccessDecisionVoter3");
+
+        PageBeanConfigEntry pageBeanConfigEntry = ViewConfigCache.getViewDefinition(RegistrationStep01PageBean.class)
+                .getPageBeanDefinitions().iterator().next();
+
+        assertEquals(pageBeanConfigEntry.getBeanClass(), RegistrationStep01PageBean.class);
+        assertEquals(pageBeanConfigEntry.getPreRenderViewMethods().size(), 1);
+    }
+
+    @Test
+    public void testInlineViewConfigDetection()
+    {
+        assertTrue(viewConfigExtension.isInlineViewConfig(OrderOverviewPage.class));
+        assertTrue(viewConfigExtension.isInlineViewConfig(RegistrationStep01PageBean.class));
+    }
+
+    @Test
+    public void testMissingInlineViewConfigRootMarkerWithInlineViewConfig()
+    {
+        viewConfigExtension.addInlinePageDefinition(OrderOverviewPage.class);
+
+        try
+        {
+            assertEquals(ViewConfigCache.getViewDefinition(
+                    OrderOverviewPage.class).getViewId(),
+                    "/order/orderOverview.xhtml");
+        }
+        catch (IllegalStateException e)
+        {
+            return;
+        }
+        fail();
+    }
+
+    @Test
+    public void testAmbiguousInlineViewConfigRootMarkerWithInlineViewConfig()
+    {
+        try
+        {
+            viewConfigExtension.setInlineViewConfigRootMarker(SubfolderViewConfigRootMarker.class);
+            viewConfigExtension.setInlineViewConfigRootMarker(getClass());
+        }
+        catch (IllegalStateException e)
+        {
+            return;
+        }
+        fail();
+    }
 }

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/BasefolderViewConfigRootMarker.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/BasefolderViewConfigRootMarker.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/BasefolderViewConfigRootMarker.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/BasefolderViewConfigRootMarker.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.test.impl.config.view.inline.pages;
+
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.InlineViewConfigRoot;
+
+/**
+ * @author Gerhard Petracek
+ */
+@InlineViewConfigRoot(pageBeanPostfix = {"Page", "PageBean"})
+public interface BasefolderViewConfigRootMarker
+{
+}

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/RenamedBasefolderViewConfigRootMarker.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/RenamedBasefolderViewConfigRootMarker.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/RenamedBasefolderViewConfigRootMarker.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/RenamedBasefolderViewConfigRootMarker.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.test.impl.config.view.inline.pages;
+
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.InlineViewConfigRoot;
+
+/**
+ * @author Gerhard Petracek
+ */
+@InlineViewConfigRoot(basePath = "/views/*", pageBeanPostfix = {"Page", "PageBean"})
+public interface RenamedBasefolderViewConfigRootMarker
+{
+}

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/SubfolderViewConfigRootMarker.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/SubfolderViewConfigRootMarker.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/SubfolderViewConfigRootMarker.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/SubfolderViewConfigRootMarker.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.test.impl.config.view.inline.pages;
+
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.InlineViewConfigRoot;
+
+/**
+ * @author Gerhard Petracek
+ */
+@InlineViewConfigRoot(basePath = "/*", pageBeanPostfix = {"Page", "PageBean"})
+public interface SubfolderViewConfigRootMarker
+{
+}

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/OrderOverviewPage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/OrderOverviewPage.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/OrderOverviewPage.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/OrderOverviewPage.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,32 @@
+/*
+ * 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.test.impl.config.view.inline.pages.order;
+
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page;
+
+import javax.inject.Named;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Page
+@Named
+public class OrderOverviewPage implements SecuredPage
+{
+}

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/SecuredPage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/SecuredPage.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/SecuredPage.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/SecuredPage.java Sun Feb  6 03:12:37 2011
@@ -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.jsf.test.impl.config.view.inline.pages.order;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.core.api.security.Secured;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Secured(value = TestAccessDecisionVoter3.class)
+public interface SecuredPage extends ViewConfig
+{
+}

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/TestAccessDecisionVoter3.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/TestAccessDecisionVoter3.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/TestAccessDecisionVoter3.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/order/TestAccessDecisionVoter3.java Sun Feb  6 03:12:37 2011
@@ -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.jsf.test.impl.config.view.inline.pages.order;
+
+import org.apache.myfaces.extensions.cdi.core.api.security.AccessDecisionVoter;
+import org.apache.myfaces.extensions.cdi.core.api.security.SecurityViolation;
+
+import javax.interceptor.InvocationContext;
+import java.util.Set;
+
+/**
+ * @author Gerhard Petracek
+ */
+class TestAccessDecisionVoter3 implements AccessDecisionVoter
+{
+    public Set<SecurityViolation> checkPermission(InvocationContext invocationContext)
+    {
+        //do nothing
+        return null;
+    }
+}

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/registration/RegistrationStep01PageBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/registration/RegistrationStep01PageBean.java?rev=1067579&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/registration/RegistrationStep01PageBean.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/inline/pages/registration/RegistrationStep01PageBean.java Sun Feb  6 03:12:37 2011
@@ -0,0 +1,46 @@
+/*
+ * 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.test.impl.config.view.inline.pages.registration;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.PreRenderView;
+
+import javax.enterprise.inject.Model;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Page
+@Model
+public class RegistrationStep01PageBean implements ViewConfig
+{
+    private boolean preloaded = false;
+
+    @PreRenderView
+    protected void preload()
+    {
+        this.preloaded = true;
+    }
+
+    public boolean isPreloaded()
+    {
+        return preloaded;
+    }
+}



Mime
View raw message