[jboss-cvs] JBossAS SVN: r82511 - in projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas: ejb3 and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 23 06:16:38 EST 2008
Author: alesj
Date: 2008-12-23 06:16:38 -0500 (Tue, 23 Dec 2008)
New Revision: 82511
Modified:
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/WebBeanDiscoveryImpl.java
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/JBossBussinessInterfaceDescriptorAdaptor.java
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossEJBDescriptorAdaptor.java
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMessageDrivenBeanDescriptorAdaptor.java
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMethodDescriptor.java
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossSessionBeanDescriptorAdaptor.java
Log:
Lookup check.
Simple code refactoring.
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/WebBeanDiscoveryImpl.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/WebBeanDiscoveryImpl.java 2008-12-23 11:10:27 UTC (rev 82510)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/WebBeanDiscoveryImpl.java 2008-12-23 11:16:38 UTC (rev 82511)
@@ -39,5 +39,4 @@
{
return environment.getWebBeansXml();
}
-
}
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 11:10:27 UTC (rev 82510)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/EjbDiscoveryEnvironment.java 2008-12-23 11:16:38 UTC (rev 82511)
@@ -2,53 +2,67 @@
import java.util.ArrayList;
import java.util.List;
-
import javax.servlet.ServletContext;
import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.DeployerClient;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.common.registrar.spi.NotBoundException;
import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
-import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
-import org.jboss.webbeans.integration.jbossas.vdf.KernelVDFConnector;
+import org.jboss.webbeans.integration.jbossas.vdf.KernelControllerVDFConnector;
+/**
+ * EjbDiscoveryEnvironment.
+ *
+ * @author <a href="mailto:alr at jboss.com">ALR</a>
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
public class EjbDiscoveryEnvironment
{
+ private static final String MC_BEAN_NAME_MAIN_DEPLOYER = "MainDeployer";
- private List<EjbDescriptor<?>> ejbs;
-
- //private static final Log log = Logging.getLogProvider(EjbDiscoveryEnvironment.class);
-
- private Kernel kernel;
+ private KernelController controller;
private EjbReferenceResolver resolver;
- private static final String MC_BEAN_NAME_MAIN_DEPLOYER = "MainDeployer";
-
+ private List<EjbDescriptor<?>> ejbs;
+
public EjbDiscoveryEnvironment(ServletContext servletContext)
{
- KernelVDFConnector kernelVDFConnector = new KernelVDFConnector(servletContext);
- kernel = kernelVDFConnector.getUtility();
- resolver = (EjbReferenceResolver) lookup("org.jboss.ejb3.EjbReferenceResolver");
+ KernelControllerVDFConnector controllerVDFConnector = new KernelControllerVDFConnector(servletContext);
+ if (controllerVDFConnector.isValid() == false)
+ throw new IllegalArgumentException("No such KernelController utility: " + servletContext);
+
+ controller = controllerVDFConnector.getUtility();
+ resolver = (EjbReferenceResolver) lookup("org.jboss.ejb3.EjbReferenceResolver", true);
+
ejbs = new ArrayList<EjbDescriptor<?>>();
discoverEjbs();
}
-
+
+ /**
+ * Get ejbs.
+ *
+ * @return the ejbs
+ */
public List<EjbDescriptor<?>> getEjbs()
{
return ejbs;
}
+ /**
+ * Discover ejbs.
+ */
protected void discoverEjbs()
{
/*
@@ -67,10 +81,14 @@
// Get the associated DU
DeploymentUnit du = mds.getDeploymentUnit(d.getName());
discoverEjbs(du);
-
}
}
-
+
+ /**
+ * Discover ejbs.
+ *
+ * @param du the deployment unit
+ */
protected void discoverEjbs(DeploymentUnit du)
{
// Ensure it's an EJB3 DU (by looking for the processed metadata)
@@ -100,36 +118,38 @@
discoverEjbs(childDu);
}
}
-
+
/**
- * Obtains the value bound at the specified name,
- * throwing RuntimeException if there is nothing
- * bound at the key. If the "checkInstalled"
- * flag is true, this implementation will
- * also ensure that the lookup value is of
- * ControllerState.INSTALLED, else NotBoundException
- *
- * @param name
- * @param checkInstalled
- * @throws NotBoundException
- * @return
+ * Get the bean from the MC controller.
+ *
+ * @param name the bean name
+ * @param shouldExist must the bean be present
+ * @return the bean
*/
- public Object lookup(final Object name) throws NotBoundException
+ Object lookup(final Object name, boolean shouldExist)
{
// Get Controller Context
- ControllerContext context = kernel.getController().getContext(name, null);
+ ControllerContext context = controller.getContext(name, ControllerState.INSTANTIATED);
+ if (context == null)
+ {
+ if (shouldExist)
+ {
+ // less restrictive state look
+ ControllerContext cc = controller.getContext(name, null);
+ throw new IllegalArgumentException("No such instantiated bean: " + name + " [" + cc + "]");
+ }
+ else
+ {
+ return null;
+ }
+ }
// If there's an error with the context, throw it
Throwable error = context.getError();
if (error != null)
- {
- throw new RuntimeException("Could not lookup object at name \"" + name
- + "\" due to an error with the underlying " + ControllerContext.class.getSimpleName(), error);
- }
+ throw new RuntimeException("Could not lookup object at name \"" + name + "\" due to an error with the underlying MC context.", error);
// Return
- Object target = context.getTarget();
- return target;
+ return context.getTarget();
}
-
}
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossBussinessInterfaceDescriptorAdaptor.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossBussinessInterfaceDescriptorAdaptor.java 2008-12-23 11:10:27 UTC (rev 82510)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossBussinessInterfaceDescriptorAdaptor.java 2008-12-23 11:16:38 UTC (rev 82511)
@@ -8,7 +8,6 @@
public class JBossBussinessInterfaceDescriptorAdaptor<T> implements BusinessInterfaceDescriptor<T>
{
-
private Class<T> type;
private String jndiName;
@@ -43,6 +42,5 @@
public String toString()
{
return getInterface() + " jndi name: " + getJndiName();
- }
-
+ }
}
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossEJBDescriptorAdaptor.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossEJBDescriptorAdaptor.java 2008-12-23 11:10:27 UTC (rev 82510)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossEJBDescriptorAdaptor.java 2008-12-23 11:16:38 UTC (rev 82511)
@@ -8,7 +8,6 @@
public abstract class JBossEJBDescriptorAdaptor<T> implements EjbDescriptor<T>
{
-
private final Class<T> type;
private final String ejbName;
@@ -83,6 +82,5 @@
public int hashCode()
{
return getEjbName().hashCode();
- }
-
+ }
}
\ No newline at end of file
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMessageDrivenBeanDescriptorAdaptor.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMessageDrivenBeanDescriptorAdaptor.java 2008-12-23 11:10:27 UTC (rev 82510)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMessageDrivenBeanDescriptorAdaptor.java 2008-12-23 11:16:38 UTC (rev 82511)
@@ -8,9 +8,6 @@
public class JBossMessageDrivenBeanDescriptorAdaptor<T> extends JBossEJBDescriptorAdaptor<T>
{
-
-
-
public JBossMessageDrivenBeanDescriptorAdaptor(JBossMessageDrivenBeanMetaData messageDrivenBeanMetaData, DeploymentUnit deploymentUnit, EjbReferenceResolver resolver)
{
super(messageDrivenBeanMetaData, deploymentUnit, resolver);
@@ -58,6 +55,5 @@
{
// Not relevant
return null;
- }
-
+ }
}
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMethodDescriptor.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMethodDescriptor.java 2008-12-23 11:10:27 UTC (rev 82510)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossMethodDescriptor.java 2008-12-23 11:16:38 UTC (rev 82511)
@@ -6,7 +6,6 @@
public class JBossMethodDescriptor implements MethodDescriptor
{
-
private Class<?> declaringClass;
private String methodName;
private Class<?>[] methodParameterTypes;
@@ -46,6 +45,5 @@
public Class<?>[] getMethodParameterTypes()
{
return methodParameterTypes;
- }
-
+ }
}
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossSessionBeanDescriptorAdaptor.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossSessionBeanDescriptorAdaptor.java 2008-12-23 11:10:27 UTC (rev 82510)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb3/JBossSessionBeanDescriptorAdaptor.java 2008-12-23 11:16:38 UTC (rev 82511)
@@ -13,7 +13,6 @@
public class JBossSessionBeanDescriptorAdaptor<T> extends JBossEJBDescriptorAdaptor<T> implements EjbDescriptor<T>
{
-
private final List<BusinessInterfaceDescriptor<?>> localBusinessInterfaces;
private final List<BusinessInterfaceDescriptor<?>> remoteBusinessInterfaces;
private final List<MethodDescriptor> removeMethods;
@@ -97,6 +96,5 @@
public String getLocalJndiName()
{
return localJndiName;
- }
-
+ }
}
More information about the jboss-cvs-commits
mailing list