/** * Set the {@link BeanWiringInfoResolver} to use. * <p>The default behavior is to look for a bean with the same name as the class. * As an alternative, consider using annotation-driven bean wiring. * @see ClassNameBeanWiringInfoResolver * @see org.springframework.beans.factory.annotation.AnnotationBeanWiringInfoResolver */ public void setBeanWiringInfoResolver(BeanWiringInfoResolver beanWiringInfoResolver) { Assert.notNull(beanWiringInfoResolver, "BeanWiringInfoResolver must not be null"); this.beanWiringInfoResolver = beanWiringInfoResolver; }
/** * Set the interface that the proxy must implement. * @param serviceInterface the interface that the proxy must implement * @throws IllegalArgumentException if the supplied {@code serviceInterface} * is not an interface type */ public void setServiceInterface(Class<?> serviceInterface) { Assert.notNull(serviceInterface, "'serviceInterface' must not be null"); Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface"); this.serviceInterface = serviceInterface; }
/** * Create a new {@code PropertySource} with the given name and source object. */ public PropertySource(String name, T source) { Assert.hasText(name, "Property source name must contain at least one character"); Assert.notNull(source, "Property source must not be null"); this.name = name; this.source = source; }
@SuppressWarnings("unchecked") HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters, Log logger) { Assert.notNull(responseType, "'responseType' must not be null"); Assert.notEmpty(messageConverters, "'messageConverters' must not be empty"); this.responseType = responseType; this.responseClass = (responseType instanceof Class ? (Class<T>) responseType : null); this.messageConverters = messageConverters; this.logger = logger; }
@Override public final void afterPropertiesSet() throws Exception { Assert.notNull(this.host, "Host must not be null"); Assert.isTrue(this.port >= 0, "Port must not be a negative number"); Assert.isTrue(this.httpHandler != null || this.handlerMap != null, "No HttpHandler configured"); Assert.state(!this.running, "Cannot reconfigure while running"); synchronized (this.lifecycleMonitor) { initServer(); } }
@Override public List<WebSocketExtension> getExtensions() { Assert.state(this.extensions != null, "WebSocket session is not yet initialized"); return this.extensions; }
@Override public void sendRedirect(String url) throws IOException { Assert.state(!isCommitted(), "Cannot send redirect - response is already committed"); Assert.notNull(url, "Redirect URL must not be null"); setHeader(HttpHeaders.LOCATION, url); setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); setCommitted(true); }
/** * Set the start delay in milliseconds. * <p>The start delay is added to the current system time (when the bean starts) * to control the start time of the trigger. */ public void setStartDelay(long startDelay) { Assert.isTrue(startDelay >= 0, "Start delay cannot be negative"); this.startDelay = startDelay; }
private static void assertValidContextPath(String contextPath) { Assert.hasText(contextPath, "Context path must not be empty"); if (contextPath.equals("/")) { return; } Assert.isTrue(contextPath.startsWith("/"), "Context path must begin with '/'"); Assert.isTrue(!contextPath.endsWith("/"), "Context path must not end with '/'"); }
/** * Set the name of the session header to use for the session id. * The name is used to extract the session id from the request headers as * well to set the session id on the response headers. * <p>By default set to {@code DEFAULT_HEADER_NAME} * @param headerName the header name */ public void setHeaderName(String headerName) { Assert.hasText(headerName, "'headerName' must not be empty"); this.headerName = headerName; }
protected ParameterizedTypeReference() { Class<?> parameterizedTypeReferenceSubclass = findParameterizedTypeReferenceSubclass(getClass()); Type type = parameterizedTypeReferenceSubclass.getGenericSuperclass(); Assert.isInstanceOf(ParameterizedType.class, type, "Type must be a parameterized type"); ParameterizedType parameterizedType = (ParameterizedType) type; Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); Assert.isTrue(actualTypeArguments.length == 1, "Number of type arguments must be 1"); this.type = actualTypeArguments[0]; }
/** * Create an instance with the given converters. */ public CompositeMessageConverter(Collection<MessageConverter> converters) { Assert.notEmpty(converters, "Converters must not be empty"); this.converters = new ArrayList<>(converters); }
public final void sendMessage(WebSocketMessage<?> message) throws IOException { Assert.state(!isClosed(), "Cannot send a message when session is closed"); Assert.isInstanceOf(TextMessage.class, message, "SockJS supports text messages only"); sendMessageInternal(((TextMessage) message).getPayload()); }
/** * Construct a new {@code MappingJackson2CborHttpMessageConverter} with a custom {@link ObjectMapper} * (must be configured with a {@code CBORFactory} instance). * You can use {@link Jackson2ObjectMapperBuilder} to build it easily. * @see Jackson2ObjectMapperBuilder#cbor() */ public MappingJackson2CborHttpMessageConverter(ObjectMapper objectMapper) { super(objectMapper, new MediaType("application", "cbor")); Assert.isInstanceOf(CBORFactory.class, objectMapper.getFactory(), "CBORFactory required"); }
public WebMvcStompWebSocketEndpointRegistration( String[] paths, WebSocketHandler webSocketHandler, TaskScheduler sockJsTaskScheduler) { Assert.notEmpty(paths, "No paths specified"); Assert.notNull(webSocketHandler, "WebSocketHandler must not be null"); this.paths = paths; this.webSocketHandler = webSocketHandler; this.sockJsTaskScheduler = sockJsTaskScheduler; }
/** * Return the Quartz Scheduler instance that this accessor operates on. */ @Override public Scheduler getScheduler() { Assert.state(this.scheduler != null, "No Scheduler set"); return this.scheduler; }
/** * Create a new <code>FastByteArrayOutputStream</code> * with the specified initial capacity. * @param initialBlockSize the initial buffer size in bytes */ public FastByteArrayOutputStream(int initialBlockSize) { Assert.isTrue(initialBlockSize > 0, "Initial block size must be greater than 0"); this.initialBlockSize = initialBlockSize; this.nextBlockSize = initialBlockSize; }
/** * Set the STOMP message broker host. */ public void setRelayHost(String relayHost) { Assert.hasText(relayHost, "relayHost must not be empty"); this.relayHost = relayHost; }
/** * Set the list of {@link MediaType} objects supported by this converter. */ public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) { Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty"); this.supportedMediaTypes = new ArrayList<>(supportedMediaTypes); }
/** * {@inheritDoc} * The {@code ObjectMapper} must be configured with a {@code SmileFactory} instance. */ @Override public void setObjectMapper(ObjectMapper objectMapper) { Assert.isInstanceOf(SmileFactory.class, objectMapper.getFactory(), "SmileFactory required"); super.setObjectMapper(objectMapper); }