myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r691216 - in /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController: ViewControllerFactory.java jsf/ViewControllerPhaseListener.java jsf/ViewControllerVariableResolver.java
Date Tue, 02 Sep 2008 12:29:14 GMT
Author: imario
Date: Tue Sep  2 05:29:14 2008
New Revision: 691216

URL: http://svn.apache.org/viewvc?rev=691216&view=rev
Log:
expose the view controller through ViewControllerFactory.getInstance()

Added:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java
  (with props)
Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerVariableResolver.java

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java?rev=691216&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java
(added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java
Tue Sep  2 05:29:14 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.orchestra.viewController;
+
+import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
+
+/**
+ * Lookup the viewController. <br />
+ * If a bean with name "org.apache.myfaces.orchestra.viewController.ViewControllerManager"
exists this view controller
+ * will be used, else the {@link DefaultViewControllerManager} will be used.
+ */
+public class ViewControllerFactory
+{
+    private final static ViewControllerManager DEFAULT_VCM = new DefaultViewControllerManager();
+
+    public static ViewControllerManager getInstance()
+    {
+        ViewControllerManager manager = (ViewControllerManager)
+                FrameworkAdapter.getCurrentInstance().getBean(ViewControllerManager.VIEW_CONTROLLER_MANAGER_NAME);
+        if (manager != null)
+        {
+            return manager;
+        }
+
+        return DEFAULT_VCM;
+    }
+}

Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java?rev=691216&r1=691215&r2=691216&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
(original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
Tue Sep  2 05:29:14 2008
@@ -19,16 +19,16 @@
 
 package org.apache.myfaces.orchestra.viewController.jsf;
 
-import java.util.Set;
-import java.util.TreeSet;
+import org.apache.myfaces.orchestra.viewController.ViewControllerFactory;
+import org.apache.myfaces.orchestra.viewController.ViewControllerManager;
 
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.event.PhaseEvent;
 import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
-
-import org.apache.myfaces.orchestra.viewController.ViewControllerManager;
+import java.util.Set;
+import java.util.TreeSet;
 
 /**
  * Causes lifecycle methods to be invoked on backing beans that are associated with
@@ -36,7 +36,7 @@
  * <p>
  * Method executeInitView is invoked on the configured ViewControllerManager when ...
  * <p>
- * 
+ *
  * <p>
  * See the javadoc for class ViewControllerManager on how to configure this.
  * <p>
@@ -80,7 +80,7 @@
         // Try to init the view in every phase, just so we are sure to never miss it.
         // This skips the actual call if init has already happened.
         executeInitView(event.getFacesContext());
-        
+
         if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
         {
             preRenderResponse(event.getFacesContext());
@@ -130,7 +130,7 @@
      */
     protected void assertConversationState(FacesContext facesContext)
     {
-        ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+        ViewControllerManager manager = ViewControllerFactory.getInstance();
         if (manager == null)
         {
             return;
@@ -150,7 +150,7 @@
      */
     protected void preRenderResponse(FacesContext facesContext)
     {
-        ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+        ViewControllerManager manager = ViewControllerFactory.getInstance();
         if (manager == null)
         {
             return;
@@ -179,7 +179,7 @@
      */
     protected void postRestoreView(FacesContext facesContext)
     {
-        ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+        ViewControllerManager manager = ViewControllerFactory.getInstance();
         if (manager == null)
         {
             return;
@@ -222,7 +222,7 @@
      */
     protected void preInvokeApplication(FacesContext facesContext)
     {
-        ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+        ViewControllerManager manager = ViewControllerFactory.getInstance();
         if (manager == null)
         {
             return;

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerVariableResolver.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerVariableResolver.java?rev=691216&r1=691215&r2=691216&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerVariableResolver.java
(original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerVariableResolver.java
Tue Sep  2 05:29:14 2008
@@ -18,13 +18,13 @@
  */
 package org.apache.myfaces.orchestra.viewController.jsf;
 
+import org.apache.myfaces.orchestra.viewController.ViewControllerFactory;
+import org.apache.myfaces.orchestra.viewController.ViewControllerManager;
+
 import javax.faces.context.FacesContext;
 import javax.faces.el.EvaluationException;
 import javax.faces.el.VariableResolver;
 
-import org.apache.myfaces.orchestra.viewController.DefaultViewControllerManager;
-import org.apache.myfaces.orchestra.viewController.ViewControllerManager;
-
 /**
  * Provides a way to access the viewController through the JSF expression language (EL)
  * using the special variable name <code>oxViewController</code>.
@@ -32,7 +32,6 @@
 public class ViewControllerVariableResolver extends VariableResolver
 {
     private final static String VIEW_CONTROLLER_VARIABLE = "oxViewController";
-    private final static ViewControllerManager DEFAULT_VCM = new DefaultViewControllerManager();
 
     private final VariableResolver original;
 
@@ -45,23 +44,10 @@
     {
         if (VIEW_CONTROLLER_VARIABLE.equals(variableName))
         {
-            ViewControllerManager manager = getViewControllerManager(facesContext);
+            ViewControllerManager manager = ViewControllerFactory.getInstance();
             return manager.getViewController(facesContext.getViewRoot().getViewId());
         }
 
         return original.resolveVariable(facesContext, variableName);
     }
-
-    static ViewControllerManager getViewControllerManager(FacesContext context)
-    {
-        ViewControllerManager manager = (ViewControllerManager) context.getApplication()
-            .getVariableResolver().resolveVariable(
-                    context, ViewControllerManager.VIEW_CONTROLLER_MANAGER_NAME);
-        if (manager != null)
-        {
-            return manager;
-        }
-
-        return DEFAULT_VCM;
-    }
 }



Mime
View raw message