[webbeans-dev] Re: CreationalContext.destroyDependents()

Gavin King gavin.king at gmail.com
Tue May 26 02:29:48 EDT 2009


Oh no, I guess you can have the container handle this by wrapping Contextual:

  class ContextualWrapper<X> implements Contextual<X> {
	
	Contextual<X> contextual;
	DependentObjects dependentObjects;
	
	ContextualWrapper(DependentObjects dependentObjects) {
		this.dependentObjects = dependentObjects;
	}
	
	public X create(CreationalContext<X> cc) {
		return contextual.create(cc);
	}
	
	public void destroy(X instance) {
		contextual.destroy(instance);
		dependentObjects.destroy();
	}
		
  }

That works, right?

On Mon, May 25, 2009 at 8:36 PM, Gavin King <gavin.king at gmail.com> wrote:
> Folks, I think we should add a new method to CreationalContext, to
> allow for easier and efficient implementation of custom Context
> objects.
>
>    public interface CreationalContext<T> {
>        public void push(T incompleteInstance);
>        public void destroy();
>    }
>
> The destroy() method would destroy any dependent objects of the
> instance that was created in that CreationalContext.
>
> The custom Context would be responsible for maintaining the list of
> CreationalContexts internally, and calling destroy() on each of them
> when the context is destroyed. This would allow the container to
> optimize out any map lookups, etc.
>
> WDYT?
>
> --
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
>



-- 
Gavin King
gavin.king at gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org




More information about the weld-dev mailing list