-
Notifications
You must be signed in to change notification settings - Fork 77
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
Initial specification text for method invokers #697
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InvokerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package jakarta.enterprise.inject.build.compatible.spi; | ||
|
||
import jakarta.enterprise.invoke.InvokerBuilder; | ||
import jakarta.enterprise.lang.model.declarations.MethodInfo; | ||
|
||
/** | ||
* Factory for {@link InvokerBuilder}s. | ||
* | ||
* @since 4.1 | ||
*/ | ||
public interface InvokerFactory { | ||
/** | ||
* Returns a new {@link InvokerBuilder} for given method of given bean. The builder | ||
* eventually produces an opaque representation of the generated invoker. | ||
* <p> | ||
* If an invoker may not be built for given {@code bean} or for given {@code method}, | ||
* an exception is thrown. | ||
* | ||
* @param bean target bean of the invoker, must not be {@code null} | ||
* @param method target method of the invoker, must not be {@code null} | ||
* @return the invoker builder, never {@code null} | ||
*/ | ||
InvokerBuilder<InvokerInfo> createInvoker(BeanInfo bean, MethodInfo method); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say I am not a big fan of this.
You still need
BeanInfo
as an argument, so this just adds an extra step along the way where your@Registration
method needs an extra argument.Technically, you could also attempt to pass in some custom impl of
BeanInfo
which I don't suppose we want users to try.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that a
@Registration
method must declare exactly one parameter of typeBeanInfo
orInterceptorInfo
orObserverInfo
, I considered specifying that anInvokerFactory
parameter may be declared on a@Registration
method that declares a parameter of typeBeanInfo
and thatBeanInfo
is the target bean of the invokers created by the factory, and thenInvokerFactory.createInvoker()
would only have a single parameter of typeMethodInfo
. In the end, it felt a little too magical to me.The main reason why I don't want
BeanInfo.createInvoker()
is thatBeanInfo
(like all other*Info
types) is a "passive" object that only hands out information. It shouldn't have any "active" methods that configure behavior.An alternative would be something like
I'm a little hesitant about this, because it would also be a natural place for other bean configurations (bean attribute transformations, injection point transformations) and I have doubts we can do that in the
@Registration
phase, as currently specified.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand and I agree that
BeanInfo
is a "final bean state" where you can read its information. To me, that's precisely why I think the method should be there; after all, you are not configuring bean metadata anymore. Instead, you are retrieving a handle to a bean method in its final state.Like I said, I can accept being outvoted.
If this is the preferred version, I'll learn to live with it, hard as it may be ;-)
I fully concur, let's not do that.