Author: pete.muir(a)jboss.org
Date: 2009-03-14 12:43:22 -0400 (Sat, 14 Mar 2009)
New Revision: 1991
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/EjbReference.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
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.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/helpers/AbstractBootstrap.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java
Log:
WBRI-159, WBRI-165,
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-14 16:41:23
UTC (rev 1990)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-14 16:43:22
UTC (rev 1991)
@@ -65,7 +65,7 @@
import org.jboss.webbeans.context.ContextMap;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.ejb.EjbDescriptorCache;
-import org.jboss.webbeans.ejb.spi.EjbResolver;
+import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.ResolvableAnnotatedClass;
@@ -125,14 +125,13 @@
private transient List<Bean<?>> beans;
// The registered beans, mapped by implementation class
private transient final Map<Class<?>, EnterpriseBean<?>>
newEnterpriseBeanMap;
- private transient final Map<Class<?>, EnterpriseBean<?>>
enterpriseBeanMap;
// The registered decorators
private transient final Set<Decorator> decorators;
// The registered interceptors
private transient final Set<Interceptor> interceptors;
// The EJB resolver provided by the container
- private transient final EjbResolver ejbResolver;
+ private transient final EjbServices ejbServices;
private transient final EjbDescriptorCache ejbDescriptorCache;
@@ -151,17 +150,16 @@
/**
* Create a new manager
*
- * @param ejbResolver the ejbResolver to use
+ * @param ejbServices the ejbResolver to use
*/
- public ManagerImpl(NamingContext namingContext, EjbResolver ejbResolver,
ResourceLoader resourceLoader, TransactionServices transactionServices)
+ public ManagerImpl(NamingContext namingContext, EjbServices ejbServices,
ResourceLoader resourceLoader, TransactionServices transactionServices)
{
- this.ejbResolver = ejbResolver;
+ this.ejbServices = ejbServices;
this.namingContext = namingContext;
this.resourceLoader = resourceLoader;
this.transactionServices = transactionServices;
this.beans = new CopyOnWriteArrayList<Bean<?>>();
this.newEnterpriseBeanMap = new ConcurrentHashMap<Class<?>,
EnterpriseBean<?>>();
- this.enterpriseBeanMap = new ConcurrentHashMap<Class<?>,
EnterpriseBean<?>>();
this.resolver = new Resolver(this);
this.clientProxyProvider = new ClientProxyProvider();
this.decorators = new HashSet<Decorator>();
@@ -381,10 +379,6 @@
{
newEnterpriseBeanMap.put(bean.getType(), (EnterpriseBean<?>) bean);
}
- else if (bean instanceof EnterpriseBean)
- {
- enterpriseBeanMap.put(bean.getType(), (EnterpriseBean<?>) bean);
- }
}
resolver.clear();
}
@@ -399,11 +393,6 @@
{
return newEnterpriseBeanMap;
}
-
- public Map<Class<?>, EnterpriseBean<?>> getEnterpriseBeanMap()
- {
- return enterpriseBeanMap;
- }
/**
* The beans registered with the Web Bean manager. For internal use
@@ -899,9 +888,9 @@
return namingContext;
}
- public final EjbResolver getEjbResolver()
+ public final EjbServices getEjbServices()
{
- return ejbResolver;
+ return ejbServices;
}
public final ResourceLoader getResourceLoader()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-03-14
16:41:23 UTC (rev 1990)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -35,12 +35,14 @@
import javax.inject.DefinitionException;
import javax.interceptor.Interceptor;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.DependentStorageRequest;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.ejb.api.EjbReference;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -209,7 +211,7 @@
DependentContext.INSTANCE.setActive(true);
T instance = proxyClass.newInstance();
creationalContext.push(instance);
- ((ProxyObject) instance).setHandler(new EnterpriseBeanProxyMethodHandler(this,
ejbDescriptor.getRemoveMethods()));
+ ((ProxyObject) instance).setHandler(new
EnterpriseBeanProxyMethodHandler(this));
if (log.isTraceEnabled())
log.trace("Enterprise bean instance created for bean " + this);
return instance;
@@ -375,5 +377,11 @@
}
return false;
}
+
+ public EjbReference<T> createReference()
+ {
+ return getManager().getEjbServices().resolveEJB(getEjbDescriptor(),
CurrentManager.rootManager().getNaming());
+ }
+
}
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-14
16:41:23 UTC (rev 1990)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -219,12 +219,12 @@
protected void initEjbInjectionPoints()
{
this.ejbInjectionPoints = new HashSet<AnnotatedInjectionPoint<?,
?>>();
- for (AnnotatedField<?> field :
annotatedItem.getAnnotatedFields(manager.getEjbResolver().getEJBAnnotation()))
+ for (AnnotatedField<?> field :
annotatedItem.getAnnotatedFields(manager.getEjbServices().getEJBAnnotation()))
{
this.ejbInjectionPoints.add(FieldInjectionPoint.of(this, field));
}
- for (AnnotatedMethod<?> method :
annotatedItem.getAnnotatedMethods(manager.getEjbResolver().getEJBAnnotation()))
+ for (AnnotatedMethod<?> method :
annotatedItem.getAnnotatedMethods(manager.getEjbServices().getEJBAnnotation()))
{
this.ejbInjectionPoints.add(MethodInjectionPoint.of(this, method));
}
@@ -233,7 +233,7 @@
protected void initPersistenceUnitInjectionPoints()
{
this.persistenceUnitInjectionPoints = new HashSet<AnnotatedInjectionPoint<?,
?>>();
- for (AnnotatedField<?> field :
annotatedItem.getAnnotatedFields(manager.getEjbResolver().getPersistenceContextAnnotation()))
+ for (AnnotatedField<?> field :
annotatedItem.getAnnotatedFields(manager.getEjbServices().getPersistenceContextAnnotation()))
{
if
(field.getAnnotation(PersistenceContext.class).type().equals(PersistenceContextType.EXTENDED))
{
@@ -242,7 +242,7 @@
this.persistenceUnitInjectionPoints.add(FieldInjectionPoint.of(this, field));
}
- for (AnnotatedMethod<?> method :
annotatedItem.getAnnotatedMethods(manager.getEjbResolver().getPersistenceContextAnnotation()))
+ for (AnnotatedMethod<?> method :
annotatedItem.getAnnotatedMethods(manager.getEjbServices().getPersistenceContextAnnotation()))
{
if
(method.getAnnotation(PersistenceContext.class).type().equals(PersistenceContextType.EXTENDED))
{
@@ -255,7 +255,7 @@
protected void initResourceInjectionPoints()
{
this.resourceInjectionPoints = new HashSet<AnnotatedInjectionPoint<?,
?>>();
- for (AnnotatedField<?> field :
annotatedItem.getAnnotatedFields(manager.getEjbResolver().getResourceAnnotation()))
+ for (AnnotatedField<?> field :
annotatedItem.getAnnotatedFields(manager.getEjbServices().getResourceAnnotation()))
{
this.resourceInjectionPoints.add(FieldInjectionPoint.of(this, field));
}
@@ -269,19 +269,19 @@
for (AnnotatedInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
{
- Object ejbInstance = manager.getEjbResolver().resolveEjb(injectionPoint,
manager.getNaming());
+ Object ejbInstance = manager.getEjbServices().resolveEjb(injectionPoint,
manager.getNaming());
injectionPoint.inject(beanInstance, ejbInstance);
}
for (AnnotatedInjectionPoint<?, ?> injectionPoint :
persistenceUnitInjectionPoints)
{
- Object puInstance =
manager.getEjbResolver().resolvePersistenceContext(injectionPoint, manager.getNaming());
+ Object puInstance =
manager.getEjbServices().resolvePersistenceContext(injectionPoint, manager.getNaming());
injectionPoint.inject(beanInstance, puInstance);
}
for (AnnotatedInjectionPoint<?, ?> injectionPoint : resourceInjectionPoints)
{
- Object resourceInstance =
manager.getEjbResolver().resolveResource(injectionPoint, manager.getNaming());
+ Object resourceInstance =
manager.getEjbServices().resolveResource(injectionPoint, manager.getNaming());
injectionPoint.inject(beanInstance, resourceInstance);
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-03-14
16:41:23 UTC (rev 1990)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -18,16 +18,11 @@
package org.jboss.webbeans.bean.proxy;
import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import javassist.util.proxy.MethodHandler;
-import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.ejb.api.EjbReference;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.Reflections;
@@ -44,48 +39,27 @@
// The log provider
private static final transient LogProvider log =
Logging.getLogProvider(EnterpriseBeanProxyMethodHandler.class);
- private static final ThreadLocal<Set<Class<?>>> contextualInstance;
+ private static final ThreadLocal<EnterpriseBean<?>> enterpriseBean;
static
{
- contextualInstance = new ThreadLocal<Set<Class<?>>>()
- {
-
- @Override
- protected Set<Class<?>> initialValue()
- {
- return new HashSet<Class<?>>();
- }
-
- };
+ enterpriseBean = new ThreadLocal<EnterpriseBean<?>>();
}
- // TODO Surely we can do this better!
- public static boolean isContextualInstance(Class<?> beanClass)
+ public static EnterpriseBean<?> getEnterpriseBean()
{
- return contextualInstance.get().contains(beanClass);
+ return enterpriseBean.get();
}
- private static void setContextualInstance(Class<?> beanClass, boolean
accessing)
+ private static void setEnterpriseBean(EnterpriseBean<?> bean)
{
- if (accessing)
- {
- contextualInstance.get().add(beanClass);
- }
- else
- {
- contextualInstance.get().remove(beanClass);
- }
+ enterpriseBean.set(bean);
}
- // The container provided proxy that implements all interfaces
- private final Map<Class<?>, Object> proxiedInstances;
- private final Map<Class<?>, String> jndiNames;
+ private final EjbReference<?> reference;
+ private final Class<?> objectInterface;
private boolean destroyed;
- private boolean canCallRemoveMethods;
- private final List<Method> removeMethods;
- private final Class<?> beanClass;
/**
* Constructor
@@ -94,14 +68,20 @@
*
* @param proxy The generic proxy
*/
- public EnterpriseBeanProxyMethodHandler(EnterpriseBean<?> bean,
Iterable<Method> removeMethods)
+ public EnterpriseBeanProxyMethodHandler(EnterpriseBean<?> bean)
{
- this.proxiedInstances = new HashMap<Class<?>, Object>();
- this.jndiNames = bean.getEjbDescriptor().getLocalBusinessInterfacesJndiNames();
- this.canCallRemoveMethods = bean.canCallRemoveMethods();
- this.removeMethods = bean.getEjbDescriptor().getRemoveMethods();
+ this.reference = bean.createReference();
this.destroyed = false;
- this.beanClass = bean.getType();
+ this.objectInterface = bean.getEjbDescriptor().getObjectInterface();
+ try
+ {
+ setEnterpriseBean(bean);
+ reference.create();
+ }
+ finally
+ {
+ setEnterpriseBean(null);
+ }
log.trace("Created enterprise bean proxy method handler for " + bean);
}
@@ -124,6 +104,7 @@
*/
public Object invoke(Object self, Method method, Method proceed, Object[] args) throws
Throwable
{
+ // EnterpriseBeanInstance methods
if ("isDestroyed".equals(method.getName()))
{
return destroyed;
@@ -147,38 +128,18 @@
}
Class<?> businessInterface = method.getDeclaringClass();
- Object proxiedInstance = proxiedInstances.get(businessInterface);
- if (proxiedInstance == null)
+ if (businessInterface.equals(Object.class))
{
- String jndiName = jndiNames.get(businessInterface);
- if (jndiName == null)
- {
- throw new IllegalStateException("Unable to establish jndi name to use to
lookup EJB");
- }
- try
- {
- setContextualInstance(beanClass, true);
- proxiedInstance = CurrentManager.rootManager().getNaming().lookup(jndiName,
businessInterface);
- }
- finally
- {
- setContextualInstance(beanClass, false);
- }
- proxiedInstances.put(businessInterface, proxiedInstance);
+ businessInterface = objectInterface;
}
+ Object proxiedInstance = reference.get(businessInterface);
Method proxiedMethod = Reflections.lookupMethod(method, proxiedInstance);
- try
- {
- setContextualInstance(beanClass, true);
- Object returnValue = Reflections.invokeAndWrap(proxiedMethod, proxiedInstance,
args);
- log.trace("Executed " + method + " on " + proxiedInstance +
" with parameters " + args + " and got return value " + returnValue);
- return returnValue;
- }
- finally
- {
- setContextualInstance(beanClass, false);
- }
+ Object returnValue = Reflections.invokeAndWrap(proxiedMethod, proxiedInstance,
args);
+ log.trace("Executed " + method + " on " + proxiedInstance +
" with parameters " + args + " and got return value " + returnValue);
+ return returnValue;
}
+
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-14
16:41:23 UTC (rev 1990)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -204,6 +204,7 @@
private void createEnterpriseBean(AnnotatedClass<?> annotatedClass)
{
+ // TODO Don't create enterprise bean if it has no local interfaces!
EnterpriseBean<?> bean = EnterpriseBean.of(annotatedClass, manager);
createBean(bean, annotatedClass);
beans.add(NewEnterpriseBean.of(annotatedClass, manager));
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-14
16:41:23 UTC (rev 1990)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -77,15 +77,15 @@
{
throw new IllegalStateException("NamingContext is not set");
}
- if (getEjbResolver() == null)
+ if (getEjbServices() == null)
{
- throw new IllegalStateException("EjbResolver is not set");
+ throw new IllegalStateException("EjbServices is not set");
}
if (getTransactionServices() == null)
{
log.info("Transactional services not available. Transactional observers
will be invoked synchronously.");
}
- this.manager = new ManagerImpl(getNamingContext(), getEjbResolver(),
getResourceLoader(), getTransactionServices());
+ this.manager = new ManagerImpl(getNamingContext(), getEjbServices(),
getResourceLoader(), getTransactionServices());
getManager().getNaming().bind(ManagerImpl.JNDI_KEY, getManager());
CurrentManager.setRootManager(manager);
initializeContexts();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java 2009-03-14
16:41:23 UTC (rev 1990)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -17,13 +17,7 @@
package org.jboss.webbeans.ejb;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
@@ -34,52 +28,45 @@
* constructor
*
* @author Pete Muir
- *
+ *
*/
public class InternalEjbDescriptor<T> extends ForwardingEjbDescriptor<T>
implements EjbDescriptor<T>
{
-
- private final Map<Class<?>, String> localBusinessInterfacesJndiNames;
+
+ private final Class<?> objectInterface;
+ private final boolean local;
private final EjbDescriptor<T> delegate;
- public List<Method> removeMethods;
-
+
public InternalEjbDescriptor(EjbDescriptor<T> ejbDescriptor)
{
this.delegate = ejbDescriptor;
- this.localBusinessInterfacesJndiNames = new HashMap<Class<?>,
String>();
- for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor :
ejbDescriptor.getLocalBusinessInterfaces())
- {
- localBusinessInterfacesJndiNames.put(businessInterfaceDescriptor.getInterface(),
businessInterfaceDescriptor.getJndiName());
- }
- // Internally, Object.class is added to the type hierachy of an
- // EnterpriseBean, so we need to represent that here. We can just use any
- // of the local business interfaces
Iterator<BusinessInterfaceDescriptor<?>> it =
ejbDescriptor.getLocalBusinessInterfaces().iterator();
if (it.hasNext())
{
- localBusinessInterfacesJndiNames.put(Object.class, it.next().getJndiName());
+ this.objectInterface = it.next().getInterface();
+ this.local = true;
}
- removeMethods = new ArrayList<Method>();
- for (Method removeMethod : ejbDescriptor.getRemoveMethods())
+ else
{
- removeMethods.add(removeMethod);
+ this.objectInterface = null;
+ this.local = false;
}
}
-
- public Map<Class<?>, String> getLocalBusinessInterfacesJndiNames()
+
+ @Override
+ protected EjbDescriptor<T> delegate()
{
- return Collections.unmodifiableMap(localBusinessInterfacesJndiNames);
+ return delegate;
}
-
- public List<Method> getRemoveMethods()
+
+ public boolean isLocal()
{
- return Collections.unmodifiableList(removeMethods);
+ return local;
}
-
- @Override
- protected EjbDescriptor<T> delegate()
+
+ public Class<?> getObjectInterface()
{
- return delegate;
+ return objectInterface;
}
-
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-03-14
16:41:23 UTC (rev 1990)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -25,6 +25,8 @@
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
/**
* Interceptor for handling EJB post-construct tasks
@@ -33,6 +35,13 @@
*/
public class SessionBeanInterceptor
{
+
+ private transient Log log = Logging.getLog(SessionBeanInterceptor.class);
+
+ // TODO make Bean serializable
+ private transient EnterpriseBean<Object> bean;
+ private boolean contextual;
+
/**
* Gets the underlying target and calls the post-construct method
*
@@ -43,11 +52,8 @@
public void postConstruct(InvocationContext invocationContext) throws Exception
{
Object target = invocationContext.getTarget();
- EnterpriseBean<Object> enterpriseBean = getBean(target.getClass());
- if (enterpriseBean != null)
- {
- enterpriseBean.postConstruct(target);
- }
+ initBean(target.getClass());
+ bean.postConstruct(target);
invocationContext.proceed();
}
@@ -61,12 +67,15 @@
public void preDestroy(InvocationContext invocationContext) throws Exception
{
Object target = invocationContext.getTarget();
- EnterpriseBean<Object> enterpriseBean = getBean(target.getClass());
- if (enterpriseBean != null)
+ if (bean == null)
{
- enterpriseBean.preDestroy(target);
+ log.warn("Support for destroying passivated EJBs not yet
implemented");
}
- getEnterpriseBeanInstance(enterpriseBean).setDestroyed(true);
+ bean.preDestroy(target);
+ if (contextual)
+ {
+ getEnterpriseBeanInstance(bean).setDestroyed(true);
+ }
invocationContext.proceed();
}
@@ -76,18 +85,18 @@
* @param invocationContext The invocation context
* @return The found bean or null if the bean was not an enterprise bean
*/
- private static <T> EnterpriseBean<T> getBean(Class<? extends T>
beanClass)
+ private void initBean(Class<? extends Object> beanClass)
{
- if (EnterpriseBeanProxyMethodHandler.isContextualInstance(beanClass))
+ EnterpriseBean<Object> bean = (EnterpriseBean<Object>)
EnterpriseBeanProxyMethodHandler.getEnterpriseBean();
+ if (bean != null && bean.getType().equals(beanClass))
{
- // Access all non-new enterprise beans.
- // TODO Deal with XML defined enterprise beans!
- return (EnterpriseBean<T>)
CurrentManager.rootManager().getEnterpriseBeanMap().get(beanClass);
+ this.bean = bean;
+ this.contextual = true;
}
else
{
- // Access all @New enterprise beans
- return (EnterpriseBean<T>)
CurrentManager.rootManager().getNewEnterpriseBeanMap().get(beanClass);
+ this.bean = (EnterpriseBean<Object>)
CurrentManager.rootManager().getNewEnterpriseBeanMap().get(beanClass);
+ this.contextual = false;
}
}
@@ -105,3 +114,5 @@
}
}
+
+
\ No newline at end of file
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java 2009-03-14
16:41:23 UTC (rev 1990)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -1,53 +0,0 @@
-/**
- *
- */
-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.ejb.spi.EjbResolver;
-import org.jboss.webbeans.resources.spi.NamingContext;
-
-final class MockEjBResolver implements EjbResolver
-{
- public Class<? extends Annotation> getEJBAnnotation()
- {
- return EJB.class;
- }
-
- public Class<? extends Annotation> getPersistenceContextAnnotation()
- {
- return PersistenceContext.class;
- }
-
- public Object resolveEjb(InjectionPoint injectionPoint, NamingContext namingContext)
- {
- return null;
- }
-
- public Object resolvePersistenceContext(InjectionPoint injectionPoint, NamingContext
namingContext)
- {
- return null;
- }
-
- public Class<? extends Annotation> getResourceAnnotation()
- {
- return Resource.class;
- }
-
- public Object resolveResource(InjectionPoint injectionPoint, NamingContext
namingContext)
- {
- return null;
- }
-
- public void removeEjb(Collection<Object> instance)
- {
- // No-op
- }
-}
\ No newline at end of file
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java (from rev
1971, ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
(rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -0,0 +1,78 @@
+/**
+ *
+ */
+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.ejb.api.EjbReference;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.resources.spi.NamingContext;
+
+final class MockEjBServices implements EjbServices
+{
+ public Class<? extends Annotation> getEJBAnnotation()
+ {
+ return EJB.class;
+ }
+
+ public Class<? extends Annotation> getPersistenceContextAnnotation()
+ {
+ return PersistenceContext.class;
+ }
+
+ public Object resolveEjb(InjectionPoint injectionPoint, NamingContext namingContext)
+ {
+ return null;
+ }
+
+ public Object resolvePersistenceContext(InjectionPoint injectionPoint, NamingContext
namingContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getResourceAnnotation()
+ {
+ return Resource.class;
+ }
+
+ public Object resolveResource(InjectionPoint injectionPoint, NamingContext
namingContext)
+ {
+ return null;
+ }
+
+ public void removeEjb(Collection<Object> instance)
+ {
+ // No-op
+ }
+
+ public <T> EjbReference<T> resolveEJB(EjbDescriptor<T>
ejbDescriptor, NamingContext naming)
+ {
+ return new EjbReference<T>()
+ {
+
+ public <S> S get(Class<S> businessInterfaceType)
+ {
+ return null;
+ }
+
+ public void remove()
+ {
+ // No-op
+ }
+
+ public void create()
+ {
+ // No-op
+ }
+
+ };
+ }
+}
\ No newline at end of file
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java 2009-03-14
16:41:23 UTC (rev 1990)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -21,7 +21,7 @@
import org.jboss.webbeans.bootstrap.WebBeansBootstrap;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.webbeans.ejb.spi.EjbResolver;
+import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.servlet.AbstractLifecycle;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -29,7 +29,7 @@
public class MockLifecycle extends AbstractLifecycle
{
- private static final EjbResolver MOCK_EJB_RESOLVER = new MockEjBResolver();
+ private static final EjbServices MOCK_EJB_RESOLVER = new MockEjBServices();
private static final ResourceLoader MOCK_RESOURCE_LOADER = new MockResourceLoader();
private static final TransactionServices MOCK_TRANSACTION_SERVICES = new
MockTransactionServices();
@@ -53,7 +53,7 @@
}
bootstrap = new WebBeansBootstrap();
bootstrap.setNamingContext(new MockNamingContext(null));
- bootstrap.setEjbResolver(MOCK_EJB_RESOLVER);
+ bootstrap.setEjbServices(MOCK_EJB_RESOLVER);
bootstrap.setResourceLoader(MOCK_RESOURCE_LOADER);
bootstrap.setWebBeanDiscovery(webBeanDiscovery);
bootstrap.setApplicationContext(applicationBeanStore);
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-14
16:41:23 UTC (rev 1990)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -3,7 +3,7 @@
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.ejb.spi.EjbResolver;
+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;
@@ -33,11 +33,11 @@
public void setEjbDiscovery(EjbDiscovery ejbDiscovery);
/**
- * Set the EjbResolver to use
+ * Set the EjbServices to use
*
- * @param ejbResolver
+ * @param ejbServices
*/
- public void setEjbResolver(EjbResolver ejbResolver);
+ public void setEjbServices(EjbServices ejbServices);
/**
* Set the NamingContext to use.
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/AbstractBootstrap.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/AbstractBootstrap.java 2009-03-14
16:41:23 UTC (rev 1990)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/AbstractBootstrap.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -4,7 +4,7 @@
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.ejb.spi.EjbResolver;
+import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -15,7 +15,7 @@
private WebBeanDiscovery webBeanDiscovery;
private ResourceLoader resourceLoader;
private NamingContext namingContext;
- private EjbResolver ejbResolver;
+ private EjbServices ejbServices;
private EjbDiscovery ejbDiscovery;
private BeanStore applicationContext;
private TransactionServices transactionServices;
@@ -25,9 +25,9 @@
this.ejbDiscovery = ejbDiscovery;
}
- public void setEjbResolver(EjbResolver ejbResolver)
+ public void setEjbServices(EjbServices ejbServices)
{
- this.ejbResolver = ejbResolver;
+ this.ejbServices = ejbServices;
}
public void setNamingContext(NamingContext namingContext)
@@ -65,9 +65,9 @@
return namingContext;
}
- public EjbResolver getEjbResolver()
+ public EjbServices getEjbServices()
{
- return ejbResolver;
+ return ejbServices;
}
public EjbDiscovery getEjbDiscovery()
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-14
16:41:23 UTC (rev 1990)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -4,7 +4,7 @@
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.ejb.spi.EjbResolver;
+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;
@@ -39,9 +39,9 @@
delegate().setEjbDiscovery(ejbDiscovery);
}
- public void setEjbResolver(EjbResolver ejbResolver)
+ public void setEjbServices(EjbServices ejbServices)
{
- delegate().setEjbResolver(ejbResolver);
+ delegate().setEjbServices(ejbServices);
}
public void setNamingContext(NamingContext namingContext)
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/EjbReference.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/EjbReference.java
(rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/EjbReference.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -0,0 +1,63 @@
+/*
+ * 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.api;
+
+import java.io.Serializable;
+
+/**
+ * A serializable reference to an EJB
+ *
+ * @author Pete Muir
+ * @param <T>
+ * The EJB bean class
+ */
+public interface EjbReference<T> extends Serializable
+{
+
+ /**
+ * Get the reference to the EJB for the given business interfaces
+ *
+ * The reference may be lazily instantiated; if Web Beans wishes to eagerly
+ * instantiated the bean it will call {@link #create()}.
+ *
+ * @param <S>
+ * the type of the business interface
+ * @param businessInterfaceType
+ * the type of the business interface
+ * @return a reference
+ */
+ public <S> S get(Class<S> businessInterfaceType);
+
+ /**
+ * Request the SFSB backing this reference is removed
+ *
+ * @throws UnsupportedOperationException
+ * if the reference is backed by an SLSB
+ */
+ public void remove();
+
+ /**
+ * Request that the SFSB backing this reference is instantiated, and any
+ *
+ * @PostConstruct lifecycle callbacks are executed
+ *
+ * @throws UnsupportedOperationException
+ * if the reference is backed by an SLSB
+ */
+ public void create();
+
+}
Property changes on:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/EjbReference.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java 2009-03-14
16:41:23 UTC (rev 1990)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -1,100 +0,0 @@
-package org.jboss.webbeans.ejb.spi;
-
-import java.lang.annotation.Annotation;
-
-import javax.inject.manager.InjectionPoint;
-
-import org.jboss.webbeans.resources.spi.NamingContext;
-
-/**
- * A container should implement this interface to allow the Web Beans RI to
- * resolve EJBs, Resources and JPA persistence units
- *
- * TODO This probably needs renaming to EjbLifecycle
- *
- * @author Pete Muir
- *
- */
-public interface EjbResolver
-{
-
- public static final String PROPERTY_NAME = EjbResolver.class.getName();
-
- /**
- * Resolve the value for the given @EJB injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the EJB
- * @throws IllegalArgumentException
- * if the injection point is not annotated with @EJB, or, if the
- * injection point is a method that doesn't follow JavaBean
- * conventions
- * @throws IllegalStateException
- * if no EJBs can be resolved for injection
- */
- public Object resolveEjb(InjectionPoint injectionPoint, NamingContext namingContext);
-
-// /**
-// * Request the EJB container remove an EJB
-// *
-// * @param instances all objects retrieved from the container for this EJB
-// */
-// public void removeEjb(Collection<Object> instances);
-
- /**
- * Resolve the value for the given @PersistenceContext injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @param namingContext
- * the pluggable Web Beans JNDI lookup facility
- * @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, NamingContext
namingContext);
-
- /**
- * Resolve the value for the given @Resource injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @param namingContext
- * the pluggable Web Beans JNDI lookup facility
- * @return an instance of the resource
- * @throws IllegalArgumentException
- * if the injection point is not annotated with @Resource, or, if
- * the injection point is a method that doesn't follow JavaBean
- * conventions
- * @throws IllegalStateException
- * if no resource can be resolved for injection
- */
- public Object resolveResource(InjectionPoint injectionPoint, NamingContext
namingContext);
-
- /**
- * Get the annotation which defines an @EJB injection point
- *
- * @return the annotation which defines an @EJB injection point
- */
- public Class<? extends Annotation> getEJBAnnotation();
-
- /**
- * Get the annotation which defines a @PersistenceContext injection point
- *
- * @return the annotation which defines a @PersistenceContext injection point
- */
- public Class<? extends Annotation> getPersistenceContextAnnotation();
-
- /**
- * Get the annotation which defines a @Resource injection point
- *
- * @return the annotation which defines a @Resource injection point
- */
- public Class<? extends Annotation> getResourceAnnotation();
-
-}
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java (from rev
1966, ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
(rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -0,0 +1,119 @@
+/*
+ * 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;
+
+import java.lang.annotation.Annotation;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.ejb.api.EjbReference;
+import org.jboss.webbeans.resources.spi.NamingContext;
+
+/**
+ * A container should implement this interface to allow the Web Beans RI to
+ * resolve EJBs, Resources and JPA persistence units
+ *
+ * @author Pete Muir
+ *
+ */
+public interface EjbServices
+{
+
+ public static final String PROPERTY_NAME = EjbServices.class.getName();
+
+ /**
+ * Resolve the value for the given @EJB injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the EJB
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with @EJB, or, if the
+ * injection point is a method that doesn't follow JavaBean
+ * conventions
+ * @throws IllegalStateException
+ * if no EJBs can be resolved for injection
+ */
+ public Object resolveEjb(InjectionPoint injectionPoint, NamingContext namingContext);
+
+ /**
+ * Resolve the value for the given @PersistenceContext injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @param namingContext
+ * the pluggable Web Beans JNDI lookup facility
+ * @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, NamingContext
namingContext);
+
+ /**
+ * Resolve the value for the given @Resource injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @param namingContext
+ * the pluggable Web Beans JNDI lookup facility
+ * @return an instance of the resource
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with @Resource, or, if
+ * the injection point is a method that doesn't follow JavaBean
+ * conventions
+ * @throws IllegalStateException
+ * if no resource can be resolved for injection
+ */
+ public Object resolveResource(InjectionPoint injectionPoint, NamingContext
namingContext);
+
+ /**
+ * Request an EJB instance from the container
+ *
+ * @param <T> the type of the bean class
+ * @param ejbDescriptor the ejb to resolve
+ * @param namingContext the pluggable Web Beans JNDI lookup facility
+ * @return a reference to the EJB
+ */
+ public <T> EjbReference<T> resolveEJB(EjbDescriptor<T>
ejbDescriptor, NamingContext namingContext);
+
+ /**
+ * Get the annotation which defines an @EJB injection point
+ *
+ * @return the annotation which defines an @EJB injection point
+ */
+ public Class<? extends Annotation> getEJBAnnotation();
+
+ /**
+ * Get the annotation which defines a @PersistenceContext injection point
+ *
+ * @return the annotation which defines a @PersistenceContext injection point
+ */
+ public Class<? extends Annotation> getPersistenceContextAnnotation();
+
+ /**
+ * Get the annotation which defines a @Resource injection point
+ *
+ * @return the annotation which defines a @Resource injection point
+ */
+ public Class<? extends Annotation> getResourceAnnotation();
+
+}
Property changes on:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java 2009-03-14
16:41:23 UTC (rev 1990)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -1,78 +0,0 @@
-package org.jboss.webbeans.ejb.spi.helpers;
-
-import java.lang.annotation.Annotation;
-
-import javax.inject.manager.InjectionPoint;
-
-import org.jboss.webbeans.ejb.spi.EjbResolver;
-import org.jboss.webbeans.resources.spi.NamingContext;
-
-/**
- * An implementation of {@link EjbResolver} which forwards all its method calls
- * to another {@link EjbResolver}}. Subclasses should override one or more
- * methods to modify the behavior of the backing {@link EjbResolver} as desired
- * per the <a
- *
href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator
pattern</a>.
- *
- * @author Pete Muir
- *
- */
-public abstract class ForwardingEjbResolver implements EjbResolver
-{
-
- public abstract EjbResolver delegate();
-
- public Class<? extends Annotation> getEJBAnnotation()
- {
- return delegate().getEJBAnnotation();
- }
-
- public Class<? extends Annotation> getPersistenceContextAnnotation()
- {
- return delegate().getPersistenceContextAnnotation();
- }
-
- public Class<? extends Annotation> getResourceAnnotation()
- {
- return delegate().getResourceAnnotation();
- }
-
- public Object resolveEjb(InjectionPoint injectionPoint, NamingContext namingContext)
- {
- return delegate().resolveEjb(injectionPoint, namingContext);
- }
-
- public Object resolvePersistenceContext(InjectionPoint injectionPoint, NamingContext
namingContext)
- {
- return delegate().resolvePersistenceContext(injectionPoint, namingContext);
- }
-
- public Object resolveResource(InjectionPoint injectionPoint, NamingContext
namingContext)
- {
- return delegate().resolveResource(injectionPoint, namingContext);
- }
-//
-// public void removeEjb(Collection<Object> instance)
-// {
-// delegate().removeEjb(instance);
-// }
-
- @Override
- public boolean equals(Object obj)
- {
- return delegate().equals(obj);
- }
-
- @Override
- public String toString()
- {
- return delegate().toString();
- }
-
- @Override
- public int hashCode()
- {
- return delegate().hashCode();
- }
-
-}
Copied:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
(from rev 1966,
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java)
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
(rev 0)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-03-14
16:43:22 UTC (rev 1991)
@@ -0,0 +1,85 @@
+package org.jboss.webbeans.ejb.spi.helpers;
+
+import java.lang.annotation.Annotation;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.ejb.api.EjbReference;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.resources.spi.NamingContext;
+
+/**
+ * An implementation of {@link EjbServices} which forwards all its method calls
+ * to another {@link EjbServices}}. Subclasses should override one or more
+ * methods to modify the behavior of the backing {@link EjbServices} as desired
+ * per the <a
+ *
href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator
pattern</a>.
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class ForwardingEjbServices implements EjbServices
+{
+
+ public abstract EjbServices delegate();
+
+ public Class<? extends Annotation> getEJBAnnotation()
+ {
+ return delegate().getEJBAnnotation();
+ }
+
+ public Class<? extends Annotation> getPersistenceContextAnnotation()
+ {
+ return delegate().getPersistenceContextAnnotation();
+ }
+
+ public Class<? extends Annotation> getResourceAnnotation()
+ {
+ return delegate().getResourceAnnotation();
+ }
+
+ public Object resolveEjb(InjectionPoint injectionPoint, NamingContext namingContext)
+ {
+ return delegate().resolveEjb(injectionPoint, namingContext);
+ }
+
+ public <T> EjbReference<T> resolveEJB(EjbDescriptor<T>
ejbDescriptor, NamingContext namingContext)
+ {
+ return delegate().resolveEJB(ejbDescriptor, namingContext);
+ }
+
+ public Object resolvePersistenceContext(InjectionPoint injectionPoint, NamingContext
namingContext)
+ {
+ return delegate().resolvePersistenceContext(injectionPoint, namingContext);
+ }
+
+ public Object resolveResource(InjectionPoint injectionPoint, NamingContext
namingContext)
+ {
+ return delegate().resolveResource(injectionPoint, namingContext);
+ }
+//
+// public void removeEjb(Collection<Object> instance)
+// {
+// delegate().removeEjb(instance);
+// }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate().equals(obj);
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate().toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+}
Property changes on:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain