forked from apache/dubbo
/
MethodConfig.java
248 lines (195 loc) · 6.83 KB
/
MethodConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
* 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 com.alibaba.dubbo.config;
import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.config.annotation.Method;
import com.alibaba.dubbo.config.support.Parameter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* MethodConfig
*
* @export
*/
public class MethodConfig extends AbstractMethodConfig {
private static final long serialVersionUID = 884908855422675941L;
// method name
private String name;
// stat
private Integer stat;
// whether to retry
private Boolean retry;
// if it's reliable
private Boolean reliable;
// thread limits for method invocations
private Integer executes;
// if it's deprecated
private Boolean deprecated;
// whether to enable sticky
private Boolean sticky;
// whether need to return
private Boolean isReturn;
// callback instance when async-call is invoked
private Object oninvoke;
// callback method when async-call is invoked
private String oninvokeMethod;
// callback instance when async-call is returned
private Object onreturn;
// callback method when async-call is returned
private String onreturnMethod;
// callback instance when async-call has exception thrown
private Object onthrow;
// callback method when async-call has exception thrown
private String onthrowMethod;
private List<ArgumentConfig> arguments;
public MethodConfig() {
}
public MethodConfig(Method method) {
appendAnnotation(Method.class, method);
this.setReturn(method.isReturn());
this.setOninvoke(method.oninvoke());
this.setOnreturn(method.onreturn());
this.setOnthrow(method.onthrow());
if (method.arguments() != null && method.arguments().length != 0) {
List<ArgumentConfig> argumentConfigs = new ArrayList<ArgumentConfig>(method.arguments().length);
this.setArguments(argumentConfigs);
for (int i = 0; i < method.arguments().length; i++) {
ArgumentConfig argumentConfig = new ArgumentConfig(method.arguments()[i]);
argumentConfigs.add(argumentConfig);
}
}
}
public static List<MethodConfig> constructMethodConfig(Method[] methods) {
if (methods != null && methods.length != 0) {
List<MethodConfig> methodConfigs = new ArrayList<MethodConfig>(methods.length);
for (int i = 0; i < methods.length; i++) {
MethodConfig methodConfig = new MethodConfig(methods[i]);
methodConfigs.add(methodConfig);
}
return methodConfigs;
}
return Collections.emptyList();
}
@Parameter(excluded = true)
public String getName() {
return name;
}
public void setName(String name) {
checkMethodName("name", name);
this.name = name;
if (id == null || id.length() == 0) {
id = name;
}
}
public Integer getStat() {
return stat;
}
@Deprecated
public void setStat(Integer stat) {
this.stat = stat;
}
@Deprecated
public Boolean isRetry() {
return retry;
}
@Deprecated
public void setRetry(Boolean retry) {
this.retry = retry;
}
@Deprecated
public Boolean isReliable() {
return reliable;
}
@Deprecated
public void setReliable(Boolean reliable) {
this.reliable = reliable;
}
public Integer getExecutes() {
return executes;
}
public void setExecutes(Integer executes) {
this.executes = executes;
}
public Boolean getDeprecated() {
return deprecated;
}
public void setDeprecated(Boolean deprecated) {
this.deprecated = deprecated;
}
public List<ArgumentConfig> getArguments() {
return arguments;
}
@SuppressWarnings("unchecked")
public void setArguments(List<? extends ArgumentConfig> arguments) {
this.arguments = (List<ArgumentConfig>) arguments;
}
public Boolean getSticky() {
return sticky;
}
public void setSticky(Boolean sticky) {
this.sticky = sticky;
}
@Parameter(key = Constants.ON_RETURN_INSTANCE_KEY, excluded = true, attribute = true)
public Object getOnreturn() {
return onreturn;
}
public void setOnreturn(Object onreturn) {
this.onreturn = onreturn;
}
@Parameter(key = Constants.ON_RETURN_METHOD_KEY, excluded = true, attribute = true)
public String getOnreturnMethod() {
return onreturnMethod;
}
public void setOnreturnMethod(String onreturnMethod) {
this.onreturnMethod = onreturnMethod;
}
@Parameter(key = Constants.ON_THROW_INSTANCE_KEY, excluded = true, attribute = true)
public Object getOnthrow() {
return onthrow;
}
public void setOnthrow(Object onthrow) {
this.onthrow = onthrow;
}
@Parameter(key = Constants.ON_THROW_METHOD_KEY, excluded = true, attribute = true)
public String getOnthrowMethod() {
return onthrowMethod;
}
public void setOnthrowMethod(String onthrowMethod) {
this.onthrowMethod = onthrowMethod;
}
@Parameter(key = Constants.ON_INVOKE_INSTANCE_KEY, excluded = true, attribute = true)
public Object getOninvoke() {
return oninvoke;
}
public void setOninvoke(Object oninvoke) {
this.oninvoke = oninvoke;
}
@Parameter(key = Constants.ON_INVOKE_METHOD_KEY, excluded = true, attribute = true)
public String getOninvokeMethod() {
return oninvokeMethod;
}
public void setOninvokeMethod(String oninvokeMethod) {
this.oninvokeMethod = oninvokeMethod;
}
public Boolean isReturn() {
return isReturn;
}
public void setReturn(Boolean isReturn) {
this.isReturn = isReturn;
}
}