[seam-commits] Seam SVN: r12815 - in modules/faces/trunk: api/src/main/java/org/jboss/seam/faces/qualifier and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed May 26 10:49:10 EDT 2010


Author: lincolnthree
Date: 2010-05-26 10:49:09 -0400 (Wed, 26 May 2010)
New Revision: 12815

Added:
   modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/qualifier/
   modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/qualifier/Faces.java
Modified:
   modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java
Log:
Added the concept of a @Faces qualifier in order to mark when a given CDI-managed object may only be provided during an active JSF life-cycle.

Added: modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/qualifier/Faces.java
===================================================================
--- modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/qualifier/Faces.java	                        (rev 0)
+++ modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/qualifier/Faces.java	2010-05-26 14:49:09 UTC (rev 12815)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.faces.qualifier;
+
+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.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Qualifier;
+
+/**
+ * A @{@link Qualifier} for an object or @{@link Produces} method that depends
+ * on the presence of an active JSF life-cycle in order to be injected
+ * successfully. This means that JSF must currently be servicing an active
+ * Request in order for an object qualified with <b>this</b> annotation in order
+ * to be available.
+ * 
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Retention(RUNTIME)
+public @interface Faces
+{
+
+}

Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java	2010-05-26 14:37:17 UTC (rev 12814)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/international/FacesLocaleResolver.java	2010-05-26 14:49:09 UTC (rev 12815)
@@ -22,11 +22,13 @@
 package org.jboss.seam.faces.international;
 
 import java.util.Locale;
+
 import javax.enterprise.inject.Produces;
-
+import javax.faces.context.FacesContext;
 import javax.inject.Inject;
-import javax.faces.context.FacesContext;
 
+import org.jboss.seam.faces.qualifier.Faces;
+
 /**
  * A specialized version of the LocaleProducer that returns the Locale
  * associated with the current UIViewRoot or, if the UIViewRoot has not been
@@ -41,10 +43,11 @@
 
    public boolean isActive()
    {
-      return facesContext != null && facesContext.getCurrentPhaseId() != null;
+      return (facesContext != null) && (facesContext.getCurrentPhaseId() != null);
    }
 
    @Produces
+   @Faces
    public Locale getLocale()
    {
       if (facesContext.getViewRoot() != null)



More information about the seam-commits mailing list