Skip to content

Commit

Permalink
Disposal Methods oops...
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2307 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
Daniel Roth committed Apr 5, 2009
1 parent 94d70eb commit 677ee4a
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
Expand Up @@ -14,15 +14,13 @@
import javax.inject.Disposes;
import javax.inject.Initializer;
import javax.inject.Produces;
import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;

Expand All @@ -38,8 +36,8 @@ protected DisposalMethodBean(ManagerImpl manager, AnnotatedMethod<T> disposalMet
initInjectionPoints();
initType();
initTypes();
this.id = createId("DisposalMethod-" + declaringBean.getName() + "-"+ disposalMethod.getSignature().toString());
this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());

}

protected AbstractClassBean<?> declaringBean;
Expand All @@ -53,10 +51,11 @@ protected void initType()
this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getRawType();
}

public AnnotatedMethod<T> getAnnotatedItem() {
return disposalMethodInjectionPoint;
public AnnotatedMethod<T> getAnnotatedItem()
{
return disposalMethodInjectionPoint;
}

public static <T> DisposalMethodBean<T> of(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, AbstractClassBean<?> declaringBean)
{
return new DisposalMethodBean<T>(manager, disposalMethod, declaringBean);
Expand Down Expand Up @@ -95,6 +94,20 @@ public Class<? extends Annotation> getDeploymentType()
return declaringBean.getDeploymentType();
}

/**
* Initializes the API types
*/
@Override
protected void initTypes()
{
Set<Type> types = new HashSet<Type>();
types = new HashSet<Type>();
types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getFlattenedTypeHierarchy());
types.add(getType());
types.add(Object.class);
super.types = types;
}

public Set<AnnotatedInjectionPoint<?, ?>> getInjectionPoints()
{
return injectionPoints;
Expand Down Expand Up @@ -143,7 +156,7 @@ public T create(CreationalContext<T> creationalContext)

public void invokeDisposeMethod(Object instance)
{

List<Object> parameters = new LinkedList<Object>();

parameters.add(instance);
Expand All @@ -158,11 +171,11 @@ public void invokeDisposeMethod(Object instance)

try
{
disposalMethodInjectionPoint.invoke(beanInstance, parameters.toArray());
disposalMethodInjectionPoint.invoke(beanInstance, parameters.toArray());
}
catch (Exception e)
{
// TODO:
// TODO:
}

}
Expand Down Expand Up @@ -234,8 +247,8 @@ protected void specialize(BeanDeployerEnvironment environment)
throw new IllegalStateException(toString() + " does not specialize a bean");
}
this.specializedBean = environment.getProducerMethod(superClassMethod);
}
}

@Override
public Class<T> getType()
{
Expand Down

0 comments on commit 677ee4a

Please sign in to comment.