myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored CDI utils
Date Sun, 14 Jul 2019 19:42:37 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new e2b28f3  refactored CDI utils
e2b28f3 is described below

commit e2b28f3bc353248e1cb862dbf8f102ecc715970e
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Sun Jul 14 21:40:23 2019 +0200

    refactored CDI utils
---
 .../cdi/behavior/FacesBehaviorCDIWrapper.java      |   2 +-
 .../behavior/FacesClientBehaviorCDIWrapper.java    |   2 +-
 .../myfaces/cdi/config/FacesConfigExtension.java   |   2 +-
 .../cdi/converter/FacesConverterCDIWrapper.java    |   4 +-
 .../myfaces/cdi/model/DataModelBuilderProxy.java   |   2 +-
 .../cdi/model/DynamicDataModelProducer.java        |   2 +-
 .../myfaces/cdi/model/FacesDataModelExtension.java |   2 +-
 .../org/apache/myfaces/cdi/util/BeanProvider.java  | 104 ---------------------
 .../java/org/apache/myfaces/cdi/util/CDIUtils.java |  20 ++--
 .../cdi/validator/FacesValidatorCDIWrapper.java    |   2 +-
 .../myfaces/cdi/view/CDIViewScopeProviderImpl.java |   8 +-
 .../apache/myfaces/cdi/view/ViewScopeCDIMap.java   |   8 +-
 .../myfaces/cdi/view/ViewScopeContextImpl.java     |   5 +-
 .../annotation/DefaultAnnotationProvider.java      |   4 +-
 .../org/apache/myfaces/el/ELResolverBuilder.java   |   2 +-
 .../flow/cdi/DefaultCDIFacesFlowProvider.java      |  12 +--
 .../org/apache/myfaces/flow/cdi/FlowScopeMap.java  |   7 +-
 .../myfaces/flow/cdi/FlowScopedContextImpl.java    |   5 +-
 .../myfaces/push/WebsocketComponentRenderer.java   |  12 +--
 .../apache/myfaces/push/WebsocketConfigurator.java |   2 +-
 .../apache/myfaces/push/cdi/PushContextImpl.java   |  12 +--
 .../apache/myfaces/push/cdi/WebsocketViewBean.java |   2 +-
 .../myfaces/webapp/AbstractFacesInitializer.java   |   4 +-
 23 files changed, 50 insertions(+), 175 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesBehaviorCDIWrapper.java
b/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesBehaviorCDIWrapper.java
index 3f2f1e5..d07ca53 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesBehaviorCDIWrapper.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesBehaviorCDIWrapper.java
@@ -54,7 +54,7 @@ public class FacesBehaviorCDIWrapper implements PartialStateHolder, Behavior,
Fa
     {
         if (delegate == null)
         {
-            delegate = (Behavior) CDIUtils.getInstance(CDIUtils.getBeanManager(
+            delegate = (Behavior) CDIUtils.get(CDIUtils.getBeanManager(
                 FacesContext.getCurrentInstance().getExternalContext()), 
                     Behavior.class, true, new FacesBehaviorAnnotationLiteral(behaviorId,
true));
         }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesClientBehaviorCDIWrapper.java
b/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesClientBehaviorCDIWrapper.java
index 504eb76..68cee8c 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesClientBehaviorCDIWrapper.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/behavior/FacesClientBehaviorCDIWrapper.java
@@ -76,7 +76,7 @@ public class FacesClientBehaviorCDIWrapper implements PartialStateHolder,
Client
     {
         if (delegate == null)
         {
-            delegate = (ClientBehavior) CDIUtils.getInstance(CDIUtils.getBeanManager(
+            delegate = (ClientBehavior) CDIUtils.get(CDIUtils.getBeanManager(
                 FacesContext.getCurrentInstance().getExternalContext()), 
                     ClientBehavior.class, true, new FacesBehaviorAnnotationLiteral(behaviorId,
true));
         }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/config/FacesConfigExtension.java b/impl/src/main/java/org/apache/myfaces/cdi/config/FacesConfigExtension.java
index c868e2d..0d86899 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/config/FacesConfigExtension.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/config/FacesConfigExtension.java
@@ -62,7 +62,7 @@ public class FacesConfigExtension implements Extension
     
     public void afterDeploymentValidation(@Observes AfterDeploymentValidation adv, BeanManager
beanManager)
     {
-        FacesConfigBeanHolder holder = CDIUtils.lookup(beanManager, FacesConfigBeanHolder.class);
+        FacesConfigBeanHolder holder = CDIUtils.get(beanManager, FacesConfigBeanHolder.class);
         
         holder.setFacesConfigVersion(facesConfigVersion);
     }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterCDIWrapper.java
b/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterCDIWrapper.java
index d4c05dd..8840e59 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterCDIWrapper.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterCDIWrapper.java
@@ -67,13 +67,13 @@ public class FacesConverterCDIWrapper implements PartialStateHolder, Converter,
         {
             if (converterId != null)
             {
-                delegate = (Converter) CDIUtils.getInstance(CDIUtils.getBeanManager(
+                delegate = (Converter) CDIUtils.get(CDIUtils.getBeanManager(
                     FacesContext.getCurrentInstance().getExternalContext()), 
                         Converter.class, true, new FacesConverterAnnotationLiteral(Object.class,
converterId, true));
             }
             else if (forClass != null)
             {
-                delegate = (Converter) CDIUtils.getInstance(CDIUtils.getBeanManager(
+                delegate = (Converter) CDIUtils.get(CDIUtils.getBeanManager(
                     FacesContext.getCurrentInstance().getExternalContext()), 
                         Converter.class, true, new FacesConverterAnnotationLiteral(forClass,
"", true));
             }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/model/DataModelBuilderProxy.java b/impl/src/main/java/org/apache/myfaces/cdi/model/DataModelBuilderProxy.java
index 45f2c74..044cc8e 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/model/DataModelBuilderProxy.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/model/DataModelBuilderProxy.java
@@ -34,7 +34,7 @@ public class DataModelBuilderProxy extends DataModelBuilder
     public DataModel createDataModel(FacesContext facesContext, Class<?> forClass,
Object value)
     {
         BeanManager beanManager = CDIUtils.getBeanManager(facesContext.getExternalContext());
-        FacesDataModelClassBeanHolder holder = CDIUtils.lookup(beanManager, FacesDataModelClassBeanHolder.class);
+        FacesDataModelClassBeanHolder holder = CDIUtils.get(beanManager, FacesDataModelClassBeanHolder.class);
         return holder.createDataModel(facesContext, forClass, value);
     }
     
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/model/DynamicDataModelProducer.java
b/impl/src/main/java/org/apache/myfaces/cdi/model/DynamicDataModelProducer.java
index 3b824b3..aaeee63 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/model/DynamicDataModelProducer.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/model/DynamicDataModelProducer.java
@@ -50,7 +50,7 @@ public class DynamicDataModelProducer extends AbstractDynamicProducer<Map<Class<
     protected Map<Class<?>,Class<? extends DataModel>> createDataModel(
             CreationalContext<Map<Class<?>,Class<? extends DataModel>>>
cc)
     {
-        FacesDataModelClassBeanHolder holder = CDIUtils.lookup(getBeanManager(), FacesDataModelClassBeanHolder.class);
+        FacesDataModelClassBeanHolder holder = CDIUtils.get(getBeanManager(), FacesDataModelClassBeanHolder.class);
         return holder.getClassInstanceToDataModelWrapperClassMap();
     }
 }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelExtension.java
b/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelExtension.java
index 89ef79f..9b8cab4 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelExtension.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelExtension.java
@@ -74,7 +74,7 @@ public class FacesDataModelExtension implements Extension
     
     public void afterDeploymentValidation(@Observes AfterDeploymentValidation adv, BeanManager
beanManager)
     {
-        FacesDataModelClassBeanHolder holder = CDIUtils.lookup(beanManager, FacesDataModelClassBeanHolder.class);
+        FacesDataModelClassBeanHolder holder = CDIUtils.get(beanManager, FacesDataModelClassBeanHolder.class);
         for (DataModelInfo typeInfo : types)
         {
             holder.addFacesDataModel(typeInfo.getForClass(), 
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/util/BeanProvider.java b/impl/src/main/java/org/apache/myfaces/cdi/util/BeanProvider.java
deleted file mode 100644
index 0681f6b..0000000
--- a/impl/src/main/java/org/apache/myfaces/cdi/util/BeanProvider.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.cdi.util;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.Set;
-
-/**
- * <p>This class contains utility methods to resolve contextual references
- * in situations where no injection is available because the
- * current class is not managed by the CDI Container. This can happen
- * in e.g. a JPA-2.0 EntityListener, a ServletFilter, a Spring managed
- * Bean, etc.</p>
- *
- * <p><b>Attention:</b> This method is intended for being used in user
code at runtime.
- * If this method gets used during Container boot (in an Extension), non-portable
- * behaviour results. The CDI specification only allows injection of the
- * BeanManager during CDI-Container boot time.</p>
- *
- */
-@Typed()
-public final class BeanProvider
-{
-
-    private BeanProvider()
-    {
-        // this is a utility class which doesn't get instantiated.
-    }
-
-    /**
-     *
-     * @param beanManager the BeanManager to use
-     * @param type the type of the bean in question
-     * @param optional if <code>true</code> it will return <code>null</code>
if no bean could be found or created.
-     *                 Otherwise it will throw an {@code IllegalStateException}
-     * @param qualifiers additional qualifiers which further distinct the resolved bean
-     * @param <T> target type
-     * @return the resolved Contextual Reference
-     */
-    public static <T> T getContextualReference(BeanManager beanManager,
-                                               Class<T> type,
-                                               boolean optional,
-                                               Annotation... qualifiers)
-    {
-        Set<Bean<?>> beans = beanManager.getBeans(type, qualifiers);
-
-        if (beans == null || beans.isEmpty())
-        {
-            if (optional)
-            {
-                return null;
-            }
-
-            throw new IllegalStateException("Could not find beans for Type=" + type
-                    + " and qualifiers:" + Arrays.toString(qualifiers));
-        }
-
-        return getContextualReference(type, beanManager, beans);
-    }
-
-    /**
-     * Internal helper method to resolve the right bean and resolve the contextual reference.
-     *
-     * @param <T> target type
-     * @param type the type of the bean in question
-     * @param beanManager current bean-manager
-     * @param beans beans in question
-     * @return the contextual reference
-     */
-    private static <T> T getContextualReference(Class<T> type, BeanManager beanManager,
Set<Bean<?>> beans)
-    {
-        Bean<?> bean = beanManager.resolve(beans);
-
-        //logWarningIfDependent(bean);
-
-        CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
-
-        @SuppressWarnings({ "unchecked", "UnnecessaryLocalVariable" })
-        T result = (T) beanManager.getReference(bean, type, creationalContext);
-        return result;
-    }
-
-}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/util/CDIUtils.java b/impl/src/main/java/org/apache/myfaces/cdi/util/CDIUtils.java
index e6fd568..7ddb853 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/util/CDIUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/util/CDIUtils.java
@@ -44,20 +44,12 @@ public class CDIUtils
             AbstractFacesInitializer.CDI_BEAN_MANAGER_INSTANCE);
     }
 
-
-
-    public static <T> T lookup(BeanManager bm, Class<T> clazz)
+    public static <T> T get(BeanManager bm, Class<T> clazz)
     {
         Set<Bean<?>> beans = bm.getBeans(clazz);
         return resolveInstance(bm, beans, clazz);
     }
 
-    public static Object lookup(BeanManager bm, String name)
-    {
-        Set<Bean<?>> beans = bm.getBeans(name);
-        return resolveInstance(bm, beans, Object.class);
-    }
-
     private static <T> T resolveInstance(BeanManager bm, Set<Bean<?>> beans,
Type type)
     {
         Bean<?> bean = bm.resolve(beans);
@@ -68,7 +60,7 @@ public class CDIUtils
     }
     
     @SuppressWarnings("unchecked")
-    public static <T> Bean<T> resolve(BeanManager beanManager, Class<T>
beanClass, Annotation... qualifiers)
+    public static <T> Bean<T> get(BeanManager beanManager, Class<T> beanClass,
Annotation... qualifiers)
     {
         Set<Bean<?>> beans = beanManager.getBeans(beanClass, qualifiers);
 
@@ -83,13 +75,13 @@ public class CDIUtils
         return (Bean<T>) beanManager.resolve(beans);
     }
 
-    public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass,

+    public static <T> T get(BeanManager beanManager, Class<T> beanClass, 
             boolean create, Annotation... qualifiers)
     {
         try
         {
-            Bean<T> bean = resolve(beanManager, beanClass, qualifiers);
-            return (bean != null) ? getInstance(beanManager, bean, create) : null;
+            Bean<T> bean = get(beanManager, beanClass, qualifiers);
+            return (bean != null) ? get(beanManager, bean, create) : null;
         }
         catch (ContextNotActiveException e)
         {
@@ -97,7 +89,7 @@ public class CDIUtils
         }
     }
 
-    public static <T> T getInstance(BeanManager beanManager, Bean<T> bean, boolean
create)
+    public static <T> T get(BeanManager beanManager, Bean<T> bean, boolean create)
     {
         Context context = beanManager.getContext(bean.getScope());
 
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorCDIWrapper.java
b/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorCDIWrapper.java
index c30c81a..5c15bc9 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorCDIWrapper.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorCDIWrapper.java
@@ -55,7 +55,7 @@ public class FacesValidatorCDIWrapper implements PartialStateHolder, Validator,
     {
         if (delegate == null)
         {
-            delegate = (Validator) CDIUtils.getInstance(CDIUtils.getBeanManager(
+            delegate = (Validator) CDIUtils.get(CDIUtils.getBeanManager(
                 FacesContext.getCurrentInstance().getExternalContext()), 
                     Validator.class, true, new FacesValidatorAnnotationLiteral(validatorId,
false, true));
         }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/CDIViewScopeProviderImpl.java
b/impl/src/main/java/org/apache/myfaces/cdi/view/CDIViewScopeProviderImpl.java
index 4488a47..62d7ae2 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/CDIViewScopeProviderImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/CDIViewScopeProviderImpl.java
@@ -23,7 +23,6 @@ import javax.enterprise.inject.spi.BeanManager;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.servlet.ServletContext;
-import org.apache.myfaces.cdi.util.BeanProvider;
 import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.cdi.JsfApplicationArtifactHolder;
 import org.apache.myfaces.spi.ViewScopeProvider;
@@ -44,8 +43,8 @@ public class CDIViewScopeProviderImpl extends ViewScopeProvider
         Object context = externalContext.getContext();
         if (context instanceof ServletContext)
         {
-            JsfApplicationArtifactHolder appBean = CDIUtils.lookup(beanManager, 
-                JsfApplicationArtifactHolder.class);
+            JsfApplicationArtifactHolder appBean =
+                    CDIUtils.get(beanManager, JsfApplicationArtifactHolder.class);
             appBean.setServletContext((ServletContext) context);
         }
     }
@@ -54,8 +53,7 @@ public class CDIViewScopeProviderImpl extends ViewScopeProvider
     {
         if (viewScopeBeanHolder == null)
         {
-            viewScopeBeanHolder = BeanProvider.getContextualReference(
-                beanManager, ViewScopeBeanHolder.class, false);
+            viewScopeBeanHolder = CDIUtils.get(beanManager, ViewScopeBeanHolder.class);
         }
         return viewScopeBeanHolder;
     }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java
index 9023a27..9522389 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java
@@ -43,7 +43,7 @@ public class ViewScopeCDIMap implements Map<String, Object>
     {
         BeanManager beanManager = CDIUtils.getBeanManager(facesContext.getExternalContext());
 
-        ViewScopeBeanHolder bean = CDIUtils.lookup(beanManager, ViewScopeBeanHolder.class);
+        ViewScopeBeanHolder bean = CDIUtils.get(beanManager, ViewScopeBeanHolder.class);
 
         // 1. get a new view scope id
         _viewScopeId = bean.generateUniqueViewScopeId();
@@ -55,7 +55,7 @@ public class ViewScopeCDIMap implements Map<String, Object>
     {
         BeanManager beanManager = CDIUtils.getBeanManager(facesContext.getExternalContext());
 
-        ViewScopeBeanHolder bean = CDIUtils.lookup(beanManager, ViewScopeBeanHolder.class);
+        ViewScopeBeanHolder bean = CDIUtils.get(beanManager, ViewScopeBeanHolder.class);
 
         // 1. get a new view scope id
         _viewScopeId = viewScopeId;
@@ -74,7 +74,7 @@ public class ViewScopeCDIMap implements Map<String, Object>
             FacesContext facesContext = FacesContext.getCurrentInstance();
             BeanManager beanManager = CDIUtils.getBeanManager(facesContext.getExternalContext());
 
-            ViewScopeBeanHolder bean = CDIUtils.lookup(beanManager, ViewScopeBeanHolder.class);
+            ViewScopeBeanHolder bean = CDIUtils.get(beanManager, ViewScopeBeanHolder.class);
             
             storage = bean.getContextualStorage(beanManager, _viewScopeId);
         }
@@ -183,7 +183,7 @@ public class ViewScopeCDIMap implements Map<String, Object>
 
             if (beanManager != null)
             {
-                ViewScopeBeanHolder bean = CDIUtils.lookup(beanManager, ViewScopeBeanHolder.class);
+                ViewScopeBeanHolder bean = CDIUtils.get(beanManager, ViewScopeBeanHolder.class);
                 if (bean != null)
                 {
                     ViewScopeContextualStorage st = bean.getContextualStorage(beanManager,
_viewScopeId);
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
index 752ff38..2198998 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
@@ -31,7 +31,7 @@ import javax.enterprise.inject.spi.PassivationCapable;
 import javax.faces.context.FacesContext;
 import javax.faces.view.ViewScoped;
 
-import org.apache.myfaces.cdi.util.BeanProvider;
+import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
 import org.apache.myfaces.view.ViewScopeProxyMap;
 
@@ -78,8 +78,7 @@ public class ViewScopeContextImpl implements Context
                 "oam.view.ViewScopeBeanHolder");
         if (viewScopeBeanHolder == null)
         {
-            viewScopeBeanHolder = BeanProvider.getContextualReference(
-                beanManager, ViewScopeBeanHolder.class, false);
+            viewScopeBeanHolder = CDIUtils.get(beanManager, ViewScopeBeanHolder.class);
             facesContext.getExternalContext().getApplicationMap().put(
                 "oam.view.ViewScopeBeanHolder", viewScopeBeanHolder);
         }
diff --git a/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
b/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
index 236cafc..9472adc 100644
--- a/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
@@ -50,7 +50,6 @@ import javax.faces.render.FacesRenderer;
 import javax.faces.validator.FacesValidator;
 import javax.faces.view.facelets.FaceletsResourceResolver;
 
-import org.apache.myfaces.cdi.util.BeanProvider;
 import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.config.MyfacesConfig;
 import org.apache.myfaces.util.ClassUtils;
@@ -146,8 +145,7 @@ public class DefaultAnnotationProvider extends AnnotationProvider
         if (MyfacesConfig.getCurrentInstance(ctx).isUseCdiForAnnotationScanning())
         {
             BeanManager beanManager = CDIUtils.getBeanManager(ctx);
-            CdiAnnotationProviderExtension extension =
-                    BeanProvider.getContextualReference(beanManager, CdiAnnotationProviderExtension.class,
false);
+            CdiAnnotationProviderExtension extension = CDIUtils.get(beanManager, CdiAnnotationProviderExtension.class);
             return extension.getMap();
         }
 
diff --git a/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilder.java b/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilder.java
index d64edda..64b8e3f 100644
--- a/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilder.java
+++ b/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilder.java
@@ -150,7 +150,7 @@ public class ELResolverBuilder
         BeanManager beanManager = CDIUtils.getBeanManager(facesContext.getExternalContext());
         if (beanManager != null)
         {
-            FacesConfigBeanHolder holder = CDIUtils.lookup(beanManager, FacesConfigBeanHolder.class);
+            FacesConfigBeanHolder holder = CDIUtils.get(beanManager, FacesConfigBeanHolder.class);
             if (holder != null)
             {
                 FacesConfig.Version version = holder.getFacesConfigVersion();
diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
b/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
index d0f389f..8cce97d 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
@@ -28,7 +28,6 @@ import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Producer;
 import javax.faces.context.FacesContext;
 import javax.faces.flow.Flow;
-import org.apache.myfaces.cdi.util.BeanProvider;
 import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.flow.FlowUtils;
 import org.apache.myfaces.spi.FacesFlowProvider;
@@ -69,7 +68,7 @@ public class DefaultCDIFacesFlowProvider extends FacesFlowProvider
         FacesContext facesContext = FacesContext.getCurrentInstance();
         if (facesContext != null && isFlowScopeBeanHolderCreated(facesContext))
         {
-            FlowScopeBeanHolder flowScopeBeanHolder = BeanProvider.getContextualReference(
+            FlowScopeBeanHolder flowScopeBeanHolder = CDIUtils.get(
                 _beanManager, FlowScopeBeanHolder.class, false);
             if (flowScopeBeanHolder != null)
             {
@@ -93,8 +92,7 @@ public class DefaultCDIFacesFlowProvider extends FacesFlowProvider
         {
             flows = new ArrayList<>();
 
-            FlowBuilderExtension extension =
-                    BeanProvider.getContextualReference(beanManager, FlowBuilderExtension.class,
true);
+            FlowBuilderExtension extension = CDIUtils.get(beanManager, FlowBuilderExtension.class);
             for (Producer<Flow> producer : extension.getFlowProducers())
             {
                 Flow flow = producer.produce(beanManager.<Flow>createCreationalContext(null));
@@ -111,7 +109,7 @@ public class DefaultCDIFacesFlowProvider extends FacesFlowProvider
         BeanManager beanManager = getBeanManager(context);
         if (beanManager != null)
         {
-            FlowScopeBeanHolder beanHolder = CDIUtils.lookup(beanManager, FlowScopeBeanHolder.class);
+            FlowScopeBeanHolder beanHolder = CDIUtils.get(beanManager, FlowScopeBeanHolder.class);
             beanHolder.createCurrentFlowScope(context);
         }
 
@@ -125,7 +123,7 @@ public class DefaultCDIFacesFlowProvider extends FacesFlowProvider
         BeanManager beanManager = getBeanManager(context);
         if (beanManager != null)
         {
-            FlowScopeBeanHolder beanHolder = CDIUtils.lookup(beanManager, FlowScopeBeanHolder.class);
+            FlowScopeBeanHolder beanHolder = CDIUtils.get(beanManager, FlowScopeBeanHolder.class);
             beanHolder.destroyCurrentFlowScope(context);
         }
 
@@ -158,7 +156,7 @@ public class DefaultCDIFacesFlowProvider extends FacesFlowProvider
                 BeanManager beanManager = getBeanManager(facesContext);
                 if (beanManager != null)
                 {
-                    FlowScopeBeanHolder beanHolder = CDIUtils.lookup(beanManager, FlowScopeBeanHolder.class);
+                    FlowScopeBeanHolder beanHolder = CDIUtils.get(beanManager, FlowScopeBeanHolder.class);
 
                     //Refresh client window for flow scope
                     beanHolder.refreshClientWindow(facesContext);
diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeMap.java b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeMap.java
index 0a5b602..a0ae610 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeMap.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeMap.java
@@ -23,7 +23,6 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 import javax.enterprise.inject.spi.BeanManager;
-import org.apache.myfaces.cdi.util.BeanProvider;
 
 /**
  * 
@@ -49,13 +48,11 @@ public class FlowScopeMap implements Map
         {
             if (create)
             {
-                _flowScopeBeanHolder = CDIUtils.lookup(_beanManager,
-                    FlowScopeBeanHolder.class);
+                _flowScopeBeanHolder = CDIUtils.get(_beanManager, FlowScopeBeanHolder.class);
             }
             else if (!_initOptional)
             {
-                _flowScopeBeanHolder = BeanProvider.getContextualReference(
-                    _beanManager, FlowScopeBeanHolder.class, true);
+                _flowScopeBeanHolder = CDIUtils.get(_beanManager, FlowScopeBeanHolder.class,
false);
                 _initOptional = true;
             }
         }
diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
index 4a768cf..22aea28 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
@@ -33,7 +33,7 @@ import javax.faces.context.FacesContext;
 import javax.faces.flow.Flow;
 import javax.faces.flow.FlowHandler;
 import javax.faces.flow.FlowScoped;
-import org.apache.myfaces.cdi.util.BeanProvider;
+import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
 import org.apache.myfaces.cdi.util.ContextualStorage;
 import org.apache.myfaces.flow.FlowReference;
@@ -79,8 +79,7 @@ public class FlowScopedContextImpl implements Context
                 "oam.flow.FlowScopeBeanHolder");
         if (flowScopeBeanHolder == null)
         {
-            flowScopeBeanHolder = BeanProvider.getContextualReference(
-                beanManager, FlowScopeBeanHolder.class, false);
+            flowScopeBeanHolder = CDIUtils.get(beanManager, FlowScopeBeanHolder.class);
             facesContext.getExternalContext().getApplicationMap().put(
                 "oam.flow.FlowScopeBeanHolder", flowScopeBeanHolder);
         }
diff --git a/impl/src/main/java/org/apache/myfaces/push/WebsocketComponentRenderer.java b/impl/src/main/java/org/apache/myfaces/push/WebsocketComponentRenderer.java
index afe4e2f..c3564a2 100644
--- a/impl/src/main/java/org/apache/myfaces/push/WebsocketComponentRenderer.java
+++ b/impl/src/main/java/org/apache/myfaces/push/WebsocketComponentRenderer.java
@@ -118,15 +118,15 @@ public class WebsocketComponentRenderer extends Renderer implements
ComponentSys
         // TODO: use a single bean and entry point for this algorithm.
         BeanManager beanManager = CDIUtils.getBeanManager(facesContext.getExternalContext());
 
-        WebsocketChannelTokenBuilderBean channelTokenBean = CDIUtils.lookup(
+        WebsocketChannelTokenBuilderBean channelTokenBean = CDIUtils.get(
                 beanManager,
                 WebsocketChannelTokenBuilderBean.class);
 
         // This bean is required because you always need to register the token, so it can
be properly destroyed
-        WebsocketViewBean viewTokenBean = CDIUtils.lookup(
+        WebsocketViewBean viewTokenBean = CDIUtils.get(
                 beanManager,
                 WebsocketViewBean.class);
-        WebsocketSessionBean sessionTokenBean = CDIUtils.lookup(
+        WebsocketSessionBean sessionTokenBean = CDIUtils.get(
                 beanManager, WebsocketSessionBean.class);
 
         // Create channel token 
@@ -155,7 +155,7 @@ public class WebsocketComponentRenderer extends Renderer implements ComponentSys
         }
 
         // Ask these two scopes 
-        WebsocketApplicationBean appTokenBean = CDIUtils.getInstance(
+        WebsocketApplicationBean appTokenBean = CDIUtils.get(
                 beanManager, WebsocketApplicationBean.class, false);
 
         // Register token and metadata in the proper bean
@@ -165,7 +165,7 @@ public class WebsocketComponentRenderer extends Renderer implements ComponentSys
         }
         else if (scope.equals("session"))
         {
-            sessionTokenBean = (sessionTokenBean != null) ? sessionTokenBean : CDIUtils.lookup(
+            sessionTokenBean = (sessionTokenBean != null) ? sessionTokenBean : CDIUtils.get(
                     CDIUtils.getBeanManager(facesContext.getExternalContext()),
                     WebsocketSessionBean.class);
 
@@ -174,7 +174,7 @@ public class WebsocketComponentRenderer extends Renderer implements ComponentSys
         else
         {
             //Default application
-            appTokenBean = (appTokenBean != null) ? appTokenBean : CDIUtils.lookup(
+            appTokenBean = (appTokenBean != null) ? appTokenBean : CDIUtils.get(
                     CDIUtils.getBeanManager(facesContext.getExternalContext()),
                     WebsocketApplicationBean.class);
 
diff --git a/impl/src/main/java/org/apache/myfaces/push/WebsocketConfigurator.java b/impl/src/main/java/org/apache/myfaces/push/WebsocketConfigurator.java
index f1df296..de5631f 100644
--- a/impl/src/main/java/org/apache/myfaces/push/WebsocketConfigurator.java
+++ b/impl/src/main/java/org/apache/myfaces/push/WebsocketConfigurator.java
@@ -68,7 +68,7 @@ public class WebsocketConfigurator extends ServerEndpointConfig.Configurator
         }
         
         BeanManager beanManager = CDI.current().getBeanManager();
-        WebsocketSessionBean websocketSessionBean = CDIUtils.getInstance(
+        WebsocketSessionBean websocketSessionBean = CDIUtils.get(
                 beanManager, WebsocketSessionBean.class, false);
         
         if (websocketSessionBean != null)
diff --git a/impl/src/main/java/org/apache/myfaces/push/cdi/PushContextImpl.java b/impl/src/main/java/org/apache/myfaces/push/cdi/PushContextImpl.java
index 2892094..14a7ebe 100644
--- a/impl/src/main/java/org/apache/myfaces/push/cdi/PushContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/push/cdi/PushContextImpl.java
@@ -64,17 +64,17 @@ public class PushContextImpl implements PushContext
             beanManager = CDI.current().getBeanManager();
         }
         
-        WebsocketApplicationBean appTokenBean = CDIUtils.getInstance(beanManager, 
+        WebsocketApplicationBean appTokenBean = CDIUtils.get(beanManager, 
                 WebsocketApplicationBean.class, false);
         WebsocketViewBean viewTokenBean = null;
         WebsocketSessionBean sessionTokenBean = null;
         
         if (CDIUtils.isSessionScopeActive(beanManager))
         {
-            sessionTokenBean = CDIUtils.getInstance(beanManager, WebsocketSessionBean.class,
false);
+            sessionTokenBean = CDIUtils.get(beanManager, WebsocketSessionBean.class, false);
             if (CDIUtils.isViewScopeActive(beanManager))
             {
-                viewTokenBean = CDIUtils.getInstance(beanManager, WebsocketViewBean.class,
false);
+                viewTokenBean = CDIUtils.get(beanManager, WebsocketViewBean.class, false);
             }
         }
         
@@ -150,17 +150,17 @@ public class PushContextImpl implements PushContext
             beanManager = CDI.current().getBeanManager();
         }
         
-        WebsocketApplicationBean appTokenBean = CDIUtils.getInstance(beanManager, 
+        WebsocketApplicationBean appTokenBean = CDIUtils.get(beanManager, 
                 WebsocketApplicationBean.class, false);
         WebsocketViewBean viewTokenBean = null;
         WebsocketSessionBean sessionTokenBean = null;
         
         if (CDIUtils.isSessionScopeActive(beanManager))
         {
-            sessionTokenBean = CDIUtils.getInstance(beanManager, WebsocketSessionBean.class,
false);
+            sessionTokenBean = CDIUtils.get(beanManager, WebsocketSessionBean.class, false);
             if (CDIUtils.isViewScopeActive(beanManager))
             {
-                viewTokenBean = CDIUtils.getInstance(beanManager, WebsocketViewBean.class,
false);
+                viewTokenBean = CDIUtils.get(beanManager, WebsocketViewBean.class, false);
             }
         }
         
diff --git a/impl/src/main/java/org/apache/myfaces/push/cdi/WebsocketViewBean.java b/impl/src/main/java/org/apache/myfaces/push/cdi/WebsocketViewBean.java
index bf5a5fd..228011b 100644
--- a/impl/src/main/java/org/apache/myfaces/push/cdi/WebsocketViewBean.java
+++ b/impl/src/main/java/org/apache/myfaces/push/cdi/WebsocketViewBean.java
@@ -139,7 +139,7 @@ public class WebsocketViewBean implements Serializable
     @PreDestroy
     public void destroy()
     {
-        WebsocketSessionBean sessionHandler = CDIUtils.lookup(CDI.current().getBeanManager(),

+        WebsocketSessionBean sessionHandler = CDIUtils.get(CDI.current().getBeanManager(),

                 WebsocketSessionBean.class);
         if (sessionHandler != null)
         {
diff --git a/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java b/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
index 79f0b45..da1fd06 100644
--- a/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
+++ b/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
@@ -60,7 +60,6 @@ import javax.faces.push.PushContext;
 import javax.websocket.DeploymentException;
 import javax.websocket.server.ServerContainer;
 import javax.websocket.server.ServerEndpointConfig;
-import org.apache.myfaces.cdi.util.BeanProvider;
 import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.config.MyfacesConfig;
 import org.apache.myfaces.config.annotation.CdiAnnotationProviderExtension;
@@ -270,8 +269,7 @@ public abstract class AbstractFacesInitializer implements FacesInitializer
         if (ExternalSpecifications.isCDIAvailable(externalContext))
         {
             BeanManager beanManager = CDIUtils.getBeanManager(externalContext);
-            CdiAnnotationProviderExtension extension =
-                    BeanProvider.getContextualReference(beanManager, CdiAnnotationProviderExtension.class,
true);
+            CdiAnnotationProviderExtension extension = CDIUtils.get(beanManager, CdiAnnotationProviderExtension.class);
             if (extension != null)
             {
                 extension.release();


Mime
View raw message