List<LunchRestaurant> getLunchRestaurants(@AstrixPartitionedRouting String... restaurantNames); }
private Class<? extends RemoteResultReducer<?>> getReducer(AstrixPartitionedRouting partitionBy, Method targetServiceMethod) { Class<? extends RemoteResultReducer<?>> reducerType = (Class<? extends RemoteResultReducer<?>>) partitionBy.reducer(); RemotingProxyUtil.validateRemoteResultReducer(targetServiceMethod, reducerType); return reducerType; }
private PartitionedRouter createRouter(AstrixPartitionedRouting partitionedRouting) { Class<?> elementType = this.partitionedArgumentContainerType.getElementType(); if (!partitionedRouting.routingMethod().isEmpty()) { Method routingMethod; try { routingMethod = elementType.getMethod(partitionedRouting.routingMethod()); return PartitionedRouter.routingMethod(routingMethod); } catch (NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException("Failed to find routing method for partitioned routing:\n" + "service: " + ReflectionUtil.fullMethodName(proxiedMethod) + "\n" + "@AstrixPartitionedRouting.routingMethod: " + partitionedRouting.routingMethod(), e); } } return PartitionedRouter.identity(); }
private ContainerType getPartitionedArgumentContainerType(Method proxiedMethod, AstrixPartitionedRouting partitionBy) { Class<?> partitionedArgumentType = proxiedMethod.getParameterTypes()[partitionedArgumentIndex]; if (partitionedArgumentType.isArray()) { return new ArrayContainerType(partitionedArgumentType.getComponentType()); } Class<? extends Collection<?>> collectionFactory = (Class<? extends Collection<?>>) partitionBy.collectionFactory(); if (!proxiedMethod.getParameterTypes()[partitionedArgumentIndex].isAssignableFrom(collectionFactory)) { throw new IllegalArgumentException(String.format("Collection class supplied by @AstrixPartitionedRouting is not " + "compatible with argument type, argumentType=%s classType=%s", proxiedMethod.getParameterTypes()[partitionedArgumentIndex].getName(), collectionFactory)); } Type rawType = proxiedMethod.getGenericParameterTypes()[partitionedArgumentIndex]; if (!(rawType instanceof ParameterizedType)) { throw new IllegalArgumentException("Illegal service method: " + ReflectionUtil.fullMethodName(proxiedMethod) + ".\nWhen defining a routingMethod for @AstrixPartitionedRouting the target Collection type must not be a raw type. \nwas: " + rawType); } ParameterizedType partitionedArgumentTypeParameters = (ParameterizedType) rawType; return new CollectionContainerType(collectionFactory, (Class<?>)partitionedArgumentTypeParameters.getActualTypeArguments()[0]); }