name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
dubbo_CacheFilter_invoke_rdh
/** * If cache is configured, dubbo will invoke method on each method call. If cache value is returned by cache store * then it will return otherwise call the remote method and return value. If remote method's return value has error * then it will not cache the value. * * @param invoker * service * @param invocation * invocation. * @return Cache returned value if found by the underlying cache store. If cache miss it will call target method. * @throws RpcException */ @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if ((cacheFactory == null) || ConfigUtils.isEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), CACHE_KEY))) { return invoker.invoke(invocation); } Cache cache = cacheFactory.getCache(invoker.getUrl(), invocation); if (cache == null) { return invoker.invoke(invocation); } String key = StringUtils.toArgumentString(invocation.getArguments()); Object value = cache.get(key); return value != null ? onCacheValuePresent(invocation, value) : onCacheValueNotPresent(invoker, invocation, cache, key); }
3.26
dubbo_AbstractConnectionClient_release_rdh
/** * Decreases the reference count by 1 and calls {@link this#destroy} if the reference count reaches 0. */ public final boolean release() { long remainingCount = COUNTER_UPDATER.decrementAndGet(this); if (remainingCount == 0) { m1(); return true; } else if (remainingCount <= (-1)) { logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", "This instance has been destroyed");return false; } else { return false; } }
3.26
dubbo_AbstractConnectionClient_getCounter_rdh
/** * Get counter */ public long getCounter() { return COUNTER_UPDATER.get(this); }
3.26
dubbo_PackableMethod_parseRequest_rdh
/** * A packable method is used to customize serialization for methods. It can provide a common wrapper * for RESP / Protobuf. */
3.26
dubbo_ConfigValidationUtils_checkMock_rdh
/** * Legitimacy check and setup of local simulated operations. The operations can be a string with Simple operation or * a classname whose {@link Class} implements a particular function * * @param interfaceClass * for provider side, it is the {@link Class} of the service that will be exported; for consumer * side, it is the {@link Class} of the remote service interface that will be referenced */ public static void checkMock(Class<?> interfaceClass, AbstractInterfaceConfig config) { String mock = config.getMock(); if (ConfigUtils.isEmpty(mock)) { return; } String normalizedMock = MockInvoker.normalizeMock(mock); if (normalizedMock.startsWith(RETURN_PREFIX)) { normalizedMock = normalizedMock.substring(RETURN_PREFIX.length()).trim();try { // Check whether the mock value is legal, if it is illegal, throw exception MockInvoker.parseMockValue(normalizedMock);} catch (Exception e) { throw new IllegalStateException((("Illegal mock return in <dubbo:service/reference ... " + "mock=\"") + mock) + "\" />"); } } else if (normalizedMock.startsWith(THROW_PREFIX)) { normalizedMock = normalizedMock.substring(THROW_PREFIX.length()).trim(); if (ConfigUtils.isNotEmpty(normalizedMock)) { try { // Check whether the mock value is legal MockInvoker.getThrowable(normalizedMock); } catch (Exception e) { throw new IllegalStateException((("Illegal mock throw in <dubbo:service/reference ... " + "mock=\"") + mock) + "\" />"); } } } else { // Check whether the mock class is a implementation of the interfaceClass, and if it has a default // constructor MockInvoker.getMockObject(config.getScopeModel().getExtensionDirector(), normalizedMock, interfaceClass); } }
3.26
dubbo_ConfigValidationUtils_checkMultiExtension_rdh
/** * Check whether there is a <code>Extension</code> who's name (property) is <code>value</code> (special treatment is * required) * * @param type * The Extension type * @param property * The extension key * @param value * The Extension name */ public static void checkMultiExtension(ScopeModel scopeModel, Class<?> type, String property, String value) { checkMultiExtension(scopeModel, Collections.singletonList(type), property, value); }
3.26
dubbo_ServiceInstanceMetadataUtils_getEndpoint_rdh
/** * Get the property value of port by the specified {@link ServiceInstance#getMetadata() the metadata of * service instance} and protocol * * @param serviceInstance * {@link ServiceInstance service instance} * @param protocol * the name of protocol, e.g, dubbo, rest, and so on * @return if not found, return <code>null</code> */ public static Endpoint getEndpoint(ServiceInstance serviceInstance, String protocol) { List<Endpoint> v8 = ((DefaultServiceInstance) (serviceInstance)).getEndpoints(); if (v8 != null) { for (Endpoint endpoint : v8) { if (endpoint.getProtocol().equals(protocol)) { return endpoint; } } } return null; }
3.26
dubbo_ServiceInstanceMetadataUtils_getMetadataStorageType_rdh
/** * Get the metadata storage type specified by the peer instance. * * @return storage type, remote or local */ public static String getMetadataStorageType(ServiceInstance serviceInstance) { Map<String, String> metadata = serviceInstance.getMetadata(); return metadata.getOrDefault(METADATA_STORAGE_TYPE_PROPERTY_NAME, DEFAULT_METADATA_STORAGE_TYPE); }
3.26
dubbo_ServiceInstanceMetadataUtils_setDefaultParams_rdh
/** * Set the default parameters via the specified {@link URL providerURL} * * @param params * the parameters * @param providerURL * the provider's {@link URL} */ private static void setDefaultParams(Map<String, String> params, URL providerURL) { for (String parameterName : DEFAULT_REGISTER_PROVIDER_KEYS) { String parameterValue = providerURL.getParameter(parameterName); if (!isBlank(parameterValue)) { params.put(parameterName, parameterValue); } } }
3.26
dubbo_ServiceInstanceMetadataUtils_setMetadataStorageType_rdh
/** * Set the metadata storage type in specified {@link ServiceInstance service instance} * * @param serviceInstance * {@link ServiceInstance service instance} * @param metadataType * remote or local */ public static void setMetadataStorageType(ServiceInstance serviceInstance, String metadataType) { Map<String, String> metadata = serviceInstance.getMetadata(); metadata.put(METADATA_STORAGE_TYPE_PROPERTY_NAME, metadataType); }
3.26
dubbo_ServiceInstanceMetadataUtils_getExportedServicesRevision_rdh
/** * The revision for all exported Dubbo services from the specified {@link ServiceInstance}. * * @param serviceInstance * the specified {@link ServiceInstance} * @return <code>null</code> if not exits */ public static String getExportedServicesRevision(ServiceInstance serviceInstance) { return Optional.ofNullable(serviceInstance.getServiceMetadata()).map(MetadataInfo::getRevision).filter(StringUtils::isNotEmpty).orElse(serviceInstance.getMetadata(EXPORTED_SERVICES_REVISION_PROPERTY_NAME));}
3.26
dubbo_ConfigurationCache_computeIfAbsent_rdh
/** * Get Cached Value * * @param key * key * @param function * function to produce value, should not return `null` * @return value */ public String computeIfAbsent(String key, Function<String, String> function) { String value = cache.get(key); // value might be empty here! // empty value from config center will be cached here if (value == null) { // lock free, tolerate repeat apply, will return previous value cache.putIfAbsent(key, function.apply(key)); value = cache.get(key); } return value; }
3.26
dubbo_ParamType_addSupportTypes_rdh
/** * exclude null types * * @param classes * @return */ private static List<Class> addSupportTypes(Class... classes) { ArrayList<Class> types = new ArrayList<>(); for (Class clazz : classes) { if (clazz == null) { continue; } types.add(clazz); } return types; }
3.26
dubbo_BasicJsonWriter_print_rdh
/** * Write the specified text. * * @param string * the content to write */ public IndentingWriter print(String string) { write(string.toCharArray(), 0, string.length()); return this; }
3.26
dubbo_BasicJsonWriter_println_rdh
/** * Write a new line. */ public IndentingWriter println() { String separator = System.lineSeparator(); try {this.out.write(separator.toCharArray(), 0, separator.length()); } catch (IOException ex) { throw new IllegalStateException(ex); } this.prependIndent = true; return this; }
3.26
dubbo_BasicJsonWriter_indent_rdh
/** * Increase the indentation level. */ private IndentingWriter indent() { this.level++; return refreshIndent();}
3.26
dubbo_BasicJsonWriter_writeObject_rdh
/** * Write an object with the specified attributes. Each attribute is * written according to its value type: * <ul> * <li>Map: write the value as a nested object</li> * <li>List: write the value as a nested array</li> * <li>Otherwise, write a single value</li> * </ul> * * @param attributes * the attributes of the object */ public void writeObject(Map<String, Object> attributes) { writeObject(attributes, true); }
3.26
dubbo_BasicJsonWriter_writeArray_rdh
/** * Write an array with the specified items. Each item in the * list is written either as a nested object or as an attribute * depending on its type. * * @param items * the items to write * @see #writeObject(Map) */ public void writeArray(List<?> items) { writeArray(items, true); }
3.26
dubbo_BasicJsonWriter_outdent_rdh
/** * Decrease the indentation level. */ private IndentingWriter outdent() { this.level--; return refreshIndent(); }
3.26
dubbo_BasicJsonWriter_indented_rdh
/** * Increase the indentation level and execute the {@link Runnable}. Decrease the * indentation level on completion. * * @param runnable * the code to execute within an extra indentation level */ public IndentingWriter indented(Runnable runnable) { indent(); runnable.run();return outdent(); }
3.26
dubbo_RpcContextAttachment_set_rdh
/** * set value. * * @param key * @param value * @return context */ @Override @Deprecated public RpcContextAttachment set(String key, Object value) {return setAttachment(key, value); }
3.26
dubbo_RpcContextAttachment_startAsync_rdh
/** * * @return * @throws IllegalStateException */ @SuppressWarnings("unchecked") public static AsyncContext startAsync() throws IllegalStateException { RpcContextAttachment v0 = getServerAttachment(); if (v0.asyncContext == null) { v0.asyncContext = new AsyncContextImpl(); } v0.asyncContext.start(); return v0.asyncContext; }
3.26
dubbo_RpcContextAttachment_getAttachment_rdh
/** * also see {@link #getObjectAttachment(String)}. * * @param key * @return attachment */ @Override public String getAttachment(String key) { Object value = attachments.get(key); if (value instanceof String) { return ((String) (value)); } return null;// or JSON.toString(value); }
3.26
dubbo_RpcContextAttachment_getObjectAttachments_rdh
/** * get attachments. * * @return attachments */ @Override @Experimental("Experiment api for supporting Object transmission") public Map<String, Object> getObjectAttachments() { return attachments; }
3.26
dubbo_RpcContextAttachment_setAttachments_rdh
/** * set attachments * * @param attachment * @return context */ @Override public RpcContextAttachment setAttachments(Map<String, String> attachment) { this.attachments.clear(); if ((attachment != null) && (attachment.size() > 0)) { this.attachments.putAll(attachment); } return this; }
3.26
dubbo_RpcContextAttachment_copyOf_rdh
/** * Also see {@link RpcServiceContext#copyOf(boolean)} * * @return a copy of RpcContextAttachment with deep copied attachments */ public RpcContextAttachment copyOf(boolean needCopy) { if (!isValid()) { return null; } if (needCopy) { RpcContextAttachment copy = new RpcContextAttachment(); if (CollectionUtils.isNotEmptyMap(attachments)) { copy.attachments.putAll(this.attachments); } if (asyncContext != null) { copy.asyncContext = this.asyncContext; } return copy; } else { return this; } }
3.26
dubbo_ServiceBean_setApplicationEventPublisher_rdh
/** * * @param applicationEventPublisher * @since 2.6.5 */ @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.applicationEventPublisher = applicationEventPublisher; }
3.26
dubbo_ServiceBean_getBeanName_rdh
/** * Get the name of {@link ServiceBean} * * @return {@link ServiceBean}'s name * @since 2.6.5 */ @Parameter(excluded = true, attribute = false) public String getBeanName() { return this.beanName; }
3.26
dubbo_ServiceBean_publishExportEvent_rdh
/** * * @since 2.6.5 */ private void publishExportEvent() { ServiceBeanExportedEvent exportEvent = new ServiceBeanExportedEvent(this); applicationEventPublisher.publishEvent(exportEvent); }
3.26
dubbo_ServiceBean_getServiceClass_rdh
// merged from dubbox @Override protected Class getServiceClass(T ref) { if (AopUtils.isAopProxy(ref)) { return AopUtils.getTargetClass(ref); } return super.getServiceClass(ref); }
3.26
dubbo_ServiceBean_exported_rdh
/** * * @since 2.6.5 */ @Override protected void exported() { super.exported(); // Publish ServiceBeanExportedEvent publishExportEvent(); }
3.26
dubbo_ServiceBean_getService_rdh
/** * Gets associated {@link Service} * * @return associated {@link Service} */ public Service getService() { return service; }
3.26
dubbo_DubboAnnotationUtils_resolveInterfaceName_rdh
/** * Resolve the service interface name from @Service annotation attributes. * <p/> * Note: the service interface class maybe not found locally if is a generic service. * * @param attributes * annotation attributes of {@link Service @Service} * @param defaultInterfaceClass * the default class of interface * @return the interface name if found * @throws IllegalStateException * if interface name was not found */ public static String resolveInterfaceName(Map<String, Object> attributes, Class<?> defaultInterfaceClass) { // 1. get from DubboService.interfaceName() String interfaceClassName = AnnotationUtils.getAttribute(attributes, "interfaceName"); if (StringUtils.hasText(interfaceClassName)) { if ("org.apache.dubbo.rpc.service.GenericService".equals(interfaceClassName) || "com.alibaba.dubbo.rpc.service.GenericService".equals(interfaceClassName)) { throw new IllegalStateException("@Service interfaceName() cannot be GenericService: " + interfaceClassName); } return interfaceClassName; } // 2. get from DubboService.interfaceClass() Class<?> interfaceClass = AnnotationUtils.getAttribute(attributes, "interfaceClass"); if ((interfaceClass == null) || void.class.equals(interfaceClass)) { // default or set void.class for purpose. interfaceClass = null; } else if (GenericService.class.isAssignableFrom(interfaceClass)) { throw new IllegalStateException("@Service interfaceClass() cannot be GenericService :" + interfaceClass.getName()); } // 3. get from annotation element type, ignore GenericService if (((interfaceClass == null) && (defaultInterfaceClass != null)) && (!GenericService.class.isAssignableFrom(defaultInterfaceClass))) { // Find all interfaces from the annotated class // To resolve an issue : https://github.com/apache/dubbo/issues/3251 Class<?>[] allInterfaces = getAllInterfacesForClass(defaultInterfaceClass); if (allInterfaces.length > 0) { interfaceClass = allInterfaces[0]; } } Assert.notNull(interfaceClass, "@Service interfaceClass() or interfaceName() or interface class must be present!"); Assert.isTrue(interfaceClass.isInterface(), "The annotated type must be an interface!"); return interfaceClass.getName(); }
3.26
dubbo_DubboAnnotationUtils_convertParameters_rdh
/** * Resolve the parameters of {@link org.apache.dubbo.config.annotation.DubboService} * and {@link org.apache.dubbo.config.annotation.DubboReference} from the specified. * It iterates elements in order.The former element plays as key or key&value role, it would be * spilt if it contains specific string, for instance, ":" and "=". As for later element can't * be split in anytime.It will throw IllegalArgumentException If converted array length isn't * even number. * The convert cases below work in right way,which are best practice. * <p> * (array->map) * ["a","b"] ==> {a=b} * [" a "," b "] ==> {a=b} * ["a=b"] ==>{a=b} * ["a:b"] ==>{a=b} * ["a=b","c","d"] ==>{a=b,c=d} * ["a","a:b"] ==>{a="a:b"} * ["a","a,b"] ==>{a="a,b"} * </p> * * @param parameters * @return */ public static Map<String, String> convertParameters(String[] parameters) {if (ArrayUtils.isEmpty(parameters)) { return new HashMap<>(); } List<String> compatibleParameterArray = Arrays.stream(parameters).map(String::trim).reduce(new ArrayList<>(parameters.length), (list, parameter) -> { if ((list.size() % 2) == 1) { // value doesn't split list.add(parameter); return list; } String[] sp1 = parameter.split(":"); if ((sp1.length > 0) && ((sp1.length % 2) == 0)) { // key split list.addAll(Arrays.stream(sp1).map(String::trim).collect(Collectors.toList())); return list; } sp1 = parameter.split("="); if ((sp1.length > 0) && ((sp1.length % 2) == 0)) { list.addAll(Arrays.stream(sp1).map(String::trim).collect(Collectors.toList())); return list; } list.add(parameter); return list; }, (a, b) -> a); return CollectionUtils.toStringMap(compatibleParameterArray.toArray(new String[0])); }
3.26
dubbo_ApolloDynamicConfiguration_getInternalProperty_rdh
/** * This method will be used by Configuration to get valid value at runtime. * The group is expected to be 'app level', which can be fetched from the 'config.appnamespace' in url if necessary. * But I think Apollo's inheritance feature of namespace can solve the problem . */ @Override public String getInternalProperty(String key) { return dubboConfig.getProperty(key, null); }
3.26
dubbo_ApolloDynamicConfiguration_addListener_rdh
/** * Since all governance rules will lay under dubbo group, this method now always uses the default dubboConfig and * ignores the group parameter. */ @Override public void addListener(String key, String group, ConfigurationListener listener) { ApolloListener v8 = listeners.computeIfAbsent(group + key, k -> createTargetListener(key, group)); v8.addListener(listener); dubboConfig.addChangeListener(v8, Collections.singleton(key)); }
3.26
dubbo_ApolloDynamicConfiguration_m0_rdh
/** * Recommend specify namespace and group when using Apollo. * <p> * <dubbo:config-center namespace="governance" group="dubbo" />, 'dubbo=governance' is for governance rules while * 'group=dubbo' is for properties files. * * @param key * default value is 'dubbo.properties', currently useless for Apollo. * @param group * @param timeout * @return * @throws IllegalStateException */ @Override public String m0(String key, String group, long timeout) throws IllegalStateException { if (StringUtils.isEmpty(group)) { return dubboConfigFile.getContent(); } if (group.equals(url.getApplication())) { return ConfigService.getConfigFile(APOLLO_APPLICATION_KEY, ConfigFileFormat.Properties).getContent(); } ConfigFile configFile = ConfigService.getConfigFile(group, ConfigFileFormat.Properties); if (configFile == null) { throw new IllegalStateException(("There is no namespace named " + group) + " in Apollo."); } return configFile.getContent(); }
3.26
dubbo_ApolloDynamicConfiguration_createTargetListener_rdh
/** * Ignores the group parameter. * * @param key * property key the native listener will listen on * @param group * to distinguish different set of properties * @return */ private ApolloListener createTargetListener(String key, String group) { return new ApolloListener(); }
3.26
dubbo_JValidatorNew_generateMethodParameterClass_rdh
/** * try to generate methodParameterClass. * * @param clazz * interface class * @param method * invoke method * @param parameterClassName * generated parameterClassName * @return Class<?> generated methodParameterClass */ private static Class<?> generateMethodParameterClass(Class<?> clazz, Method method, String parameterClassName) throws Exception { ClassPool pool = ClassGenerator.getClassPool(clazz.getClassLoader()); synchronized(parameterClassName.intern()) { CtClass ctClass = null; try { ctClass = pool.getCtClass(parameterClassName); } catch (NotFoundException ignore) { } if (null == ctClass) { ctClass = pool.makeClass(parameterClassName); ClassFile classFile = ctClass.getClassFile(); ctClass.addConstructor(CtNewConstructor.defaultConstructor(pool.getCtClass(parameterClassName))); // parameter fields Parameter[] parameters = method.getParameters(); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); for (int i = 0; i < parameters.length; i++) { Annotation[] annotations = parameterAnnotations[i]; AnnotationsAttribute attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag); for (Annotation annotation : annotations) { if (annotation.annotationType().isAnnotationPresent(Constraint.class)) { Annotation ja = new Annotation(classFile.getConstPool(), pool.getCtClass(annotation.annotationType().getName())); Method[] members = annotation.annotationType().getMethods(); for (Method member : members) { if ((Modifier.isPublic(member.getModifiers()) && (member.getParameterTypes().length == 0)) && (member.getDeclaringClass() == annotation.annotationType())) { Object value = member.invoke(annotation); if (null != value) { MemberValue memberValue = createMemberValue(classFile.getConstPool(), pool.get(member.getReturnType().getName()), value); ja.addMemberValue(member.getName(), memberValue); } } } attribute.addAnnotation(ja); }} Parameter parameter = parameters[i]; Class<?> type = parameter.getType(); String fieldName = parameter.getName(); CtField ctField = CtField.make(((("public " + type.getCanonicalName()) + " ") + fieldName) + ";", pool.getCtClass(parameterClassName)); ctField.getFieldInfo().addAttribute(attribute); ctClass.addField(ctField); } return pool.toClass(ctClass, clazz, clazz.getClassLoader(), clazz.getProtectionDomain()); } else { return Class.forName(parameterClassName, true, clazz.getClassLoader()); } }}
3.26
dubbo_JValidatorNew_createMemberValue_rdh
// Copy from javassist.bytecode.annotation.Annotation.createMemberValue(ConstPool, CtClass); private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException { MemberValue memberValue = annotation.Annotation.createMemberValue(cp, type); if (memberValue instanceof BooleanMemberValue) { ((BooleanMemberValue) (memberValue)).setValue(((Boolean) (value))); } else if (memberValue instanceof ByteMemberValue) { ((ByteMemberValue) (memberValue)).setValue(((Byte) (value))); } else if (memberValue instanceof CharMemberValue) { ((CharMemberValue) (memberValue)).setValue(((Character) (value))); } else if (memberValue instanceof ShortMemberValue) { ((ShortMemberValue) (memberValue)).setValue(((Short) (value))); } else if (memberValue instanceof IntegerMemberValue) { ((IntegerMemberValue) (memberValue)).setValue(((Integer) (value))); } else if (memberValue instanceof LongMemberValue) { ((LongMemberValue) (memberValue)).setValue(((Long) (value))); } else if (memberValue instanceof FloatMemberValue) { ((FloatMemberValue) (memberValue)).setValue(((Float) (value))); } else if (memberValue instanceof DoubleMemberValue) { ((DoubleMemberValue) (memberValue)).setValue(((Double) (value))); } else if (memberValue instanceof ClassMemberValue) { ((ClassMemberValue) (memberValue)).setValue(((Class<?>) (value)).getName()); } else if (memberValue instanceof StringMemberValue) { ((StringMemberValue) (memberValue)).setValue(((String) (value))); } else if (memberValue instanceof EnumMemberValue) { ((EnumMemberValue) (memberValue)).setValue(((Enum<?>) (value)).name()); } else if (memberValue instanceof ArrayMemberValue) { CtClass arrayType = type.getComponentType(); int len = Array.getLength(value); MemberValue[] members = new MemberValue[len]; for (int i = 0; i < len; i++) { members[i] = createMemberValue(cp, arrayType, Array.get(value, i)); } ((ArrayMemberValue) (memberValue)).setValue(members); } return memberValue; }
3.26
dubbo_DubboHealthIndicator_resolveStatusCheckerNamesMap_rdh
/** * Resolves the map of {@link StatusChecker}'s name and its' source. * * @return non-null {@link Map} */ protected Map<String, String> resolveStatusCheckerNamesMap() { Map<String, String> statusCheckerNamesMap = new LinkedHashMap<>(); statusCheckerNamesMap.putAll(resolveStatusCheckerNamesMapFromDubboHealthIndicatorProperties()); statusCheckerNamesMap.putAll(resolveStatusCheckerNamesMapFromProtocolConfigs()); statusCheckerNamesMap.putAll(resolveStatusCheckerNamesMapFromProviderConfig()); return statusCheckerNamesMap; }
3.26
dubbo_DefaultServiceRestMetadataResolver_supportsPathVariableType_rdh
/** * Supports the type of parameter or not, based by {@link Converter}'s conversion feature * * @param parameterType * the type of parameter * @return if supports, this method will return <code>true</code>, or <code>false</code> */ private boolean supportsPathVariableType(TypeMirror parameterType) { String className = parameterType.toString(); ClassLoader classLoader = getClass().getClassLoader(); boolean supported; try { Class<?> targetType = forName(className, classLoader); supported = FrameworkModel.defaultModel().getBeanFactory().getBean(ConverterUtil.class).getConverter(String.class, targetType) != null; } catch (ClassNotFoundException e) { supported = false; } return supported; }
3.26
dubbo_ScopeModelAware_setApplicationModel_rdh
/** * Override this method if you just need application model * * @param applicationModel */ default void setApplicationModel(ApplicationModel applicationModel) { }
3.26
dubbo_ScopeModelAware_setFrameworkModel_rdh
/** * Override this method if you just need framework model * * @param frameworkModel */ default void setFrameworkModel(FrameworkModel frameworkModel) { }
3.26
dubbo_ScopeModelAware_setModuleModel_rdh
/** * Override this method if you just need module model * * @param moduleModel */ default void setModuleModel(ModuleModel moduleModel) { }
3.26
dubbo_IOUtils_write_rdh
/** * write. * * @param reader * Reader. * @param writer * Writer. * @param bufferSize * buffer size. * @return count. * @throws IOException * If an I/O error occurs */ public static long write(Reader reader, Writer writer, int bufferSize) throws IOException { int read; long total = 0; char[] buf = new char[bufferSize]; while ((read = reader.read(buf)) != (-1)) { writer.write(buf, 0, read);total += read; } return total; }
3.26
dubbo_IOUtils_read_rdh
/** * read string. * * @param reader * Reader instance. * @return String. * @throws IOException * If an I/O error occurs */ public static String read(Reader reader) throws IOException { try (StringWriter writer = new StringWriter()) { write(reader, writer); return writer.getBuffer().toString(); } }
3.26
dubbo_IOUtils_getURL_rdh
/** * use like spring code * * @param resourceLocation * @return */ public static URL getURL(String resourceLocation) throws FileNotFoundException { Assert.notNull(resourceLocation, "Resource location must not be null"); if (resourceLocation.startsWith(CommonConstants.CLASSPATH_URL_PREFIX)) { String path = resourceLocation.substring(CommonConstants.CLASSPATH_URL_PREFIX.length()); ClassLoader cl = ClassUtils.getClassLoader(); URL url = (cl != null) ? cl.getResource(path) : ClassLoader.getSystemResource(path); if (url == null) { String description = ("class path resource [" + path) + "]"; throw new FileNotFoundException(description + " cannot be resolved to URL because it does not exist"); } return url; } try { // try URL return new URL(resourceLocation); } catch (MalformedURLException ex) {// no URL -> treat as file path try {return new File(resourceLocation).toURI().toURL(); } catch (MalformedURLException ex2) { throw new FileNotFoundException(("Resource location [" + resourceLocation) + "] is neither a URL not a well-formed file path"); } } }
3.26
dubbo_IOUtils_writeLines_rdh
/** * write lines. * * @param file * file. * @param lines * lines. * @throws IOException * If an I/O error occurs */ public static void writeLines(File file, String[] lines) throws IOException { if (file == null) { throw new IOException("File is null."); }writeLines(new FileOutputStream(file), lines); }
3.26
dubbo_IOUtils_readLines_rdh
/** * read lines. * * @param is * input stream. * @return lines. * @throws IOException * If an I/O error occurs */ public static String[] readLines(InputStream is) throws IOException { List<String> lines = new ArrayList<String>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { String line; while ((line = reader.readLine()) != null) { lines.add(line); } return lines.toArray(new String[0]); } }
3.26
dubbo_QosProcessHandler_isHttp_rdh
// G for GET, and P for POST private static boolean isHttp(int magic) { return (magic == 'G') || (magic == 'P'); }
3.26
dubbo_ConfigManager_setMonitor_rdh
// MonitorConfig correlative methods @DisableInject public void setMonitor(MonitorConfig monitor) { addConfig(monitor); }
3.26
dubbo_ConfigManager_setApplication_rdh
// ApplicationConfig correlative methods /** * Set application config * * @param application * @return current application config instance */ @DisableInject public void setApplication(ApplicationConfig application) { addConfig(application); }
3.26
dubbo_ConfigManager_addProtocol_rdh
// ProtocolConfig correlative methods public void addProtocol(ProtocolConfig protocolConfig) { addConfig(protocolConfig); }
3.26
dubbo_ConfigManager_addConfigCenter_rdh
// ConfigCenterConfig correlative methods public void addConfigCenter(ConfigCenterConfig configCenter) { addConfig(configCenter); }
3.26
dubbo_ConfigManager_addMetadataReport_rdh
// MetadataReportConfig correlative methods public void addMetadataReport(MetadataReportConfig metadataReportConfig) { addConfig(metadataReportConfig); }
3.26
dubbo_ConfigManager_addRegistry_rdh
// RegistryConfig correlative methods public void addRegistry(RegistryConfig registryConfig) { addConfig(registryConfig); }
3.26
dubbo_FrameworkExecutorRepository_getMappingRefreshingExecutor_rdh
/** * Executor used to run async mapping tasks * * @return ExecutorService */ public ExecutorService getMappingRefreshingExecutor() { return mappingRefreshingExecutor; }
3.26
dubbo_FrameworkExecutorRepository_getConnectivityScheduledExecutor_rdh
/** * Scheduled executor handle connectivity check task * * @return ScheduledExecutorService */ public ScheduledExecutorService getConnectivityScheduledExecutor() { return connectivityScheduledExecutor; }
3.26
dubbo_FrameworkExecutorRepository_getSharedScheduledExecutor_rdh
/** * Get the shared schedule executor * * @return ScheduledExecutorService */ public ScheduledExecutorService getSharedScheduledExecutor() { return sharedScheduledExecutor; }
3.26
dubbo_FrameworkExecutorRepository_nextScheduledExecutor_rdh
/** * Returns a scheduler from the scheduler list, call this method whenever you need a scheduler for a cron job. * If your cron cannot burden the possible schedule delay caused by sharing the same scheduler, please consider define a dedicated one. * * @return ScheduledExecutorService */public ScheduledExecutorService nextScheduledExecutor() { return scheduledExecutors.pollItem(); }
3.26
dubbo_InstanceMetadataChangedListener_echo_rdh
/** * Echo test * Used to check consumer still online */ default String echo(String msg) { return msg; }
3.26
dubbo_TripleClientCall_halfClose_rdh
// stream listener end @Override public void halfClose() { if (!headerSent) { return; } if (canceled) { return; } stream.halfClose().addListener(f -> { if (!f.isSuccess()) { cancelByLocal(new IllegalStateException("Half close failed", f.cause())); } }); }
3.26
dubbo_TripleClientCall_onMessage_rdh
// stream listener start @Override public void onMessage(byte[] message, boolean isReturnTriException) { if (done) { LOGGER.warn(PROTOCOL_STREAM_LISTENER, "", "", (((("Received message from closed stream,connection=" + connectionClient) + " service=") + requestMetadata.service) + " method=") + requestMetadata.method.getMethodName()); return; } try {final Object unpacked = requestMetadata.packableMethod.parseResponse(message, isReturnTriException); listener.onMessage(unpacked, message.length); } catch (Throwable t) {TriRpcStatus status = TriRpcStatus.INTERNAL.withDescription("Deserialize response failed").withCause(t); cancelByLocal(status.asException()); listener.onClose(status, null, false); LOGGER.error(PROTOCOL_FAILED_RESPONSE, "", "", String.format("Failed to deserialize triple response, service=%s, method=%s,connection=%s", connectionClient, requestMetadata.service, requestMetadata.method.getMethodName()), t);} }
3.26
dubbo_AbstractPeer_getHandler_rdh
/** * * @return ChannelHandler */ @Deprecated public ChannelHandler getHandler() { return getDelegateHandler(); }
3.26
dubbo_URL_getPath_rdh
// public List<URL> getBackupUrls() { // List<org.apache.dubbo.common.URL> res = super.getBackupUrls(); // return res.stream().map(url -> new URL(url)).collect(Collectors.toList()); // } @Overridepublic String getPath() { return super.getPath(); }
3.26
dubbo_AnnotationBeanDefinitionParser_doParse_rdh
/** * parse * <prev> * &lt;dubbo:annotation package="" /&gt; * </prev> * * @param element * @param parserContext * @param builder */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {String packageToScan = element.getAttribute("package"); String[] packagesToScan = trimArrayElements(commaDelimitedListToStringArray(packageToScan)); builder.addConstructorArgValue(packagesToScan); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); /** * * @since 2.7.6 Register the common beans * @since 2.7.8 comment this code line, and migrated to * @see DubboNamespaceHandler#parse(Element, ParserContext) * @see https://github.com/apache/dubbo/issues/6174 */ // registerCommonBeans(parserContext.getRegistry()); }
3.26
dubbo_DubboLoadingStrategy_directory_rdh
/** * Dubbo {@link LoadingStrategy} * * @since 2.7.7 */public class DubboLoadingStrategy implements LoadingStrategy {@Override public String directory() {return "META-INF/dubbo/"; }
3.26
dubbo_DubboAutoConfiguration_serviceAnnotationBeanProcessor_rdh
/** * Creates {@link ServiceAnnotationPostProcessor} Bean * * @param packagesToScan * the packages to scan * @return {@link ServiceAnnotationPostProcessor} */ @ConditionalOnProperty(prefix = DUBBO_SCAN_PREFIX, name = BASE_PACKAGES_PROPERTY_NAME) @ConditionalOnBean(name = BASE_PACKAGES_BEAN_NAME) @Bean public ServiceAnnotationPostProcessor serviceAnnotationBeanProcessor(@Qualifier(BASE_PACKAGES_BEAN_NAME) Set<String> packagesToScan) { return new ServiceAnnotationPostProcessor(packagesToScan); }
3.26
dubbo_ScopeClusterInvoker_isNotRemoteOrGeneric_rdh
/** * Check if the service is a generalized call or the SCOPE_REMOTE parameter is set * * @return boolean */ private boolean isNotRemoteOrGeneric() { return (!SCOPE_REMOTE.equalsIgnoreCase(getUrl().getParameter(SCOPE_KEY))) && (!getUrl().getParameter(GENERIC_KEY, false)); }
3.26
dubbo_ScopeClusterInvoker_invoke_rdh
/** * Checks if the current ScopeClusterInvoker is exported to the local JVM and invokes the corresponding Invoker. * If it's not exported locally, then it delegates the invocation to the original Invoker. * * @param invocation * the invocation to be performed * @return the result of the invocation * @throws RpcException * if there was an error during the invocation */ @Override public Result invoke(Invocation invocation) throws RpcException { // When broadcasting, it should be called remotely. if (isBroadcast()) { if (logger.isDebugEnabled()) { logger.debug((("Performing broadcast call for method: " + RpcUtils.getMethodName(invocation)) + " of service: ") + getUrl().getServiceKey()); } return invoker.invoke(invocation); } if (peerFlag) { if (logger.isDebugEnabled()) { logger.debug((("Performing point-to-point call for method: " + RpcUtils.getMethodName(invocation)) + " of service: ") + getUrl().getServiceKey()); } // If it's a point-to-point direct connection, invoke the original Invoker return invoker.invoke(invocation); } if (isInjvmExported()) { if (logger.isDebugEnabled()) { logger.debug((("Performing local JVM call for method: " + RpcUtils.getMethodName(invocation)) + " of service: ") + getUrl().getServiceKey()); }// If it's exported to the local JVM, invoke the corresponding Invoker return injvmInvoker.invoke(invocation); } if (logger.isDebugEnabled()) { logger.debug((("Performing remote call for method: " + RpcUtils.getMethodName(invocation)) + " of service: ") + getUrl().getServiceKey());} // Otherwise, delegate the invocation to the original Invoker return invoker.invoke(invocation); }
3.26
dubbo_ScopeClusterInvoker_isInjvmExported_rdh
/** * Checks whether the current ScopeClusterInvoker is exported to the local JVM and returns a boolean value. * * @return true if the ScopeClusterInvoker is exported to the local JVM, false otherwise * @throws RpcException * if there was an error during the invocation */ private boolean isInjvmExported() { Boolean localInvoke = RpcContext.getServiceContext().getLocalInvoke(); boolean isExportedValue = isExported.get(); boolean localOnce = (localInvoke != null) && localInvoke; // Determine whether this call is local if (isExportedValue && localOnce) { return true; } // Determine whether this call is remote if ((localInvoke != null) && (!localInvoke)) { return false; } // When calling locally, determine whether it does not meet the requirements if ((!isExportedValue) && (isForceLocal() || localOnce)) { // If it's supposed to be exported to the local JVM ,but it's not, throw an exception throw new RpcException(("Local service for " + getUrl().getServiceInterface()) + " has not been exposed yet!"); } return isExportedValue && injvmFlag; }
3.26
dubbo_ScopeClusterInvoker_createInjvmInvoker_rdh
/** * Creates a new Invoker for the current ScopeClusterInvoker and exports it to the local JVM. */ private void createInjvmInvoker(Exporter<?> exporter) { if (injvmInvoker == null) { synchronized(createLock) { if (injvmInvoker == null) { URL url = new ServiceConfigURL(LOCAL_PROTOCOL, NetUtils.getLocalHost(), getUrl().getPort(), getInterface().getName(), getUrl().getParameters()); url = url.setScopeModel(getUrl().getScopeModel()); url = url.setServiceModel(getUrl().getServiceModel()); DubboServiceAddressURL consumerUrl = new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), exporter.getInvoker().getUrl(), null); Invoker<?> invoker = protocolSPI.refer(getInterface(), consumerUrl); List<Invoker<?>> invokers = new ArrayList<>(); invokers.add(invoker); injvmInvoker = Cluster.getCluster(url.getScopeModel(), Cluster.DEFAULT, false).join(new StaticDirectory(url, invokers), true); } } } }
3.26
dubbo_ScopeClusterInvoker_destroyInjvmInvoker_rdh
/** * Destroy the existing InjvmInvoker. */ private void destroyInjvmInvoker() { if (injvmInvoker != null) { injvmInvoker.destroy(); injvmInvoker = null; } }
3.26
dubbo_ScopeClusterInvoker_init_rdh
/** * Initializes the ScopeClusterInvoker instance. */ private void init() { Boolean peer = ((Boolean) (getUrl().getAttribute(PEER_KEY))); String isInjvm = getUrl().getParameter(LOCAL_PROTOCOL); // When the point-to-point direct connection is directly connected, // the initialization is directly ended if ((peer != null) && peer) { peerFlag = true; return; } // Check if the service has been exported through Injvm protocol if ((injvmInvoker == null) && LOCAL_PROTOCOL.equalsIgnoreCase(getRegistryUrl().getProtocol())) { injvmInvoker = invoker; isExported.compareAndSet(false, true); injvmFlag = true; return; } // Check if the service has been exported through Injvm protocol or the SCOPE_LOCAL parameter is set if (Boolean.TRUE.toString().equalsIgnoreCase(isInjvm) || SCOPE_LOCAL.equalsIgnoreCase(getUrl().getParameter(SCOPE_KEY))) { injvmFlag = true; } else if (isInjvm == null) { injvmFlag = isNotRemoteOrGeneric(); } protocolSPI = getUrl().getApplicationModel().getExtensionLoader(Protocol.class).getAdaptiveExtension(); injvmExporterListener = getUrl().getOrDefaultFrameworkModel().getBeanFactory().getBean(InjvmExporterListener.class); injvmExporterListener.addExporterChangeListener(this, getUrl().getServiceKey()); }
3.26
dubbo_TriDecoder_processBody_rdh
/** * Processes the GRPC message body, which depending on frame header flags may be compressed. */ private void processBody() { // There is no reliable way to get the uncompressed size per message when it's compressed, // because the uncompressed bytes are provided through an InputStream whose total size is // unknown until all bytes are read, and we don't know when it happens. byte[] stream = (compressedFlag) ? getCompressedBody() : getUncompressedBody(); listener.onRawMessage(stream);// Done with this frame, begin processing the next header. state = GrpcDecodeState.HEADER; requiredLength = HEADER_LENGTH; }
3.26
dubbo_TriDecoder_processHeader_rdh
/** * Processes the GRPC compression header which is composed of the compression flag and the outer * frame length. */ private void processHeader() {int type = accumulate.readUnsignedByte(); if ((type & RESERVED_MASK) != 0) { throw new RpcException("gRPC frame header malformed: reserved bits not zero"); } compressedFlag = (type & COMPRESSED_FLAG_MASK) != 0; requiredLength = accumulate.readInt(); // Continue reading the frame body. state = GrpcDecodeState.PAYLOAD; }
3.26
dubbo_ThreadLocalCacheFactory_createCache_rdh
/** * Takes url as an method argument and return new instance of cache store implemented by ThreadLocalCache. * * @param url * url of the method * @return ThreadLocalCache instance of cache */ @Override protected Cache createCache(URL url) { return new ThreadLocalCache(url); }
3.26
dubbo_LoggerAdapter_isConfigured_rdh
/** * Return is the current logger has been configured. * Used to check if logger is available to use. * * @return true if the current logger has been configured */ default boolean isConfigured() { return true; }
3.26
dubbo_HashedWheelTimer_clearTimeouts_rdh
/** * Clear this bucket and return all not expired / cancelled {@link Timeout}s. */ void clearTimeouts(Set<Timeout> set) { for (; ;) { HashedWheelTimeout v31 = pollTimeout(); if (v31 == null) { return; } if (v31.isExpired() || v31.isCancelled()) { continue; } set.add(v31); } }
3.26
dubbo_HashedWheelTimer_addTimeout_rdh
/** * Add {@link HashedWheelTimeout} to this bucket. */ void addTimeout(HashedWheelTimeout timeout) { assert timeout.bucket == null; timeout.bucket = this; if (head == null) { head = tail = timeout; } else { tail.next = timeout; timeout.prev = tail; tail = timeout; } }
3.26
dubbo_HashedWheelTimer_start_rdh
/** * Starts the background thread explicitly. The background thread will * start automatically on demand even if you did not call this method. * * @throws IllegalStateException * if this timer has been * {@linkplain #stop() stopped} already */public void start() { switch (WORKER_STATE_UPDATER.get(this)) { case WORKER_STATE_INIT : if (WORKER_STATE_UPDATER.compareAndSet(this, WORKER_STATE_INIT, WORKER_STATE_STARTED)) { workerThread.start();} break; case WORKER_STATE_STARTED : break; case WORKER_STATE_SHUTDOWN : throw new IllegalStateException("cannot be started once stopped"); default : throw new Error("Invalid WorkerState"); }// Wait until the startTime is initialized by the worker. while (startTime == 0) { try { startTimeInitialized.await(); } catch (InterruptedException ignore) { // Ignore - it will be ready very soon. } } }
3.26
dubbo_HashedWheelTimer_expireTimeouts_rdh
/** * Expire all {@link HashedWheelTimeout}s for the given {@code deadline}. */ void expireTimeouts(long deadline) { HashedWheelTimeout timeout = head; // process all timeouts while (timeout != null) { HashedWheelTimeout next = timeout.next; if (timeout.remainingRounds <= 0) { next = remove(timeout); if (timeout.deadline <= deadline) { timeout.expire(); } else { // The timeout was placed into a wrong slot. This should never happen. throw new IllegalStateException(String.format("timeout.deadline (%d) > deadline (%d)", timeout.deadline, deadline)); } } else if (timeout.isCancelled()) { next = remove(timeout); } else { timeout.remainingRounds--; } timeout = next; } }
3.26
dubbo_LfuCache_put_rdh
/** * API to store value against a key in the calling thread scope. * * @param key * Unique identifier for the object being store. * @param value * Value getting store */ @SuppressWarnings("unchecked") @Override public void put(Object key, Object value) { f0.put(key, value); }
3.26
dubbo_LfuCache_get_rdh
/** * API to return stored value using a key against the calling thread specific store. * * @param key * Unique identifier for cache lookup * @return Return stored object against key */ @SuppressWarnings("unchecked") @Overridepublic Object get(Object key) { return f0.get(key); }
3.26
dubbo_GovernanceRuleRepository_getRule_rdh
/** * Get the governance rule mapped to the given key and the given group * * @param key * the key to represent a configuration * @param group * the group where the key belongs to * @return target configuration mapped to the given key and the given group */ default String getRule(String key, String group) { return getRule(key, group, -1L); }
3.26
dubbo_GovernanceRuleRepository_removeListener_rdh
/** * {@link #removeListener(String, String, ConfigurationListener)} * * @param key * the key to represent a configuration * @param listener * configuration listener */ default void removeListener(String key, ConfigurationListener listener) { removeListener(key, DEFAULT_GROUP, listener); }
3.26
dubbo_GovernanceRuleRepository_addListener_rdh
/** * {@link #addListener(String, String, ConfigurationListener)} * * @param key * the key to represent a configuration * @param listener * configuration listener */ default void addListener(String key, ConfigurationListener listener) { addListener(key, DEFAULT_GROUP, listener); }
3.26
dubbo_AbstractServiceBuilder_preferSerialization_rdh
/** * The prefer serialization type * * @param preferSerialization * prefer serialization type * @return {@link B} */ public B preferSerialization(String preferSerialization) { this.preferSerialization = preferSerialization; return getThis(); }
3.26
dubbo_ConverterUtil_getConverter_rdh
/** * Get the Converter instance from {@link ExtensionLoader} with the specified source and target type * * @param sourceType * the source type * @param targetType * the target type * @return * @see ExtensionLoader#getSupportedExtensionInstances() */ public Converter<?, ?> getConverter(Class<?> sourceType, Class<?> targetType) { ConcurrentMap<Class<?>, List<Converter>> toTargetMap = ConcurrentHashMapUtils.computeIfAbsent(converterCache, sourceType, k -> new ConcurrentHashMap<>()); List<Converter> converters = ConcurrentHashMapUtils.computeIfAbsent(toTargetMap, targetType, k -> frameworkModel.getExtensionLoader(Converter.class).getSupportedExtensionInstances().stream().filter(converter -> converter.accept(sourceType, targetType)).collect(Collectors.toList())); return converters.size() > 0 ? converters.get(0) : null; }
3.26
dubbo_ConverterUtil_convertIfPossible_rdh
/** * Convert the value of source to target-type value if possible * * @param source * the value of source * @param targetType * the target type * @param <T> * the target type * @return <code>null</code> if can't be converted * @since 2.7.8 */ public <T> T convertIfPossible(Object source, Class<T> targetType) { Converter converter = getConverter(source.getClass(), targetType); if (converter != null) { return ((T) (converter.convert(source))); } return null; }
3.26
dubbo_StubServiceDescriptor_getMethod_rdh
/** * Does not use Optional as return type to avoid potential performance decrease. * * @param methodName * @param paramTypes * @return */ public MethodDescriptor getMethod(String methodName, Class<?>[] paramTypes) { List<MethodDescriptor> methodModels = methods.get(methodName); if (CollectionUtils.isNotEmpty(methodModels)) { for (MethodDescriptor descriptor : methodModels) { if (Arrays.equals(paramTypes, descriptor.getParameterClasses())) { return descriptor; } } } return null; }
3.26
dubbo_RestInvoker_createHttpConnectionCreateContext_rdh
/** * create intercept context * * @param invocation * @param serviceRestMetadata * @param restMethodMetadata * @param requestTemplate * @return */ private HttpConnectionCreateContext createHttpConnectionCreateContext(Invocation invocation, ServiceRestMetadata serviceRestMetadata, RestMethodMetadata restMethodMetadata, RequestTemplate requestTemplate) { HttpConnectionCreateContext httpConnectionCreateContext = new HttpConnectionCreateContext(); httpConnectionCreateContext.setRequestTemplate(requestTemplate); httpConnectionCreateContext.setRestMethodMetadata(restMethodMetadata); httpConnectionCreateContext.setServiceRestMetadata(serviceRestMetadata);httpConnectionCreateContext.setInvocation(invocation); httpConnectionCreateContext.setUrl(getUrl()); return httpConnectionCreateContext; }
3.26
dubbo_AbstractConditionMatcher_doPatternMatch_rdh
// range, equal or other methods protected boolean doPatternMatch(String pattern, String value, URL url, Invocation invocation, boolean isWhenCondition) { for (ValuePattern v6 : f0) { if (v6.shouldMatch(pattern)) { return v6.match(pattern, value, url, invocation, isWhenCondition); } } // this should never happen. logger.error(CLUSTER_FAILED_EXEC_CONDITION_ROUTER, "Executing condition rule value match expression error.", (((("pattern is " + pattern) + ", value is ") + value) + ", condition type ") + (isWhenCondition ? "when" : "then"), "There should at least has one ValueMatcher instance that applies to all patterns, will force to use wildcard matcher now."); ValuePattern paramValueMatcher = model.getExtensionLoader(ValuePattern.class).getExtension("wildcard"); return paramValueMatcher.match(pattern, value, url, invocation, isWhenCondition); }
3.26
dubbo_ClassSourceScanner_spiClassesWithAdaptive_rdh
/** * Filter out the spi classes with adaptive annotations * from all the class collections that can be loaded. * * @return All spi classes with adaptive annotations */ public List<Class<?>> spiClassesWithAdaptive() { Map<String, Class<?>> allClasses = getClasses(); List<Class<?>> spiClasses = new ArrayList<>(allClasses.values()).stream().filter(it -> { if (null == it) { return false; } Annotation anno = it.getAnnotation(SPI.class); if (null == anno) { return false; } Optional<Method> optional = Arrays.stream(it.getMethods()).filter(it2 -> it2.getAnnotation(Adaptive.class) != null).findAny();return optional.isPresent(); }).collect(Collectors.toList()); return spiClasses; }
3.26
dubbo_ClassSourceScanner_configClasses_rdh
/** * The required configuration class, which is a subclass of AbstractConfig, * but which excludes abstract classes. * * @return configuration class */ public List<Class<?>> configClasses() { return getClasses().values().stream().filter(c -> AbstractConfig.class.isAssignableFrom(c) && (!Modifier.isAbstract(c.getModifiers()))).collect(Collectors.toList()); }
3.26
dubbo_ClassSourceScanner_adaptiveClasses_rdh
/** * The required adaptive class. * For example: LoadBalance$Adaptive.class * * @return adaptive class */public Map<String, Class<?>> adaptiveClasses() { List<String> res = spiClassesWithAdaptive().stream().map(c -> c.getName() + "$Adaptive").collect(Collectors.toList()); return forNames(res); }
3.26
dubbo_ClassSourceScanner_scopeModelInitializer_rdh
/** * Beans that need to be injected in advance in different ScopeModels. * For example, the RouterSnapshotSwitcher that needs to be injected when ClusterScopeModelInitializer executes initializeFrameworkModel * * @return Beans that need to be injected in advance */ public List<Class<?>> scopeModelInitializer() { List<Class<?>> classes = new ArrayList<>(); classes.addAll(FrameworkModel.defaultModel().getBeanFactory().getRegisteredClasses()); classes.addAll(FrameworkModel.defaultModel().defaultApplication().getBeanFactory().getRegisteredClasses()); classes.addAll(FrameworkModel.defaultModel().defaultApplication().getDefaultModule().getBeanFactory().getRegisteredClasses()); return classes.stream().distinct().collect(Collectors.toList()); }
3.26
dubbo_PathMatcher_httpMethodMatch_rdh
/** * it is needed to compare http method when one of needCompareHttpMethod is true,and don`t compare when both needCompareHttpMethod are false * * @param that * @return */ private boolean httpMethodMatch(PathMatcher that) { return (!that.needCompareHttpMethod) || (!this.needCompareHttpMethod) ? true : Objects.equals(this.httpMethod, that.httpMethod);}
3.26
dubbo_ChannelBuffers_prefixEquals_rdh
// prefix public static boolean prefixEquals(ChannelBuffer bufferA, ChannelBuffer bufferB, int count) { final int aLen = bufferA.readableBytes(); final int bLen = bufferB.readableBytes(); if ((aLen < count) || (bLen < count)) { return false; } int aIndex = bufferA.readerIndex(); int bIndex = bufferB.readerIndex(); for (int i = count; i > 0; i--) { if (bufferA.getByte(aIndex) != bufferB.getByte(bIndex)) { return false; } aIndex++; bIndex++; } return true; }
3.26