[webbeans-commits] Webbeans SVN: r2214 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/mock and 5 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Mar 26 13:11:04 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-03-26 13:11:03 -0400 (Thu, 26 Mar 2009)
New Revision: 2214

Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
   ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
   ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
Log:
 add jpa spi, remove deprecated methods

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -43,6 +43,7 @@
 import org.jboss.webbeans.introspector.AnnotatedField;
 import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.AnnotatedParameter;
+import org.jboss.webbeans.jpa.spi.JpaServices;
 import org.jboss.webbeans.log.LogProvider;
 import org.jboss.webbeans.log.Logging;
 import org.jboss.webbeans.metadata.MetaDataCache;
@@ -260,6 +261,7 @@
       if (getManager().getServices().contains(EjbServices.class))
       {
          EjbServices ejbServices = manager.getServices().get(EjbServices.class);
+         JpaServices jpaServices = manager.getServices().get(JpaServices.class);
          for (AnnotatedInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
          {
             Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
@@ -268,7 +270,7 @@
    
          for (AnnotatedInjectionPoint<?, ?> injectionPoint : persistenceUnitInjectionPoints)
          {
-            Object puInstance = ejbServices.resolvePersistenceContext(injectionPoint);
+            Object puInstance = jpaServices.resolvePersistenceContext(injectionPoint);
             injectionPoint.inject(beanInstance, puInstance);
          }
    

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -18,6 +18,7 @@
 
 import org.jboss.webbeans.bootstrap.api.Environments;
 import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.jpa.spi.JpaServices;
 import org.jboss.webbeans.transaction.spi.TransactionServices;
 
 public class MockEELifecycle extends MockServletLifecycle
@@ -30,6 +31,7 @@
       super();
       getBootstrap().getServices().add(TransactionServices.class, MOCK_TRANSACTION_SERVICES);
       getBootstrap().getServices().add(EjbServices.class, new MockEjBServices(getWebBeanDiscovery()));
+      getBootstrap().getServices().add(JpaServices.class, new MockJpaServices(getWebBeanDiscovery()));
       getBootstrap().setEnvironment(Environments.EE);
    }
    

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -3,13 +3,9 @@
  */
 package org.jboss.webbeans.mock;
 
-import java.lang.annotation.Annotation;
 import java.util.Collection;
 
-import javax.annotation.Resource;
-import javax.ejb.EJB;
 import javax.inject.manager.InjectionPoint;
-import javax.persistence.PersistenceContext;
 
 import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
 import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -26,31 +22,11 @@
       this.ejbDiscovery = new MockEjbDiscovery(webBeanDiscovery);
    }
    
-   public Class<? extends Annotation> getEJBAnnotation()
-   {
-      return EJB.class;
-   }
-   
-   public Class<? extends Annotation> getPersistenceContextAnnotation()
-   {
-      return PersistenceContext.class;
-   }
-   
    public Object resolveEjb(InjectionPoint injectionPoint)
    {
       return null;
    }
    
-   public Object resolvePersistenceContext(InjectionPoint injectionPoint)
-   {
-      return null;
-   }
-   
-   public Class<? extends Annotation> getResourceAnnotation()
-   {
-      return Resource.class;
-   }
-   
    public Object resolveResource(InjectionPoint injectionPoint)
    {
       return null;

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -62,4 +62,6 @@
       return ejbs;
    }
    
+
+   
 }

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -16,13 +16,8 @@
  */
 package org.jboss.webbeans.bootstrap.api;
 
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
 import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.ejb.spi.EjbServices;
 import org.jboss.webbeans.manager.api.WebBeansManager;
-import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.transaction.spi.TransactionServices;
 
 /**
  * Bootstrap API for Web Beans.
@@ -34,57 +29,13 @@
 {
    
    /**
-    * Set the Web Bean Discovery to use
-    * 
-    * @param webBeanDiscovery
-    */
-   @Deprecated
-   public void setWebBeanDiscovery(WebBeanDiscovery webBeanDiscovery);
-   
-   /**
-    * Set the EjbServices to use
-    * 
-    * @param ejbServices
-    */
-   @Deprecated
-   public void setEjbServices(EjbServices ejbServices);
-   
-   /**
-    * Set the NamingContext to use.
-    * 
-    * By default @{link org.jboss.webbeans.resources.DefaultNamingContext} will 
-    * be used
-    * 
-    * @param namingContext
-    */
-   @Deprecated
-   public void setNamingContext(NamingContext namingContext);
-   
-   /**
-    * Set the ResourceLoader to use. By default @{link
-    * org.jboss.webbeans.resources.DefaultResourceLoader} will be used
-    * 
-    * @param resourceLoader
-    */
-   @Deprecated
-   public void setResourceLoader(ResourceLoader resourceLoader);
-   
-   /**
     * Set the bean store to use as backing for the application context
     * 
     * @param beanStore the bean store to use
     */
    public void setApplicationContext(BeanStore beanStore);
-   
+
    /**
-    * Set the transaction services provider to use.
-    * 
-    * @param transactionServices An implementation of TransactionService
-    */
-   @Deprecated
-   public void setTransactionServices(TransactionServices transactionServices);
-   
-   /**
     * Set the environment in use, by default {@link Environments.EE}
     * 
     * @param environment the environment to use
@@ -131,7 +82,7 @@
    /**
     * Get the services available to this bootstrap
     * 
-    * @return the services availabel
+    * @return the services available
     */
    public ServiceRegistry getServices();
    

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -22,6 +22,7 @@
 
 import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
 import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.jpa.spi.JpaServices;
 import org.jboss.webbeans.resources.spi.NamingContext;
 import org.jboss.webbeans.resources.spi.ResourceLoader;
 import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -38,12 +39,12 @@
    /**
     * Java EE5 or Java EE6
     */
-   EE(WebBeanDiscovery.class, EjbServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
+   EE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
    
    /**
     * Java EE6 Web Profile
     */
-   EE_WEB_PROFILE(WebBeanDiscovery.class, EjbServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
+   EE_WEB_PROFILE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class,TransactionServices.class, NamingContext.class, ResourceLoader.class),
    
    /**
     * Servlet container such as Tomcat

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -17,12 +17,8 @@
 package org.jboss.webbeans.bootstrap.api.helpers;
 
 import org.jboss.webbeans.bootstrap.api.Bootstrap;
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
 import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.ejb.spi.EjbServices;
 import org.jboss.webbeans.manager.api.WebBeansManager;
-import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.resources.spi.ResourceLoader;
 
 /**
  * Implementation of {@link Bootstrap} which supports the decorator pattern
@@ -54,30 +50,6 @@
       delegate().setApplicationContext(beanStore);
    }
    
-   @Deprecated
-   public void setEjbServices(EjbServices ejbServices)
-   {
-      delegate().setEjbServices(ejbServices);
-   }
-   
-   @Deprecated
-   public void setNamingContext(NamingContext namingContext)
-   {
-      delegate().setNamingContext(namingContext);
-   }
-   
-   @Deprecated
-   public void setResourceLoader(ResourceLoader resourceLoader)
-   {
-      delegate().setResourceLoader(resourceLoader);
-   }
-   
-   @Deprecated
-   public void setWebBeanDiscovery(WebBeanDiscovery webBeanDiscovery)
-   {
-      delegate().setWebBeanDiscovery(webBeanDiscovery);
-   }
-   
    public void shutdown()
    {
       delegate().shutdown();

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -24,7 +24,7 @@
 
 /**
  * A container should implement this interface to allow the Web Beans RI to
- * resolve EJBs, Resources and JPA persistence units
+ * resolve EJBs, Resources and JPA persistence units and discover EJBs
  * 
  * @author Pete Muir
  * 
@@ -48,21 +48,6 @@
    public Object resolveEjb(InjectionPoint injectionPoint);
    
    /**
-    * Resolve the value for the given @PersistenceContext injection point
-    * 
-    * @param injectionPoint
-    *           the injection point metadata
-    * @return an instance of the persistence unit
-    * @throws IllegalArgumentException
-    *            if the injection point is not annotated with
-    * @PersistenceContext, or, if the injection point is a method that doesn't
-    *                      follow JavaBean conventions
-    * @throws IllegalStateException
-    *            if no suitable persistence units can be resolved for injection
-    */
-   public Object resolvePersistenceContext(InjectionPoint injectionPoint);
-   
-   /**
     * Resolve the value for the given @Resource injection point
     * 
     * @param injectionPoint
@@ -90,7 +75,7 @@
    /**
     * Gets a descriptor for each EJB in the application
     * 
-    * @return The bean class to descriptor map 
+    * @return the EJB descriptors
     */
    public Iterable<EjbDescriptor<?>> discoverEjbs();
    

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -1,3 +1,19 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jboss.webbeans.ejb.spi.helpers;
 
 import javax.inject.manager.InjectionPoint;
@@ -31,11 +47,6 @@
       return delegate().resolveEjb(ejbDescriptor);
    }
    
-   public Object resolvePersistenceContext(InjectionPoint injectionPoint)
-   {
-      return delegate().resolvePersistenceContext(injectionPoint);
-   }
-   
    public Object resolveResource(InjectionPoint injectionPoint)
    {
       return delegate().resolveResource(injectionPoint);

Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -5,6 +5,7 @@
 import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
 import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
 import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.jpa.spi.JpaServices;
 import org.jboss.webbeans.resources.spi.NamingContext;
 import org.jboss.webbeans.resources.spi.ResourceLoader;
 import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -33,10 +34,25 @@
       bootstrap.getServices().add(NamingContext.class, new MockNamingContext());
       bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
       bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
-      bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery()); 
+      bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+      bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
       bootstrap.initialize();
    }
    
+   @Test(expectedExceptions=IllegalStateException.class)
+   public void testMissingJpaServices()
+   {
+      AbstractBootstrap bootstrap = new MockBootstrap();
+      bootstrap.setEnvironment(Environments.EE);
+      bootstrap.setApplicationContext(new ConcurrentHashMapBeanStore());
+      bootstrap.getServices().add(NamingContext.class, new MockNamingContext());
+      bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
+      bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
+      bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+      bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+      bootstrap.initialize();
+   }
+   
    @Test
    public void testEEEnv()
    {
@@ -47,7 +63,8 @@
       bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
       bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
       bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
-      bootstrap.getServices().add(EjbServices.class, new MockEjbServices()); 
+      bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+      bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
       bootstrap.initialize();
    }
    
@@ -61,7 +78,8 @@
       bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
       bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
       bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
-      bootstrap.getServices().add(EjbServices.class, new MockEjbServices()); 
+      bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+      bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
       bootstrap.initialize();
    }
    
@@ -74,7 +92,8 @@
       bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
       bootstrap.setApplicationContext(new ConcurrentHashMapBeanStore());
       bootstrap.getServices().add(EjbServices.class, new MockEjbServices()); 
-      bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery()); 
+      bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+      bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
       bootstrap.initialize();
    }
    

Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java	2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java	2009-03-26 17:11:03 UTC (rev 2214)
@@ -1,7 +1,5 @@
 package org.jboss.webbeans.bootstrap.api.test;
 
-import java.lang.annotation.Annotation;
-
 import javax.inject.manager.InjectionPoint;
 
 import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -17,24 +15,6 @@
       return null;
    }
    
-   public Class<? extends Annotation> getEJBAnnotation()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-   
-   public Class<? extends Annotation> getPersistenceContextAnnotation()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-   
-   public Class<? extends Annotation> getResourceAnnotation()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-   
    public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
    {
       // TODO Auto-generated method stub
@@ -47,12 +27,6 @@
       return null;
    }
    
-   public Object resolvePersistenceContext(InjectionPoint injectionPoint)
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-   
    public Object resolveResource(InjectionPoint injectionPoint)
    {
       // TODO Auto-generated method stub




More information about the weld-commits mailing list