Browse Source

Polishing

pull/655/merge
Juergen Hoeller 12 years ago
parent
commit
3a3c52dbdd
  1. 9
      spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java
  2. 2
      spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java
  3. 8
      spring-context/src/main/java/org/springframework/jmx/support/WebSphereMBeanServerFactoryBean.java
  4. 2
      spring-tx/src/main/java/org/springframework/transaction/config/JtaTransactionManagerFactoryBean.java
  5. 4
      spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java
  6. 22
      spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurer.java

9
spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java

@ -32,7 +32,6 @@ import org.springframework.jmx.export.annotation.AnnotationMBeanExporter;
import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.jmx.support.RegistrationPolicy;
import org.springframework.jmx.support.WebSphereMBeanServerFactoryBean; import org.springframework.jmx.support.WebSphereMBeanServerFactoryBean;
import org.springframework.jndi.JndiLocatorDelegate; import org.springframework.jndi.JndiLocatorDelegate;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -63,8 +62,10 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware,
public void setImportMetadata(AnnotationMetadata importMetadata) { public void setImportMetadata(AnnotationMetadata importMetadata) {
Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName()); Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName());
this.attributes = AnnotationAttributes.fromMap(map); this.attributes = AnnotationAttributes.fromMap(map);
Assert.notNull(this.attributes, if (this.attributes == null) {
"@EnableMBeanExport is not present on importing class " + importMetadata.getClassName()); throw new IllegalArgumentException(
"@EnableMBeanExport is not present on importing class " + importMetadata.getClassName());
}
} }
@Override @Override
@ -78,7 +79,7 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware,
} }
@Bean(name=MBEAN_EXPORTER_BEAN_NAME) @Bean(name = MBEAN_EXPORTER_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationMBeanExporter mbeanExporter() { public AnnotationMBeanExporter mbeanExporter() {
AnnotationMBeanExporter exporter = new AnnotationMBeanExporter(); AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();

2
spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java

@ -57,6 +57,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
private static final Set<ConfigurableApplicationContext> applicationContexts = private static final Set<ConfigurableApplicationContext> applicationContexts =
new LinkedHashSet<ConfigurableApplicationContext>(); new LinkedHashSet<ConfigurableApplicationContext>();
static void registerApplicationContext(ConfigurableApplicationContext applicationContext) { static void registerApplicationContext(ConfigurableApplicationContext applicationContext) {
String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME); String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME);
if (mbeanDomain != null) { if (mbeanDomain != null) {
@ -94,6 +95,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
private ConfigurableApplicationContext applicationContext; private ConfigurableApplicationContext applicationContext;
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) { public void setApplicationContext(ApplicationContext applicationContext) {
Assert.isTrue(applicationContext instanceof ConfigurableApplicationContext, Assert.isTrue(applicationContext instanceof ConfigurableApplicationContext,

8
spring-context/src/main/java/org/springframework/jmx/support/WebSphereMBeanServerFactoryBean.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.jmx.support;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
@ -34,8 +33,9 @@ import org.springframework.jmx.MBeanServerNotFoundException;
* This FactoryBean is a direct alternative to {@link MBeanServerFactoryBean}, * This FactoryBean is a direct alternative to {@link MBeanServerFactoryBean},
* which uses standard JMX 1.2 API to access the platform's MBeanServer. * which uses standard JMX 1.2 API to access the platform's MBeanServer.
* *
* <p>See Javadoc for WebSphere's <a href="http://bit.ly/UzccDt">{@code * <p>See the javadocs for WebSphere's
* AdminServiceFactory}</a> and <a href="http://bit.ly/TRlX2r">{@code MBeanFactory}</a>. * <a href="http://bit.ly/UzccDt">{@code AdminServiceFactory}</a>
* and <a href="http://bit.ly/TRlX2r">{@code MBeanFactory}</a>.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Rob Harrop * @author Rob Harrop

2
spring-tx/src/main/java/org/springframework/transaction/config/JtaTransactionManagerFactoryBean.java

@ -58,7 +58,7 @@ public class JtaTransactionManagerFactoryBean implements FactoryBean<JtaTransact
String className = resolveJtaTransactionManagerClassName(); String className = resolveJtaTransactionManagerClassName();
try { try {
Class<? extends JtaTransactionManager> clazz = (Class<? extends JtaTransactionManager>) Class<? extends JtaTransactionManager> clazz = (Class<? extends JtaTransactionManager>)
JtaTransactionManagerFactoryBean.class.getClassLoader().loadClass(className); ClassUtils.forName(className, JtaTransactionManagerFactoryBean.class.getClassLoader());
this.transactionManager = BeanUtils.instantiate(clazz); this.transactionManager = BeanUtils.instantiate(clazz);
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {

4
spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java

@ -249,8 +249,8 @@ public final class WebAsyncManager {
* @see #getConcurrentResult() * @see #getConcurrentResult()
* @see #getConcurrentResultContext() * @see #getConcurrentResultContext()
*/ */
@SuppressWarnings({"unchecked", "rawtypes" }) @SuppressWarnings({"unchecked", "rawtypes"})
public void startCallableProcessing(final Callable<?> callable, Object... processingContext) throws Exception { public void startCallableProcessing(Callable<?> callable, Object... processingContext) throws Exception {
Assert.notNull(callable, "Callable must not be null"); Assert.notNull(callable, "Callable must not be null");
startCallableProcessing(new WebAsyncTask(callable), processingContext); startCallableProcessing(new WebAsyncTask(callable), processingContext);
} }

22
spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurer.java

@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -16,6 +16,7 @@
package org.springframework.web.socket.config.annotation; package org.springframework.web.socket.config.annotation;
import java.util.List;
import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver;
@ -23,13 +24,12 @@ import org.springframework.messaging.handler.invocation.HandlerMethodReturnValue
import org.springframework.messaging.simp.config.ChannelRegistration; import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import java.util.List;
/** /**
* Defines methods for configuring message handling with simple messaging * Defines methods for configuring message handling with simple messaging
* protocols (e.g. STOMP) from WebSocket clients. Typically used to customize * protocols (e.g. STOMP) from WebSocket clients.
* the configuration provided via *
* {@link org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker @EnableWebSocketMessageBroker}. * <p>Typically used to customize the configuration provided via
* {@link EnableWebSocketMessageBroker @EnableWebSocketMessageBroker}.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
@ -69,7 +69,7 @@ public interface WebSocketMessageBrokerConfigurer {
* <p>This does not override the built-in support for resolving handler * <p>This does not override the built-in support for resolving handler
* method arguments. To customize the built-in support for argument * method arguments. To customize the built-in support for argument
* resolution, configure {@code SimpAnnotationMethodMessageHandler} directly. * resolution, configure {@code SimpAnnotationMethodMessageHandler} directly.
* @param argumentResolvers initially an empty list * @param argumentResolvers the resolvers to register (initially an empty list)
* @since 4.1.1 * @since 4.1.1
*/ */
void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers); void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers);
@ -79,7 +79,7 @@ public interface WebSocketMessageBrokerConfigurer {
* <p>Using this option does not override the built-in support for handling * <p>Using this option does not override the built-in support for handling
* return values. To customize the built-in support for handling return * return values. To customize the built-in support for handling return
* values, configure {@code SimpAnnotationMethodMessageHandler} directly. * values, configure {@code SimpAnnotationMethodMessageHandler} directly.
* @param returnValueHandlers initially an empty list * @param returnValueHandlers the handlers to register (initially an empty list)
* @since 4.1.1 * @since 4.1.1
*/ */
void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers); void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers);
@ -88,12 +88,10 @@ public interface WebSocketMessageBrokerConfigurer {
* Configure the message converters to use when extracting the payload of * Configure the message converters to use when extracting the payload of
* messages in annotated methods and when sending messages (e.g. through the * messages in annotated methods and when sending messages (e.g. through the
* "broker" SimpMessagingTemplate). * "broker" SimpMessagingTemplate).
* <p> * <p>The provided list, initially empty, can be used to add message converters
* The provided list, initially empty, can be used to add message converters
* while the boolean return value is used to determine if default message should * while the boolean return value is used to determine if default message should
* be added as well. * be added as well.
* * @param messageConverters the converters to configure (initially an empty list)
* @param messageConverters initially an empty list of converters
* @return whether to also add default converter or not * @return whether to also add default converter or not
*/ */
boolean configureMessageConverters(List<MessageConverter> messageConverters); boolean configureMessageConverters(List<MessageConverter> messageConverters);

Loading…
Cancel
Save