SpringSchemasSourceInfoImpl() {
}
}
// spring.tooling
resourceResolver.loadAllProperties(TOOLING_PARAMS_LOCATION, new PropertyHandler() {
public void handle(String key, String value, Resource source, int lineNumber) {
String namespaceAndParamName = trimToNull(key);
if (namespaceAndParamName != null) {
int index = namespaceAndParamName.indexOf("@");
String namespace = null;
String paramName = null;
if (index >= 0) {
namespace = trimToNull(namespaceAndParamName.substring(0, index));
paramName = trimToNull(namespaceAndParamName.substring(index + 1));
}
if (namespace != null && paramName != null) {
Map<String, String> params = toolingParameters.get(namespace);
if (params == null) {
params = createHashMap();
toolingParameters.put(namespace, params);
}
params.put(paramName, trimToNull(value));
}
}
}
});
// spring.schemas
resourceResolver.loadAllProperties(SCHEMA_MAPPINGS_LOCATION, new PropertyHandler() {
public void handle(String key, String value, Resource source, int lineNumber) {
String uri = trimToNull(key);
String classpathLocation = trimToNull(value);
if (uri == null || classpathLocation == null) {
return; // invalid and ignored
}
String schemaName = getSchemaName(uri);
Matcher matcher = SCHEMA_VERSION_PATTERN.matcher(schemaName);
String version = null;
if (matcher.find()) {
version = matcher.group(1);
}
SpringSchemasSourceInfoImpl pluginSourceInfo = new SpringSchemasSourceInfoImpl();
pluginSourceInfo.setSource(source, lineNumber);
Resource schemaSource = getResource(classpathLocation, uri);
if (schemaSource != null) {
Schema schema = SchemaImpl.createSpringPluggableSchema(
schemaName, version, true, desc, schemaSource,
new SourceInfoSupport<SpringSchemasSourceInfo>(pluginSourceInfo).setSource(schemaSource), toolingParameters);
nameToSchemaMappings.put(schemaName, schema);
uriToNameMappings.put(uri, schemaName);
String namespace = schema.getTargetNamespace();
if (namespace != null) {
namespaces.add(namespace);
}
}
}
});
// 在spring.handlers中,有一些namespace是没有schema的(例如:http://www.springframework.org/schema/p),所以在spring.schemas中找不到。
// 但我们需要在这里把它引进来,以方便IDE plugins读取。
resourceResolver.loadAllProperties(HANDLER_MAPPINGS_LOCATION, new PropertyHandler() {
public void handle(String key, String value, Resource source, int lineNumber) {
String namespace = trimToNull(key);
if (namespace != null) {
namespaces.add(namespace);