本文整理了Java中feign.Feign.configKey()
方法的一些代码示例,展示了Feign.configKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feign.configKey()
方法的具体详情如下:
包路径:feign.Feign
类名称:Feign
方法名:configKey
[英]Configuration keys are formatted as unresolved see tags.
For example.
Note that there is no whitespace expected in a key!
[中]配置键的格式为未解析see tags。
例如
*Route53:将匹配诸如分母之类的类。路线53。路线53
*Route53#list():将匹配分母等方法。路线53。路线53#列表()
*Route53#listAt(标记):将匹配分母等方法。路线53。路由53#列表地址(分母、路由53、标记)
*Route53#ListByName和Type(String,String):将匹配分母等方法。路线53。路由53#列表(字符串,字符串)
请注意,键中不应包含空格!
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
MethodMetadata methodMetadata = SentinelContractHolder.metadataMap
.get(method.getDeclaringClass().getName()
+ Feign.configKey(method.getDeclaringClass(), method));
代码示例来源:origin: com.netflix.feign/feign-core
/**
* @deprecated use {@link #configKey(Class, Method)} instead.
*/
@Deprecated
public static String configKey(Method method) {
return configKey(method.getDeclaringClass(), method);
}
代码示例来源:origin: com.palantir.conjure.java.runtime/conjure-java-jaxrs-client
@Override
public final List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
List<MethodMetadata> mdList = delegate.parseAndValidatateMetadata(targetType);
Map<String, MethodMetadata> methodMetadataByConfigKey = new LinkedHashMap<String, MethodMetadata>();
for (MethodMetadata md : mdList) {
methodMetadataByConfigKey.put(md.configKey(), md);
}
for (Method method : targetType.getMethods()) {
if (method.getDeclaringClass() == Object.class) {
continue;
}
String configKey = Feign.configKey(targetType, method);
MethodMetadata metadata = methodMetadataByConfigKey.get(configKey);
if (metadata != null) {
processMetadata(targetType, method, metadata);
}
}
return mdList;
}
代码示例来源:origin: com.palantir.remoting3/jaxrs-clients
@Override
public final List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
List<MethodMetadata> mdList = delegate.parseAndValidatateMetadata(targetType);
Map<String, MethodMetadata> methodMetadataByConfigKey = new LinkedHashMap<String, MethodMetadata>();
for (MethodMetadata md : mdList) {
methodMetadataByConfigKey.put(md.configKey(), md);
}
for (Method method : targetType.getMethods()) {
if (method.getDeclaringClass() == Object.class) {
continue;
}
String configKey = Feign.configKey(targetType, method);
MethodMetadata metadata = methodMetadataByConfigKey.get(configKey);
if (metadata != null) {
processMetadata(targetType, method, metadata);
}
}
return mdList;
}
代码示例来源:origin: com.palantir.remoting/feign-config
@Override
public final List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
List<MethodMetadata> mdList = delegate.parseAndValidatateMetadata(targetType);
Map<String, MethodMetadata> methodMetadataByConfigKey = new LinkedHashMap<String, MethodMetadata>();
for (MethodMetadata md : mdList) {
methodMetadataByConfigKey.put(md.configKey(), md);
}
for (Method method : targetType.getMethods()) {
if (method.getDeclaringClass() == Object.class) {
continue;
}
String configKey = Feign.configKey(targetType, method);
MethodMetadata metadata = methodMetadataByConfigKey.get(configKey);
if (metadata != null) {
processMetadata(targetType, method, metadata);
}
}
return mdList;
}
代码示例来源:origin: palantir/conjure-java-runtime
@Override
public final List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
List<MethodMetadata> mdList = delegate.parseAndValidatateMetadata(targetType);
Map<String, MethodMetadata> methodMetadataByConfigKey = new LinkedHashMap<String, MethodMetadata>();
for (MethodMetadata md : mdList) {
methodMetadataByConfigKey.put(md.configKey(), md);
}
for (Method method : targetType.getMethods()) {
if (method.getDeclaringClass() == Object.class) {
continue;
}
String configKey = Feign.configKey(targetType, method);
MethodMetadata metadata = methodMetadataByConfigKey.get(configKey);
if (metadata != null) {
processMetadata(targetType, method, metadata);
}
}
return mdList;
}
代码示例来源:origin: kptfh/feign-reactive
Map<String, MethodHandler> apply(final Target target) {
Map<String, MethodMetadata> metadata = contract.parseAndValidatateMetadata(target.type())
.stream()
.collect(Collectors.toMap(
MethodMetadata::configKey,
md -> md
));
Map<String, Method> configKeyToMethod = Stream.of(target.type().getMethods())
.collect(Collectors.toMap(
method -> Feign.configKey(target.type(), method),
method -> method
));
final Map<String, MethodHandler> result = new LinkedHashMap<>();
for (final Map.Entry<String, Method> entry : configKeyToMethod.entrySet()) {
String configKey = entry.getKey();
MethodMetadata md = metadata.get(configKey);
MethodHandler methodHandler = md != null
? factory.create(target, md)
: factory.createDefault(entry.getValue()); //isDefault(entry.getValue())
result.put(configKey, methodHandler);
}
return result;
}
}
代码示例来源:origin: io.github.reactivefeign/feign-reactive-cloud
private HystrixMethodHandler(
Target target, MethodMetadata methodMetadata,
ReactiveMethodHandler methodHandler,
CloudReactiveFeign.SetterFactory setterFactory,
@Nullable
Function<Throwable, Object> fallbackFactory) {
checkNotNull(target, "target must be not null");
checkNotNull(methodMetadata, "methodMetadata must be not null");
method = Arrays.stream(target.type().getMethods())
.filter(method -> configKey(target.type(), method).equals(methodMetadata.configKey()))
.findFirst().orElseThrow(() -> new IllegalArgumentException());
method.setAccessible(true);
returnPublisherType = ((ParameterizedType) methodMetadata.returnType()).getRawType();
this.methodHandler = checkNotNull(methodHandler, "methodHandler must be not null");
this.fallbackFactory = fallbackFactory;
checkNotNull(setterFactory, "setterFactory must be not null");
hystrixObservableCommandSetter = setterFactory.create(target, methodMetadata);
}
代码示例来源:origin: kptfh/feign-reactive
HystrixMethodHandler(
Target target, MethodMetadata methodMetadata,
MethodHandler methodHandler,
CloudReactiveFeign.SetterFactory setterFactory,
@Nullable
Function<Throwable, Object> fallbackFactory) {
checkNotNull(target, "target must be not null");
checkNotNull(methodMetadata, "methodMetadata must be not null");
method = Arrays.stream(target.type().getMethods())
.filter(method -> configKey(target.type(), method).equals(methodMetadata.configKey()))
.findFirst().orElseThrow(() -> new IllegalArgumentException());
method.setAccessible(true);
returnPublisherType = ((ParameterizedType) methodMetadata.returnType()).getRawType();
this.methodHandler = checkNotNull(methodHandler, "methodHandler must be not null");
this.fallbackFactory = fallbackFactory;
checkNotNull(setterFactory, "setterFactory must be not null");
hystrixObservableCommandSetter = setterFactory.create(target, methodMetadata);
}
代码示例来源:origin: kptfh/feign-reactive
@SuppressWarnings("unchecked")
public <T> T newInstance(Target<T> target) {
final Map<String, MethodHandler> nameToHandler = targetToHandlersByName.apply(target);
final Map<Method, InvocationHandlerFactory.MethodHandler> methodToHandler = new LinkedHashMap<>();
final List<DefaultMethodHandler> defaultMethodHandlers = new LinkedList<>();
for (final Method method : target.type().getMethods()) {
if (isDefault(method)) {
final DefaultMethodHandler handler = new DefaultMethodHandler(method);
defaultMethodHandlers.add(handler);
methodToHandler.put(method, handler);
} else {
methodToHandler.put(method,
nameToHandler.get(Feign.configKey(target.type(), method)));
}
}
final InvocationHandler handler = factory.create(target, methodToHandler);
T proxy = (T) Proxy.newProxyInstance(target.type().getClassLoader(),
new Class<?>[] {target.type()}, handler);
for (final DefaultMethodHandler defaultMethodHandler : defaultMethodHandlers) {
defaultMethodHandler.bindTo(proxy);
}
return proxy;
}
代码示例来源:origin: io.github.reactivefeign/feign-reactive-core
@SuppressWarnings("unchecked")
public <T> T newInstance(Target<T> target) {
final Map<String, MethodHandler> nameToHandler = targetToHandlersByName
.apply(target);
final Map<Method, MethodHandler> methodToHandler = new LinkedHashMap<>();
final List<DefaultMethodHandler> defaultMethodHandlers = new LinkedList<>();
for (final Method method : target.type().getMethods()) {
if (isDefault(method)) {
final DefaultMethodHandler handler = new DefaultMethodHandler(method);
defaultMethodHandlers.add(handler);
methodToHandler.put(method, handler);
}
else {
methodToHandler.put(method,
nameToHandler.get(Feign.configKey(target.type(), method)));
}
}
final InvocationHandler handler = factory.create(target, methodToHandler);
T proxy = (T) Proxy.newProxyInstance(target.type().getClassLoader(),
new Class<?>[] { target.type() }, handler);
for (final DefaultMethodHandler defaultMethodHandler : defaultMethodHandlers) {
defaultMethodHandler.bindTo(proxy);
}
return proxy;
}
代码示例来源:origin: com.netflix.feign/feign-core
/**
* creates an api binding to the {@code target}. As this invokes reflection, care should be taken
* to cache the result.
*/
@SuppressWarnings("unchecked")
@Override
public <T> T newInstance(Target<T> target) {
Map<String, MethodHandler> nameToHandler = targetToHandlersByName.apply(target);
Map<Method, MethodHandler> methodToHandler = new LinkedHashMap<Method, MethodHandler>();
List<DefaultMethodHandler> defaultMethodHandlers = new LinkedList<DefaultMethodHandler>();
for (Method method : target.type().getMethods()) {
if (method.getDeclaringClass() == Object.class) {
continue;
} else if(Util.isDefault(method)) {
DefaultMethodHandler handler = new DefaultMethodHandler(method);
defaultMethodHandlers.add(handler);
methodToHandler.put(method, handler);
} else {
methodToHandler.put(method, nameToHandler.get(Feign.configKey(target.type(), method)));
}
}
InvocationHandler handler = factory.create(target, methodToHandler);
T proxy = (T) Proxy.newProxyInstance(target.type().getClassLoader(), new Class<?>[]{target.type()}, handler);
for(DefaultMethodHandler defaultMethodHandler : defaultMethodHandlers) {
defaultMethodHandler.bindTo(proxy);
}
return proxy;
}
代码示例来源:origin: OpenFeign/feign-vertx
@Override
@SuppressWarnings("unchecked")
public <T> T newInstance(final Target<T> target) {
checkNotNull(target, "Argument target must be not null");
final Map<String, MethodHandler> nameToHandler = targetToHandlersByName.apply(target);
final Map<Method, MethodHandler> methodToHandler = new HashMap<>();
final List<DefaultMethodHandler> defaultMethodHandlers = new ArrayList<>();
for (final Method method : target.type().getMethods()) {
if (isDefault(method)) {
final DefaultMethodHandler handler = new DefaultMethodHandler(method);
defaultMethodHandlers.add(handler);
methodToHandler.put(method, handler);
} else {
methodToHandler.put(method, nameToHandler.get(Feign.configKey(target.type(), method)));
}
}
final InvocationHandler handler = factory.create(target, methodToHandler);
final T proxy = (T) Proxy.newProxyInstance(
target.type().getClassLoader(),
new Class<?>[] { target.type() },
handler);
for (final DefaultMethodHandler defaultMethodHandler : defaultMethodHandlers) {
defaultMethodHandler.bindTo(proxy);
}
return proxy;
}
代码示例来源:origin: spring-cloud/spring-cloud-openfeign
@Override
public MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
this.processedMethods.put(Feign.configKey(targetType, method), method);
MethodMetadata md = super.parseAndValidateMetadata(targetType, method);
RequestMapping classAnnotation = findMergedAnnotation(targetType,
RequestMapping.class);
if (classAnnotation != null) {
// produces - use from class annotation only if method has not specified this
if (!md.template().headers().containsKey(ACCEPT)) {
parseProduces(md, method, classAnnotation);
}
// consumes -- use from class annotation only if method has not specified this
if (!md.template().headers().containsKey(CONTENT_TYPE)) {
parseConsumes(md, method, classAnnotation);
}
// headers -- class annotation is inherited to methods, always write these if
// present
parseHeaders(md, method, classAnnotation);
}
return md;
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core
@Override
public MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
this.processedMethods.put(Feign.configKey(targetType, method), method);
MethodMetadata md = super.parseAndValidateMetadata(targetType, method);
RequestMapping classAnnotation = findMergedAnnotation(targetType,
RequestMapping.class);
if (classAnnotation != null) {
// produces - use from class annotation only if method has not specified this
if (!md.template().headers().containsKey(ACCEPT)) {
parseProduces(md, method, classAnnotation);
}
// consumes -- use from class annotation only if method has not specified this
if (!md.template().headers().containsKey(CONTENT_TYPE)) {
parseConsumes(md, method, classAnnotation);
}
// headers -- class annotation is inherited to methods, always write these if
// present
parseHeaders(md, method, classAnnotation);
}
return md;
}
代码示例来源:origin: ppdai-incubator/raptor
@Override
public MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
this.processedMethods.put(Feign.configKey(targetType, method), method);
MethodMetadata md = super.parseAndValidateMetadata(targetType, method);
RequestMapping classAnnotation = findMergedAnnotation(targetType,
RequestMapping.class);
if (classAnnotation != null) {
// produces - use from class annotation only if method has not specified this
if (!md.template().headers().containsKey(ACCEPT)) {
parseProduces(md, method, classAnnotation);
}
// consumes -- use from class annotation only if method has not specified this
if (!md.template().headers().containsKey(CONTENT_TYPE)) {
parseConsumes(md, method, classAnnotation);
}
// headers -- class annotation is inherited to methods, always write these if
// present
parseHeaders(md, method, classAnnotation);
}
return md;
}
代码示例来源:origin: io.github.openfeign/feign-hystrix
@Override
public HystrixCommand.Setter create(Target<?> target, Method method) {
String groupKey = target.name();
String commandKey = Feign.configKey(target.type(), method);
return HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
}
}
代码示例来源:origin: com.netflix.feign/feign-core
MethodMetadata data = new MethodMetadata();
data.returnType(Types.resolve(targetType, targetType, method.getGenericReturnType()));
data.configKey(Feign.configKey(targetType, method));
代码示例来源:origin: wu191287278/spring-boot-starter-dubbo
@Override
public HystrixCommand.Setter create(Target<?> target, Method method) {
String groupKey = target.name();
String commandKey = Feign.configKey(target.type(), method);
return HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(timeout)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(connections))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
}
};
代码示例来源:origin: SpringCloud/venus-cloud-feign
MethodMetadata data = new MethodMetadata();
data.returnType(Types.resolve(targetType, targetType, method.getGenericReturnType()));
data.configKey(Feign.configKey(targetType, method));
内容来源于网络,如有侵权,请联系作者删除!