-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Fluent style builder API support(#3431) #3549
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
95 changes: 95 additions & 0 deletions
95
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/annotation/Method.java
This file contains hidden or 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,95 @@ | ||
| package org.apache.dubbo.config.annotation; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Inherited; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.apache.dubbo.common.Constants; | ||
|
|
||
| @Documented | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD}) | ||
| @Inherited | ||
| public @interface Method { | ||
|
|
||
| /** | ||
| * Timeout value for service invocation, default value is 0 | ||
| */ | ||
| int timeout() default 0; | ||
|
|
||
| /** | ||
| * Service invocation retry times | ||
| * | ||
| * @see Constants#DEFAULT_RETRIES | ||
| */ | ||
| int retries() default Constants.DEFAULT_RETRIES; | ||
|
|
||
| /** | ||
| * Load balance strategy, legal values include: random, roundrobin, leastactive | ||
| * | ||
| * @see Constants#DEFAULT_LOADBALANCE | ||
| */ | ||
| String loadbalance() default Constants.DEFAULT_LOADBALANCE; | ||
|
|
||
| /** | ||
| * Whether to enable async invocation, default value is false | ||
| */ | ||
| boolean async() default false; | ||
|
|
||
| /** | ||
| * Maximum active requests allowed, default value is 0 | ||
| */ | ||
| int actives() default 0; | ||
|
|
||
| /** | ||
| * Whether the async request has already been sent, the default value is false | ||
| */ | ||
| boolean sent() default false; | ||
|
|
||
| /** | ||
| * Maximum concurrent executes for the service, default value is 0 - no limits | ||
| */ | ||
| int executes() default 0; | ||
|
|
||
| /** | ||
| * Whether the service is deprecated, default value is false | ||
| */ | ||
| boolean deprecated() default false; | ||
|
|
||
| /** | ||
| * Enable/Disable cluster sticky policy, default value is false. | ||
| */ | ||
| boolean sticky() default false; | ||
|
|
||
| /** | ||
| * Method result need return, when async is true.default value is true. | ||
| */ | ||
| boolean needReturn() default true; | ||
|
|
||
| /** | ||
| * Specify cache implementation for service invocation, legal values include: lru, threadlocal, jcache | ||
| */ | ||
| String cache() default ""; | ||
|
|
||
| /** | ||
| * Whether to use JSR303 validation, legal values are: true, false | ||
| */ | ||
| boolean validation() default false; | ||
|
|
||
| /** | ||
| * Method return trigger. return attribute must be true | ||
| */ | ||
| String onReturn() default ""; | ||
|
|
||
| /** | ||
| * Method invoke trigger. | ||
| */ | ||
| String onInvoke() default ""; | ||
|
|
||
| /** | ||
| * Method on error trigger.return attribute must be true. | ||
| */ | ||
| String onThrow() default ""; | ||
| } | ||
69 changes: 69 additions & 0 deletions
69
...nfig/dubbo-config-api/src/main/java/org/apache/dubbo/config/builders/AbstractBuilder.java
This file contains hidden or 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,69 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF 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 | ||
| * | ||
| * http://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 org.apache.dubbo.config.builders; | ||
|
|
||
| import org.apache.dubbo.common.utils.StringUtils; | ||
| import org.apache.dubbo.config.AbstractConfig; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * AbstractBuilder | ||
| * | ||
| * @since 2.7 | ||
| */ | ||
| public abstract class AbstractBuilder<T extends AbstractConfig, B extends AbstractBuilder> { | ||
| /** | ||
| * The config id | ||
| */ | ||
| protected String id; | ||
| protected String prefix; | ||
|
|
||
| protected B id(String id) { | ||
| this.id = id; | ||
| return getThis(); | ||
| } | ||
|
|
||
| protected B prefix(String prefix) { | ||
| this.prefix = prefix; | ||
| return getThis(); | ||
| } | ||
|
|
||
| protected abstract B getThis(); | ||
|
|
||
| protected static Map<String, String> appendParameter(Map<String, String> parameters, String key, String value) { | ||
| if (parameters == null) { | ||
| parameters = new HashMap<>(); | ||
| } | ||
| parameters.put(key, value); | ||
| return parameters; | ||
| } | ||
|
|
||
| protected static Map<String, String> appendParameters(Map<String, String> parameters, Map<String, String> appendParameters) { | ||
| if (parameters == null) { | ||
| parameters = new HashMap<>(); | ||
| } | ||
| parameters.putAll(appendParameters); | ||
| return parameters; | ||
| } | ||
|
|
||
| protected void build(T instance) { | ||
| if (!StringUtils.isEmpty(id)) instance.setId(id); | ||
| if (!StringUtils.isEmpty(prefix)) instance.setPrefix(prefix); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.