Skip to content

Commit a332335

Browse files
committed
WICKET-7126 javadoc + exception messages + code cleanup
1 parent c250a0f commit a332335

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

wicket-cdi/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
* <li>JNDI under java:comp/env/BeanManager (for servlet containers like Tomcat and Jetty)</li>
3333
* <li>CDI.current().getBeanManager() (portable lookup)</li>
3434
* </ul>
35-
*
35+
*
36+
* This is de default strategy used in {@link CdiConfiguration} to look for a BeanManger, unless
37+
* one is defined in CdiConfiguration(BeanManager)
38+
*
3639
* @author papegaaij
3740
*/
3841
public final class BeanManagerLookup
@@ -88,6 +91,11 @@ public BeanManager lookup()
8891
public abstract BeanManager lookup();
8992
}
9093

94+
private BeanManagerLookup()
95+
{
96+
97+
}
98+
9199
public static BeanManager lookup()
92100
{
93101
for (BeanManagerLookupStrategy curStrategy : BeanManagerLookupStrategy.values())

wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
package org.apache.wicket.cdi;
1818

1919
import jakarta.enterprise.inject.spi.BeanManager;
20-
2120
import org.apache.wicket.Application;
2221
import org.apache.wicket.MetaDataKey;
2322
import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
23+
import org.apache.wicket.util.lang.Args;
2424

2525
/**
2626
* Configures CDI integration
@@ -48,6 +48,7 @@ public CdiConfiguration()
4848

4949
public CdiConfiguration(BeanManager beanManager)
5050
{
51+
Args.notNull(beanManager, "beanManager");
5152
this.beanManager = beanManager;
5253
}
5354

@@ -65,8 +66,11 @@ public CdiConfiguration setPropagation(IConversationPropagation propagation)
6566
public BeanManager getBeanManager()
6667
{
6768
if (beanManager == null)
69+
{
6870
throw new IllegalStateException(
69-
"app not configured or no BeanManager was resolved during the configuration");
71+
"No BeanManager was resolved during configuration. Be sure " +
72+
"to specify a BeanManager in CdiConfiguration constructor or that one can be resolved by BeanManagerLookup, and that CdiConfiguration#configure is called.");
73+
}
7074
return beanManager;
7175
}
7276

@@ -77,12 +81,16 @@ public BeanManager getBeanManager()
7781
*/
7882
public void configure(Application application)
7983
{
80-
if(beanManager == null)
84+
if (beanManager == null)
85+
{
8186
beanManager = BeanManagerLookup.lookup();
87+
}
8288

8389
if (beanManager == null)
90+
{
8491
throw new IllegalStateException(
8592
"No BeanManager was set or found via the CDI provider. Check your CDI setup or specify a BeanManager in the CdiConfiguration.");
93+
}
8694

8795
if (application.getMetaData(CDI_CONFIGURATION_KEY) != null)
8896
{

0 commit comments

Comments
 (0)