deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-755 cache ViewConfigResolver proxy
Date Sun, 26 Oct 2014 22:15:05 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 5ce25042d -> 74ad4b323


DELTASPIKE-755 cache ViewConfigResolver proxy


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/74ad4b32
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/74ad4b32
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/74ad4b32

Branch: refs/heads/master
Commit: 74ad4b323ac63235f4b412ed3bd4b29a2f9e2744
Parents: 5ce2504
Author: gpetracek <gpetracek@apache.org>
Authored: Sun Oct 26 23:13:09 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Sun Oct 26 23:13:09 2014 +0100

----------------------------------------------------------------------
 .../ViewConfigAwareNavigationHandler.java       | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/74ad4b32/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/ViewConfigAwareNavigationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/ViewConfigAwareNavigationHandler.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/ViewConfigAwareNavigationHandler.java
index 5e292c0..2f92c0c 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/ViewConfigAwareNavigationHandler.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/ViewConfigAwareNavigationHandler.java
@@ -52,6 +52,8 @@ public class ViewConfigAwareNavigationHandler extends NavigationHandler
 
     private NavigationParameterContext navigationParameterContext;
 
+    private ViewConfigResolver viewConfigResolver;
+
     /**
      * Constructor which allows to use the given {@link NavigationHandler}
      *
@@ -66,7 +68,7 @@ public class ViewConfigAwareNavigationHandler extends NavigationHandler
     @Override
     public void handleNavigation(FacesContext facesContext, String fromAction, String outcome)
     {
-        initBeanManager();
+        lazyInit();
         if (outcome != null && outcome.contains("."))
         {
             String originalOutcome = outcome;
@@ -84,7 +86,7 @@ public class ViewConfigAwareNavigationHandler extends NavigationHandler
                 {
                     if (DefaultErrorView.class.getName().equals(originalOutcome))
                     {
-                        entry = JsfUtils.getViewConfigResolver().getDefaultErrorViewConfigDescriptor();
+                        entry = this.viewConfigResolver.getDefaultErrorViewConfigDescriptor();
                     }
                 }
 
@@ -108,7 +110,7 @@ public class ViewConfigAwareNavigationHandler extends NavigationHandler
 
                             loadedClass = loadedClass.getSuperclass();
                         }
-                        entry = JsfUtils.getViewConfigResolver()
+                        entry = this.viewConfigResolver
                                 .getViewConfigDescriptor((Class<? extends ViewConfig>)
loadedClass);
                     }
                 }
@@ -219,15 +221,13 @@ public class ViewConfigAwareNavigationHandler extends NavigationHandler
             return viewConfigDescriptor;
         }
 
-        return JsfUtils.getViewConfigResolver().getViewConfigDescriptor(navigateEvent.getToView());
+        return this.viewConfigResolver.getViewConfigDescriptor(navigateEvent.getToView());
     }
 
     private PreViewConfigNavigateEvent firePreViewConfigNavigateEvent(String oldViewId,
                                                                       ViewConfigDescriptor
newViewConfigDescriptor)
     {
-        ViewConfigResolver viewConfigResolver = JsfUtils.getViewConfigResolver();
-
-        ViewConfigDescriptor oldViewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(oldViewId);
+        ViewConfigDescriptor oldViewConfigDescriptor = this.viewConfigResolver.getViewConfigDescriptor(oldViewId);
 
         PreViewConfigNavigateEvent navigateEvent;
 
@@ -246,13 +246,23 @@ public class ViewConfigAwareNavigationHandler extends NavigationHandler
         return navigateEvent;
     }
 
-    private void initBeanManager()
+    private void lazyInit()
+    {
+        if (this.beanManager == null)
+        {
+            init();
+        }
+    }
+
+    private synchronized void init()
     {
         if (this.beanManager == null)
         {
             this.beanManager = BeanManagerProvider.getInstance().getBeanManager();
             this.navigationParameterContext =
                     BeanProvider.getContextualReference(NavigationParameterContext.class);
+            this.viewConfigResolver =
+                    BeanProvider.getContextualReference(ViewConfigResolver.class);
         }
     }
 }


Mime
View raw message