Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdi-dev] Minimal CDI implementation questions

Hi,

I'm hoping I could ask a few questions about some of the CDI interfaces.

I'm adapting an injection framework I've been developing on and off for the past years to be compatible with a minimal subset of CDI: The "Instance" type and the types it refers to (Handle, Bean, InjectionPoint, BeanAttributes).  The framework is tailored to my personal needs, but is quite extensive, supporting scopes, producers, assisted injection, optional injection, providers, lists and sets. It allows for custom annotation strategies and extensions, and I'm seeing if it can support CDI style injection simply by configuring it differently. When implementing `Instance` however I noticed quite some internal structures are exposed (`Handle` exposes `Bean` which then exposes a whole host of other classes and interfaces).

I have a few questions regarding those interfaces:

1) How does an InjectionPoint handle an implicit dependency on an owner class (container class)? For example, when you have a non-static Producer method, it can only be called after its owner class is instantiated. The Producer's parameters are injection points, but my framework also lists the owner class as an injection point, representing the "this" parameter that is implicitely needed for calling a non-static Producer method. For such an injection point, my implementation returns `null` for `getMember()` to indicate the injection point represents the owner class. How is this handled in CDI?

2) The BeanAttributes class has a `getQualifiers` method.  Does this include qualifiers detected in any stereotypes it might be annotated with? What's the reasoning behind listing stereotypes separately? Similar question for `getScope` although I'm assuming there that it must be getting the scope from the stereotype (if present and not overriden).

3) Is `BeanAttributes#getScope` allowed to return `null`? In CDI Beans always have a scope, even if it is just `Dependent` AFAIK. My own implementation does not return the annotation, but instead immediately returns the appropriate `ScopeResolver` which is never `null` even for unscoped beans -- when not annotated, the annotation would be `null` though.

4) `BeanAttributes#getName` seems to allude you can return `null` here if it has no name, or is it supposed to return an empty string in that case?

Best regards,

John Hendrikx




Back to the top