[jboss-cvs] JBossAS SVN: r86388 - in projects/webbeans-ri-int/trunk: ejb/src/main/java/org/jboss/webbeans/integration/ejb and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 26 13:13:18 EDT 2009
Author: petemuir
Date: 2009-03-26 13:13:18 -0400 (Thu, 26 Mar 2009)
New Revision: 86388
Added:
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/JBossJpaServices.java
Modified:
projects/webbeans-ri-int/trunk/deployer/src/main/resources/META-INF/webbeans-ejb-jboss-beans.xml
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java
Log:
add jpa spi, remove deprecated methods
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/resources/META-INF/webbeans-ejb-jboss-beans.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/resources/META-INF/webbeans-ejb-jboss-beans.xml 2009-03-26 16:07:03 UTC (rev 86387)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/resources/META-INF/webbeans-ejb-jboss-beans.xml 2009-03-26 17:13:18 UTC (rev 86388)
@@ -9,6 +9,10 @@
<beanfactory name="JBossEjbServices" class="org.jboss.webbeans.integration.ejb.JBossEjbServices">
<property name="resolver"><inject bean="WBJBossEjb" property="resolver"/></property>
+ <property name="jbossEjb"><inject bean="WBJBossEjb" /></property>
+ </beanfactory>
+
+ <beanfactory name="JBossJpaServices" class="org.jboss.webbeans.integration.ejb.JBossJpaServices">
<property name="persistenceUnitDependencyResolver"><inject bean="PersistenceUnitDependencyResolver" /></property>
<property name="jbossEjb"><inject bean="WBJBossEjb" /></property>
</beanfactory>
Added: 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 (rev 0)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/AbstractJBossServices.java 2009-03-26 17:13:18 UTC (rev 86388)
@@ -0,0 +1,49 @@
+package org.jboss.webbeans.integration.ejb;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+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;
+
+ public AbstractJBossServices() throws NamingException
+ {
+ final Context context = new InitialContext();
+ this.naming = new AbstractNamingContext()
+ {
+
+ @Override
+ public Context getContext()
+ {
+ return context;
+ }
+
+ };
+ }
+
+ public void setDeploymentUnit(DeploymentUnit du)
+ {
+ if (du == null)
+ {
+ throw new IllegalArgumentException("Null deployment unit.");
+ }
+
+ topLevelDeploymentUnit = du.getTopLevel();
+ }
+
+ public void setJbossEjb(JBossEjb jbossEjb)
+ {
+ this.jbossEjb = jbossEjb;
+ }
+
+}
\ No newline at end of file
Property changes on: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/AbstractJBossServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-03-26 16:07:03 UTC (rev 86387)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java 2009-03-26 17:13:18 UTC (rev 86388)
@@ -8,32 +8,22 @@
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.inject.manager.InjectionPoint;
-import javax.naming.Context;
-import javax.naming.InitialContext;
import javax.naming.NamingException;
-import javax.persistence.PersistenceContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
import org.jboss.ejb3.common.resolvers.spi.EjbReference;
import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
-import org.jboss.jpa.deployment.ManagedEntityManagerFactory;
-import org.jboss.jpa.deployment.PersistenceUnitDeployment;
-import org.jboss.jpa.injection.InjectedEntityManagerFactory;
-import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
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.metadata.web.jboss.JBossWebMetaData;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.integration.ejb.util.JBossEjb;
import org.jboss.webbeans.integration.ejb.util.Reflections;
import org.jboss.webbeans.integration.vdf.DeploymentUnitAware;
import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.resources.spi.helpers.AbstractNamingContext;
/**
* An implementation of EjbServices for JBoss EJB3
@@ -41,84 +31,29 @@
* @author Pete Muir
* @author ales.justin at jboss.org
*/
-public class JBossEjbServices implements EjbServices, DeploymentUnitAware
+public class JBossEjbServices extends AbstractJBossServices implements EjbServices, DeploymentUnitAware
{
private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
- protected DeploymentUnit topLevelDeploymentUnit;
-
protected EjbReferenceResolver resolver;
- protected PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
- protected JBossEjb jbossEjb;
private List<EjbDescriptor<?>> ejbs = new ArrayList<EjbDescriptor<?>>();
- // TODO replace this with a JBoss equivalent :-)
- private final NamingContext naming;
-
public JBossEjbServices() throws NamingException
{
- final Context context = new InitialContext();
- this.naming = new AbstractNamingContext()
- {
-
-
- @Override
- public Context getContext()
- {
- return context;
- }
-
- };
+ super();
}
- public void setDeploymentUnit(DeploymentUnit du)
- {
- if (du == null)
- throw new IllegalArgumentException("Null deployment unit.");
-
- topLevelDeploymentUnit = du.getTopLevel();
-
- discoverEjbs(du.getTopLevel());
- }
-
public void setResolver(EjbReferenceResolver resolver)
{
this.resolver = resolver;
}
-
- public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver persistenceUnitDependencyResolver)
+
+ @Override
+ public void setDeploymentUnit(DeploymentUnit du)
{
- this.persistenceUnitDependencyResolver = persistenceUnitDependencyResolver;
+ super.setDeploymentUnit(du);
+ discoverEjbs(du.getTopLevel());
}
- public void setJbossEjb(JBossEjb jbossEjb)
- {
- this.jbossEjb = jbossEjb;
- }
-
- private static String getPersistenceUnitSupplier(DeploymentUnit deploymentUnit, PersistenceUnitDependencyResolver persistenceUnitDependencyResolver, String persistenceUnitName)
- {
- if ((deploymentUnit.getAttachment(AttachmentNames.PROCESSED_METADATA, JBossMetaData.class) != null && deploymentUnit.getAttachment(JBossMetaData.class).isEJB3x()) || (deploymentUnit.getAttachment(JBossWebMetaData.class) != null))
- {
- try
- {
- return persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName);
- }
- catch (IllegalArgumentException e)
- {
- // No-op, means we can't find the PU in this DU
- }
- }
- for (DeploymentUnit child : deploymentUnit.getChildren())
- {
- String beanName = getPersistenceUnitSupplier(child, persistenceUnitDependencyResolver, persistenceUnitName);
- if (beanName != null)
- {
- return beanName;
- }
- }
- return null;
- }
-
public Object resolveEjb(InjectionPoint injectionPoint)
{
if (!injectionPoint.isAnnotationPresent(EJB.class))
@@ -173,27 +108,6 @@
};
}
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
- {
- if (!injectionPoint.isAnnotationPresent(PersistenceContext.class))
- {
- throw new IllegalArgumentException("No @PersistenceContext annotation found on injection point " + injectionPoint);
- }
- if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1)
- {
- 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);
- if (beanName == null)
- {
- throw new IllegalStateException("No persistence unit available which can be injected into " + injectionPoint);
- }
- PersistenceUnitDeployment deployment = jbossEjb.lookupPersistenceUnitDeployment(beanName);
- ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory();
- return new InjectedEntityManagerFactory(managedFactory).createEntityManager();
- }
-
public Object resolveResource(InjectionPoint injectionPoint)
{
if (!injectionPoint.isAnnotationPresent(Resource.class))
Added: 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 (rev 0)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossJpaServices.java 2009-03-26 17:13:18 UTC (rev 86388)
@@ -0,0 +1,85 @@
+package org.jboss.webbeans.integration.ejb;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+
+import javax.inject.manager.InjectionPoint;
+import javax.naming.NamingException;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
+import org.jboss.jpa.deployment.ManagedEntityManagerFactory;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.injection.InjectedEntityManagerFactory;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.webbeans.jpa.spi.JpaServices;
+
+public class JBossJpaServices extends AbstractJBossServices implements JpaServices
+{
+
+ public JBossJpaServices() throws NamingException
+ {
+ super();
+ }
+
+ protected PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+
+ public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver persistenceUnitDependencyResolver)
+ {
+ this.persistenceUnitDependencyResolver = persistenceUnitDependencyResolver;
+ }
+
+ public Iterable<Class<?>> discoverEntities()
+ {
+ return Collections.emptyList();
+ }
+
+ public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ {
+ if (!injectionPoint.isAnnotationPresent(PersistenceContext.class))
+ {
+ throw new IllegalArgumentException("No @PersistenceContext annotation found on injection point " + injectionPoint);
+ }
+ if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1)
+ {
+ 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);
+ if (beanName == null)
+ {
+ throw new IllegalStateException("No persistence unit available which can be injected into " + injectionPoint);
+ }
+ PersistenceUnitDeployment deployment = jbossEjb.lookupPersistenceUnitDeployment(beanName);
+ ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory();
+ return new InjectedEntityManagerFactory(managedFactory).createEntityManager();
+ }
+
+ private static String getPersistenceUnitSupplier(DeploymentUnit deploymentUnit, PersistenceUnitDependencyResolver persistenceUnitDependencyResolver, String persistenceUnitName)
+ {
+ if ((deploymentUnit.getAttachment(AttachmentNames.PROCESSED_METADATA, JBossMetaData.class) != null && deploymentUnit.getAttachment(JBossMetaData.class).isEJB3x()) || (deploymentUnit.getAttachment(JBossWebMetaData.class) != null))
+ {
+ try
+ {
+ return persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName);
+ }
+ catch (IllegalArgumentException e)
+ {
+ // No-op, means we can't find the PU in this DU
+ }
+ }
+ for (DeploymentUnit child : deploymentUnit.getChildren())
+ {
+ String beanName = getPersistenceUnitSupplier(child, persistenceUnitDependencyResolver, persistenceUnitName);
+ if (beanName != null)
+ {
+ return beanName;
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossJpaServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java 2009-03-26 16:07:03 UTC (rev 86387)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java 2009-03-26 17:13:18 UTC (rev 86388)
@@ -41,7 +41,7 @@
public static final String WEB_BEANS_CLASSPATH = "WEB_BEANS_CLASSPATH";
public static final String WEB_BEANS_DEPLOYMENT_FLAG = "WEB_BEANS_DEPLOYMENT_FLAG";
- public static final String WEB_BEANS_BOOTSTRAP_BEAN = "_WebBeansBootstrap";
+ public static final String WEB_BEANS_BOOTSTRAP_BEAN = "_WebBeansBootstrapBean";
/**
* Get bootstrap bean name.
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java 2009-03-26 16:07:03 UTC (rev 86387)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeansBootstrapDeployer.java 2009-03-26 17:13:18 UTC (rev 86388)
@@ -28,6 +28,8 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.bootstrap.api.Environments;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.integration.microcontainer.deployer.DeployersUtils;
@@ -56,11 +58,14 @@
unit.addAttachment(envName + "_" + BeanMetaData.class.getSimpleName(), envWrapper.getBeanMetaData());
String bootstrapName = DeployersUtils.getBootstrapBeanName(unit);
- BeanMetaDataBuilder bootstrap = BeanMetaDataBuilder.createBuilder(bootstrapName, "org.jboss.webbeans.bootstrap.WebBeansBootstrap");
+ BeanMetaDataBuilder bootstrap = BeanMetaDataBuilder.createBuilder(bootstrapName, "org.jboss.webbeans.bootstrap.api.helpers.BootstrapBean");
+ bootstrap.addConstructorParameter(Bootstrap.class.getName(), createBootstrap(unit));
bootstrap.addPropertyMetaData("webBeanDiscovery", bootstrap.createInject(envName));
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("transactionServices", bootstrap.createInject("JBossTransactionServices"));
bootstrap.addPropertyMetaData("applicationContext", createBeanStore());
+ bootstrap.addPropertyMetaData("environment", Environments.EE);
bootstrap.setCreate("initialize");
bootstrap.setStart("boot");
bootstrap.setDestroy("shutdown");
@@ -96,4 +101,14 @@
unit.addAttachment(beanName + "_" + BeanMetaData.class.getSimpleName(), builder.getBeanMetaData());
return builder.createInject(beanName);
}
+
+ protected ValueMetaData createBootstrap(DeploymentUnit unit)
+ {
+ String beanName = unit.getName() + "_WebBeansBootstrap";
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(beanName, "org.jboss.webbeans.bootstrap.WebBeansBootstrap");
+ unit.addAttachment(beanName + "_" + BeanMetaData.class.getSimpleName(), builder.getBeanMetaData());
+ return builder.createInject(beanName);
+ }
+
+
}
More information about the jboss-cvs-commits
mailing list