[seam-commits] Seam SVN: r12181 - in modules/faces/trunk: src/main/java/org/jboss/seam/faces and 5 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Mar 11 10:47:37 EST 2010


Author: lincolnthree
Date: 2010-03-11 10:47:36 -0500 (Thu, 11 Mar 2010)
New Revision: 12181

Added:
   modules/faces/trunk/faces-config.NavData
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/SeamFacesException.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedContext.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedExtension.java
   modules/faces/trunk/src/main/resources/META-INF/services/
   modules/faces/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
Removed:
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/DataModels.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/Faces.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/FacesManagedCookie.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/RedirectException.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/Validation.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIImport.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java
Modified:
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java
Log:
First working version with @ViewScoped

Added: modules/faces/trunk/faces-config.NavData
===================================================================
--- modules/faces/trunk/faces-config.NavData	                        (rev 0)
+++ modules/faces/trunk/faces-config.NavData	2010-03-11 15:47:36 UTC (rev 12181)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scene Scope="Project" version="2">
+    <Scope Scope="Faces Configuration Only"/>
+    <Scope Scope="Project"/>
+    <Scope Scope="All Faces Configurations"/>
+</Scene>

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/DataModels.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/DataModels.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/DataModels.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,60 +0,0 @@
-package org.jboss.seam.faces;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.model.DataModel;
-
-import org.jboss.seam.faces.model.ArrayDataModel;
-import org.jboss.seam.faces.model.ListDataModel;
-import org.jboss.seam.faces.model.MapDataModel;
-import org.jboss.seam.faces.model.SetDataModel;
-
-//import org.jboss.seam.framework.Query;
-/**
- * Wraps a collection as a JSF {@link DataModel}. May be overridden
- * and extended if you don't like the built in collections
- * which are supported: list, map, set, array.
- *
- * @author pmuir
- */
-public class DataModels
-{
-   /**
-    * Wrap the value in a DataModel
-    * 
-    * This implementation supports {@link List}, {@link Map}, {@link Set} and
-    * arrays
-    */
-   public DataModel getDataModel(Object value)
-   {
-      if (value instanceof List)
-      {
-         return new ListDataModel((List) value);
-      }
-      else if (value instanceof Object[])
-      {
-         return new ArrayDataModel((Object[]) value);
-      }
-      else if (value instanceof Map)
-      {
-         return new MapDataModel((Map) value);
-      }
-      else if (value instanceof Set)
-      {
-         return new SetDataModel((Set) value);
-      }
-      else
-      {
-         throw new IllegalArgumentException("unknown collection type: " + value.getClass());
-      }
-   }
-   /**
-    * Wrap the the Seam Framework {@link Query} in a JSF DataModel
-    */
-//   public DataModel getDataModel(Query query)
-//   {
-//      return getDataModel( query.getResultList() );
-//   }
-}

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/Faces.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/Faces.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/Faces.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,28 +0,0 @@
-package org.jboss.seam.faces;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Binding type for JSF-specific beans.
- * 
- * @author Dan Allen
- */
- at Target( { TYPE, METHOD, PARAMETER, FIELD })
- at Retention(RUNTIME)
- at Documented
- at Qualifier
- at Inherited
-public @interface Faces
-{
-}

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/FacesManagedCookie.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/FacesManagedCookie.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/FacesManagedCookie.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,60 +0,0 @@
-package org.jboss.seam.faces;
-
-import javax.faces.context.FacesContext;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
-
-/**
- * Selector implementation for JSF environments
- * 
- * @author Shane Bryzak
- */
-public class FacesManagedCookie //extends ManagedCookie
-{
-   private static final long serialVersionUID = 7212365784926629129L;
-
-//   @Override
-//   public void clearCookieValue()
-//   {
-//      Cookie cookie = getCookie();
-//      if ( cookie!=null )
-//      {
-//         HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
-//         cookie.setValue(null);
-//         cookie.setPath(getCookiePath());
-//         cookie.setMaxAge(0);
-//         response.addCookie(cookie);
-//      }
-//   }
-//
-//   @Override
-//   public Cookie getCookie()
-//   {
-//      FacesContext ctx = FacesContext.getCurrentInstance();
-//      if (ctx != null)
-//      {
-//          return (Cookie) ctx.getExternalContext().getRequestCookieMap()
-//            .get( getCookieName() );
-//      }
-//      else
-//      {
-//         return null;
-//      }
-//   }
-//
-//   @Override
-//   public void setCookieValueIfEnabled(String value)
-//   {
-//      FacesContext ctx = FacesContext.getCurrentInstance();
-//
-//      if ( isCookieEnabled() && ctx != null)
-//      {
-//         HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
-//         Cookie cookie = new Cookie( getCookieName(), value );
-//         cookie.setMaxAge( getCookieMaxAge() );
-//         cookie.setPath(getCookiePath());
-//         response.addCookie(cookie);
-//      }
-//   }
-}

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/RedirectException.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/RedirectException.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/RedirectException.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,17 +0,0 @@
-package org.jboss.seam.faces;
-
-import java.io.IOException;
-
-public class RedirectException extends RuntimeException
-{
-
-   public RedirectException(IOException ioe)
-   {
-      super(ioe);
-   }
-   
-   public RedirectException(String message)
-   {
-      super(message);
-   }
-}

Added: modules/faces/trunk/src/main/java/org/jboss/seam/faces/SeamFacesException.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/SeamFacesException.java	                        (rev 0)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/SeamFacesException.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -0,0 +1,22 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.jboss.seam.faces;
+
+/**
+ *
+ * @author lbaxter
+ */
+public class SeamFacesException extends RuntimeException{
+
+    public SeamFacesException(String string)
+    {
+    }
+
+    public SeamFacesException()
+    {
+    }
+
+}

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/Validation.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/Validation.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/Validation.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,52 +0,0 @@
-package org.jboss.seam.faces;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.faces.events.ValidationFailedEvent;
-
-/**
- * Allows the application to determine whether the JSF validation
- * phase completed successfully, or if a validation failure
- * occurred. This functionality is actually provided by JSF 2 now.
- * What this class does is raise a {@link ValidationFailedEvent}
- * so that observers can react accordingly.
- * 
- * @author Gavin king
- */
- at Named
-public class Validation
-{
-   private boolean succeeded;
-   private boolean failed;
-   
-   @Inject BeanManager manager;
-   
-   public void afterProcessValidations(FacesContext facesContext)
-   {
-      failed = facesContext.isValidationFailed();
-	   if (failed)
-      {
-         manager.fireEvent(new ValidationFailedEvent());
-      }
-      succeeded = !failed;
-   }
-
-   public boolean isSucceeded()
-   {
-      return succeeded;
-   }
-
-   public boolean isFailed()
-   {
-      return failed;
-   }
-
-   public void fail()
-   {
-      failed = true;
-      succeeded = false;
-   }
-}

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIImport.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIImport.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIImport.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,65 +0,0 @@
-package org.jboss.seam.faces.component;
-
-import javax.faces.component.UIComponentBase;
-
-/**
- * @author Dan Allen
- */
-public class UIImport extends UIComponentBase
-{
-
-   // ------------------------------------------------------ Manifest Constants
-
-   /**
-    * <p>
-    * The standard component type for this component.
-    * </p>
-    */
-   public static final String COMPONENT_TYPE = "org.jboss.seam.faces.Import";
-
-   /**
-    * <p>
-    * The standard component type for this component.
-    * </p>
-    */
-   public static final String COMPONENT_FAMILY = "org.jboss.seam.faces.Import";
-   
-   /**
-    * Properties that are tracked by state saving.
-    */
-   enum PropertyKeys {
-       namespaces
-   }
-   
-   // ------------------------------------------------------------ Constructors
-
-   /**
-    * <p>
-    * Create a new {@link UIImport} instance with default property values.
-    * </p>
-    */
-   public UIImport()
-   {
-      super();
-      setRendererType(null);
-   }
-
-   // -------------------------------------------------------------- Properties
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_FAMILY;
-   }
-
-   public Object getNamespaces()
-   {
-      return getStateHelper().eval(PropertyKeys.namespaces);
-   }
-   
-   public void setNamespaces(Object namespaces)
-   {
-      getStateHelper().put(PropertyKeys.namespaces, namespaces);
-   }
-   
-}

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,69 +0,0 @@
-package org.jboss.seam.faces.component;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponentBase;
-
-/**
- * 
- * TODO add login-required attribute. If require fails, we only force them to login
- * if that helps them get to the page.
- * 
- * @author Dan Allen
- */
-public class UIRestrictView extends UIComponentBase
-{
-
-   // ------------------------------------------------------ Manifest Constants
-
-   /**
-    * <p>
-    * The standard component type for this component.
-    * </p>
-    */
-   public static final String COMPONENT_TYPE = "org.jboss.seam.faces.RestrictView";
-
-   /**
-    * <p>
-    * The standard component type for this component.
-    * </p>
-    */
-   public static final String COMPONENT_FAMILY = "org.jboss.seam.faces.RestrictView";
-   
-   /**
-    * Properties that are tracked by state saving.
-    */
-   enum PropertyKeys {
-       require
-   }
-   
-   // ------------------------------------------------------------ Constructors
-
-   /**
-    * <p>
-    * Create a new {@link UIRestrictView} instance with default property values.
-    * </p>
-    */
-   public UIRestrictView()
-   {
-      super();
-      setRendererType(null);
-   }
-
-   // -------------------------------------------------------------- Properties
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_FAMILY;
-   }
-
-   public ValueExpression getRequire()
-   {
-      return (ValueExpression) getStateHelper().get(PropertyKeys.require);
-   }
-   
-   public void setRequire(ValueExpression require)
-   {
-      getStateHelper().put(PropertyKeys.require, require);
-   }
-}

Modified: modules/faces/trunk/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java	2010-03-11 15:47:25 UTC (rev 12180)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -1,6 +1,7 @@
 package org.jboss.seam.faces.international;
 
 import java.util.Locale;
+import javax.enterprise.inject.Produces;
 
 import javax.inject.Inject;
 import javax.faces.context.FacesContext;
@@ -23,7 +24,7 @@
       return facesContext != null && facesContext.getCurrentPhaseId() != null;
    }
    
-   public Locale getLocale()
+   public @Produces Locale getLocale()
    {
       if (facesContext.getViewRoot() != null)
       {

Added: modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedContext.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedContext.java	                        (rev 0)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedContext.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -0,0 +1,227 @@
+/*
+* 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.jboss.seam.faces.scopes;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import javax.faces.bean.ViewScoped;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PreDestroyViewMapEvent;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+
+/**
+* This class provides the contexts lifecycle for the
+* new JSF-2 &#064;ViewScoped Context
+*
+* @author <a href="mailto:struberg at yahoo.de">Mark Struberg</a>
+*/
+public class ViewScopedContext implements Context, SystemEventListener
+{
+
+    private final static String COMPONENT_MAP_NAME ="codi.componentInstanceMap";
+    private final static String CREATIONAL_MAP_NAME ="codi.creationalInstanceMap";
+
+    private boolean isJsfSubscribed = false;
+
+
+    public <T> T get(Contextual<T> component)
+    {
+        checkActive();
+
+        if(!isJsfSubscribed)
+        {
+            FacesContext.getCurrentInstance().getApplication().subscribeToEvent(PreDestroyViewMapEvent.class, this);
+
+            isJsfSubscribed = true;
+        }
+
+        Map<String, Object> viewMap = getViewMap();
+
+        @SuppressWarnings("unchecked")
+        ConcurrentHashMap<Contextual<?>, Object> componentInstanceMap = (ConcurrentHashMap<Contextual<?>, Object>) viewMap.get(COMPONENT_MAP_NAME);
+
+        if(componentInstanceMap == null) {
+            return null;
+        }
+
+        @SuppressWarnings("unchecked")
+        T instance = (T) componentInstanceMap.get(component);
+
+        return instance;
+    }
+
+    public <T> T get(Contextual<T> component, CreationalContext<T> creationalContext)
+    {
+        checkActive();
+
+        Map<String, Object> viewMap = getViewMap();
+
+        @SuppressWarnings("unchecked")
+        ConcurrentHashMap<Contextual<?>, Object> componentInstanceMap = (ConcurrentHashMap<Contextual<?>, Object>) viewMap.get(COMPONENT_MAP_NAME);
+
+        if(componentInstanceMap == null)
+        {
+            // TODO we now need to start being carefull with reentrancy...
+            componentInstanceMap = new ConcurrentHashMap<Contextual<?>, Object>();
+            viewMap.put(COMPONENT_MAP_NAME, componentInstanceMap);
+        }
+
+        @SuppressWarnings("unchecked")
+        ConcurrentHashMap<Contextual<?>, CreationalContext<?>> creationalContextMap = (ConcurrentHashMap<Contextual<?>, CreationalContext<?>>) viewMap.get(CREATIONAL_MAP_NAME);
+        if(creationalContextMap == null)
+        {
+            // TODO we now need to start being carefull with reentrancy...
+            creationalContextMap = new ConcurrentHashMap<Contextual<?>, CreationalContext<?>>();
+            viewMap.put(CREATIONAL_MAP_NAME, creationalContextMap);
+        }
+
+        @SuppressWarnings("unchecked")
+        T instance = (T) componentInstanceMap.get(component);
+        if (instance != null)
+        {
+            return instance;
+        }
+
+        if(creationalContext == null)
+        {
+            return null;
+        }
+
+        synchronized (componentInstanceMap)
+        {
+            // just to make sure...
+            @SuppressWarnings("unchecked")
+            T i = (T)componentInstanceMap.get(component);
+            if (i != null)
+            {
+                return i;
+            }
+
+            instance = component.create(creationalContext);
+
+            if (instance != null)
+            {
+                componentInstanceMap.put(component, instance);
+                creationalContextMap.put(component, creationalContext);
+            }
+        }
+
+        return instance;
+    }
+
+    public Class<? extends Annotation> getScope()
+    {
+        return ViewScoped.class;
+    }
+
+    /**
+* The view context is active if a valid ViewRoot could be detected.
+*/
+    public boolean isActive()
+    {
+        return getViewRoot() != null;
+    }
+
+    private void checkActive()
+    {
+        if (!isActive())
+        {
+            throw new ContextNotActiveException("WebBeans context with scope annotation @ViewScoped is not active with respect to the current thread");
+        }
+    }
+
+    public boolean isListenerForSource(Object source) {
+        if (source instanceof UIViewRoot)
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+* We get PreDestroyViewMapEvent events from the JSF servlet and destroy our contextual
+* instances. This should (theoretically!) also get fired if the webapp closes, so there
+* should be no need to manually track all view scopes and destroy them at a shutdown.
+*
+* @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
+*/
+    @SuppressWarnings("unchecked")
+    public void processEvent(SystemEvent event) {
+        if (event instanceof PreDestroyViewMapEvent)
+        {
+            // better use the viewmap we get from the event to prevent concurrent modification problems
+            Map<String, Object> viewMap = ((UIViewRoot) event.getSource()).getViewMap();
+
+            ConcurrentHashMap<Contextual<?>, Object> componentInstanceMap
+                    = (ConcurrentHashMap<Contextual<?>, Object>) viewMap.get(COMPONENT_MAP_NAME);
+
+            ConcurrentHashMap<Contextual<?>, CreationalContext<?>> creationalContextMap
+                    = (ConcurrentHashMap<Contextual<?>, CreationalContext<?>>) viewMap.get(CREATIONAL_MAP_NAME);
+
+            if(componentInstanceMap != null) {
+                for ( Entry<Contextual<?>, Object> componentEntry : componentInstanceMap.entrySet())
+                {
+                    // there is no nice way to explain the Java Compiler that we are handling the same type T,
+                    // therefore we need completely drop the type information :(
+                    Contextual contextual = componentEntry.getKey();
+                    Object instance = componentEntry.getValue();
+                    CreationalContext creational = creationalContextMap.get(contextual);
+
+                    contextual.destroy(instance, creational);
+                }
+            }
+        }
+    }
+
+
+    protected UIViewRoot getViewRoot()
+    {
+        FacesContext context = FacesContext.getCurrentInstance();
+
+        if(context != null)
+        {
+            return context.getViewRoot();
+        }
+
+        return null;
+    }
+
+    protected Map<String, Object> getViewMap()
+    {
+        UIViewRoot viewRoot = getViewRoot();
+
+        if (viewRoot != null)
+        {
+            return viewRoot.getViewMap(true);
+        }
+
+        return null;
+    }
+}
\ No newline at end of file

Added: modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedExtension.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedExtension.java	                        (rev 0)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/scopes/ViewScopedExtension.java	2010-03-11 15:47:36 UTC (rev 12181)
@@ -0,0 +1,30 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.jboss.seam.faces.scopes;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+import javax.faces.bean.ViewScoped;
+
+/**
+ *
+ * @author lbaxter
+ */
+public class ViewScopedExtension implements Extension {
+
+    public void addScope(@Observes BeforeBeanDiscovery event)
+    {
+        event.addScope(ViewScoped.class, true, true);
+    }
+
+    public void registerContext(@Observes AfterBeanDiscovery event)
+    {
+        event.addContext(new ViewScopedContext());
+    }
+
+}

Added: modules/faces/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- modules/faces/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension	                        (rev 0)
+++ modules/faces/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension	2010-03-11 15:47:36 UTC (rev 12181)
@@ -0,0 +1 @@
+org.jboss.seam.faces.scopes.ViewScopedExtension
\ No newline at end of file



More information about the seam-commits mailing list