[cdi-dev] Question on BeanManager#createInstance()

Martin Kouba mkouba at redhat.com
Mon Mar 27 02:34:47 EDT 2017


Dne 24.3.2017 v 22:19 Laird Nelson napsal(a):
> Hello; BeanManager#createInstance() says (in part):
>
> "Instances of dependent scoped beans obtained with this Instance must be
> explicitly destroyed by calling Instance.destroy(Object)."
>
> From the standpoint of the caller of, say,
> instance.select(MyBean.class), how is that caller supposed to know
> whether MyBean is in dependent scope or not?

The caller usually knows what bean it's working with.

> Is it anticipated that
> they will call BeanManager#getBeans() and investigate the Bean objects?
> Should Instance have a getScope() method on it, or the like?

There was a proposal to enhance Instance similarly as Weld API does:
http://docs.jboss.org/weld/reference/latest/en-US/html/injection.html#_enhanced_version_of_literal_javax_enterprise_inject_instance_literal

But it was rejected/postponed. See also CDI-515, CDI-589, CDI-651 and 
related discussions.

>
> Thanks,
> Best,
> Laird
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
>

-- 
Martin Kouba
Senior Software Engineer
Red Hat, Czech Republic


More information about the cdi-dev mailing list