pedrosans commented on code in PR #1369:
URL: https://github.com/apache/wicket/pull/1369#discussion_r2813553630
##########
wicket-cdi/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java:
##########
@@ -100,47 +83,22 @@ public BeanManager lookup()
return null;
}
}
- },
- FALLBACK {
- @Override
- public BeanManager lookup()
- {
- return
CdiConfiguration.get(Application.get()).getFallbackBeanManager();
- }
};
public abstract BeanManager lookup();
}
- private static BeanManagerLookupStrategy lastSuccessful =
BeanManagerLookupStrategy.CUSTOM;
-
- private BeanManagerLookup()
- {
- }
-
public static BeanManager lookup()
{
- BeanManager ret = lastSuccessful.lookup();
- if (ret != null)
- return ret;
-
for (BeanManagerLookupStrategy curStrategy :
BeanManagerLookupStrategy.values())
{
- ret = curStrategy.lookup();
+ BeanManager ret = curStrategy.lookup();
if (ret != null)
{
- lastSuccessful = curStrategy;
return ret;
}
}
-
- throw new IllegalStateException(
- "No BeanManager found via the CDI provider and no
fallback specified. Check your "
- + "CDI setup or specify a fallback BeanManager
in the CdiConfiguration.");
+ return null;
Review Comment:
To maintain the fallbackBeanManager logic without a exception try/catch
hassle. Right now the user can:
```
bm = BeanManagerLookup.lookup();
if (bm == null)
bm = fallbackBeamManager;
new CdiConfiguration(bm);
```
provide their own fallback option if the lookup fail. Conceptually, the new
BeanManagerLookup is just a lookup and not the class encapsulating the entire
BeanManager resolution code as previously done. Being so I found it ok to
return null. I can change the javadoc to better explain the new type role.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]