[webbeans-commits] Webbeans SVN: r815 - in ri/trunk: webbeans-ri/src/main/java/org/jboss/webbeans/bean and 3 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Jan 7 14:30:58 EST 2009
Author: pete.muir at jboss.org
Date: 2009-01-07 14:30:58 -0500 (Wed, 07 Jan 2009)
New Revision: 815
Modified:
ri/trunk/jboss-as/resources/webbeans-deployers-jboss-beans.xml
ri/trunk/webbeans-ri-spi/pom.xml
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockBootstrap.java
Log:
start work on @PersistenceContext
Modified: ri/trunk/jboss-as/resources/webbeans-deployers-jboss-beans.xml
===================================================================
--- ri/trunk/jboss-as/resources/webbeans-deployers-jboss-beans.xml 2009-01-07 19:03:04 UTC (rev 814)
+++ ri/trunk/jboss-as/resources/webbeans-deployers-jboss-beans.xml 2009-01-07 19:30:58 UTC (rev 815)
@@ -20,10 +20,10 @@
<bean name="PostEjbJarMetadataDeployer" class="org.jboss.webbeans.integration.microcontainer.deployer.metadata.WBEjbInterceptorMetadataDeployer"/>
<!-- Responsible for enabling classloader isolation for Web Bean jars -->
- <!-- <bean name="PostJBossMetadataDeployer" class="org.jboss.webbeans.integration.microcontainer.deployer.metadata.PostJBossMetadataDeployer"/>-->
+ <bean name="PostJBossMetadataDeployer" class="org.jboss.webbeans.integration.microcontainer.deployer.metadata.PostJBossMetadataDeployer"/>
<!-- Responsible for enabling classloader isolation for Web Bean wars -->
- <!-- <bean name="PostJBossWebMetadataDeployer" class="org.jboss.webbeans.integration.microcontainer.deployer.metadata.PostJBossWebMetadataDeployer"/>-->
+ <bean name="PostJBossWebMetadataDeployer" class="org.jboss.webbeans.integration.microcontainer.deployer.metadata.PostJBossWebMetadataDeployer"/>
<!-- Responsible for adding the Web Beans RI listener to the Servlet -->
<bean name="PostWebMetadataDeployer" class="org.jboss.webbeans.integration.microcontainer.deployer.metadata.PostWebMetadataDeployer"/>
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-07 19:03:04 UTC (rev 814)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-07 19:30:58 UTC (rev 815)
@@ -23,9 +23,11 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import javax.persistence.EntityManagerFactory;
import javax.webbeans.DefinitionException;
import javax.webbeans.Initializer;
import javax.webbeans.InjectionPoint;
+
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.context.DependentContext;
@@ -218,25 +220,22 @@
for (AnnotatedField<?> field : annotatedItem.getAnnotatedFields(manager.getEjbResolver().getEJBAnnotation()))
{
InjectionPoint injectionPoint = new InjectionPointImpl(field, this, beanInstance);
- String name = manager.getEjbResolver().resolveEjb(injectionPoint);
- Object ejbInstance = manager.getNaming().lookup(name, Object.class);
+ Object ejbInstance = manager.getEjbResolver().resolveEjb(injectionPoint, manager.getNaming());
field.inject(beanInstance, ejbInstance);
}
for (AnnotatedMethod<?> method : annotatedItem.getAnnotatedMethods(manager.getEjbResolver().getEJBAnnotation()))
{
InjectionPoint injectionPoint = new InjectionPointImpl(method, this, beanInstance);
- String name = manager.getEjbResolver().resolveEjb(injectionPoint);
- Object ejbInstance = manager.getNaming().lookup(name, Object.class);
+ Object ejbInstance = manager.getEjbResolver().resolveEjb(injectionPoint, manager.getNaming());
method.invoke(beanInstance, ejbInstance);
}
for (AnnotatedField<?> field : annotatedItem.getAnnotatedFields(manager.getEjbResolver().getPersistenceContextAnnotation()))
{
InjectionPoint injectionPoint = new InjectionPointImpl(field, this, beanInstance);
- String name = manager.getEjbResolver().resolvePersistenceUnit(injectionPoint);
- Object puInstance = manager.getNaming().lookup(name, Object.class);
- field.inject(beanInstance, puInstance);
+ EntityManagerFactory entityManagerFactory = manager.getEjbResolver().resolvePersistenceUnit(injectionPoint, manager.getNaming());
+ field.inject(beanInstance, entityManagerFactory.createEntityManager());
}
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockBootstrap.java 2009-01-07 19:03:04 UTC (rev 814)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockBootstrap.java 2009-01-07 19:30:58 UTC (rev 815)
@@ -3,6 +3,7 @@
import java.lang.annotation.Annotation;
import javax.ejb.EJB;
+import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.webbeans.InjectionPoint;
@@ -49,13 +50,13 @@
return PersistenceContext.class;
}
- public String resolveEjb(InjectionPoint injectionPoint)
+ public Object resolveEjb(InjectionPoint injectionPoint, Naming naming)
{
// TODO Implement EJB resolution for Unit tests
return null;
}
- public String resolvePersistenceUnit(InjectionPoint injectionPoint)
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint, Naming naming)
{
// TODO Implement PU resolution for Unit tests
return null;
Modified: ri/trunk/webbeans-ri-spi/pom.xml
===================================================================
--- ri/trunk/webbeans-ri-spi/pom.xml 2009-01-07 19:03:04 UTC (rev 814)
+++ ri/trunk/webbeans-ri-spi/pom.xml 2009-01-07 19:30:58 UTC (rev 815)
@@ -14,6 +14,12 @@
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-api</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>org.testng</groupId>
Modified: ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java
===================================================================
--- ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java 2009-01-07 19:03:04 UTC (rev 814)
+++ ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java 2009-01-07 19:30:58 UTC (rev 815)
@@ -2,8 +2,11 @@
import java.lang.annotation.Annotation;
+import javax.persistence.EntityManagerFactory;
import javax.webbeans.InjectionPoint;
+import org.jboss.webbeans.resources.spi.Naming;
+
/**
* A container should implement this interface to allow the Web Beans RI to
* resolve EJBs and JPA persistence units
@@ -22,7 +25,7 @@
* @param injectionPoint The injection point metadata
* @return the JNDI name
*/
- public String resolveEjb(InjectionPoint injectionPoint);
+ public Object resolveEjb(InjectionPoint injectionPoint, Naming naming);
/**
* Resolve the JNDI name for the @PersistenceContext injection point
@@ -30,7 +33,7 @@
* @param injectionPoint The injection point metadata
* @return the JNDI name
*/
- public String resolvePersistenceUnit(InjectionPoint injectionPoint);
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint, Naming naming);
public Class<? extends Annotation> getEJBAnnotation();
More information about the weld-commits
mailing list