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
The following commit(s) were added to refs/heads/CAMEL-13870 by this push: new b1ae9c6 CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress. b1ae9c6 is described below commit b1ae9c61e7059687d9b109b8dc213591d3393cf8 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Aug 22 13:54:52 2019 +0200 CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress. --- .../org/apache/camel/spi/BeanIntrospection.java | 77 ++------------ .../impl/engine/DefaultBeanIntrospection.java | 115 --------------------- .../management/ManagedBeanIntrospectionTest.java | 2 +- 3 files changed, 7 insertions(+), 187 deletions(-) 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 a116ab7..74d8b94 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 @@ -1,13 +1,13 @@ -/** +/* * 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> + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * 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. @@ -16,7 +16,6 @@ */ package org.apache.camel.spi; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; import java.util.Set; @@ -27,7 +26,8 @@ import org.apache.camel.StaticService; import org.apache.camel.TypeConverter; import org.apache.camel.meta.Experimental; -// TODO: Keep only public used methods so we can remove the tech debt +// TODO: Add javadoc for methods +// TODO: Consolidate some of the methods /** * Used for introspecting beans properties via Java reflection; such as extracting current property values, @@ -95,27 +95,6 @@ public interface BeanIntrospection extends StaticService { // Introspection // ---------------------------------------------------- - boolean isGetter(Method method); - - String getGetterShorthandName(Method method); - - String getSetterShorthandName(Method method); - - boolean isSetter(Method method, boolean allowBuilderPattern); - - boolean isSetter(Method method); - - /** - * Will inspect the target for properties. - * <p/> - * Notice a property must have both a getter/setter method to be included. - * Notice all <tt>null</tt> values won't be included. - * - * @param target the target bean - * @return the map with found properties - */ - Map<String, Object> getNonNullProperties(Object target); - /** * Will inspect the target for properties. * <p/> @@ -150,8 +129,6 @@ public interface BeanIntrospection extends StaticService { */ ClassInfo cacheClass(Class<?> clazz); - Object getProperty(Object target, String propertyName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException; - Object getOrElseProperty(Object target, String propertyName, Object defaultValue); Object getOrElseProperty(Object target, String propertyName, Object defaultValue, boolean ignoreCase); @@ -160,40 +137,6 @@ public interface BeanIntrospection extends StaticService { Method getPropertyGetter(Class<?> type, String propertyName, boolean ignoreCase) throws NoSuchMethodException; - Method getPropertySetter(Class<?> type, String propertyName) throws NoSuchMethodException; - - boolean isPropertyIsGetter(Class<?> type, String propertyName); - - /** - * @deprecated use org.apache.camel.support.PropertyBindingSupport - */ - @Deprecated - boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix, boolean allowBuilderPattern) throws Exception; - - /** - * @deprecated use org.apache.camel.support.PropertyBindingSupport - */ - @Deprecated - boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix) throws Exception; - - /** - * @deprecated use org.apache.camel.support.PropertyBindingSupport - */ - @Deprecated - boolean setProperties(CamelContext context, TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception; - - /** - * @deprecated use org.apache.camel.support.PropertyBindingSupport - */ - @Deprecated - boolean setProperties(TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception; - - /** - * @deprecated use org.apache.camel.support.PropertyBindingSupport - */ - @Deprecated - boolean setProperties(Object target, Map<String, Object> properties) throws Exception; - /** * This method supports three modes to set a property: * @@ -226,16 +169,8 @@ public interface BeanIntrospection extends StaticService { 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; - boolean setProperty(TypeConverter typeConverter, Object target, String name, Object value) throws Exception; - @Deprecated - boolean setProperty(Object target, String name, Object value, boolean allowBuilderPattern) throws Exception; - - @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/DefaultBeanIntrospection.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultBeanIntrospection.java index 20936dd..f03286f 100644 --- 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 @@ -16,7 +16,6 @@ */ package org.apache.camel.impl.engine; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; import java.util.Set; @@ -84,36 +83,6 @@ public class DefaultBeanIntrospection extends ServiceSupport implements BeanIntr } @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) { invoked.incrementAndGet(); log("getProperties", target); @@ -128,13 +97,6 @@ public class DefaultBeanIntrospection extends ServiceSupport implements BeanIntr } @Override - public Object getProperty(Object target, String propertyName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - invoked.incrementAndGet(); - log("getProperty", target); - return IntrospectionSupport.getProperty(target, propertyName); - } - - @Override public Object getOrElseProperty(Object target, String propertyName, Object defaultValue) { invoked.incrementAndGet(); log("getOrElseProperty", target); @@ -163,60 +125,6 @@ public class DefaultBeanIntrospection extends ServiceSupport implements BeanIntr } @Override - public Method getPropertySetter(Class<?> type, String propertyName) throws NoSuchMethodException { - invoked.incrementAndGet(); - log("getPropertySetter", type); - return IntrospectionSupport.getPropertySetter(type, propertyName); - } - - @Override - public boolean isPropertyIsGetter(Class<?> type, String propertyName) { - invoked.incrementAndGet(); - log("isPropertyIsGetter", type); - return IntrospectionSupport.isPropertyIsGetter(type, propertyName); - } - - @Override - @Deprecated - public boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix, boolean allowBuilderPattern) throws Exception { - invoked.incrementAndGet(); - log("setProperties", target); - return IntrospectionSupport.setProperties(target, properties, optionPrefix, allowBuilderPattern); - } - - @Override - @Deprecated - public boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix) throws Exception { - invoked.incrementAndGet(); - log("setProperties", target); - return IntrospectionSupport.setProperties(target, properties, optionPrefix); - } - - @Override - @Deprecated - public boolean setProperties(CamelContext context, TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception { - invoked.incrementAndGet(); - log("setProperties", target); - return IntrospectionSupport.setProperties(context, typeConverter, target, properties); - } - - @Override - @Deprecated - public boolean setProperties(TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception { - invoked.incrementAndGet(); - log("setProperties", target); - return IntrospectionSupport.setProperties(typeConverter, target, properties); - } - - @Override - @Deprecated - public boolean setProperties(Object target, Map<String, Object> properties) throws Exception { - invoked.incrementAndGet(); - log("setProperties", target); - 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 { invoked.incrementAndGet(); log("setProperty", target); @@ -238,13 +146,6 @@ public class DefaultBeanIntrospection extends ServiceSupport implements BeanIntr } @Override - public boolean setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value) throws Exception { - invoked.incrementAndGet(); - log("setProperty", target); - return IntrospectionSupport.setProperty(context, typeConverter, target, name, value); - } - - @Override public boolean setProperty(TypeConverter typeConverter, Object target, String name, Object value) throws Exception { invoked.incrementAndGet(); log("setProperty", target); @@ -252,22 +153,6 @@ public class DefaultBeanIntrospection extends ServiceSupport implements BeanIntr } @Override - @Deprecated - public boolean setProperty(Object target, String name, Object value, boolean allowBuilderPattern) throws Exception { - invoked.incrementAndGet(); - log("setProperty", target); - return IntrospectionSupport.setProperty(target, name, value, allowBuilderPattern); - } - - @Override - @Deprecated - public boolean setProperty(Object target, String name, Object value) throws Exception { - invoked.incrementAndGet(); - log("setProperty", target); - return IntrospectionSupport.setProperty(target, name, value); - } - - @Override public Set<Method> findSetterMethods(Class<?> clazz, String name, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) { invoked.incrementAndGet(); log("findSetterMethods", clazz); diff --git a/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedBeanIntrospectionTest.java b/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedBeanIntrospectionTest.java index 336ec46..93596d6 100644 --- a/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedBeanIntrospectionTest.java +++ b/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedBeanIntrospectionTest.java @@ -65,7 +65,7 @@ public class ManagedBeanIntrospectionTest extends ManagementTestSupport { Long counter = (Long) mbeanServer.getAttribute(on, "InvokedCounter"); assertEquals("Should not have been invoked", 0, counter.intValue()); - Object dummy = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getProperty(this, "dummy"); + Object dummy = context.getExtension(ExtendedCamelContext.class).getBeanIntrospection().getOrElseProperty(this, "dummy", null); assertEquals("MyDummy", dummy); counter = (Long) mbeanServer.getAttribute(on, "InvokedCounter");