[jboss-cvs] JBossAS SVN: r82536 - projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 23 16:46:56 EST 2008
Author: petemuir
Date: 2008-12-23 16:46:56 -0500 (Tue, 23 Dec 2008)
New Revision: 82536
Modified:
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/EjbDiscoveryEnvironment.java
Log:
Better error message if EjbReferenceResolver is missing
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/EjbDiscoveryEnvironment.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/EjbDiscoveryEnvironment.java 2008-12-23 20:28:06 UTC (rev 82535)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/EjbDiscoveryEnvironment.java 2008-12-23 21:46:56 UTC (rev 82536)
@@ -23,10 +23,39 @@
* EjbDiscoveryEnvironment.
*
* @author <a href="mailto:alr at jboss.com">ALR</a>
+ * @author Pete Muir
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
public class EjbDiscoveryEnvironment
{
+
+ private class NoSuchInstantiatedBeanException extends IllegalArgumentException
+ {
+
+ public NoSuchInstantiatedBeanException()
+ {
+ super();
+ }
+
+ public NoSuchInstantiatedBeanException(String arg0, Throwable arg1)
+ {
+ super(arg0, arg1);
+ }
+
+ public NoSuchInstantiatedBeanException(String arg0)
+ {
+ super(arg0);
+ }
+
+ public NoSuchInstantiatedBeanException(Throwable arg0)
+ {
+ super(arg0);
+ }
+
+ }
+
+ private static final String MC_BEAN_NAME_EJB_REFERENCE_RESOLVER = "org.jboss.ejb3.EjbReferenceResolver";
+
private KernelController controller;
private EjbReferenceResolver resolver;
@@ -39,7 +68,7 @@
throw new IllegalArgumentException("No such KernelController utility: " + servletContext);
controller = controllerVDFConnector.getUtility();
- resolver = (EjbReferenceResolver) lookup("org.jboss.ejb3.EjbReferenceResolver", true);
+ resolver = lookupEjbReferenceResolver();
VFSDeploymentUnitVDFConnector duConnector = new VFSDeploymentUnitVDFConnector(servletContext);
if (duConnector.isValid() == false)
@@ -87,6 +116,22 @@
}
}
}
+
+ /**
+ * Get the EjbReferenceResolver from the MC controller
+ * @return the EjbReferenceResolver
+ */
+ protected EjbReferenceResolver lookupEjbReferenceResolver()
+ {
+ try
+ {
+ return (EjbReferenceResolver) lookup(MC_BEAN_NAME_EJB_REFERENCE_RESOLVER, false);
+ }
+ catch (NoSuchInstantiatedBeanException e)
+ {
+ throw new IllegalStateException("EjbReferenceResolver cannot be found, check that you have correctly updated JBoss EJB3");
+ }
+ }
/**
* Get the bean from the MC controller.
@@ -95,7 +140,7 @@
* @param shouldExist must the bean be present
* @return the bean
*/
- Object lookup(final Object name, boolean shouldExist)
+ protected Object lookup(final Object name, boolean shouldExist)
{
// Get Controller Context
ControllerContext context = controller.getContext(name, ControllerState.INSTANTIATED);
@@ -105,20 +150,13 @@
{
// less restrictive state look
ControllerContext cc = controller.getContext(name, null);
- throw new IllegalArgumentException("No such instantiated bean: " + name + " [" + cc + "]");
+ throw new NoSuchInstantiatedBeanException("No such instantiated bean: " + name + " [" + cc + "]");
}
else
{
return null;
}
- }
-
- if (context == null)
- {
- // User reports context comes back null
- throw new IllegalStateException("Ejb3ReferenceResolver cannot be found, check that you have correctly updated JBoss EJB3");
- }
-
+ }
// If there's an error with the context, throw it
Throwable error = context.getError();
More information about the jboss-cvs-commits
mailing list