KOkkmiao opened a new issue #9568:
URL: https://github.com/apache/dubbo/issues/9568
<!-- For all design discussions please continue. -->
### JaketConfigurationUtils 以固定死的目录加载配置不太合理。
```
public class JaketConfigurationUtils {
private static final String CONFIGURATION_FILE = "jaket.properties";
private static String[] includedInterfacePackages;
private static String[] includedTypePackages;
private static String[] closedTypes;
static {
Properties props = new Properties();
InputStream inStream =
JaketConfigurationUtils.class.getClassLoader().getResourceAsStream(CONFIGURATION_FILE);
try {
props.load(inStream);
String value = (String) props.get("included_interface_packages");
if (StringUtils.isNotEmpty(value)) {
includedInterfacePackages = value.split(",");
}
value = props.getProperty("included_type_packages");
if (StringUtils.isNotEmpty(value)) {
includedTypePackages = value.split(",");
}
value = props.getProperty("closed_types");
if (StringUtils.isNotEmpty(value)) {
closedTypes = value.split(",");
}
} catch (Throwable e) {
// Ignore it.
}
}
}
```
DefaultTypeBuilder 对原始类型的无用递归。
```
org.apache.dubbo.metadata.definition.TypeDefinitionBuilder#build
public static TypeDefinition build(Type type, Class<?> clazz, Map<Class<?>,
TypeDefinition> typeCache) {
TypeBuilder builder = getGenericTypeBuilder(type, clazz);
TypeDefinition td;
if (builder != null) {
td = builder.build(type, clazz, typeCache);
td.setTypeBuilderName(builder.getClass().getName());
} else {
td = DefaultTypeBuilder.build(clazz, typeCache);
td.setTypeBuilderName(DefaultTypeBuilder.class.getName());
}
if (isSimpleType(clazz)) { // changed since 2.7.6
这里移除了原始类型的数据properties。能在DefaultTypeBuilder 里做吗?
td.setProperties(null);
}
return td;
}
---------
```
```
例如:
public final class DefaultTypeBuilder {
public static TypeDefinition build(Class<?> clazz, Map<Class<?>,
TypeDefinition> typeCache) {
// final String canonicalName = clazz.getCanonicalName();
final String name = clazz.getName();
TypeDefinition td = new TypeDefinition(name);
// Try to get a cached definition
if (typeCache.containsKey(clazz)) {
return typeCache.get(clazz);
}
if (isSimpleType(clazz)) {
return td;
}
// Primitive type
if (!JaketConfigurationUtils.needAnalyzing(clazz)) {
return td;
}
// Custom type
TypeDefinition ref = new TypeDefinition(name);
ref.set$ref(name);
typeCache.put(clazz, ref);
List<Field> fields = ClassUtils.getNonStaticFields(clazz);
for (Field field : fields) {
String fieldName = field.getName();
Class<?> fieldClass = field.getType();
Type fieldType = field.getGenericType();
TypeDefinition fieldTd = TypeDefinitionBuilder.build(fieldType,
fieldClass, typeCache);
td.getProperties().put(fieldName, fieldTd);
}
typeCache.put(clazz, td);
return td;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]