This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0fbcc1e5a8b2917fa11d31ee207b96329f0ef1a4 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Mon Apr 15 13:46:44 2024 +0200 (chores) camel-core: cleaned up duplicated code --- .../apache/camel/impl/debugger/BacklogTracer.java | 12 ++--- .../impl/converter/BaseTypeConverterRegistry.java | 16 +++--- .../camel/catalog/impl/AbstractCamelCatalog.java | 54 +++++++++----------- .../aggregate/AggregationStrategyBeanInfo.java | 59 +++++++++------------- .../core/xml/AbstractCamelContextFactoryBean.java | 38 +++++++------- .../support/RestConsumerContextPathMatcher.java | 45 ++++++----------- .../component/ApiMethodPropertiesHelper.java | 36 ++++++------- .../java/org/apache/camel/util/StringHelper.java | 18 +++++-- .../java/org/apache/camel/xml/in/BaseParser.java | 38 ++++++-------- 9 files changed, 136 insertions(+), 180 deletions(-) diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java index bc49984feef..000c36633f2 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java @@ -345,13 +345,7 @@ public final class BacklogTracer extends ServiceSupport implements org.apache.ca public String dumpTracedMessagesAsXml(String nodeId) { List<BacklogTracerEventMessage> events = dumpTracedMessages(nodeId); - StringBuilder sb = new StringBuilder(); - sb.append("<").append(BacklogTracerEventMessage.ROOT_TAG).append("s>"); - for (BacklogTracerEventMessage event : events) { - sb.append("\n").append(event.toXml(2)); - } - sb.append("\n</").append(BacklogTracerEventMessage.ROOT_TAG).append("s>"); - return sb.toString(); + return wrapAroundRootTag(events); } @Override @@ -380,6 +374,10 @@ public final class BacklogTracer extends ServiceSupport implements org.apache.ca public String dumpAllTracedMessagesAsXml() { List<BacklogTracerEventMessage> events = dumpAllTracedMessages(); + return wrapAroundRootTag(events); + } + + private static String wrapAroundRootTag(List<BacklogTracerEventMessage> events) { StringBuilder sb = new StringBuilder(); sb.append("<").append(BacklogTracerEventMessage.ROOT_TAG).append("s>"); for (BacklogTracerEventMessage event : events) { diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java b/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java index aa58325cec6..792d9a21173 100644 --- a/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java +++ b/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java @@ -199,13 +199,7 @@ public abstract class BaseTypeConverterRegistry extends CoreTypeConverterRegistr protected Collection<URL> getLoaderUrls(String basePath) throws IOException { List<URL> loaderResources = new ArrayList<>(); - for (ClassLoader classLoader : resolver.getClassLoaders()) { - Enumeration<URL> resources = classLoader.getResources(basePath); - while (resources.hasMoreElements()) { - URL url = resources.nextElement(); - loaderResources.add(url); - } - } + addResources(basePath, loaderResources); return loaderResources; } @@ -252,14 +246,18 @@ public abstract class BaseTypeConverterRegistry extends CoreTypeConverterRegistr protected Collection<URL> getFallbackUrls() throws IOException { List<URL> loaderResources = new ArrayList<>(); + addResources(META_INF_SERVICES_FALLBACK_TYPE_CONVERTER, loaderResources); + return loaderResources; + } + + private void addResources(String metaInfServicesFallbackTypeConverter, List<URL> loaderResources) throws IOException { for (ClassLoader classLoader : resolver.getClassLoaders()) { - Enumeration<URL> resources = classLoader.getResources(META_INF_SERVICES_FALLBACK_TYPE_CONVERTER); + Enumeration<URL> resources = classLoader.getResources(metaInfServicesFallbackTypeConverter); while (resources.hasMoreElements()) { URL url = resources.nextElement(); loaderResources.add(url); } } - return loaderResources; } protected void loadFallbackTypeConverters() throws IOException, ClassNotFoundException { diff --git a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java b/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java index 170a17817aa..42fa7e23aae 100644 --- a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java +++ b/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java @@ -61,6 +61,8 @@ import org.apache.camel.util.ReflectionHelper; import org.apache.camel.util.StringHelper; import org.apache.camel.util.URISupport; +import static org.apache.camel.util.StringHelper.isDashed; + /** * Base class for both the runtime RuntimeCamelCatalog from camel-core and the complete CamelCatalog from camel-catalog. */ @@ -1124,18 +1126,7 @@ public abstract class AbstractCamelCatalog { String suffix = null; int posDot = nOption.indexOf('.'); int posBracket = nOption.indexOf('['); - if (posDot > 0 && posBracket > 0) { - int first = Math.min(posDot, posBracket); - suffix = nOption.substring(first); - nOption = nOption.substring(0, first); - } else if (posDot > 0) { - suffix = nOption.substring(posDot); - nOption = nOption.substring(0, posDot); - } else if (posBracket > 0) { - suffix = nOption.substring(posBracket); - nOption = nOption.substring(0, posBracket); - } - doValidateConfigurationProperty(result, rows, name, value, longKey, nOption, suffix); + validateConfigurationProperty(posDot, posBracket, suffix, nOption, result, rows, name, value, longKey); } } else if (key.startsWith("main.") || key.startsWith("resilience4j.") @@ -1163,25 +1154,31 @@ public abstract class AbstractCamelCatalog { String suffix = null; int posDot = nOption.indexOf('.', secondDot); int posBracket = nOption.indexOf('[', secondDot); - if (posDot > 0 && posBracket > 0) { - int first = Math.min(posDot, posBracket); - suffix = nOption.substring(first); - nOption = nOption.substring(0, first); - } else if (posDot > 0) { - suffix = nOption.substring(posDot); - nOption = nOption.substring(0, posDot); - } else if (posBracket > 0) { - suffix = nOption.substring(posBracket); - nOption = nOption.substring(0, posBracket); - } - - doValidateConfigurationProperty(result, rows, name, value, longKey, nOption, suffix); + validateConfigurationProperty(posDot, posBracket, suffix, nOption, result, rows, name, value, longKey); } } return result; } + private void validateConfigurationProperty( + int posDot, int posBracket, String suffix, String nOption, ConfigurationPropertiesValidationResult result, + Map<String, BaseOptionModel> rows, String name, String value, String longKey) { + if (posDot > 0 && posBracket > 0) { + int first = Math.min(posDot, posBracket); + suffix = nOption.substring(first); + nOption = nOption.substring(0, first); + } else if (posDot > 0) { + suffix = nOption.substring(posDot); + nOption = nOption.substring(0, posDot); + } else if (posBracket > 0) { + suffix = nOption.substring(posBracket); + nOption = nOption.substring(0, posBracket); + } + + doValidateConfigurationProperty(result, rows, name, value, longKey, nOption, suffix); + } + private void doValidateConfigurationProperty( ConfigurationPropertiesValidationResult result, Map<String, BaseOptionModel> rows, @@ -1606,14 +1603,9 @@ public abstract class AbstractCamelCatalog { if (text == null) { return null; } - int length = text.length(); - if (length == 0) { - return text; - } - if (text.indexOf('-') == -1) { + if (!isDashed(text)) { return text; } - StringBuilder sb = new StringBuilder(); for (int i = 0; i < text.length(); i++) { diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategyBeanInfo.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategyBeanInfo.java index 130f38790b4..51bca24ceb0 100644 --- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategyBeanInfo.java +++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategyBeanInfo.java @@ -70,49 +70,36 @@ public class AggregationStrategyBeanInfo { } List<AggregationStrategyParameterInfo> oldParameters = new ArrayList<>(); - List<AggregationStrategyParameterInfo> newParameters = new ArrayList<>(); - for (int i = 0; i < size / 2; i++) { - Class<?> oldType = parameterTypes[i]; - if (oldParameters.isEmpty()) { - // the first parameter is the body - Expression oldBody = ExpressionBuilder.mandatoryBodyExpression(oldType); - AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, oldType, oldBody); - oldParameters.add(info); - } else if (oldParameters.size() == 1) { - // the 2nd parameter is the headers - Expression oldHeaders = ExpressionBuilder.headersExpression(); - AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, oldType, oldHeaders); - oldParameters.add(info); - } else if (oldParameters.size() == 2) { - // the 3rd parameter is the properties - Expression oldProperties = ExpressionBuilder.exchangePropertiesExpression(); - AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, oldType, oldProperties); - oldParameters.add(info); - } + addParameters(parameterTypes, i, oldParameters); } + List<AggregationStrategyParameterInfo> newParameters = new ArrayList<>(); for (int i = size / 2; i < size; i++) { - Class<?> newType = parameterTypes[i]; - if (newParameters.isEmpty()) { - // the first parameter is the body - Expression newBody = ExpressionBuilder.mandatoryBodyExpression(newType); - AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, newType, newBody); - newParameters.add(info); - } else if (newParameters.size() == 1) { - // the 2nd parameter is the headers - Expression newHeaders = ExpressionBuilder.headersExpression(); - AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, newType, newHeaders); - newParameters.add(info); - } else if (newParameters.size() == 2) { - // the 3rd parameter is the properties - Expression newProperties = ExpressionBuilder.exchangePropertiesExpression(); - AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, newType, newProperties); - newParameters.add(info); - } + addParameters(parameterTypes, i, newParameters); } return new AggregationStrategyMethodInfo(method, oldParameters, newParameters); } + private static void addParameters(Class<?>[] parameterTypes, int i, List<AggregationStrategyParameterInfo> parameters) { + Class<?> parameterType = parameterTypes[i]; + if (parameters.isEmpty()) { + // the first parameter is the body + Expression body = ExpressionBuilder.mandatoryBodyExpression(parameterType); + AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, parameterType, body); + parameters.add(info); + } else if (parameters.size() == 1) { + // the 2nd parameter is the headers + Expression headersExpression = ExpressionBuilder.headersExpression(); + AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, parameterType, headersExpression); + parameters.add(info); + } else if (parameters.size() == 2) { + // the 3rd parameter is the properties + Expression properties = ExpressionBuilder.exchangePropertiesExpression(); + AggregationStrategyParameterInfo info = new AggregationStrategyParameterInfo(i, parameterType, properties); + parameters.add(info); + } + } + } diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java index d31086ce978..ec41707d2a5 100644 --- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java +++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java @@ -1400,16 +1400,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex PackageScanDefinition packageScanDef = getPackageScan(); if (packageScanDef != null && !packageScanDef.getPackages().isEmpty()) { // use package scan filter - PatternBasedPackageScanFilter filter = new PatternBasedPackageScanFilter(); - // support property placeholders in include and exclude - for (String include : packageScanDef.getIncludes()) { - include = getContext().resolvePropertyPlaceholders(include); - filter.addIncludePattern(include); - } - for (String exclude : packageScanDef.getExcludes()) { - exclude = getContext().resolvePropertyPlaceholders(exclude); - filter.addExcludePattern(exclude); - } + final PatternBasedPackageScanFilter filter + = addPatterns(packageScanDef.getIncludes(), packageScanDef.getExcludes()); String[] normalized = normalizePackages(getContext(), packageScanDef.getPackages()); findRouteBuildersByPackageScan(normalized, filter, builders); @@ -1419,16 +1411,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex ContextScanDefinition contextScanDef = getContextScan(); if (contextScanDef != null) { // use package scan filter - PatternBasedPackageScanFilter filter = new PatternBasedPackageScanFilter(); - // support property placeholders in include and exclude - for (String include : contextScanDef.getIncludes()) { - include = getContext().resolvePropertyPlaceholders(include); - filter.addIncludePattern(include); - } - for (String exclude : contextScanDef.getExcludes()) { - exclude = getContext().resolvePropertyPlaceholders(exclude); - filter.addExcludePattern(exclude); - } + final PatternBasedPackageScanFilter filter + = addPatterns(contextScanDef.getIncludes(), contextScanDef.getExcludes()); // lets be false by default, to skip prototype beans boolean includeNonSingletons = contextScanDef.getIncludeNonSingletons() != null && Boolean.parseBoolean(contextScanDef.getIncludeNonSingletons()); @@ -1436,6 +1420,20 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex } } + private PatternBasedPackageScanFilter addPatterns(List<String> contextScanDef, List<String> contextScanDef1) { + PatternBasedPackageScanFilter filter = new PatternBasedPackageScanFilter(); + // support property placeholders in include and exclude + for (String include : contextScanDef) { + include = getContext().resolvePropertyPlaceholders(include); + filter.addIncludePattern(include); + } + for (String exclude : contextScanDef1) { + exclude = getContext().resolvePropertyPlaceholders(exclude); + filter.addExcludePattern(exclude); + } + return filter; + } + protected abstract void findRouteBuildersByPackageScan( String[] packages, PackageScanFilter filter, List<RoutesBuilder> builders) throws Exception; diff --git a/core/camel-support/src/main/java/org/apache/camel/support/RestConsumerContextPathMatcher.java b/core/camel-support/src/main/java/org/apache/camel/support/RestConsumerContextPathMatcher.java index ba534ae8a44..100d0980e87 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/RestConsumerContextPathMatcher.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/RestConsumerContextPathMatcher.java @@ -89,19 +89,9 @@ public final class RestConsumerContextPathMatcher { } // remove starting/ending slashes - if (requestPath.startsWith("/")) { - requestPath = requestPath.substring(1); - } - if (requestPath.endsWith("/")) { - requestPath = requestPath.substring(0, requestPath.length() - 1); - } + requestPath = removePathSlashes(requestPath); // remove starting/ending slashes - if (consumerPath.startsWith("/")) { - consumerPath = consumerPath.substring(1); - } - if (consumerPath.endsWith("/")) { - consumerPath = consumerPath.substring(0, consumerPath.length() - 1); - } + consumerPath = removePathSlashes(consumerPath); if (matchOnUriPrefix && requestPath.toLowerCase(Locale.ENGLISH).startsWith(consumerPath.toLowerCase(Locale.ENGLISH))) { return true; @@ -326,19 +316,9 @@ public final class RestConsumerContextPathMatcher { } // remove starting/ending slashes - if (requestPath.startsWith("/")) { - requestPath = requestPath.substring(1); - } - if (requestPath.endsWith("/")) { - requestPath = requestPath.substring(0, requestPath.length() - 1); - } + requestPath = removePathSlashes(requestPath); // remove starting/ending slashes - if (consumerPath.startsWith("/")) { - consumerPath = consumerPath.substring(1); - } - if (consumerPath.endsWith("/")) { - consumerPath = consumerPath.substring(0, consumerPath.length() - 1); - } + consumerPath = removePathSlashes(consumerPath); // split using single char / is optimized in the jdk String[] requestPaths = requestPath.split("/"); @@ -367,6 +347,16 @@ public final class RestConsumerContextPathMatcher { return true; } + private static String removePathSlashes(String path) { + if (path.startsWith("/")) { + path = path.substring(1); + } + if (path.endsWith("/")) { + path = path.substring(0, path.length() - 1); + } + return path; + } + /** * Counts the number of uri template's curlyBraces in the path * @@ -377,12 +367,7 @@ public final class RestConsumerContextPathMatcher { int curlyBraces = 0; // remove starting/ending slashes - if (consumerPath.startsWith("/")) { - consumerPath = consumerPath.substring(1); - } - if (consumerPath.endsWith("/")) { - consumerPath = consumerPath.substring(0, consumerPath.length() - 1); - } + consumerPath = removePathSlashes(consumerPath); String[] consumerPaths = consumerPath.split("/"); for (String p2 : consumerPaths) { diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java index 85dc639d59c..2ad2be9c693 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java @@ -110,16 +110,7 @@ public abstract class ApiMethodPropertiesHelper<C> { .resolvePropertyConfigurer(endpointConfiguration.getClass().getName(), context); // use reflection free configurer (if possible) if (configurer instanceof ExtendedPropertyConfigurerGetter) { - ExtendedPropertyConfigurerGetter getter = (ExtendedPropertyConfigurerGetter) configurer; - Set<String> all = getter.getAllOptions(endpointConfiguration).keySet(); - for (String name : all) { - Object value = getter.getOptionValue(endpointConfiguration, name, true); - if (value != null) { - // lower case the first letter which is what the properties map expects - String key = Character.toLowerCase(name.charAt(0)) + name.substring(1); - properties.put(key, value); - } - } + useGetters(endpointConfiguration, properties, (ExtendedPropertyConfigurerGetter) configurer); } else { PluginHelper.getBeanIntrospection(context).getProperties(endpointConfiguration, properties, null, false); @@ -167,16 +158,7 @@ public abstract class ApiMethodPropertiesHelper<C> { .resolvePropertyConfigurer(endpointConfiguration.getClass().getName(), context); // use reflection free configurer (if possible) if (configurer instanceof ExtendedPropertyConfigurerGetter) { - ExtendedPropertyConfigurerGetter getter = (ExtendedPropertyConfigurerGetter) configurer; - Set<String> all = getter.getAllOptions(endpointConfiguration).keySet(); - for (String name : all) { - Object value = getter.getOptionValue(endpointConfiguration, name, true); - if (value != null) { - // lower case the first letter which is what the properties map expects - String key = Character.toLowerCase(name.charAt(0)) + name.substring(1); - properties.put(key, value); - } - } + useGetters(endpointConfiguration, properties, (ExtendedPropertyConfigurerGetter) configurer); } else { PluginHelper.getBeanIntrospection(context).getProperties(endpointConfiguration, properties, null, false); @@ -186,4 +168,18 @@ public abstract class ApiMethodPropertiesHelper<C> { } } + private static void useGetters( + Object endpointConfiguration, Map<String, Object> properties, ExtendedPropertyConfigurerGetter configurer) { + ExtendedPropertyConfigurerGetter getter = configurer; + Set<String> all = getter.getAllOptions(endpointConfiguration).keySet(); + for (String name : all) { + Object value = getter.getOptionValue(endpointConfiguration, name, true); + if (value != null) { + // lower case the first letter which is what the properties map expects + String key = Character.toLowerCase(name.charAt(0)) + name.substring(1); + properties.put(key, value); + } + } + } + } diff --git a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java index ca7b731f5af..c4c95c9b19d 100644 --- a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java +++ b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java @@ -535,6 +535,17 @@ public final class StringHelper { return dashToCamelCase(text, false); } + /** + * Whether the string contains dashes or not + * + * @param text the string to check + * @return true if it contains dashes or false otherwise + */ + public static boolean isDashed(String text) { + int length = text.length(); + return length != 0 && text.indexOf('-') != -1; + } + /** * Converts the string from dash format into camel case (hello-great-world -> helloGreatWorld) * @@ -546,15 +557,12 @@ public final class StringHelper { if (text == null) { return null; } - int length = text.length(); - if (length == 0) { - return text; - } - if (text.indexOf('-') == -1) { + if (!isDashed(text)) { return text; } // there is at least 1 dash so the capacity can be shorter + int length = text.length(); StringBuilder sb = new StringBuilder(length - 1); boolean upper = false; int singleQuotes = 0; diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java index f114b3f3123..8570efbb7c2 100644 --- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java +++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java @@ -128,17 +128,7 @@ public class BaseParser { T definition, AttributeHandler<T> attributeHandler, ElementHandler<T> elementHandler, ValueHandler<T> valueHandler, boolean supportsExternalNamespaces) throws IOException, XmlPullParserException { - if (definition instanceof LineNumberAware) { - // we want to get the line number where the tag starts (in case its multi-line) - int line = parser.getStartLineNumber(); - if (line == -1) { - line = parser.getLineNumber(); - } - ((LineNumberAware) definition).setLineNumber(line); - if (resource != null) { - ((LineNumberAware) definition).setLocation(resource.getLocation()); - } - } + setLocation(definition); if (definition instanceof NamespaceAware) { final Map<String, String> namespaces = new LinkedHashMap<>(); for (int i = 0; i < parser.getNamespaceCount(parser.getDepth()); i++) { @@ -218,17 +208,7 @@ public class BaseParser { if (event == XmlPullParser.TEXT) { if (!parser.isWhitespace()) { T definition = definitionSupplier.get(); - if (definition instanceof LineNumberAware) { - // we want to get the line number where the tag starts (in case its multi-line) - int line = parser.getStartLineNumber(); - if (line == -1) { - line = parser.getLineNumber(); - } - ((LineNumberAware) definition).setLineNumber(line); - if (resource != null) { - ((LineNumberAware) definition).setLocation(resource.getLocation()); - } - } + setLocation(definition); valueHandler.accept(definition, parser.getText()); answer.add(definition); } @@ -258,6 +238,20 @@ public class BaseParser { } } + private <T> void setLocation(T definition) { + if (definition instanceof LineNumberAware) { + // we want to get the line number where the tag starts (in case its multi-line) + int line = parser.getStartLineNumber(); + if (line == -1) { + line = parser.getLineNumber(); + } + ((LineNumberAware) definition).setLineNumber(line); + if (resource != null) { + ((LineNumberAware) definition).setLocation(resource.getLocation()); + } + } + } + protected Class<?> asClass(String val) throws XmlPullParserException { try { return Class.forName(val);