[JBoss JIRA] (CDI-6) Clarify InjectionTarget method parameters
by Pete Muir (JIRA)
[ https://issues.jboss.org/browse/CDI-6?page=com.atlassian.jira.plugin.syst... ]
Pete Muir updated CDI-6:
------------------------
Fix Version/s: 1.1 (Proposed)
(was: 1.1.PRD)
> Clarify InjectionTarget method parameters
> -----------------------------------------
>
> Key: CDI-6
> URL: https://issues.jboss.org/browse/CDI-6
> Project: CDI Specification Issues
> Issue Type: Clarification
> Components: Portable Extensions
> Affects Versions: 1.0
> Reporter: Jozef Hartinger
> Assignee: Pete Muir
> Priority: Minor
> Fix For: 1.1 (Proposed)
>
>
> For the inject() method, the spec says: "inject() performs dependency injection upon the given object". It is not clear to me what does the "given object" refer two. if the CDI implementation uses proxies to implement interceptors and decorators, I can see two candidates for "the given object":
> - the product of the produce() method including interceptors and decorators -> a proxy
> - the target instance -> the object created by calling a constructor (no interception/decoration)
> Arguments for the first option
> - Let's have and extension that adds additional dependency injection capabilities by providing a custom InjectionTarget implementation and wrapping default InjectionTarget instances with custom ones. The custom InjectionTarget implementation does the additional DI in the inject() method and delegates to the default InjectionTarget instance to finish the injection. This implementation needs a direct access to the target instance (it cannot access field values through a proxy)
> - Interceptor-like behavior - similarity to interceptors, where the InvocationContext.getTarget() returns the (non-intercepted) target instance
> Arguments for the second option
> - the contract of the produce() method says: "produce() calls the constructor annotated @Inject if it exists, or the constructor with no parameters otherwise, as defined in Section 5.5.1, "Injection using the bean constructor", and returns the resulting instance. If the class has inter- ceptors, produce() is responsible for building the interceptors and decorators of the instance." which means it returns an intercepted/decorated instance.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years
[JBoss JIRA] (CDI-89) Add @Unwraps from Seam Solder
by Pete Muir (JIRA)
[ https://issues.jboss.org/browse/CDI-89?page=com.atlassian.jira.plugin.sys... ]
Pete Muir updated CDI-89:
-------------------------
Assignee: Pete Muir
Fix Version/s: 1.1.PRD
(was: 1.1 (Proposed))
This is now covered by the pull request for CDI-139 https://github.com/jboss/cdi/pull/100 - please review!
> Add @Unwraps from Seam Solder
> ------------------------------
>
> Key: CDI-89
> URL: https://issues.jboss.org/browse/CDI-89
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Concepts
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Assignee: Pete Muir
> Fix For: 1.1.PRD
>
>
> @Unwraps allows for an essentially stateless scope for producer methods and fields.
> At injection time a dependent scoped proxy is injected into the injection point. When a methods is invoked on this proxy it calls the corresponding @Unwraps methods to get the instance to invoke the method on.
> Because the proxy is @Dependent scoped, the @Unwraps method can inject the corresponding InjectionPoint.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years
[JBoss JIRA] (CDI-224) Support Decoration of no interface beans
by Aslak Knutsen (JIRA)
Aslak Knutsen created CDI-224:
---------------------------------
Summary: Support Decoration of no interface beans
Key: CDI-224
URL: https://issues.jboss.org/browse/CDI-224
Project: CDI Specification Issues
Issue Type: Feature Request
Components: Decorators
Affects Versions: 1.0
Reporter: Aslak Knutsen
According to CDI 1.0 Spec:
"Decorators may be associated with any managed bean that is not itself an interceptor or decorator or with any EJB session bean."
"The set of decorated types of a decorator includes all bean types of the managed bean which are Java interfaces, except for java.io.Serializable. The decorator bean class and its superclasses are not decorated types of the decorator."
Both CDI and EJB support No interface beans, but for some reason Decorators only work on methods from a Interface. While Interceptors on the other hand work fine with Classes.
I can see no technical reason to why Decorators should only work on Interfaces since all Proxies etc should already be in place.
{code}
import javax.decorator.Decorator;
import javax.decorator.Delegate;
import javax.enterprise.inject.Any;
import javax.inject.Inject;
import junit.framework.Assert;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.BeansXml;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class DecoratesClassTestCase {
@Deployment
public static WebArchive create() {
return ShrinkWrap.create(WebArchive.class)
.addAsWebInfResource(
new BeansXml().decorators(BusinessDecorator.class), "beans.xml");
}
@Test
public void shouldBeAbleToDecorate(BusinessObject business) throws Exception {
Assert.assertEquals("Decorated Test", business.send("Test"));
}
@Decorator
public static abstract class BusinessDecorator extends BusinessObject {
@Inject @Delegate @Any
private BusinessObject delegate;
public String send(String msg) {
return "Decorated " + delegate.send(msg);
}
}
public static class BusinessObject {
public String send(String msg) {
return msg;
}
}
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years
[JBoss JIRA] (CDI-89) Add @Unwraps from Seam Solder
by Pete Muir (JIRA)
[ https://issues.jboss.org/browse/CDI-89?page=com.atlassian.jira.plugin.sys... ]
Pete Muir commented on CDI-89:
------------------------------
>From the CDI 1.1 EG meeting, 19th Sept
{quote}
Some beans want to manage their own lifecycle, and explicitly destroy an instance.
We discussed adding a destroy() method to an interface which extends Context, which custom contexts need to implement in order to support removing arbitrary instances. This forms an SPI.
We discussed that there should be an SPI for this, and proposed sharing a solution with CDI-139. We ran over all the possibilities we could come up with for identifying the bean to be destroyed, and discussed that either you get passed a dependent scoped instance or a proxy. In both cases, you can destroy the instance from just this info.
{quote}
> Add @Unwraps from Seam Solder
> ------------------------------
>
> Key: CDI-89
> URL: https://issues.jboss.org/browse/CDI-89
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Concepts
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 1.1 (Proposed)
>
>
> @Unwraps allows for an essentially stateless scope for producer methods and fields.
> At injection time a dependent scoped proxy is injected into the injection point. When a methods is invoked on this proxy it calls the corresponding @Unwraps methods to get the instance to invoke the method on.
> Because the proxy is @Dependent scoped, the @Unwraps method can inject the corresponding InjectionPoint.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years