Skip to content

Commit

Permalink
Tidy up dependentcontext tests and start on the ejb remove stuff
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1803 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Mar 7, 2009
1 parent 2ba430e commit 53621ca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
13 changes: 8 additions & 5 deletions impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
Expand Up @@ -235,18 +235,21 @@ public T create(CreationalContext<T> creationalContext)
}
}

/**
* Destroys an instance of the bean
*
* @param instance The instance
*/
public void destroy(T instance)
{
if (instance == null)
{
throw new IllegalArgumentException("instance to destroy cannot be null");
}
EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
if (enterpiseBeanInstance.isDestroyed())
{
return;
}
else
{
// TODO getManager().getEjbResolver().removeEjb(enterpiseBeanInstance.getUnproxiedInstances());
}
}

/**
Expand Down
Expand Up @@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.bean.proxy;

import java.util.Collection;

/**
* Interface implemented by all enterprise bean proxies to determine if
* the enterprise bean has already had a remove method called by the application
Expand All @@ -33,4 +35,10 @@ public interface EnterpriseBeanInstance
*/
public boolean isDestroyed();

/**
* The unproxied version of this object
* @return
*/
public Collection<Object> getUnproxiedInstances();

}
Expand Up @@ -4,6 +4,7 @@
package org.jboss.webbeans.mock;

import java.lang.annotation.Annotation;
import java.util.Collection;

import javax.annotation.Resource;
import javax.ejb.EJB;
Expand Down Expand Up @@ -44,4 +45,9 @@ public Object resolveResource(InjectionPoint injectionPoint, NamingContext namin
{
return null;
}

public void removeEjb(Collection<Object> instance)
{
// No-op
}
}
37 changes: 25 additions & 12 deletions spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java
Expand Up @@ -10,6 +10,8 @@
* 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
*
*/
Expand All @@ -21,27 +23,37 @@ public interface EjbResolver
/**
* Resolve the value for the given @EJB injection point
*
* @param injectionPoint the injection point metadata
* @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
* 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
* @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
* 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
*/
Expand All @@ -50,12 +62,14 @@ public interface EjbResolver
/**
* Resolve the value for the given @Resource injection point
*
* @param injectionPoint the injection point metadata
* @param namingContext the pluggable Web Beans JNDI lookup facility
* @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
* 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
Expand Down Expand Up @@ -83,5 +97,4 @@ public interface EjbResolver
*/
public Class<? extends Annotation> getResourceAnnotation();


}
Expand Up @@ -51,6 +51,11 @@ public Object resolveResource(InjectionPoint injectionPoint, NamingContext namin
{
return delegate().resolveResource(injectionPoint, namingContext);
}
//
// public void removeEjb(Collection<Object> instance)
// {
// delegate().removeEjb(instance);
// }

@Override
public boolean equals(Object obj)
Expand Down

0 comments on commit 53621ca

Please sign in to comment.