You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Romain Manni-Bucau (JIRA)" <ji...@apache.org> on 2012/05/04 11:06:48 UTC

[jira] [Updated] (DELTASPIKE-172) Improve BeanProvider

     [ https://issues.apache.org/jira/browse/DELTASPIKE-172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Romain Manni-Bucau updated DELTASPIKE-172:
------------------------------------------

    Description: 
BeanProvider is a very cool way to get bean from not managed objects but it is not so cool to use with @Dependent CDI Beans because it is not cleanable

return with the bean the creational context can help to do so ("you are not managed so clean it yourself")

instead of returning the bean a wrapper could be returned like for instance (this class should be enhanced since it manages only one dependent instance):

public class BeanInstance {
    private Object bean;
    private CreationalContext<?> context;

    public BeanInstance(Object bean, CreationalContext<?> context) {
        this.bean = bean;
        this.context = context;
    }

    public boolean isResolved() {
        return bean != null;
    }

    public Object getBean() {
        return bean;
    }

    public void release() {
        context.release();
    }
}

  was:
BeanProvider is a very cool way to get bean from not managed objects but it is not so cool to use with @Dependent CDI Beans because it is not cleanable

return with the bean the creational context can help to do so ("you are not managed so clean it yourself")

instead of returning the bean a wrapper could be returned like for instance:

public class BeanInstance {
    private Object bean;
    private CreationalContext<?> context;

    public BeanInstance(Object bean, CreationalContext<?> context) {
        this.bean = bean;
        this.context = context;
    }

    public boolean isResolved() {
        return bean != null;
    }

    public Object getBean() {
        return bean;
    }

    public void release() {
        context.release();
    }
}

    
> Improve BeanProvider
> --------------------
>
>                 Key: DELTASPIKE-172
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-172
>             Project: DeltaSpike
>          Issue Type: Improvement
>            Reporter: Romain Manni-Bucau
>            Assignee: Gerhard Petracek
>
> BeanProvider is a very cool way to get bean from not managed objects but it is not so cool to use with @Dependent CDI Beans because it is not cleanable
> return with the bean the creational context can help to do so ("you are not managed so clean it yourself")
> instead of returning the bean a wrapper could be returned like for instance (this class should be enhanced since it manages only one dependent instance):
> public class BeanInstance {
>     private Object bean;
>     private CreationalContext<?> context;
>     public BeanInstance(Object bean, CreationalContext<?> context) {
>         this.bean = bean;
>         this.context = context;
>     }
>     public boolean isResolved() {
>         return bean != null;
>     }
>     public Object getBean() {
>         return bean;
>     }
>     public void release() {
>         context.release();
>     }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira