[jboss-cvs] JBossAS SVN: r87134 - in projects/webbeans-ri-int/trunk: deployer/src/main/java/org/jboss/webbeans/integration/deployer/env and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 10 11:50:58 EDT 2009
Author: petemuir
Date: 2009-04-10 11:50:58 -0400 (Fri, 10 Apr 2009)
New Revision: 87134
Added:
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossWebServices.java
Modified:
projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-ejb-jboss-beans.xml
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/AbstractJBossServices.java
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossJpaServices.java
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java
Log:
Add bean structures and lifecycle for enterprise resources
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-ejb-jboss-beans.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-ejb-jboss-beans.xml 2009-04-10 15:49:22 UTC (rev 87133)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-ejb-jboss-beans.xml 2009-04-10 15:50:58 UTC (rev 87134)
@@ -19,6 +19,8 @@
<bean name="JBossResourceServices" class="org.jboss.webbeans.integration.ejb.JBossResourceServices" />
+ <bean name="JBossWebServices" class="org.jboss.webbeans.integration.ejb.JBossWebServices" />
+
<bean name="JBossTransactionServices" class="org.jboss.webbeans.integration.transaction.JBossTransactionServices">
<property name="transactionManager"><inject bean="RealTransactionManager" option="callback" /></property>
</bean>
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-04-10 15:49:22 UTC (rev 87133)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-04-10 15:50:58 UTC (rev 87134)
@@ -49,6 +49,7 @@
addOutput(BeanMetaData.class);
}
+ @Override
public void deploy(DeploymentUnit unit, WebBeanDiscoveryEnvironment env) throws DeploymentException
{
String unitName = unit.getName();
@@ -64,6 +65,7 @@
bootstrap.addPropertyMetaData("ejbServices", createEjbConnector("JBossEjbServices", "org.jboss.webbeans.integration.ejb.JBossEjbServices", unit));
bootstrap.addPropertyMetaData("jpaServices", createEjbConnector("JBossJpaServices", "org.jboss.webbeans.integration.ejb.JBossJpaServices", unit));
bootstrap.addPropertyMetaData("resourceServices", bootstrap.createInject("JBossResourceServices"));
+ bootstrap.addPropertyMetaData("webServices", bootstrap.createInject("JBossWebServices"));
bootstrap.addPropertyMetaData("transactionServices", bootstrap.createInject("JBossTransactionServices"));
bootstrap.addPropertyMetaData("applicationContext", createBeanStore());
bootstrap.addPropertyMetaData("environment", Environments.EE);
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java 2009-04-10 15:49:22 UTC (rev 87133)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java 2009-04-10 15:50:58 UTC (rev 87134)
@@ -67,5 +67,10 @@
{
return Collections.emptySet();
}
+
+ public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
+ {
+ return null;
+ }
}
Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/AbstractJBossServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/AbstractJBossServices.java 2009-04-10 15:49:22 UTC (rev 87133)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/AbstractJBossServices.java 2009-04-10 15:50:58 UTC (rev 87134)
@@ -6,29 +6,17 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.webbeans.integration.ejb.util.JBossEjb;
-import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.resources.spi.helpers.AbstractNamingContext;
public class AbstractJBossServices
{
protected DeploymentUnit topLevelDeploymentUnit;
protected JBossEjb jbossEjb;
- protected final NamingContext naming;
+ protected final Context context;
public AbstractJBossServices() throws NamingException
{
- final Context context = new InitialContext();
- this.naming = new AbstractNamingContext()
- {
-
- @Override
- public Context getContext()
- {
- return context;
- }
-
- };
+ context = new InitialContext();
}
public void setDeploymentUnit(DeploymentUnit du)
Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java 2009-04-10 15:49:22 UTC (rev 87133)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java 2009-04-10 15:50:58 UTC (rev 87134)
@@ -7,6 +7,7 @@
import java.util.List;
import javax.ejb.EJB;
+import javax.inject.ExecutionException;
import javax.inject.manager.InjectionPoint;
import javax.naming.NamingException;
@@ -22,7 +23,6 @@
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.integration.vdf.DeploymentUnitAware;
-import org.jboss.webbeans.resources.spi.NamingContext;
/**
* An implementation of EjbServices for JBoss EJB3
@@ -32,7 +32,7 @@
*/
public class JBossEjbServices extends AbstractJBossServices implements EjbServices, DeploymentUnitAware
{
- private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
+
protected EjbReferenceResolver resolver;
private final List<EjbDescriptor<?>> ejbs = new ArrayList<EjbDescriptor<?>>();
private final List<String> ejbContainerNames = new ArrayList<String>();
@@ -89,23 +89,56 @@
{
throw new IllegalStateException("No EJBs available which can be injected into " + injectionPoint);
}
- return naming.lookup(jndiName, Object.class);
+ try
+ {
+ return context.lookup(jndiName);
+ }
+ catch (NamingException e)
+ {
+ throw new ExecutionException("Error retreiving EJB from JNDI for injection point " + injectionPoint, e);
+ }
}
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
{
- return new JBossSessionObjectReference(ejbDescriptor)
+ try
{
-
- private static final long serialVersionUID = -5063126026455936612L;
-
- @Override
- protected NamingContext getNamingContext()
+ return new JBossSessionObjectReference(ejbDescriptor, context);
+ }
+ catch (NamingException e)
+ {
+ throw new ExecutionException("Error retreiving EJB from JNDI " + ejbDescriptor, e);
+ }
+ }
+
+ public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
+ {
+ if (mappedName != null)
+ {
+ try
{
- return naming;
+ return context.lookup(mappedName);
}
-
- };
+ catch (NamingException e)
+ {
+ throw new ExecutionException("Error retreiving EJB from JNDI with mappedName " + mappedName, e);
+ }
+ }
+ else if (jndiName != null)
+ {
+ try
+ {
+ return context.lookup(jndiName);
+ }
+ catch (NamingException e)
+ {
+ throw new ExecutionException("Error retreiving EJB from JNDI with mappedName " + jndiName, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("jndiName, mappedName and ejbLink are null");
+ }
}
/**
Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossJpaServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossJpaServices.java 2009-04-10 15:49:22 UTC (rev 87133)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossJpaServices.java 2009-04-10 15:50:58 UTC (rev 87134)
@@ -6,6 +6,8 @@
import javax.inject.manager.InjectionPoint;
import javax.naming.NamingException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -38,7 +40,7 @@
return Collections.emptyList();
}
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint)
{
if (!injectionPoint.isAnnotationPresent(PersistenceContext.class))
{
@@ -48,15 +50,35 @@
{
throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (must have exactly one parameter) " + injectionPoint);
}
- String persistenceUnitName = injectionPoint.getAnnotation(PersistenceContext.class).unitName();
- String beanName = getPersistenceUnitSupplier(topLevelDeploymentUnit, persistenceUnitDependencyResolver, persistenceUnitName);
+ try
+ {
+ return resolvePersistenceContext((injectionPoint.getAnnotation(PersistenceContext.class).unitName()));
+ }
+ catch (IllegalStateException e)
+ {
+ throw new IllegalStateException("Unable to resolve persistence context for " + injectionPoint);
+ }
+ }
+
+ public EntityManager resolvePersistenceContext(String unitName)
+ {
+ return resolvePersistenceUnit(unitName).createEntityManager();
+ }
+
+ public EntityManagerFactory resolvePersistenceUnit(String unitName)
+ {
+ if (unitName == null)
+ {
+ throw new IllegalArgumentException("unitName is null");
+ }
+ String beanName = getPersistenceUnitSupplier(topLevelDeploymentUnit, persistenceUnitDependencyResolver, unitName);
if (beanName == null)
{
- throw new IllegalStateException("No persistence unit available which can be injected into " + injectionPoint);
+ throw new IllegalStateException("No persistence unit available for " + unitName);
}
PersistenceUnitDeployment deployment = jbossEjb.lookupPersistenceUnitDeployment(beanName);
ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory();
- return new InjectedEntityManagerFactory(managedFactory).createEntityManager();
+ return new InjectedEntityManagerFactory(managedFactory);
}
private static String getPersistenceUnitSupplier(DeploymentUnit deploymentUnit, PersistenceUnitDependencyResolver persistenceUnitDependencyResolver, String persistenceUnitName)
Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java 2009-04-10 15:49:22 UTC (rev 87133)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java 2009-04-10 15:50:58 UTC (rev 87134)
@@ -1,20 +1,22 @@
package org.jboss.webbeans.integration.ejb;
import java.util.Iterator;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
-import org.jboss.webbeans.resources.spi.NamingContext;
-public abstract class JBossSessionObjectReference implements SessionObjectReference
+public class JBossSessionObjectReference implements SessionObjectReference
{
private static final long serialVersionUID = 8227728506645839338L;
private final Object reference;
- public JBossSessionObjectReference(EjbDescriptor<?> descriptor)
+ public JBossSessionObjectReference(EjbDescriptor<?> descriptor, Context context) throws NamingException
{
Iterator<BusinessInterfaceDescriptor<?>> it = descriptor.getLocalBusinessInterfaces().iterator();
if (!it.hasNext())
@@ -23,7 +25,7 @@
}
String fullJndiName = it.next().getJndiName();
String jndiName = fullJndiName.substring(0, fullJndiName.lastIndexOf("-"));
- reference = getNamingContext().lookup(jndiName, Object.class);
+ reference = context.lookup(jndiName);
}
public void create()
@@ -45,6 +47,4 @@
}
- protected abstract NamingContext getNamingContext();
-
}
Added: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossWebServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossWebServices.java (rev 0)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossWebServices.java 2009-04-10 15:50:58 UTC (rev 87134)
@@ -0,0 +1,25 @@
+package org.jboss.webbeans.integration.ejb;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.webbeans.resources.spi.helpers.AbstractResourceServices;
+
+public class JBossWebServices extends AbstractResourceServices
+{
+
+ private final Context context;
+
+ public JBossWebServices() throws NamingException
+ {
+ this.context = new InitialContext();
+ }
+
+ @Override
+ protected Context getContext()
+ {
+ return context;
+ }
+
+}
Property changes on: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossWebServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jboss-cvs-commits
mailing list