-
Notifications
You must be signed in to change notification settings - Fork 925
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
Implement @Attribute Injection. #5547
Merged
+394
−36
Merged
Changes from 31 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
eac6431
skeleton code for @Attribute injection.
chickenchickenlove 2801cdd
Implement Attribute Injection : Apply review
chickenchickenlove 889d887
make test code for Attribute injection.
chickenchickenlove 94a93af
remove duplicate code from AnnotatedValueResolverTest
chickenchickenlove 42ef9a2
Implement Attribute Injection : Apply review2
chickenchickenlove ab8a08a
Implement Attribute Injection : Apply review3
chickenchickenlove 3fac84e
Implement Attribute Injection : Apply review3. remove useless comments.
chickenchickenlove f3f8b74
Fix lint, Apply review
chickenchickenlove 821e18f
Add user docs
chickenchickenlove dce9520
Update core/src/main/java/com/linecorp/armeria/server/annotation/Attr…
chickenchickenlove fc5771a
Update core/src/main/java/com/linecorp/armeria/server/annotation/Attr…
chickenchickenlove f017563
Update core/src/main/java/com/linecorp/armeria/server/annotation/Attr…
chickenchickenlove 1927e46
Update core/src/main/java/com/linecorp/armeria/server/annotation/Attr…
chickenchickenlove ee7a466
Use @default.class and fix link of java docs.
chickenchickenlove 65868b7
Merge branch 'main' into 240329-try1
chickenchickenlove 1d0b6c7
fix lint error
chickenchickenlove 1877117
Update site/src/pages/docs/server-annotated-service.mdx
chickenchickenlove bdb0088
Update site/src/pages/docs/server-annotated-service.mdx
chickenchickenlove 29543f9
Apply comment to server-annotated-service docs.
chickenchickenlove 957378f
Update core/src/main/java/com/linecorp/armeria/server/annotation/Attr…
chickenchickenlove 2893d3d
modify misstypo
chickenchickenlove c70c2fb
remove findName().
chickenchickenlove c1de466
Throw ClassCastException on AttributeResolver.
chickenchickenlove e6632fa
modify miss typoe
chickenchickenlove 065e43a
Apply code review
chickenchickenlove e80075f
apply code review
chickenchickenlove 5874745
apply review
chickenchickenlove c6519ab
apply review
chickenchickenlove bb087a7
apply review
chickenchickenlove 4560943
apply review
chickenchickenlove 0dd3e77
Update core/src/main/java/com/linecorp/armeria/server/annotation/Attr…
chickenchickenlove 65bc886
throw immedetely if valued is failed to be cast.
chickenchickenlove c27629b
Update core/src/main/java/com/linecorp/armeria/internal/server/annota…
chickenchickenlove 3943f70
Update core/src/main/java/com/linecorp/armeria/internal/server/annota…
chickenchickenlove 3df348b
Update core/src/test/java/com/linecorp/armeria/internal/server/annota…
chickenchickenlove 7230534
apply review
chickenchickenlove 72d26b2
fix lint error.
chickenchickenlove 8f3631c
Update core/src/main/java/com/linecorp/armeria/server/annotation/Attr…
chickenchickenlove 9013388
apply review
chickenchickenlove 588c8bb
Merge branch 'main' into 240329-try1
chickenchickenlove 70d76cb
fix lint error
chickenchickenlove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
49 changes: 49 additions & 0 deletions
49
core/src/main/java/com/linecorp/armeria/server/annotation/Attribute.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,49 @@ | ||
/* | ||
* Copyright 2016 LINE Corporation | ||
* | ||
* LINE Corporation licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.linecorp.armeria.server.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import com.linecorp.armeria.common.RequestContext; | ||
|
||
import io.netty.util.AttributeKey; | ||
|
||
/** | ||
* Annotation for mapping an attribute of the given {@link AttributeKey}, retrieved | ||
* from a {@link RequestContext}, onto the following elements. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.PARAMETER) | ||
public @interface Attribute { | ||
chickenchickenlove marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* The name of the {@link AttributeKey} to bind to. | ||
chickenchickenlove marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* You might also want to specify the {@link #prefix()}. | ||
*/ | ||
String value(); | ||
chickenchickenlove marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* The class of the {@link AttributeKey} to bind to. If you created an {@link AttributeKey} with | ||
* {@code AttributeKey.valueOf(MyAttributeKeys.class, "INT_ATTR")}, | ||
* the {@link #prefix()} should be {@code MyAttributeKeys.class}. | ||
* See <a href="https://armeria.dev/docs/advanced-custom-attributes/">advanced-customer-attributes</a>. | ||
*/ | ||
Class<?> prefix() default Attribute.class; | ||
trustin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Oops, something went wrong.
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.
Micro optimization) Should we do this when
rawType
is created to avoid additional costs?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.
You are right 👍
Using
rawType
might result in some additional costs due to Wrapping in all AnnotatedValueResolvers that do not use rawType. However, unnecessary calls will be made at most once duringinitialization
, and afterwards, it could save on the cost of Wrapping with each incoming user request.