List of usage examples for org.springframework.util Assert notEmpty
public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier)
From source file:org.springframework.integration.gemfire.inbound.ContinuousQueryMessageProducer.java
public void setSupportedEventTypes(CqEventType... eventTypes) { Assert.notEmpty(eventTypes, "eventTypes must not be empty"); this.supportedEventTypes = new HashSet<CqEventType>(Arrays.asList(eventTypes)); }
From source file:org.springframework.integration.history.MessageHistory.java
private MessageHistory(List<Properties> components) { Assert.notEmpty(components, "component list must not be empty"); this.components = components; }
From source file:org.springframework.integration.history.MessageHistoryConfigurer.java
public void setComponentNamePatterns(String[] componentNamePatterns) { Assert.notEmpty(componentNamePatterns, "componentNamePatterns must not be empty"); this.componentNamePatterns = componentNamePatterns; }
From source file:org.springframework.integration.ip.tcp.connection.FailoverClientConnectionFactory.java
public FailoverClientConnectionFactory(List<AbstractClientConnectionFactory> factories) { super("", 0); Assert.notEmpty(factories, "At least one factory is required"); this.factories = factories; }
From source file:org.springframework.integration.jpa.support.parametersource.ExpressionEvaluatingParameterSourceFactory.java
/** * Define the (optional) parameter values. * @param parameters the parameters to be set *//* w w w.ja v a 2 s . c o m*/ public void setParameters(List<JpaParameter> parameters) { Assert.notEmpty(parameters, "parameters must not be null or empty."); for (JpaParameter parameter : parameters) { Assert.notNull(parameter, "The provided list (parameters) cannot contain null values."); } this.parameters = parameters; this.expressionEvaluator.getEvaluationContext().setVariable("staticParameters", ExpressionEvaluatingParameterSourceUtils.convertStaticParameters(parameters)); }
From source file:org.springframework.integration.kafka.listener.ConcurrentMessageListenerDispatcher.java
public ConcurrentMessageListenerDispatcher(Object delegateListener, ErrorHandler errorHandler, Collection<Partition> partitions, OffsetManager offsetManager, int consumers, int queueSize, Executor taskExecutor) {// w w w.j av a2s . com Assert.isTrue( delegateListener instanceof MessageListener || delegateListener instanceof AcknowledgingMessageListener, "Either a " + MessageListener.class.getName() + " or a " + AcknowledgingMessageListener.class.getName() + " must be provided"); Assert.notEmpty(partitions, "A set of partitions must be provided"); Assert.isTrue(consumers <= partitions.size(), "The number of consumers must be smaller or equal to the number of partitions"); Assert.notNull(delegateListener, "A delegate must be provided"); this.delegateListener = delegateListener; this.errorHandler = errorHandler; this.partitions = partitions; this.offsetManager = offsetManager; this.consumers = consumers; this.queueSize = queueSize; this.taskExecutor = taskExecutor; }
From source file:org.springframework.integration.kafka.listener.KafkaMessageListenerContainer.java
public KafkaMessageListenerContainer(ConnectionFactory connectionFactory, Partition... partitions) { Assert.notNull(connectionFactory, "A connection factory must be supplied"); Assert.notEmpty(partitions, "A list of partitions must be provided"); Assert.noNullElements(partitions, "The list of partitions cannot contain null elements"); this.kafkaTemplate = new KafkaTemplate(connectionFactory); this.partitions = partitions; this.topics = null; }
From source file:org.springframework.integration.util.MessagingMethodInvokerHelper.java
private Map<Class<?>, HandlerMethod> findHandlerMethodsForTarget(final Object targetObject, final Class<? extends Annotation> annotationType, final String methodName, final boolean requiresReply) { final Map<Class<?>, HandlerMethod> candidateMethods = new HashMap<Class<?>, HandlerMethod>(); final Map<Class<?>, HandlerMethod> fallbackMethods = new HashMap<Class<?>, HandlerMethod>(); final AtomicReference<Class<?>> ambiguousFallbackType = new AtomicReference<Class<?>>(); final Class<?> targetClass = this.getTargetClass(targetObject); MethodFilter methodFilter = new UniqueMethodFilter(targetClass); ReflectionUtils.doWithMethods(targetClass, new MethodCallback() { public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { boolean matchesAnnotation = false; if (method.isBridge()) { return; }// w w w. j a va2s. c o m if (isMethodDefinedOnObjectClass(method)) { return; } if (method.getDeclaringClass().equals(Proxy.class)) { return; } if (!Modifier.isPublic(method.getModifiers())) { return; } if (requiresReply && void.class.equals(method.getReturnType())) { return; } if (methodName != null && !methodName.equals(method.getName())) { return; } if (annotationType != null && AnnotationUtils.findAnnotation(method, annotationType) != null) { matchesAnnotation = true; } HandlerMethod handlerMethod = null; try { handlerMethod = new HandlerMethod(method, canProcessMessageList); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Method [" + method + "] is not eligible for Message handling.", e); } return; } Class<?> targetParameterType = handlerMethod.getTargetParameterType().getObjectType(); if (matchesAnnotation || annotationType == null) { Assert.isTrue(!candidateMethods.containsKey(targetParameterType), "Found more than one method match for type [" + targetParameterType + "]"); candidateMethods.put(targetParameterType, handlerMethod); } else { if (fallbackMethods.containsKey(targetParameterType)) { // we need to check for duplicate type matches, // but only if we end up falling back // and we'll only keep track of the first one ambiguousFallbackType.compareAndSet(null, targetParameterType); } fallbackMethods.put(targetParameterType, handlerMethod); } } }, methodFilter); if (!candidateMethods.isEmpty()) { return candidateMethods; } if ((fallbackMethods.isEmpty() || ambiguousFallbackType.get() != null) && ServiceActivator.class.equals(annotationType)) { // a Service Activator can fallback to either MessageHandler.handleMessage(m) or RequestReplyExchanger.exchange(m) List<Method> frameworkMethods = new ArrayList<Method>(); Class<?>[] allInterfaces = org.springframework.util.ClassUtils.getAllInterfacesForClass(targetClass); for (Class<?> iface : allInterfaces) { try { if ("org.springframework.integration.gateway.RequestReplyExchanger".equals(iface.getName())) { frameworkMethods.add(targetClass.getMethod("exchange", Message.class)); } else if ("org.springframework.integration.core.MessageHandler".equals(iface.getName()) && !requiresReply) { frameworkMethods.add(targetClass.getMethod("handleMessage", Message.class)); } } catch (Exception e) { // should never happen (but would fall through to errors below) } } if (frameworkMethods.size() == 1) { HandlerMethod handlerMethod = new HandlerMethod(frameworkMethods.get(0), canProcessMessageList); return Collections.<Class<?>, HandlerMethod>singletonMap(Object.class, handlerMethod); } } Assert.notEmpty(fallbackMethods, "Target object of type [" + this.targetObject.getClass() + "] has no eligible methods for handling Messages."); Assert.isNull(ambiguousFallbackType.get(), "Found ambiguous parameter type [" + ambiguousFallbackType + "] for method match: " + fallbackMethods.values()); return fallbackMethods; }
From source file:org.springframework.messaging.converter.AbstractMessageConverter.java
/** * Whether this converter should convert messages for which no content type * could be resolved through the configured * {@link org.springframework.messaging.converter.ContentTypeResolver}. * <p>A converter can configured to be strict only when a * {@link #setContentTypeResolver contentTypeResolver} is configured and the * list of {@link #getSupportedMimeTypes() supportedMimeTypes} is not be empty. * <p>When this flag is set to {@code true}, {@link #supportsMimeType(MessageHeaders)} * will return {@code false} if the {@link #setContentTypeResolver contentTypeResolver} * is not defined or if no content-type header is present. *///from www. ja va2 s . c o m public void setStrictContentTypeMatch(boolean strictContentTypeMatch) { if (strictContentTypeMatch) { Assert.notEmpty(getSupportedMimeTypes(), "Strict match requires non-empty list of supported mime types"); Assert.notNull(getContentTypeResolver(), "Strict match requires ContentTypeResolver"); } this.strictContentTypeMatch = strictContentTypeMatch; }
From source file:org.springframework.messaging.handler.invocation.reactive.AbstractEncoderMethodReturnValueHandler.java
protected AbstractEncoderMethodReturnValueHandler(List<Encoder<?>> encoders, ReactiveAdapterRegistry registry) { Assert.notEmpty(encoders, "At least one Encoder is required"); Assert.notNull(registry, "ReactiveAdapterRegistry is required"); this.encoders = Collections.unmodifiableList(encoders); this.adapterRegistry = registry; }