This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-13870 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 96d6f7fb42701c3888012dadee42f057e5546258 Author: Claus Ibsen <[email protected]> AuthorDate: Thu Aug 22 10:10:02 2019 +0200 CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress. --- .../org/apache/camel/ExtendedCamelContext.java | 6 + .../org/apache/camel/spi/BeanIntrospection.java | 5 +- .../camel/impl/engine/AbstractCamelContext.java | 8 + .../impl/engine/CamelPostProcessorHelper.java | 5 +- .../impl/engine/DefaultBeanIntrospection.java | 210 +++++++++++++++++++++ .../apache/camel/model/LoadBalancerDefinition.java | 1 - .../cloud/ServiceCallExpressionConfiguration.java | 3 +- .../ServiceCallServiceChooserConfiguration.java | 3 +- .../ServiceCallServiceDiscoveryConfiguration.java | 3 +- .../ServiceCallServiceFilterConfiguration.java | 3 +- ...erviceCallServiceLoadBalancerConfiguration.java | 3 +- .../camel/model/language/ExpressionDefinition.java | 4 +- .../reifier/dataformat/DataFormatReifier.java | 6 +- .../camel/reifier/rest/RestBindingReifier.java | 16 +- .../DefaultComponentVerifierExtension.java | 7 +- .../org/apache/camel/support/DefaultComponent.java | 2 +- .../org/apache/camel/support/DefaultEndpoint.java | 3 +- .../org/apache/camel/support/EndpointHelper.java | 3 +- .../apache/camel/support/IntrospectionSupport.java | 3 + .../camel/support/PropertyBindingSupport.java | 38 ++-- .../camel/support/ScheduledPollConsumer.java | 3 +- .../camel/support/ScheduledPollEndpoint.java | 3 +- .../camel/support/builder/ExpressionBuilder.java | 4 +- .../support/component/AbstractApiComponent.java | 4 +- .../component/ApiMethodPropertiesHelper.java | 2 +- .../org/apache/camel/support/jndi/JndiContext.java | 1 + .../support/management/MBeanInfoAssembler.java | 1 + 27 files changed, 286 insertions(+), 64 deletions(-) diff --git a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java index 450b98a..6ffdcea 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java @@ -25,6 +25,7 @@ import java.util.concurrent.ScheduledExecutorService; import org.apache.camel.spi.AnnotationBasedProcessorFactory; import org.apache.camel.spi.AsyncProcessorAwaitManager; +import org.apache.camel.spi.BeanIntrospection; import org.apache.camel.spi.BeanProcessorFactory; import org.apache.camel.spi.BeanProxyFactory; import org.apache.camel.spi.CamelBeanPostProcessor; @@ -333,4 +334,9 @@ public interface ExtendedCamelContext extends CamelContext { */ void setAsyncProcessorAwaitManager(AsyncProcessorAwaitManager manager); + /** + * Gets the {@link BeanIntrospection} + */ + BeanIntrospection getBeanIntrospection(); + } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java b/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java index 64de871..98a5a81 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java @@ -19,6 +19,7 @@ package org.apache.camel.spi; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; +import java.util.Set; import org.apache.camel.CamelContext; import org.apache.camel.TypeConverter; @@ -164,8 +165,6 @@ public interface BeanIntrospection { boolean setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value, String refName, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) throws Exception; - boolean isPropertyPlaceholder(CamelContext context, Object value); - boolean setProperty(CamelContext context, Object target, String name, Object value) throws Exception; boolean setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value) throws Exception; @@ -178,4 +177,6 @@ public interface BeanIntrospection { @Deprecated boolean setProperty(Object target, String name, Object value) throws Exception; + Set<Method> findSetterMethods(Class<?> clazz, String name, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase); + } diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java index 15bd973..2211f86 100644 --- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java +++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java @@ -80,6 +80,7 @@ import org.apache.camel.impl.transformer.TransformerKey; import org.apache.camel.impl.validator.ValidatorKey; import org.apache.camel.spi.AnnotationBasedProcessorFactory; import org.apache.camel.spi.AsyncProcessorAwaitManager; +import org.apache.camel.spi.BeanIntrospection; import org.apache.camel.spi.BeanProcessorFactory; import org.apache.camel.spi.BeanProxyFactory; import org.apache.camel.spi.CamelBeanPostProcessor; @@ -254,6 +255,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext private volatile UnitOfWorkFactory unitOfWorkFactory; private volatile RouteController routeController; private volatile ScheduledExecutorService errorHandlerExecutorService; + private final BeanIntrospection beanIntrospection = new DefaultBeanIntrospection(); private final DeferServiceFactory deferServiceFactory = new DefaultDeferServiceFactory(); private final AnnotationBasedProcessorFactory annotationBasedProcessorFactory = new DefaultAnnotationBasedProcessorFactory(); @@ -2771,6 +2773,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext forceStopLazyInitialization(); // stop to clear introspection cache + ServiceHelper.stopService(beanIntrospection); IntrospectionSupport.stop(); if (log.isInfoEnabled()) { @@ -3655,6 +3658,11 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext } @Override + public BeanIntrospection getBeanIntrospection() { + return beanIntrospection; + } + + @Override public void setAutoStartup(Boolean autoStartup) { this.autoStartup = autoStartup; } diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java index 8befc59..56cfdf2 100644 --- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java +++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java @@ -40,7 +40,6 @@ import org.apache.camel.Service; import org.apache.camel.spi.BeanProxyFactory; import org.apache.camel.spi.PropertiesComponent; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.service.ServiceHelper; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -179,10 +178,10 @@ public class CamelPostProcessorHelper implements CamelContextAware { // 2. then the getter with Endpoint as postfix // 3. then if start with on then try step 1 and 2 again, but omit the on prefix try { - Object value = IntrospectionSupport.getOrElseProperty(bean, propertyName, null); + Object value = getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().getOrElseProperty(bean, propertyName, null); if (value == null) { // try endpoint as postfix - value = IntrospectionSupport.getOrElseProperty(bean, propertyName + "Endpoint", null); + value = getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().getOrElseProperty(bean, propertyName + "Endpoint", null); } if (value == null && propertyName.startsWith("on")) { // retry but without the on as prefix diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultBeanIntrospection.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultBeanIntrospection.java new file mode 100644 index 0000000..f9f9b79 --- /dev/null +++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultBeanIntrospection.java @@ -0,0 +1,210 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.impl.engine; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.Set; + +import org.apache.camel.CamelContext; +import org.apache.camel.TypeConverter; +import org.apache.camel.spi.BeanIntrospection; +import org.apache.camel.support.IntrospectionSupport; +import org.apache.camel.support.service.ServiceSupport; + +@SuppressWarnings("deprecation") +public class DefaultBeanIntrospection extends ServiceSupport implements BeanIntrospection { + + @Override + public boolean isGetter(Method method) { + return IntrospectionSupport.isGetter(method); + } + + @Override + public String getGetterShorthandName(Method method) { + return IntrospectionSupport.getGetterShorthandName(method); + } + + @Override + public String getSetterShorthandName(Method method) { + return IntrospectionSupport.getSetterShorthandName(method); + } + + @Override + public boolean isSetter(Method method, boolean allowBuilderPattern) { + return IntrospectionSupport.isSetter(method, allowBuilderPattern); + } + + @Override + public boolean isSetter(Method method) { + return IntrospectionSupport.isSetter(method); + } + + @Override + public Map<String, Object> getNonNullProperties(Object target) { + return IntrospectionSupport.getNonNullProperties(target); + } + + @Override + public boolean getProperties(Object target, Map<String, Object> properties, String optionPrefix) { + return IntrospectionSupport.getProperties(target, properties, optionPrefix); + } + + @Override + public boolean getProperties(Object target, Map<String, Object> properties, String optionPrefix, boolean includeNull) { + return IntrospectionSupport.getProperties(target, properties, optionPrefix, includeNull); + } + + @Override + public boolean hasProperties(Map<String, Object> properties, String optionPrefix) { + return IntrospectionSupport.hasProperties(properties, optionPrefix); + } + + @Override + public Object getProperty(Object target, String propertyName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { + return IntrospectionSupport.getProperty(target, propertyName); + } + + @Override + public Object getOrElseProperty(Object target, String propertyName, Object defaultValue) { + return IntrospectionSupport.getOrElseProperty(target, propertyName, defaultValue); + } + + @Override + public Object getOrElseProperty(Object target, String propertyName, Object defaultValue, boolean ignoreCase) { + return IntrospectionSupport.getOrElseProperty(target, propertyName, defaultValue, ignoreCase); + } + + @Override + public Method getPropertyGetter(Class<?> type, String propertyName) throws NoSuchMethodException { + return IntrospectionSupport.getPropertyGetter(type, propertyName); + } + + @Override + public Method getPropertyGetter(Class<?> type, String propertyName, boolean ignoreCase) throws NoSuchMethodException { + return IntrospectionSupport.getPropertyGetter(type, propertyName, ignoreCase); + } + + @Override + public Method getPropertySetter(Class<?> type, String propertyName) throws NoSuchMethodException { + return IntrospectionSupport.getPropertySetter(type, propertyName); + } + + @Override + public boolean isPropertyIsGetter(Class<?> type, String propertyName) { + return IntrospectionSupport.isPropertyIsGetter(type, propertyName); + } + + @Override + @Deprecated + public boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix, boolean allowBuilderPattern) throws Exception { + return IntrospectionSupport.setProperties(target, properties, optionPrefix, allowBuilderPattern); + } + + @Override + @Deprecated + public boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix) throws Exception { + return IntrospectionSupport.setProperties(target, properties, optionPrefix); + } + + @Override + public Map<String, Object> extractProperties(Map<String, Object> properties, String optionPrefix) { + return IntrospectionSupport.extractProperties(properties, optionPrefix); + } + + @Override + public Map<String, Object> extractProperties(Map<String, Object> properties, String optionPrefix, boolean remove) { + return IntrospectionSupport.extractProperties(properties, optionPrefix, remove); + } + + @Override + @Deprecated + public Map<String, String> extractStringProperties(Map<String, Object> properties) { + return IntrospectionSupport.extractStringProperties(properties); + } + + @Override + @Deprecated + public boolean setProperties(CamelContext context, TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception { + return IntrospectionSupport.setProperties(context, typeConverter, target, properties); + } + + @Override + @Deprecated + public boolean setProperties(TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception { + return IntrospectionSupport.setProperties(typeConverter, target, properties); + } + + @Override + @Deprecated + public boolean setProperties(Object target, Map<String, Object> properties) throws Exception { + return IntrospectionSupport.setProperties(target, properties); + } + + @Override + public boolean setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value, String refName, boolean allowBuilderPattern) throws Exception { + return IntrospectionSupport.setProperty(context, typeConverter, target, name, value, refName, allowBuilderPattern); + } + + @Override + public boolean setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value, String refName, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) throws Exception { + return IntrospectionSupport.setProperty(context, typeConverter, target, name, value, refName, allowBuilderPattern, allowPrivateSetter, ignoreCase); + } + + @Override + public boolean setProperty(CamelContext context, Object target, String name, Object value) throws Exception { + return IntrospectionSupport.setProperty(context, target, name, value); + } + + @Override + public boolean setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value) throws Exception { + return IntrospectionSupport.setProperty(context, typeConverter, target, name, value); + } + + @Override + public boolean setProperty(TypeConverter typeConverter, Object target, String name, Object value) throws Exception { + return IntrospectionSupport.setProperty(typeConverter, target, name, value); + } + + @Override + @Deprecated + public boolean setProperty(Object target, String name, Object value, boolean allowBuilderPattern) throws Exception { + return IntrospectionSupport.setProperty(target, name, value, allowBuilderPattern); + } + + @Override + @Deprecated + public boolean setProperty(Object target, String name, Object value) throws Exception { + return IntrospectionSupport.setProperty(target, name, value); + } + + @Override + public Set<Method> findSetterMethods(Class<?> clazz, String name, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) { + return IntrospectionSupport.findSetterMethods(clazz, name, allowBuilderPattern, allowPrivateSetter, ignoreCase); + } + + @Override + protected void doStart() throws Exception { + // noop + } + + @Override + protected void doStop() throws Exception { + IntrospectionSupport.stop(); + } +} diff --git a/core/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java index 7948897..fcff847 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java @@ -27,7 +27,6 @@ import javax.xml.namespace.QName; import org.apache.camel.processor.loadbalancer.LoadBalancer; import org.apache.camel.spi.Metadata; -import org.apache.camel.support.IntrospectionSupport; /** * Balances message processing among a number of nodes diff --git a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java index 131766d..3335e76 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java @@ -42,7 +42,6 @@ import org.apache.camel.model.PropertyDefinition; import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.spi.Metadata; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; @Metadata(label = "routing,cloud") @@ -244,7 +243,7 @@ public class ServiceCallExpressionConfiguration extends IdentifiedType implement try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(this, parameters, null, false); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(this, parameters, null, false); parameters.replaceAll( (k, v) -> { diff --git a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java index 4366890..033dcf0 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java @@ -38,7 +38,6 @@ import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.PropertyDefinition; import org.apache.camel.spi.Metadata; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; import org.apache.camel.util.ObjectHelper; @@ -162,7 +161,7 @@ public class ServiceCallServiceChooserConfiguration extends IdentifiedType imple try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(this, parameters, null, false); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(this, parameters, null, false); parameters.replaceAll( (k, v) -> { diff --git a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java index 81524ac..b2b334a 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java @@ -39,7 +39,6 @@ import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.PropertyDefinition; import org.apache.camel.spi.Metadata; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; import org.apache.camel.util.ObjectHelper; @@ -169,7 +168,7 @@ public class ServiceCallServiceDiscoveryConfiguration extends IdentifiedType imp try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(this, parameters, null, false); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(this, parameters, null, false); parameters.replaceAll( (k, v) -> { diff --git a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java index 5a4c3dc..6b704f7 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java @@ -38,7 +38,6 @@ import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.PropertyDefinition; import org.apache.camel.spi.Metadata; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; import org.apache.camel.util.ObjectHelper; @@ -162,7 +161,7 @@ public class ServiceCallServiceFilterConfiguration extends IdentifiedType implem try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(this, parameters, null, false); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(this, parameters, null, false); parameters.replaceAll( (k, v) -> { diff --git a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java index 07f7c23..417c83e 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java @@ -38,7 +38,6 @@ import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.PropertyDefinition; import org.apache.camel.spi.Metadata; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; import org.apache.camel.util.ObjectHelper; @@ -162,7 +161,7 @@ public class ServiceCallServiceLoadBalancerConfiguration extends IdentifiedType try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(this, parameters, null, false); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(this, parameters, null, false); parameters.replaceAll( (k, v) -> { diff --git a/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java index 4f59766f..b5ec0b6 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java @@ -36,6 +36,7 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.Exchange; import org.apache.camel.Expression; import org.apache.camel.ExpressionFactory; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.NoSuchLanguageException; import org.apache.camel.Predicate; import org.apache.camel.model.DefinitionPropertyPlaceholderConfigurer; @@ -44,7 +45,6 @@ import org.apache.camel.spi.Language; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.RouteContext; import org.apache.camel.support.ExpressionToPredicateAdapter; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.ScriptHelper; import org.apache.camel.util.CollectionStringBuffer; import org.apache.camel.util.ObjectHelper; @@ -329,7 +329,7 @@ public class ExpressionDefinition implements Expression, Predicate, OtherAttribu */ protected void setProperty(CamelContext camelContext, Object bean, String name, Object value) { try { - IntrospectionSupport.setProperty(camelContext, bean, name, value); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(camelContext, bean, name, value); } catch (Exception e) { throw new IllegalArgumentException("Failed to set property " + name + " on " + bean + ". Reason: " + e, e); diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java index 61a9337..ffb7d6f 100644 --- a/core/camel-core/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java +++ b/core/camel-core/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.function.Function; import org.apache.camel.CamelContext; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.model.DataFormatDefinition; import org.apache.camel.model.Model; import org.apache.camel.model.ProcessorDefinitionHelper; @@ -66,7 +67,6 @@ import org.apache.camel.model.dataformat.YAMLDataFormat; import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; import org.apache.camel.model.dataformat.ZipFileDataFormat; import org.apache.camel.spi.DataFormat; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import static org.apache.camel.support.EndpointHelper.isReferenceParameter; @@ -232,9 +232,9 @@ public abstract class DataFormatReifier<T extends DataFormatDefinition> { try { String ref = value instanceof String ? value.toString() : null; if (isReferenceParameter(ref) && camelContext != null) { - IntrospectionSupport.setProperty(camelContext, camelContext.getTypeConverter(), bean, name, null, ref, true); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(camelContext, camelContext.getTypeConverter(), bean, name, null, ref, true); } else { - IntrospectionSupport.setProperty(camelContext, bean, name, value); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(camelContext, bean, name, value); } } catch (Exception e) { throw new IllegalArgumentException("Failed to set property: " + name + " on: " + bean + ". Reason: " + e, e); diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/rest/RestBindingReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/rest/RestBindingReifier.java index 2110edf..4b245b9 100644 --- a/core/camel-core/src/main/java/org/apache/camel/reifier/rest/RestBindingReifier.java +++ b/core/camel-core/src/main/java/org/apache/camel/reifier/rest/RestBindingReifier.java @@ -21,12 +21,12 @@ import java.util.Map; import javax.xml.bind.JAXBContext; import org.apache.camel.CamelContext; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.model.rest.RestBindingDefinition; import org.apache.camel.processor.RestBindingAdvice; import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.RestConfiguration; import org.apache.camel.spi.RouteContext; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; public class RestBindingReifier { @@ -96,8 +96,8 @@ public class RestBindingReifier { clazz = context.getClassResolver().resolveMandatoryClass(typeName); } if (clazz != null) { - IntrospectionSupport.setProperty(context.getTypeConverter(), json, "unmarshalType", clazz); - IntrospectionSupport.setProperty(context.getTypeConverter(), json, "useList", type.endsWith("[]")); + context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context.getTypeConverter(), json, "unmarshalType", clazz); + context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context.getTypeConverter(), json, "useList", type.endsWith("[]")); } setAdditionalConfiguration(config, context, json, "json.in."); @@ -108,8 +108,8 @@ public class RestBindingReifier { outClazz = context.getClassResolver().resolveMandatoryClass(typeName); } if (outClazz != null) { - IntrospectionSupport.setProperty(context.getTypeConverter(), outJson, "unmarshalType", outClazz); - IntrospectionSupport.setProperty(context.getTypeConverter(), outJson, "useList", outType.endsWith("[]")); + context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context.getTypeConverter(), outJson, "unmarshalType", outClazz); + context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context.getTypeConverter(), outJson, "useList", outType.endsWith("[]")); } setAdditionalConfiguration(config, context, outJson, "json.out."); } @@ -147,7 +147,7 @@ public class RestBindingReifier { } if (clazz != null) { JAXBContext jc = JAXBContext.newInstance(clazz); - IntrospectionSupport.setProperty(context.getTypeConverter(), jaxb, "context", jc); + context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context.getTypeConverter(), jaxb, "context", jc); } setAdditionalConfiguration(config, context, jaxb, "xml.in."); @@ -159,11 +159,11 @@ public class RestBindingReifier { } if (outClazz != null) { JAXBContext jc = JAXBContext.newInstance(outClazz); - IntrospectionSupport.setProperty(context.getTypeConverter(), outJaxb, "context", jc); + context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context.getTypeConverter(), outJaxb, "context", jc); } else if (clazz != null) { // fallback and use the context from the input JAXBContext jc = JAXBContext.newInstance(clazz); - IntrospectionSupport.setProperty(context.getTypeConverter(), outJaxb, "context", jc); + context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context.getTypeConverter(), outJaxb, "context", jc); } setAdditionalConfiguration(config, context, outJaxb, "xml.out."); } diff --git a/core/camel-support/src/main/java/org/apache/camel/component/extension/verifier/DefaultComponentVerifierExtension.java b/core/camel-support/src/main/java/org/apache/camel/component/extension/verifier/DefaultComponentVerifierExtension.java index 148111c..66e19f3 100644 --- a/core/camel-support/src/main/java/org/apache/camel/component/extension/verifier/DefaultComponentVerifierExtension.java +++ b/core/camel-support/src/main/java/org/apache/camel/component/extension/verifier/DefaultComponentVerifierExtension.java @@ -25,11 +25,11 @@ import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; import org.apache.camel.Component; import org.apache.camel.ComponentAware; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.component.extension.ComponentVerifierExtension; import org.apache.camel.runtimecatalog.EndpointValidationResult; import org.apache.camel.runtimecatalog.RuntimeCamelCatalog; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; import static org.apache.camel.util.StreamUtils.stream; @@ -194,10 +194,7 @@ public class DefaultComponentVerifierExtension implements ComponentVerifierExten } protected <T> T setProperties(T instance, String prefix, Map<String, Object> properties) throws Exception { - return setProperties( - instance, - IntrospectionSupport.extractProperties(properties, prefix, false) - ); + return setProperties(instance, getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().extractProperties(properties, prefix, false)); } protected <T> Optional<T> getOption(Map<String, Object> parameters, String key, Class<T> type) { diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java index f802404..01e56f78 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java @@ -282,7 +282,7 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone Map<String, Object> param = parameters; if (optionPrefix != null) { - param = IntrospectionSupport.extractProperties(parameters, optionPrefix); + param = getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().extractProperties(parameters, optionPrefix); } if (param.size() > 0) { diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java index 6ebee7f..72174b6 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java @@ -27,6 +27,7 @@ import org.apache.camel.Consumer; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.PollingConsumer; import org.apache.camel.ResolveEndpointFailedException; import org.apache.camel.spi.ExceptionHandler; @@ -395,7 +396,7 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint @Override public void configureProperties(Map<String, Object> options) { - Map<String, Object> consumerProperties = IntrospectionSupport.extractProperties(options, "consumer."); + Map<String, Object> consumerProperties = getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().extractProperties(options, "consumer."); if (consumerProperties != null && !consumerProperties.isEmpty()) { setConsumerProperties(consumerProperties); } diff --git a/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java index b72a4fb..7e5d00f 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java @@ -29,6 +29,7 @@ import org.apache.camel.DelegateEndpoint; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.PollingConsumer; import org.apache.camel.Processor; import org.apache.camel.ResolveEndpointFailedException; @@ -181,7 +182,7 @@ public final class EndpointHelper { Object v = entry.getValue(); String value = v != null ? v.toString() : null; if (isReferenceParameter(value)) { - boolean hit = IntrospectionSupport.setProperty(context, context.getTypeConverter(), bean, name, null, value, true); + boolean hit = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context, context.getTypeConverter(), bean, name, null, value, true); if (hit) { // must remove as its a valid option and we could configure it it.remove(); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java index fe0dd72..61c4069 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java @@ -57,7 +57,10 @@ import static org.apache.camel.util.ObjectHelper.isNotEmpty; * <p/> * This implementation will use a cache when the {@link #getProperties(Object, java.util.Map, String)} * method is being used. Also the {@link #cacheClass(Class)} method gives access to the introspect cache. + * + * @deprecated use {@link org.apache.camel.spi.BeanIntrospection} */ +@Deprecated public final class IntrospectionSupport { private static final Logger LOG = LoggerFactory.getLogger(IntrospectionSupport.class); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java index 9e328f4..ccc40ad 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java @@ -26,15 +26,13 @@ import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Supplier; import org.apache.camel.CamelContext; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.PropertyBindingException; import org.apache.camel.spi.PropertyConfigurer; import org.apache.camel.util.StringHelper; -import static org.apache.camel.support.EndpointHelper.isReferenceParameter; -import static org.apache.camel.support.IntrospectionSupport.findSetterMethods; import static org.apache.camel.util.ObjectHelper.isNotEmpty; /** @@ -342,14 +340,14 @@ public final class PropertyBindingSupport { boolean bindNullOnly, boolean deepNesting, OnAutowiring callback) throws Exception { Map<String, Object> properties = new LinkedHashMap<>(); - IntrospectionSupport.getProperties(target, properties, null); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(target, properties, null); boolean hit = false; for (Map.Entry<String, Object> entry : properties.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); - Class<?> type = getGetterType(target, key, false); + Class<?> type = getGetterType(camelContext, target, key, false); boolean skip = parents.contains(value) || value instanceof CamelContext; if (skip) { @@ -365,7 +363,7 @@ public final class PropertyBindingSupport { if (lookup.size() == 1) { value = lookup.iterator().next(); if (value != null) { - hit |= IntrospectionSupport.setProperty(camelContext, target, key, value); + hit |= camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(camelContext, target, key, value); if (hit && callback != null) { callback.onAutowire(target, key, type, value); } @@ -376,7 +374,7 @@ public final class PropertyBindingSupport { // attempt to create new instances to walk down the tree if its null (deepNesting option) if (value == null && deepNesting) { // okay is there a setter so we can create a new instance and set it automatic - Method method = findBestSetterMethod(target.getClass(), key, true, true, false); + Method method = findBestSetterMethod(camelContext, target.getClass(), key, true, true, false); if (method != null) { Class<?> parameterType = method.getParameterTypes()[0]; if (parameterType != null && org.apache.camel.util.ObjectHelper.hasDefaultPublicNoArgConstructor(parameterType)) { @@ -550,14 +548,14 @@ public final class PropertyBindingSupport { // we should only iterate until until 2nd last so we use -1 in the for loop for (int i = 0; i < parts.length - 1; i++) { String part = parts[i]; - Object prop = getOrElseProperty(newTarget, part, null, ignoreCase); + Object prop = getOrElseProperty(context, newTarget, part, null, ignoreCase); if (prop == null) { if (!deepNesting) { // okay we cannot go further down break; } // okay is there a setter so we can create a new instance and set it automatic - Method method = findBestSetterMethod(newClass, part, fluentBuilder, allowPrivateSetter, ignoreCase); + Method method = findBestSetterMethod(context, newClass, part, fluentBuilder, allowPrivateSetter, ignoreCase); if (method != null) { Class<?> parameterType = method.getParameterTypes()[0]; Object instance = null; @@ -620,7 +618,7 @@ public final class PropertyBindingSupport { } } else if (value.toString().equals("#autowired")) { // we should get the type from the setter - Method method = findBestSetterMethod(target.getClass(), name, fluentBuilder, allowPrivateSetter, ignoreCase); + Method method = findBestSetterMethod(context, target.getClass(), name, fluentBuilder, allowPrivateSetter, ignoreCase); if (method != null) { Class<?> parameterType = method.getParameterTypes()[0]; Set<?> types = context.getRegistry().findByType(parameterType); @@ -641,7 +639,7 @@ public final class PropertyBindingSupport { } } - boolean hit = IntrospectionSupport.setProperty(context, context.getTypeConverter(), target, name, value, refName, fluentBuilder, allowPrivateSetter, ignoreCase); + boolean hit = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context, context.getTypeConverter(), target, name, value, refName, fluentBuilder, allowPrivateSetter, ignoreCase); if (!hit && mandatory) { // there is no setter with this given name, so lets report this as a problem throw new IllegalArgumentException("Cannot find setter method: " + name + " on bean: " + target + " of type: " + target.getClass().getName() + " when binding property: " + ognlPath); @@ -649,7 +647,7 @@ public final class PropertyBindingSupport { return hit; } - private static Object getOrElseProperty(Object target, String property, Object defaultValue, boolean ignoreCase) { + private static Object getOrElseProperty(CamelContext context, Object target, String property, Object defaultValue, boolean ignoreCase) { String key = property; String lookupKey = null; @@ -660,7 +658,7 @@ public final class PropertyBindingSupport { key = property.substring(0, pos); } - Object answer = IntrospectionSupport.getOrElseProperty(target, key, defaultValue, ignoreCase); + Object answer = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getOrElseProperty(target, key, defaultValue, ignoreCase); if (answer instanceof Map && lookupKey != null) { Map map = (Map) answer; answer = map.getOrDefault(lookupKey, defaultValue); @@ -681,17 +679,17 @@ public final class PropertyBindingSupport { return answer != null ? answer : defaultValue; } - private static Method findBestSetterMethod(Class clazz, String name, + private static Method findBestSetterMethod(CamelContext context, Class clazz, String name, boolean fluentBuilder, boolean allowPrivateSetter, boolean ignoreCase) { // is there a direct setter? - Set<Method> candidates = findSetterMethods(clazz, name, false, allowPrivateSetter, ignoreCase); + Set<Method> candidates = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().findSetterMethods(clazz, name, false, allowPrivateSetter, ignoreCase); if (candidates.size() == 1) { return candidates.iterator().next(); } // okay now try with builder pattern if (fluentBuilder) { - candidates = findSetterMethods(clazz, name, fluentBuilder, allowPrivateSetter, ignoreCase); + candidates = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().findSetterMethods(clazz, name, fluentBuilder, allowPrivateSetter, ignoreCase); if (candidates.size() == 1) { return candidates.iterator().next(); } @@ -700,15 +698,15 @@ public final class PropertyBindingSupport { return null; } - private static Class getGetterType(Object target, String name, boolean ignoreCase) { + private static Class getGetterType(CamelContext context, Object target, String name, boolean ignoreCase) { try { if (ignoreCase) { - Method getter = IntrospectionSupport.getPropertyGetter(target.getClass(), name, true); + Method getter = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getPropertyGetter(target.getClass(), name, true); if (getter != null) { return getter.getReturnType(); } } else { - Method getter = IntrospectionSupport.getPropertyGetter(target.getClass(), name); + Method getter = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getPropertyGetter(target.getClass(), name); if (getter != null) { return getter.getReturnType(); } @@ -739,7 +737,7 @@ public final class PropertyBindingSupport { String value = v != null ? v.toString() : null; if (isReferenceParameter(value)) { try { - boolean hit = IntrospectionSupport.setProperty(context, context.getTypeConverter(), target, name, null, value, true); + boolean hit = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(context, context.getTypeConverter(), target, name, null, value, true); if (hit) { // must remove as its a valid option and we could configure it it.remove(); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java index c620048..098ff92 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.FailedToCreateConsumerException; import org.apache.camel.LoggingLevel; import org.apache.camel.PollingConsumerPollingStrategy; @@ -419,7 +420,7 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements R // configure scheduler with options from this consumer Map<String, Object> properties = new LinkedHashMap<>(); - IntrospectionSupport.getProperties(this, properties, null); + getEndpoint().getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(this, properties, null); PropertyBindingSupport.build().bind(getEndpoint().getCamelContext(), scheduler, properties); if (schedulerProperties != null && !schedulerProperties.isEmpty()) { // need to use a copy in case the consumer is restarted so we keep the properties diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollEndpoint.java b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollEndpoint.java index f9a846c..4d06813 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollEndpoint.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollEndpoint.java @@ -22,6 +22,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.apache.camel.Component; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.LoggingLevel; import org.apache.camel.PollingConsumer; import org.apache.camel.ResolveEndpointFailedException; @@ -107,7 +108,7 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint { protected void configureScheduledPollConsumerProperties(Map<String, Object> options, Map<String, Object> consumerProperties) { // special for scheduled poll consumers as we want to allow end users to configure its options // from the URI parameters without the consumer. prefix - Map<String, Object> schedulerProperties = IntrospectionSupport.extractProperties(options, "scheduler."); + Map<String, Object> schedulerProperties = getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().extractProperties(options, "scheduler."); if (schedulerProperties != null && !schedulerProperties.isEmpty()) { setSchedulerProperties(schedulerProperties); } diff --git a/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java index ef8abc9..00cc314 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java @@ -31,6 +31,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.CamelExecutionException; import org.apache.camel.Exchange; import org.apache.camel.Expression; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.InvalidPayloadException; import org.apache.camel.Message; import org.apache.camel.NoSuchLanguageException; @@ -44,7 +45,6 @@ import org.apache.camel.support.ExchangeHelper; import org.apache.camel.support.ExpressionAdapter; import org.apache.camel.support.GroupIterator; import org.apache.camel.support.GroupTokenIterator; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.LanguageSupport; import org.apache.camel.util.IOHelper; import org.apache.camel.util.ObjectHelper; @@ -1417,7 +1417,7 @@ public class ExpressionBuilder { protected static void setProperty(CamelContext camelContext, Object bean, String name, Object value) { try { - IntrospectionSupport.setProperty(camelContext, bean, name, value); + camelContext.getExtension(ExtendedCamelContext.class).getBeanIntrospection().setProperty(camelContext, bean, name, value); } catch (Exception e) { throw new IllegalArgumentException("Failed to set property " + name + " on " + bean + ". Reason: " + e, e); } diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java index ad68368..84a9077 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiComponent.java @@ -23,9 +23,9 @@ import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelException; import org.apache.camel.Endpoint; +import org.apache.camel.ExtendedCamelContext; import org.apache.camel.spi.Metadata; import org.apache.camel.support.DefaultComponent; -import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.support.PropertyBindingSupport; /** @@ -108,7 +108,7 @@ public abstract class AbstractApiComponent<E extends Enum<E> & ApiName, T, S ext final Map<String, Object> componentProperties = new HashMap<>(); // copy component configuration, if set if (configuration != null) { - IntrospectionSupport.getProperties(configuration, componentProperties, null, false); + getCamelContext().getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperties(configuration, componentProperties, null, false); } // create endpoint configuration with component properties 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 d6674aa..0aca298 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 @@ -89,8 +89,8 @@ public abstract class ApiMethodPropertiesHelper<C> { } public void getEndpointProperties(Object endpointConfiguration, Map<String, Object> properties) { - Set<String> names = null; + // TODO: camel context if (IntrospectionSupport.getProperties(endpointConfiguration, properties, null, false)) { names = properties.keySet(); // remove component config properties so we only have endpoint properties diff --git a/core/camel-support/src/main/java/org/apache/camel/support/jndi/JndiContext.java b/core/camel-support/src/main/java/org/apache/camel/support/jndi/JndiContext.java index d926508..b185713 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/jndi/JndiContext.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/jndi/JndiContext.java @@ -441,6 +441,7 @@ public class JndiContext implements Context, Serializable { } } + @Deprecated protected static Object createBean(Class<?> type, Map<String, Object> properties, String prefix) throws Exception { Object value = ObjectHelper.newInstance(type); IntrospectionSupport.setProperties(value, properties, prefix); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java b/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java index 1a790be..924e326 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java @@ -190,6 +190,7 @@ public class MBeanInfoAssembler implements Service { LOG.trace("Extracting attributes and operations from class: {}", managedClass); // introspect the class, and leverage the cache to have better performance + // TODO: get this via camel context IntrospectionSupport.ClassInfo cache = IntrospectionSupport.cacheClass(managedClass); for (IntrospectionSupport.MethodInfo cacheInfo : cache.methods) {
