[JBoss JIRA] (CDI-10) Add ability to access a bean instance from a proxy
by Romain Manni-Bucau (JIRA)
[ https://issues.jboss.org/browse/CDI-10?page=com.atlassian.jira.plugin.sys... ]
Romain Manni-Bucau commented on CDI-10:
---------------------------------------
About the need: a not cdi proxy friendly lib will not identify the class of the proxied instance and fields if not forwarded so the user type instance can be needed to do vallidation, state update etc...we can argue the lib can become cdi bit the opposite should be doable, ie let a dev integrate cdi with a not cdi lib IMO.
Technically I agree with Mark we need a way to define the unwrapping level we want.
> Add ability to access a bean instance from a proxy
> --------------------------------------------------
>
> Key: CDI-10
> URL: https://issues.jboss.org/browse/CDI-10
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occasions when it would be useful to access a bean instance directly from a proxy. This could be achieved by making all proxies assignable to an interface (say BeanProxy) that provides a getBeanInstance() method.
> Client code that needs access to the actual instance can check if the object is assignable to the BeanProxy interface and then call getBeanInstance() to get the actual instance if required.
> This is something that is probably more useful to extension writers than the end user, but there have already been a few requests on the weld forum about this so it is probably worth considering.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-10) Add ability to access a bean instance from a proxy
by Mark Struberg (JIRA)
[ https://issues.jboss.org/browse/CDI-10?page=com.atlassian.jira.plugin.sys... ]
Mark Struberg commented on CDI-10:
----------------------------------
In OWB we also store the already decorated/intercepted instance in the Contexts. That's the reason why the 'unrolling' sometimes need to look through all the proxies in the chain.
> Add ability to access a bean instance from a proxy
> --------------------------------------------------
>
> Key: CDI-10
> URL: https://issues.jboss.org/browse/CDI-10
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occasions when it would be useful to access a bean instance directly from a proxy. This could be achieved by making all proxies assignable to an interface (say BeanProxy) that provides a getBeanInstance() method.
> Client code that needs access to the actual instance can check if the object is assignable to the BeanProxy interface and then call getBeanInstance() to get the actual instance if required.
> This is something that is probably more useful to extension writers than the end user, but there have already been a few requests on the weld forum about this so it is probably worth considering.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-572) support JSR-303 bean validation in CDI beans
by Mark Struberg (JIRA)
[ https://issues.jboss.org/browse/CDI-572?page=com.atlassian.jira.plugin.sy... ]
Mark Struberg commented on CDI-572:
-----------------------------------
[~mkouba] yes, @Inject might be needed. But one could also use @PostConstruct to init this field. Or use Method injection. All that doesn't matter. Point is that _after_ all the injection was done and the instance is fully initialized it could be useful to invoke JSR-303 on it.
> Also what should happen if a validation fails?
Well that's a good question. What happens if there is some Exception in @PostConstruct? Guess the same should happen here as well. Or even throw a nice validation Exception.
I agree with [[~Sven Linstaedt] that those checks only make sense at runtime. It might as well be that it fails for one request but passes for another one... If you think about business data producers this also makes perfect sense.
> support JSR-303 bean validation in CDI beans
> --------------------------------------------
>
> Key: CDI-572
> URL: https://issues.jboss.org/browse/CDI-572
> Project: CDI Specification Issues
> Issue Type: Epic
> Reporter: Mark Struberg
>
> Consider a bean like
> {code}
> @SessionScoped
> public class CurrentUser {
> @javax.validation.constraint.NotNull
> @javax.validation.constraint.Length(10)
> private String userId;
> ...
> }
> {code}
> We could easily check this and invoke JSR-303 (if available) in the Producer<T>. Please note that for a custom Producer they have to care for it themselves.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-10) Add ability to access a bean instance from a proxy
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-10?page=com.atlassian.jira.plugin.sys... ]
Martin Kouba commented on CDI-10:
---------------------------------
[~tzwoenn] Good point as well. However, not all beans come from an AnnotatedType (e.g. producer methods, custom beans, etc.) so it's not 1:1 relation. The topic is complicated. We should be careful here.
> Add ability to access a bean instance from a proxy
> --------------------------------------------------
>
> Key: CDI-10
> URL: https://issues.jboss.org/browse/CDI-10
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occasions when it would be useful to access a bean instance directly from a proxy. This could be achieved by making all proxies assignable to an interface (say BeanProxy) that provides a getBeanInstance() method.
> Client code that needs access to the actual instance can check if the object is assignable to the BeanProxy interface and then call getBeanInstance() to get the actual instance if required.
> This is something that is probably more useful to extension writers than the end user, but there have already been a few requests on the weld forum about this so it is probably worth considering.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-10) Add ability to access a bean instance from a proxy
by Sven Linstaedt (JIRA)
[ https://issues.jboss.org/browse/CDI-10?page=com.atlassian.jira.plugin.sys... ]
Sven Linstaedt commented on CDI-10:
-----------------------------------
For the purpose of reading class metadata (fields, methods, annotations, ...) of bean instances one can also make their Beans (and maybe also AnnotatedType, so other frameworks benefit from metadata being overridable) able to lookup. E.g. via BeanManager like BeanManager#lookupBeanOf(T proxy), so their is no need to unproxy bean references just for being able to access their java type.
> Add ability to access a bean instance from a proxy
> --------------------------------------------------
>
> Key: CDI-10
> URL: https://issues.jboss.org/browse/CDI-10
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occasions when it would be useful to access a bean instance directly from a proxy. This could be achieved by making all proxies assignable to an interface (say BeanProxy) that provides a getBeanInstance() method.
> Client code that needs access to the actual instance can check if the object is assignable to the BeanProxy interface and then call getBeanInstance() to get the actual instance if required.
> This is something that is probably more useful to extension writers than the end user, but there have already been a few requests on the weld forum about this so it is probably worth considering.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-572) support JSR-303 bean validation in CDI beans
by Sven Linstaedt (JIRA)
[ https://issues.jboss.org/browse/CDI-572?page=com.atlassian.jira.plugin.sy... ]
Sven Linstaedt commented on CDI-572:
------------------------------------
Something like {{javax.enterprise.inject.InvalidResolutionException}} ?
Seriously one can also argue for validation annotations being qualifiers, so ambigous beans for injection point may exists as along as exactly one of them passes validation. Which ultimately renders injection point validation being a runtime validation, not performable a bootstrap time.
> support JSR-303 bean validation in CDI beans
> --------------------------------------------
>
> Key: CDI-572
> URL: https://issues.jboss.org/browse/CDI-572
> Project: CDI Specification Issues
> Issue Type: Epic
> Reporter: Mark Struberg
>
> Consider a bean like
> {code}
> @SessionScoped
> public class CurrentUser {
> @javax.validation.constraint.NotNull
> @javax.validation.constraint.Length(10)
> private String userId;
> ...
> }
> {code}
> We could easily check this and invoke JSR-303 (if available) in the Producer<T>. Please note that for a custom Producer they have to care for it themselves.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-572) support JSR-303 bean validation in CDI beans
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-572?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-572:
----------------------------------
Also what should happen if a validation fails?
> support JSR-303 bean validation in CDI beans
> --------------------------------------------
>
> Key: CDI-572
> URL: https://issues.jboss.org/browse/CDI-572
> Project: CDI Specification Issues
> Issue Type: Epic
> Reporter: Mark Struberg
>
> Consider a bean like
> {code}
> @SessionScoped
> public class CurrentUser {
> @javax.validation.constraint.NotNull
> @javax.validation.constraint.Length(10)
> private String userId;
> ...
> }
> {code}
> We could easily check this and invoke JSR-303 (if available) in the Producer<T>. Please note that for a custom Producer they have to care for it themselves.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-572) support JSR-303 bean validation in CDI beans
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-572?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-572:
----------------------------------
[~struberg] Isn't there {{@Inject}} missing in the example?
> support JSR-303 bean validation in CDI beans
> --------------------------------------------
>
> Key: CDI-572
> URL: https://issues.jboss.org/browse/CDI-572
> Project: CDI Specification Issues
> Issue Type: Epic
> Reporter: Mark Struberg
>
> Consider a bean like
> {code}
> @SessionScoped
> public class CurrentUser {
> @javax.validation.constraint.NotNull
> @javax.validation.constraint.Length(10)
> private String userId;
> ...
> }
> {code}
> We could easily check this and invoke JSR-303 (if available) in the Producer<T>. Please note that for a custom Producer they have to care for it themselves.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month
[JBoss JIRA] (CDI-572) support JSR-303 bean validation in CDI beans
by Mark Struberg (JIRA)
Mark Struberg created CDI-572:
---------------------------------
Summary: support JSR-303 bean validation in CDI beans
Key: CDI-572
URL: https://issues.jboss.org/browse/CDI-572
Project: CDI Specification Issues
Issue Type: Epic
Reporter: Mark Struberg
Consider a bean like
{code}
@SessionScoped
public class CurrentUser {
@javax.validation.constraint.NotNull
@javax.validation.constraint.Length(10)
private String userId;
...
}
{code}
We could easily check this and invoke JSR-303 (if available) in the Producer<T>. Please note that for a custom Producer they have to care for it themselves.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
9 years, 1 month