public void addMethods(final String path, final Collection<MethodAccess> methods) { /* Only add methods that could be REST endpoints. */ methods.stream().filter(methodAccess -> !methodAccess.isPrivate() && //No private methods !methodAccess.isStatic() && //No static methods !methodAccess.method().isSynthetic() && //No synthetic methods !methodAccess.method().getDeclaringClass().getName().contains("$$EnhancerByGuice$$") && !methodAccess.name().contains("$")) //No methods with $ as this could be Scala generated // method or byte code lib generated .forEach(methodAccess -> addMethod(path, methodAccess)); }
final Object[] inputParams, final List<Object> preparedArgumentList) { final Class<?>[] parameterTypes = serviceMethod.method().getParameterTypes();
final Class<?>[] parameterTypes = serviceMethod.method().getParameterTypes(); if (serviceMethod.method().getReturnType() == void.class && (list.size() - 1 == serviceMethod.parameterTypes().length)) { if (parameterTypes[0] == Callback.class) { list = Lists.slc(list, 1); //remove the callback from the args bc the callback is called
if (Collection.class.isAssignableFrom(returnType)) { genericReturnType = GenericReturnType.COLLECTION; ParameterizedType genericReturnType = (ParameterizedType) methodAccess.method().getGenericReturnType(); this.returnTypeComponent = (Class) genericReturnType.getActualTypeArguments()[0]; } else if (Map.class.isAssignableFrom(returnType)) { genericReturnType = GenericReturnType.MAP; ParameterizedType genericReturnType = (ParameterizedType) methodAccess.method().getGenericReturnType(); this.returnTypeComponentKey = (Class) genericReturnType.getActualTypeArguments()[0]; this.returnTypeComponentValue = (Class) genericReturnType.getActualTypeArguments()[1]; } else if (Optional.class.isAssignableFrom(returnType)) { genericReturnType = GenericReturnType.OPTIONAL; ParameterizedType genericReturnType = (ParameterizedType) methodAccess.method().getGenericReturnType(); this.returnTypeComponent = (Class) genericReturnType.getActualTypeArguments()[0]; } else if (JSendResponse.class.isAssignableFrom(returnType)) { genericReturnType = GenericReturnType.JSEND; ParameterizedType genericReturnType = (ParameterizedType) methodAccess.method().getGenericReturnType();
private void deduceReturnInfoFromCallbackArg() { Type[] genericParameterTypes = methodAccess.method().getGenericParameterTypes(); Type callback = genericParameterTypes[0]; if (callback instanceof ParameterizedType) {
public ServiceBuilder setServiceObject(final Object serviceObject) { if (serviceObject == null) { throw new IllegalArgumentException("ServiceBuilder setServiceObject:: serviceObject cant be null"); } ClassMeta<?> classMeta = ClassMeta.classMeta(serviceObject.getClass()); Iterable<MethodAccess> methods = classMeta.methods(); Set<String> methodNames = new HashSet<>(); for (MethodAccess methodAccess : methods) { if (methodAccess.isPrivate() || methodAccess.method().getDeclaringClass().getName().contains("$$EnhancerByGuice$$")) { continue; } if (methodNames.contains(methodAccess.name())) { logger.error("QBit does not support method overloading methods in Service Queues" + " problem name " + methodAccess.name() + " is overloaded " + methodNames + " from class " + classMeta.longName()); } else { methodNames.add(methodAccess.name()); } } this.serviceObject = serviceObject; return this; }
final Class<?>[] parameterTypes = methodAccess.method().getParameterTypes();
private <T> Map<String, String> createMethodToChannelMap(final String channelPrefix, final Class<T> eventBusProxyInterface) { final Map<String, String> methodToChannelMap = new ConcurrentHashMap<>(20); final ClassMeta<T> classMeta = classMeta(eventBusProxyInterface); final AnnotationData classAnnotation = classMeta.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); final String classEventBusName = AnnotationUtils.getClassEventChannelName(classMeta, classAnnotation); classMeta.methods().forEach(methodAccess -> { AnnotationData methodAnnotation = methodAccess.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); String methodEventBusName = methodAnnotation != null && methodAnnotation.getValues().get("value") != null ? methodAnnotation.getValues().get("value").toString() : null; if (Str.isEmpty(methodEventBusName)) { methodEventBusName = methodAccess.name(); } final String channelName = createChannelName(channelPrefix, classEventBusName, methodEventBusName); methodToChannelMap.put(methodAccess.method().toString(), channelName); }); return methodToChannelMap; }
Type t0 = method.method().getGenericReturnType(); if (t0 instanceof ParameterizedType) { ParameterizedType parameterizedType = ((ParameterizedType) t0);
private void extractPathsFromRequestMetaList(final String servicePath, final Map<String, PathBuilder> pathBuilderMap, final List<ServiceMethodMeta> methodMetas) { for (ServiceMethodMeta methodMeta : methodMetas) { final List<RequestMeta> requestEndpoints = methodMeta.getRequestEndpoints(); final MethodAccess methodAccess = methodMeta.getMethodAccess(); if (methodAccess.method().isSynthetic()) { continue; } if (methodAccess.annotation("HideMethod") != null) { continue; } for (RequestMeta requestMeta : requestEndpoints) { final String requestURI = (servicePath + requestMeta.getRequestURI()).replaceAll("//", "/"); final PathBuilder pathBuilder = createPathBuilderIfAbsent(pathBuilderMap, requestURI); final List<RequestMethod> requestMethods = requestMeta.getRequestMethods(); for (RequestMethod requestMethod : requestMethods) { /* If one fails, we want to continue processing. */ try { extractPathFromRequestMeta(methodMeta, methodAccess, requestMeta, pathBuilder, requestMethod); } catch (Exception ex) { logger.warn("Problem processing path {} {}", requestURI, methodAccess.name()); logger.debug("Problem processing path", ex); } } } } }
public Method invokeReducerLongIntReturnLongMethod(Object object, String methodName) { MethodAccess methodAccess; methodAccess = methodMap.get(methodName); return methodAccess.method(); }
public Method invokeReducerLongIntReturnLongMethod(Object object, String methodName) { MethodAccess methodAccess; methodAccess = methodMap.get(methodName); return methodAccess.method(); }
public Method invokeReducerLongIntReturnLongMethod(Object object) { MethodAccess methodAccess; if (methods.size()==1) { methodAccess = methods.get(0); } else { methodAccess = methodMap.get("reduce"); } return methodAccess.method(); }
public Method invokeReducerLongIntReturnLongMethod(Object object) { MethodAccess methodAccess; if (methods.size()==1) { methodAccess = methods.get(0); } else { methodAccess = methodMap.get("reduce"); } return methodAccess.method(); }
public void addMethods(final String path, final Collection<MethodAccess> methods) { /* Only add methods that could be REST endpoints. */ methods.stream().filter(methodAccess -> !methodAccess.isPrivate() && //No private methods !methodAccess.isStatic() && //No static methods !methodAccess.method().isSynthetic() && //No synthetic methods !methodAccess.method().getDeclaringClass().getName().contains("$$EnhancerByGuice$$") && !methodAccess.name().contains("$")) //No methods with $ as this could be Scala generated // method or byte code lib generated .forEach(methodAccess -> addMethod(path, methodAccess)); }
public void addMethods(final String path, final Collection<MethodAccess> methods) { /* Only add methods that could be REST endpoints. */ methods.stream().filter(methodAccess -> !methodAccess.isPrivate() && //No private methods !methodAccess.isStatic() && //No static methods !methodAccess.method().isSynthetic() && //No synthetic methods !methodAccess.name().contains("$")) //No methods with $ as this could be Scala generated // method or byte code lib generated .forEach(methodAccess -> addMethod(path, methodAccess)); }
public ServiceBuilder setServiceObject(final Object serviceObject) { if (serviceObject == null) { throw new IllegalArgumentException("ServiceBuilder setServiceObject:: serviceObject cant be null"); } ClassMeta<?> classMeta = ClassMeta.classMeta(serviceObject.getClass()); Iterable<MethodAccess> methods = classMeta.methods(); Set<String> methodNames = new HashSet<>(); for (MethodAccess methodAccess : methods) { if (methodAccess.isPrivate()) { continue; } if (methodAccess.method().getDeclaringClass().isInterface()) { continue; } if (methodNames.contains(methodAccess.name())) { logger.error("QBit does not support method overloading methods in Service Queues" + " problem name " + methodAccess.name() + " is overloaded " + methodNames + " from class " + classMeta.longName()); } else { methodNames.add(methodAccess.name()); } } this.serviceObject = serviceObject; return this; }
private <T> Map<String, String> createMethodToChannelMap(final String channelPrefix, final Class<T> eventBusProxyInterface) { final Map<String, String> methodToChannelMap = new ConcurrentHashMap<>(20); final ClassMeta<T> classMeta = classMeta(eventBusProxyInterface); final AnnotationData classAnnotation = classMeta.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); final String classEventBusName = AnnotationUtils.getClassEventChannelName(classMeta, classAnnotation); classMeta.methods().forEach(methodAccess -> { AnnotationData methodAnnotation = methodAccess.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); String methodEventBusName = methodAnnotation != null && methodAnnotation.getValues().get("value") != null ? methodAnnotation.getValues().get("value").toString() : null; if (Str.isEmpty(methodEventBusName)) { methodEventBusName = methodAccess.name(); } final String channelName = createChannelName(channelPrefix, classEventBusName, methodEventBusName); methodToChannelMap.put(methodAccess.method().toString(), channelName); }); return methodToChannelMap; }
private <T> Map<String, String> createMethodToChannelMap(final String channelPrefix, final Class<T> eventBusProxyInterface) { final Map<String, String> methodToChannelMap = new ConcurrentHashMap<>(20); final ClassMeta<T> classMeta = classMeta(eventBusProxyInterface); final AnnotationData classAnnotation = classMeta.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); final String classEventBusName = AnnotationUtils.getClassEventChannelName(classMeta, classAnnotation); classMeta.methods().forEach(methodAccess -> { AnnotationData methodAnnotation = methodAccess.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); String methodEventBusName = methodAnnotation != null && methodAnnotation.getValues().get("value") != null ? methodAnnotation.getValues().get("value").toString() : null; if (Str.isEmpty(methodEventBusName)) { methodEventBusName = methodAccess.name(); } final String channelName = createChannelName(channelPrefix, classEventBusName, methodEventBusName); methodToChannelMap.put(methodAccess.method().toString(), channelName); }); return methodToChannelMap; }