public void deleteObject(Session session, Object entityBean) { ObjectHelper.invokeMethod(method, entityBean); } };
@Override public void deleteObject(EntityManager entityManager, Object entityBean, Exchange exchange) { // The entityBean could be an Object array if (entityType.isInstance(entityBean)) { if (useExchangeParameter) { ObjectHelper.invokeMethod(method, entityBean, exchange); } else { ObjectHelper.invokeMethod(method, entityBean); } } } };
public void deleteObject(EntityManager entityManager, Object entityBean, Exchange exchange) { if (entityType.isInstance(entityBean)) { if (useExchangeParameter) { ObjectHelper.invokeMethod(method, entityBean, exchange); } else { ObjectHelper.invokeMethod(method, entityBean); } } } };
public String retrieveValue(String key) { Object v = ObjectHelper.invokeMethod(method, delegate, key); return v == null ? null : v.toString(); }
private void setExchangeInJob(Exchange exchange) { try { final Method setExchangeMethod = job.getClass().getMethod("setExchange", new Class[]{Exchange.class}); LOG.debug("Pass the exchange from route to Job"); ObjectHelper.invokeMethod(setExchangeMethod, job, exchange); } catch (NoSuchMethodException e) { LOG.debug("No setExchange(exchange) method found in Job, the message data will be ignored"); } }
private void setExchangeInJob(Exchange exchange) { try { final Method setExchangeMethod = job.getClass().getMethod("setExchange", new Class[]{Exchange.class}); LOG.debug("Pass the exchange from route to Job"); ObjectHelper.invokeMethod(setExchangeMethod, job, exchange); } catch (NoSuchMethodException e) { LOG.debug("No setExchange(exchange) method found in Job, the message data will be ignored"); } }
protected void setterBeanInjection(Method method, String name, Object bean, String beanName) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes != null) { if (parameterTypes.length != 1) { LOG.warn("Ignoring badly annotated method for injection due to incorrect number of parameters: {}", method); } else { Object value = getInjectionBeanValue(parameterTypes[0], name); ObjectHelper.invokeMethod(method, bean, value); } } }
@SuppressWarnings({"rawtypes"}) public static Object invokeSyncMethod(Object syncClient, String invokeMethod, Object request) { Object[] params = convertObjects2Primitives(request, null); Class[] paramsTypes = (Class[])params[0]; Object[] paramsValues = (Object[])params[1]; Method method = ReflectionHelper.findMethod(syncClient.getClass(), invokeMethod, paramsTypes); if (method == null) { throw new IllegalArgumentException("Thrift service client method not found: " + syncClient.getClass().getName() + "." + invokeMethod + printParamsTypes(paramsTypes)); } Object result = ObjectHelper.invokeMethod(method, syncClient, paramsValues); return result; }
protected void setterInjection(Method method, Object bean, String beanName, String endpointUri, String endpointRef, String endpointProperty) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes != null) { if (parameterTypes.length != 1) { LOG.warn("Ignoring badly annotated method for injection due to incorrect number of parameters: {}", method); } else { String propertyName = ObjectHelper.getPropertyName(method); Object value = getInjectionValue(parameterTypes[0], endpointUri, endpointRef, endpointProperty, propertyName, bean, beanName); ObjectHelper.invokeMethod(method, bean, value); } } }
protected void setterPropertyInjection(Method method, String propertyValue, String propertyDefaultValue, Object bean, String beanName) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes != null) { if (parameterTypes.length != 1) { LOG.warn("Ignoring badly annotated method for injection due to incorrect number of parameters: {}", method); } else { String propertyName = ObjectHelper.getPropertyName(method); Object value = getInjectionPropertyValue(parameterTypes[0], propertyValue, propertyDefaultValue, propertyName, bean, beanName); ObjectHelper.invokeMethod(method, bean, value); } } }
@SuppressWarnings({"rawtypes"}) public static void invokeAsyncMethod(Object asyncClient, String invokeMethod, Object request, AsyncClientMethodCallback methodCallback) { Object[] params = convertObjects2Primitives(request, methodCallback); Class[] paramsTypes = (Class[])params[0]; Object[] paramsValues = (Object[])params[1]; Method method = ReflectionHelper.findMethod(asyncClient.getClass(), invokeMethod, paramsTypes); if (method == null) { throw new IllegalArgumentException("Thrift service client method not found: " + asyncClient.getClass().getName() + "." + invokeMethod + printParamsTypes(paramsTypes)); } ObjectHelper.invokeMethod(method, asyncClient, paramsValues); }
@SuppressWarnings({"rawtypes", "unchecked"}) public static Object constructAsyncClientInstance(String packageName, String serviceName, TNonblockingTransport transport, ThriftExchangeProtocol exchangeProtocol, final CamelContext context) { Object asynClientInstance = null; Class[] getterParamTypes = {TNonblockingTransport.class}; Class[] constructorParamTypes = {TAsyncClientManager.class, TProtocolFactory.class}; String clientClassName = packageName + "." + serviceName + "$" + ThriftConstants.THRIFT_ASYNC_CLIENT_CLASS_NAME + "$" + ThriftConstants.THRIFT_ASYNC_CLIENT_FACTORY_NAME; try { Class clientClass = context.getClassResolver().resolveMandatoryClass(clientClassName); Constructor factoryConstructor = clientClass.getConstructor(constructorParamTypes); Object factoryInstance = factoryConstructor.newInstance(new TAsyncClientManager(), constructAsyncProtocol(exchangeProtocol)); Method asyncClientGetter = ReflectionHelper.findMethod(clientClass, ThriftConstants.THRIFT_ASYNC_CLIENT_GETTER_NAME, getterParamTypes); if (asyncClientGetter == null) { throw new IllegalArgumentException("Thrift async client getter not found: " + clientClassName + "." + ThriftConstants.THRIFT_ASYNC_CLIENT_GETTER_NAME); } asynClientInstance = ObjectHelper.invokeMethod(asyncClientGetter, factoryInstance, transport); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Thrift sync client class not found: " + clientClassName); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Thrift sync client factory class not found: " + clientClassName); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | IOException | SecurityException e) { throw new IllegalArgumentException(e); } return asynClientInstance; }
value = ObjectHelper.invokeMethod(m, null, value); } else { value = ObjectHelper.invokeMethod(m, value);
Method method = converterClass.getMethod("setXStream", new Class[]{XStream.class}); if (method != null) { ObjectHelper.invokeMethod(method, converter, xstream);
value = ObjectHelper.invokeMethod(m, null, value); } else { value = ObjectHelper.invokeMethod(m, value);