-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "addBeanDefiningAnnotation" method #827
Comments
I honestly don't think this is necessary, it would be just an alias for default ClassConfig addBeanDefiningAnnotation(Class<? extends Annotation> annotation) {
// stereotypes are bean defining annotations
return addStereotype(annotation);
} I'm also fairly sure no such API exists in Portable Extensions (looking at |
That's a fair point, I agree it doesn't seem very helpful.
Note that Weld has this for SE environment only. What I mean is that there is a subtle distinction between:
Namely in WFLY, there were/are use cases where not all deployments are CDI-enabled allowing WFLY to skip Weld bootstrap altogether. But for that, you need to be able to scan (search Jandex index) the deployment for known CDI bean defining annotations before you ask Weld to process CDI extensions. A few links relevant links that I was able to dig up:
|
Why not? At the least it should maybe be added or explained, and officially supported that |
Personally, I don't see general lack of knowledge as a justification to duplicate methods in API. If users (perhaps rather extension/framework authors) do not know That being said, I agree documenting it is a good idea 👍 |
I don't know. If a method is called As a developer you look for X, but then you need to invoke a method Y. I mean, conceptually creating a stereotype is something different from adding a bean defining annotation is it not? Otherwise, why did you choose the name |
Btw, the stereo type description also doesn't say that stereo types are specifically or primarily for making random annotations bean defining: " A stereotype encapsulates any combination of: a default scope, and a set of interceptor bindings. A stereotype may also specify that: all beans with the stereotype have defaulted bean names, or that all beans with the stereotype are alternatives. A bean may declare zero, one or multiple stereotypes. Stereotype annotations may be applied to a bean class or producer method or field. |
Yeah, I agree that we should state that a stereotype is a bean defining annotation in that description. It's sort of implied by the fact you can set a default scope, but it would be helpful to spell it out. However, I don't think that using a stereotype to add a bean defining annotation is a hack, based on that description:
What reason does a framework have for adding a bean defining annotation if not to add a scope or to identify a special role for certain beans? (There may be some, but those seem like the two obvious reasons.) What wasn't really obvious to me when I first read this description was:
|
A library (possibly another spec in Jakarta EE) can currently add custom bean defining annotations using
MetaAnnotations.addStereotype
. This is however quite ugly and just uses the side-effect that stereo types are bean defining.Implementations like Weld have an explicit method for this. See
https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_extending_bean_defining_annotations
I would like to propose adding a method so libraries can add their own custom bean defining annotations, e.g. using
MetaAnnotations.addBeanDefiningAnnotation
.The text was updated successfully, but these errors were encountered: