[webbeans-commits] Webbeans SVN: r2215 - in ri/trunk/spi/src/main/java/org/jboss/webbeans: bootstrap/api/helpers and 3 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Mar 26 13:12:40 EDT 2009


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

Added:
   ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/
   ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/
   ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/
   ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
Log:
 add jpa spi, remove deprecated methods

Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java	                        (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java	2009-03-26 17:12:40 UTC (rev 2215)
@@ -0,0 +1,126 @@
+package org.jboss.webbeans.bootstrap.api.helpers;
+
+import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.bootstrap.api.Environment;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
+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.jpa.spi.JpaServices;
+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;
+
+/**
+ * A bean version of bootstrap that delegates to the underlying bootstrap impl
+ * 
+ * @author Pete Muir
+ *
+ */
+public class BootstrapBean implements Bootstrap
+{
+   
+   private final Bootstrap bootstrap;
+
+   public BootstrapBean(Bootstrap bootstrap)
+   {
+      this.bootstrap = bootstrap;
+   }
+   
+   public void setEjbServices(EjbServices ejbServices)
+   {
+      bootstrap.getServices().add(EjbServices.class, ejbServices);
+   }
+   
+   public EjbServices getEjbServices()
+   {
+      return bootstrap.getServices().get(EjbServices.class);
+   }
+   
+   public void setJpaServices(JpaServices jpaServices)
+   {
+      bootstrap.getServices().add(JpaServices.class, jpaServices);
+   }
+   
+   public JpaServices getJpaServices()
+   {
+      return bootstrap.getServices().get(JpaServices.class);
+   }
+
+   public void setWebBeanDiscovery(WebBeanDiscovery webBeanDiscovery)
+   {
+      bootstrap.getServices().add(WebBeanDiscovery.class, webBeanDiscovery);
+   }
+
+   public WebBeanDiscovery getWebBeanDiscovery()
+   {
+      return bootstrap.getServices().get(WebBeanDiscovery.class);
+   }
+
+   public void setTransactionServices(TransactionServices transactionServices)
+   {
+      bootstrap.getServices().add(TransactionServices.class, transactionServices);
+   }
+
+   public TransactionServices getTransactionServices()
+   {
+      return bootstrap.getServices().get(TransactionServices.class);
+   }
+   
+   public void setApplicationContext(BeanStore applicationContext)
+   {
+      bootstrap.setApplicationContext(applicationContext);      
+   }
+   
+   public void setNamingContext(NamingContext namingContext)
+   {
+      bootstrap.getServices().add(NamingContext.class, namingContext);
+   }
+   
+   public NamingContext getNamingContext()
+   {
+      return bootstrap.getServices().get(NamingContext.class);
+   }
+   
+   public void setResourceLoader(ResourceLoader resourceLoader)
+   {
+      bootstrap.getServices().add(ResourceLoader.class, resourceLoader);
+   }
+   
+   public ResourceLoader getResourceLoader()
+   {
+      return bootstrap.getServices().get(ResourceLoader.class);
+   }
+   
+   public void boot()
+   {
+      bootstrap.boot();
+   }
+   
+   public WebBeansManager getManager()
+   {
+      return bootstrap.getManager();
+   }
+   
+   public ServiceRegistry getServices()
+   {
+      return bootstrap.getServices();
+   }
+   
+   public void initialize()
+   {
+      bootstrap.initialize();
+   }
+   
+   public void setEnvironment(Environment environment)
+   {
+      bootstrap.setEnvironment(environment);
+   }
+   
+   public void shutdown()
+   {
+      bootstrap.shutdown();
+   }
+   
+}


Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java	                        (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java	2009-03-26 17:12:40 UTC (rev 2215)
@@ -0,0 +1,55 @@
+/*
+ * 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.jpa.spi;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow the Web Beans RI to
+ * resolve JPA persistence units and discover entities
+ * 
+ * @author Pete Muir
+ * 
+ */
+public interface JpaServices extends Service
+{
+   
+   /**
+    * Gets the class for each entity in the application
+    * 
+    * @return the entity classes 
+    */
+   public Iterable<Class<?>> discoverEntities();
+   
+   /**
+    * 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);
+   
+}


Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java	                        (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java	2009-03-26 17:12:40 UTC (rev 2215)
@@ -0,0 +1,66 @@
+/*
+ * 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.jpa.spi.helpers;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.jpa.spi.JpaServices;
+
+/**
+ * An implementation of {@link JpaServices} which forwards all its method calls
+ * to another {@link JpaServices}}. Subclasses should override one or more 
+ * methods to modify the behavior of the backing {@link JpaServices} as desired
+ * per the <a
+ * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
+ * 
+ * @author Pete Muir
+ *
+ */
+public abstract class ForwardingJpaServices implements JpaServices
+{
+   
+   protected abstract JpaServices delegate();
+   
+   public Iterable<Class<?>> discoverEntities()
+   {
+      return delegate().discoverEntities();
+   }
+   
+   public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+   {
+      return delegate().resolvePersistenceContext(injectionPoint);
+   }
+   
+   @Override
+   public String toString()
+   {
+      return delegate().toString();
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      return delegate().hashCode();
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      return delegate().equals(obj);
+   }
+   
+}


Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list