deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject deltaspike git commit: [DELTASPIKE-770] Overload BeanProvider#getContextualReference with (BeanManager, String, boolean. Class) variant
Date Fri, 07 Nov 2014 19:10:19 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 780204879 -> 2041f2a81


[DELTASPIKE-770] Overload BeanProvider#getContextualReference with (BeanManager, String, boolean.
Class) variant


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

Branch: refs/heads/master
Commit: 2041f2a8142496fdfd361e13227fc3451cae8b52
Parents: 7802048
Author: mbenson <mbenson@apache.org>
Authored: Fri Nov 7 13:09:26 2014 -0600
Committer: mbenson <mbenson@apache.org>
Committed: Fri Nov 7 13:09:26 2014 -0600

----------------------------------------------------------------------
 .../core/api/provider/BeanProvider.java         | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2041f2a8/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanProvider.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanProvider.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanProvider.java
index af9912c..b2ce5ab 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanProvider.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanProvider.java
@@ -207,7 +207,28 @@ public final class BeanProvider
      */
     public static <T> T getContextualReference(String name, boolean optional, Class<T>
type)
     {
-        BeanManager beanManager = getBeanManager();
+        return getContextualReference(getBeanManager(), name, optional, type);
+    }
+
+    /**
+     * <p>Get a Contextual Reference by its EL Name.
+     * This only works for beans with the &#064;Named annotation.</p>
+     *
+     * <p><b>Attention:</b> please see the notes on manually resolving
&#064;Dependent bean
+     * in {@link #getContextualReference(Class, boolean, java.lang.annotation.Annotation...)}!</p>
+     *
+     *
+     * @param beanManager the BeanManager to use
+     * @param name the EL name of the bean
+     * @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 type the type of the bean in question - use {@link #getContextualReference(String,
boolean)}
+     *             if the type is unknown e.g. in dyn. use-cases
+     * @param <T> target type
+     * @return the resolved Contextual Reference
+     */
+    public static <T> T getContextualReference(BeanManager beanManager, String name,
boolean optional, Class<T> type)
+    {
         Set<Bean<?>> beans = beanManager.getBeans(name);
 
         if (beans == null || beans.isEmpty())


Mime
View raw message