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

Gavin King gavin.king at gmail.com
Tue May 26 02:43:16 EDT 2009


Hrm, does not quite work unless ContextualWrapper implements equals()
in a funny way and the Context calls equals() in its internal lookup.

So probably the destroy() method is better.

On Mon, May 25, 2009 at 11:29 PM, Gavin King <gavin.king at gmail.com> wrote:
> 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
>



-- 
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