diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java b/org.springframework.aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java index 4985a5fd35..5891bc8455 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.util.StringUtils; * @author Rob Harrop * @since 2.0 */ -public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware { +public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware { private String targetBeanName; @@ -78,11 +78,11 @@ public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware } - public Object getObject() throws Exception { + public Method getObject() throws Exception { return this.method; } - public Class getObjectType() { + public Class getObjectType() { return Method.class; } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java index ac65af3dc3..a58c86584c 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.util.ClassUtils; * @since 2.0 */ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig - implements FactoryBean, BeanClassLoaderAware, InitializingBean { + implements FactoryBean, BeanClassLoaderAware, InitializingBean { private Object target; @@ -196,7 +196,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig return this.proxy; } - public Class getObjectType() { + public Class getObjectType() { if (this.proxy != null) { return this.proxy.getClass(); } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java index 21fef364ed..9b4461fcb4 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java @@ -89,7 +89,7 @@ import org.springframework.util.ObjectUtils; * @see Advised */ public class ProxyFactoryBean extends ProxyCreatorSupport - implements FactoryBean, BeanClassLoaderAware, BeanFactoryAware { + implements FactoryBean, BeanClassLoaderAware, BeanFactoryAware { /** * This suffix in a value in an interceptor list indicates to expand globals. @@ -256,7 +256,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport * a single one), the target bean type, or the TargetSource's target class. * @see org.springframework.aop.TargetSource#getTargetClass */ - public Class getObjectType() { + public Class getObjectType() { synchronized (this) { if (this.singletonInstance != null) { return this.singletonInstance.getClass(); @@ -448,7 +448,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport else { // If we get here, we need to add a named interceptor. // We must check if it's a singleton or prototype. - Object advice = null; + Object advice; if (this.singleton || this.beanFactory.isSingleton(name)) { // Add the real Advisor/Advice to the chain. advice = this.beanFactory.getBean(name); diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java b/org.springframework.aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java index 8a3d783fba..b13a9eb509 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ import org.springframework.util.ClassUtils; * @since 2.0 * @see #setProxyTargetClass */ -public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean, BeanFactoryAware { +public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean, BeanFactoryAware { /** The TargetSource that manages scoping */ private final SimpleBeanTargetSource scopedTargetSource = new SimpleBeanTargetSource(); @@ -117,7 +117,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean, return this.proxy; } - public Class getObjectType() { + public Class getObjectType() { if (this.proxy != null) { return this.proxy.getClass(); } diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java index db83b47266..6e5d0f5780 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; /** - * FactoryBean which retrieves a static or non-static field value. + * {@link FactoryBean} which retrieves a static or non-static field value. * *

Typically used for retrieving public static final constants. Usage example: * @@ -52,7 +52,8 @@ import org.springframework.util.StringUtils; * @since 1.1 * @see #setStaticField */ -public class FieldRetrievingFactoryBean implements FactoryBean, BeanNameAware, BeanClassLoaderAware, InitializingBean { +public class FieldRetrievingFactoryBean + implements FactoryBean, BeanNameAware, BeanClassLoaderAware, InitializingBean { private Class targetClass; @@ -205,7 +206,7 @@ public class FieldRetrievingFactoryBean implements FactoryBean, BeanNameAware, B } } - public Class getObjectType() { + public Class getObjectType() { return (this.fieldObject != null ? this.fieldObject.getType() : null); } diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java index 0f54f6407a..51440d47da 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.beans.support.ArgumentConvertingMethodInvoker; import org.springframework.util.ClassUtils; /** - * FactoryBean which returns a value which is the result of a static or instance + * {@link FactoryBean} which returns a value which is the result of a static or instance * method invocation. For most use cases it is better to just use the container's * built-in factory method support for the same purpose, since that is smarter at * converting arguments. This factory bean is still useful though when you need to @@ -88,7 +88,7 @@ import org.springframework.util.ClassUtils; * @since 21.11.2003 */ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker - implements FactoryBean, BeanClassLoaderAware, BeanFactoryAware, InitializingBean { + implements FactoryBean, BeanClassLoaderAware, BeanFactoryAware, InitializingBean { private boolean singleton = true; @@ -196,7 +196,7 @@ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker * Return the type of object that this FactoryBean creates, * or null if not known in advance. */ - public Class getObjectType() { + public Class getObjectType() { if (!isPrepared()) { // Not fully initialized yet -> return null to indicate "not known yet". return null; diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java index ab55bc47e3..ce3e914dc8 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ import org.springframework.util.StringUtils; * @see #setTargetBeanName * @see #setPropertyPath */ -public class PropertyPathFactoryBean implements FactoryBean, BeanNameAware, BeanFactoryAware { +public class PropertyPathFactoryBean implements FactoryBean, BeanNameAware, BeanFactoryAware { private static final Log logger = LogFactory.getLog(PropertyPathFactoryBean.class); @@ -207,7 +207,7 @@ public class PropertyPathFactoryBean implements FactoryBean, BeanNameAware, Bean return target.getPropertyValue(this.propertyPath); } - public Class getObjectType() { + public Class getObjectType() { return this.resultType; } diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java index fa2997f00b..192f6b7e66 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,9 +35,8 @@ import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; /** - * A {@link org.springframework.beans.factory.FactoryBean} implementation that - * takes an interface which must have one or more methods with - * the signatures MyType xxx() or MyType xxx(MyIdType id) + * A {@link FactoryBean} implementation that takes an interface which must have one or more + * methods with the signatures MyType xxx() or MyType xxx(MyIdType id) * (typically, MyService getService() or MyService getService(String id)) * and creates a dynamic proxy which implements that interface, delegating to an * underlying {@link org.springframework.beans.factory.BeanFactory}. @@ -188,7 +187,7 @@ import org.springframework.util.StringUtils; * @see #setServiceMappings * @see ObjectFactoryCreatingFactoryBean */ -public class ServiceLocatorFactoryBean implements FactoryBean, BeanFactoryAware, InitializingBean { +public class ServiceLocatorFactoryBean implements FactoryBean, BeanFactoryAware, InitializingBean { private Class serviceLocatorInterface; @@ -328,7 +327,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFactoryAware, return this.proxy; } - public Class getObjectType() { + public Class getObjectType() { return this.serviceLocatorInterface; } @@ -359,6 +358,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFactoryAware, } } + @SuppressWarnings("unchecked") private Object invokeServiceLocatorMethod(Method method, Object[] args) throws Exception { Class serviceLocatorMethodReturnType = getServiceLocatorMethodReturnType(method); try { diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java index 6e9045aa3d..e39193f4cc 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java +++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java @@ -53,7 +53,7 @@ import org.springframework.jndi.JndiLocatorSupport; * @see commonj.timers.TimerListener */ public class TimerManagerFactoryBean extends JndiLocatorSupport - implements FactoryBean, InitializingBean, DisposableBean, Lifecycle { + implements FactoryBean, InitializingBean, DisposableBean, Lifecycle { private TimerManager timerManager; @@ -169,11 +169,11 @@ public class TimerManagerFactoryBean extends JndiLocatorSupport // Implementation of FactoryBean interface //--------------------------------------------------------------------- - public Object getObject() { + public TimerManager getObject() { return this.timerManager; } - public Class getObjectType() { + public Class getObjectType() { return (this.timerManager != null ? this.timerManager.getClass() : TimerManager.class); } diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java index 0e42a59381..8310b767ee 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java +++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ import org.springframework.util.MethodInvoker; * @see #setConcurrent */ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethodInvoker - implements FactoryBean, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean { + implements FactoryBean, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean { private String name; @@ -171,7 +171,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod String name = (this.name != null ? this.name : this.beanName); // Consider the concurrent flag to choose between stateful and stateless job. - Class jobClass = (this.concurrent ? (Class) MethodInvokingJob.class : StatefulMethodInvokingJob.class); + Class jobClass = (this.concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class); // Build JobDetail instance. this.jobDetail = new JobDetail(name, this.group, jobClass); @@ -181,8 +181,8 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod // Register job listener names. if (this.jobListenerNames != null) { - for (int i = 0; i < this.jobListenerNames.length; i++) { - this.jobDetail.addJobListener(this.jobListenerNames[i]); + for (String jobListenerName : this.jobListenerNames) { + this.jobDetail.addJobListener(jobListenerName); } } @@ -229,7 +229,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod return this.jobDetail; } - public Class getObjectType() { + public Class getObjectType() { return JobDetail.class; } diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java index 74b0b37dc4..c5b97d0f19 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java +++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java @@ -87,7 +87,7 @@ import org.springframework.util.CollectionUtils; * @see org.springframework.transaction.interceptor.TransactionProxyFactoryBean */ public class SchedulerFactoryBean extends SchedulerAccessor - implements FactoryBean, BeanNameAware, ApplicationContextAware, InitializingBean, DisposableBean, Lifecycle { + implements FactoryBean, BeanNameAware, ApplicationContextAware, InitializingBean, DisposableBean, Lifecycle { public static final String PROP_THREAD_COUNT = "org.quartz.threadPool.threadCount"; @@ -665,11 +665,11 @@ public class SchedulerFactoryBean extends SchedulerAccessor return this.scheduler; } - public Object getObject() { + public Scheduler getObject() { return this.scheduler; } - public Class getObjectType() { + public Class getObjectType() { return (this.scheduler != null) ? this.scheduler.getClass() : Scheduler.class; } diff --git a/org.springframework.context.support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java b/org.springframework.context.support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java index 0f5935628a..cf1652b5b6 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java +++ b/org.springframework.context.support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2002-2006 the original author or authors. - * + * Copyright 2002-2009 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ import org.springframework.context.ResourceLoaderAware; * @see org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer */ public class FreeMarkerConfigurationFactoryBean extends FreeMarkerConfigurationFactory - implements FactoryBean, InitializingBean, ResourceLoaderAware { + implements FactoryBean, InitializingBean, ResourceLoaderAware { private Configuration configuration; @@ -61,11 +61,11 @@ public class FreeMarkerConfigurationFactoryBean extends FreeMarkerConfigurationF } - public Object getObject() { + public Configuration getObject() { return this.configuration; } - public Class getObjectType() { + public Class getObjectType() { return Configuration.class; } diff --git a/org.springframework.context.support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java b/org.springframework.context.support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java index 16baa02032..8d25492aa6 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java +++ b/org.springframework.context.support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2002-2006 the original author or authors. - * + * Copyright 2002-2009 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -48,7 +48,7 @@ import org.springframework.context.ResourceLoaderAware; * @see org.springframework.web.servlet.view.velocity.VelocityConfigurer */ public class VelocityEngineFactoryBean extends VelocityEngineFactory - implements FactoryBean, InitializingBean, ResourceLoaderAware { + implements FactoryBean, InitializingBean, ResourceLoaderAware { private VelocityEngine velocityEngine; @@ -58,11 +58,11 @@ public class VelocityEngineFactoryBean extends VelocityEngineFactory } - public Object getObject() { + public VelocityEngine getObject() { return this.velocityEngine; } - public Class getObjectType() { + public Class getObjectType() { return VelocityEngine.class; } diff --git a/org.springframework.context/src/main/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBean.java index a3860c166d..2eeef7627a 100644 --- a/org.springframework.context/src/main/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.util.ClassUtils; /** - * Convenient factory for local Stateless Session Bean (SLSB) proxies. + * Convenient {@link FactoryBean} for local Stateless Session Bean (SLSB) proxies. * Designed for EJB 2.x, but works for EJB 3 Session Beans as well. * *

See {@link org.springframework.jndi.JndiObjectLocator} for info on @@ -49,7 +49,7 @@ import org.springframework.util.ClassUtils; * @see AbstractSlsbInvokerInterceptor#setCacheHome */ public class LocalStatelessSessionProxyFactoryBean extends LocalSlsbInvokerInterceptor - implements FactoryBean, BeanClassLoaderAware { + implements FactoryBean, BeanClassLoaderAware { /** The business interface of the EJB we're proxying */ private Class businessInterface; @@ -95,7 +95,7 @@ public class LocalStatelessSessionProxyFactoryBean extends LocalSlsbInvokerInter return this.proxy; } - public Class getObjectType() { + public Class getObjectType() { return this.businessInterface; } diff --git a/org.springframework.context/src/main/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBean.java index da9c39f7e3..84e9eb6b3e 100644 --- a/org.springframework.context/src/main/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.util.ClassUtils; /** - * Convenient factory for remote SLSB proxies. + * Convenient {@link FactoryBean} for remote SLSB proxies. * Designed for EJB 2.x, but works for EJB 3 Session Beans as well. * *

See {@link org.springframework.jndi.JndiObjectLocator} for info on @@ -59,7 +59,7 @@ import org.springframework.util.ClassUtils; * @see AbstractRemoteSlsbInvokerInterceptor#setRefreshHomeOnConnectFailure */ public class SimpleRemoteStatelessSessionProxyFactoryBean extends SimpleRemoteSlsbInvokerInterceptor - implements FactoryBean, BeanClassLoaderAware { + implements FactoryBean, BeanClassLoaderAware { /** The business interface of the EJB we're proxying */ private Class businessInterface; @@ -109,7 +109,7 @@ public class SimpleRemoteStatelessSessionProxyFactoryBean extends SimpleRemoteSl return this.proxy; } - public Class getObjectType() { + public Class getObjectType() { return this.businessInterface; } diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java index ad3e99f88e..3cd7878f01 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ import org.springframework.util.ClassUtils; * @see InvalidInvocationException */ public class MBeanProxyFactoryBean extends MBeanClientInterceptor - implements FactoryBean, BeanClassLoaderAware, InitializingBean { + implements FactoryBean, BeanClassLoaderAware, InitializingBean { private Class proxyInterface; @@ -98,7 +98,7 @@ public class MBeanProxyFactoryBean extends MBeanClientInterceptor return this.mbeanProxy; } - public Class getObjectType() { + public Class getObjectType() { return this.proxyInterface; } diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java index 6339f0ff4d..9a1f3991cf 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ package org.springframework.jmx.support; import java.io.IOException; +import java.util.HashMap; import java.util.Map; import java.util.Properties; - import javax.management.JMException; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; @@ -32,10 +32,11 @@ import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.jmx.JmxException; +import org.springframework.util.CollectionUtils; /** - * FactoryBean that creates a JSR-160 JMXConnectorServer, - * optionally registers it with the MBeanServer and then starts it. + * {@link FactoryBean} that creates a JSR-160 {@link JMXConnectorServer}, + * optionally registers it with the {@link MBeanServer} and then starts it. * *

The JMXConnectorServer can be started in a separate thread by setting the * threaded property to true. You can configure this thread to be a @@ -52,7 +53,7 @@ import org.springframework.jmx.JmxException; * @see MBeanServer */ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport - implements FactoryBean, InitializingBean, DisposableBean { + implements FactoryBean, InitializingBean, DisposableBean { /** The default service URL */ public static final String DEFAULT_SERVICE_URL = "service:jmx:jmxmp://localhost:9875"; @@ -60,7 +61,7 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport private String serviceUrl = DEFAULT_SERVICE_URL; - private Map environment; + private Map environment = new HashMap(); private ObjectName objectName; @@ -83,15 +84,17 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport * as java.util.Properties (String key/value pairs). */ public void setEnvironment(Properties environment) { - this.environment = environment; + CollectionUtils.mergePropertiesIntoMap(environment, this.environment); } /** * Set the environment properties used to construct the JMXConnector * as a Map of String keys and arbitrary Object values. */ - public void setEnvironmentMap(Map environment) { - this.environment = environment; + public void setEnvironmentMap(Map environment) { + if (environment != null) { + this.environment.putAll(environment); + } } /** @@ -182,11 +185,11 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport } - public Object getObject() { + public JMXConnectorServer getObject() { return this.connectorServer; } - public Class getObjectType() { + public Class getObjectType() { return (this.connectorServer != null ? this.connectorServer.getClass() : JMXConnectorServer.class); } diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java index 260c203e4e..be62dbcabf 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ package org.springframework.jmx.support; import java.io.IOException; import java.net.MalformedURLException; +import java.util.HashMap; import java.util.Map; import java.util.Properties; - import javax.management.MBeanServerConnection; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; @@ -34,9 +34,10 @@ import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.ClassUtils; +import org.springframework.util.CollectionUtils; /** - * FactoryBean that creates a JMX 1.2 MBeanServerConnection + * {@link FactoryBean} that creates a JMX 1.2 MBeanServerConnection * to a remote MBeanServer exposed via a JMXServerConnector. * Exposes the MBeanServer for bean references. * @@ -49,11 +50,11 @@ import org.springframework.util.ClassUtils; * @see org.springframework.jmx.access.NotificationListenerRegistrar#setServer */ public class MBeanServerConnectionFactoryBean - implements FactoryBean, BeanClassLoaderAware, InitializingBean, DisposableBean { + implements FactoryBean, BeanClassLoaderAware, InitializingBean, DisposableBean { private JMXServiceURL serviceUrl; - private Map environment; + private Map environment = new HashMap(); private boolean connectOnStartup = true; @@ -78,15 +79,17 @@ public class MBeanServerConnectionFactoryBean * as java.util.Properties (String key/value pairs). */ public void setEnvironment(Properties environment) { - this.environment = environment; + CollectionUtils.mergePropertiesIntoMap(environment, this.environment); } /** * Set the environment properties used to construct the JMXConnector * as a Map of String keys and arbitrary Object values. */ - public void setEnvironmentMap(Map environment) { - this.environment = environment; + public void setEnvironmentMap(Map environment) { + if (environment != null) { + this.environment.putAll(environment); + } } /** @@ -143,11 +146,11 @@ public class MBeanServerConnectionFactoryBean } - public Object getObject() { + public MBeanServerConnection getObject() { return this.connection; } - public Class getObjectType() { + public Class getObjectType() { return (this.connection != null ? this.connection.getClass() : MBeanServerConnection.class); } diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerFactoryBean.java index c2cc24569d..84bd891c90 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/support/MBeanServerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.jmx.MBeanServerNotFoundException; /** - * FactoryBean that obtains an {@link javax.management.MBeanServer} reference + * {@link FactoryBean} that obtains an {@link javax.management.MBeanServer} reference * through the standard JMX 1.2 {@link javax.management.MBeanServerFactory} * API (which is available on JDK 1.5 or as part of a JMX 1.2 provider). * Exposes the MBeanServer for bean references. @@ -51,7 +51,7 @@ import org.springframework.jmx.MBeanServerNotFoundException; * @see MBeanServerConnectionFactoryBean * @see ConnectorServerFactoryBean */ -public class MBeanServerFactoryBean implements FactoryBean, InitializingBean, DisposableBean { +public class MBeanServerFactoryBean implements FactoryBean, InitializingBean, DisposableBean { protected final Log logger = LogFactory.getLog(getClass()); @@ -178,11 +178,11 @@ public class MBeanServerFactoryBean implements FactoryBean, InitializingBean, Di } - public Object getObject() { + public MBeanServer getObject() { return this.server; } - public Class getObjectType() { + public Class getObjectType() { return (this.server != null ? this.server.getClass() : MBeanServer.class); } diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/support/WebSphereMBeanServerFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/jmx/support/WebSphereMBeanServerFactoryBean.java index 02fbce38bd..14c135954e 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/support/WebSphereMBeanServerFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/support/WebSphereMBeanServerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.jmx.MBeanServerNotFoundException; /** - * FactoryBean that obtains a WebSphere {@link javax.management.MBeanServer} + * {@link FactoryBean} that obtains a WebSphere {@link javax.management.MBeanServer} * reference through WebSphere's proprietary AdminServiceFactory API, * available on WebSphere 5.1 and higher. * @@ -42,7 +42,7 @@ import org.springframework.jmx.MBeanServerNotFoundException; * @see javax.management.MBeanServer * @see MBeanServerFactoryBean */ -public class WebSphereMBeanServerFactoryBean implements FactoryBean, InitializingBean { +public class WebSphereMBeanServerFactoryBean implements FactoryBean, InitializingBean { private static final String ADMIN_SERVICE_FACTORY_CLASS = "com.ibm.websphere.management.AdminServiceFactory"; @@ -60,10 +60,10 @@ public class WebSphereMBeanServerFactoryBean implements FactoryBean, Initializin * this.mbeanServer = AdminServiceFactory.getMBeanFactory().getMBeanServer(); */ Class adminServiceClass = getClass().getClassLoader().loadClass(ADMIN_SERVICE_FACTORY_CLASS); - Method getMBeanFactoryMethod = adminServiceClass.getMethod(GET_MBEAN_FACTORY_METHOD, new Class[0]); - Object mbeanFactory = getMBeanFactoryMethod.invoke(null, new Object[0]); - Method getMBeanServerMethod = mbeanFactory.getClass().getMethod(GET_MBEAN_SERVER_METHOD, new Class[0]); - this.mbeanServer = (MBeanServer) getMBeanServerMethod.invoke(mbeanFactory, new Object[0]); + Method getMBeanFactoryMethod = adminServiceClass.getMethod(GET_MBEAN_FACTORY_METHOD); + Object mbeanFactory = getMBeanFactoryMethod.invoke(null); + Method getMBeanServerMethod = mbeanFactory.getClass().getMethod(GET_MBEAN_SERVER_METHOD); + this.mbeanServer = (MBeanServer) getMBeanServerMethod.invoke(mbeanFactory); } catch (ClassNotFoundException ex) { throw new MBeanServerNotFoundException("Could not find WebSphere's AdminServiceFactory class", ex); @@ -79,11 +79,11 @@ public class WebSphereMBeanServerFactoryBean implements FactoryBean, Initializin } - public Object getObject() { + public MBeanServer getObject() { return this.mbeanServer; } - public Class getObjectType() { + public Class getObjectType() { return (this.mbeanServer != null ? this.mbeanServer.getClass() : MBeanServer.class); } diff --git a/org.springframework.context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java index 694e56eafd..9914e0dbda 100644 --- a/org.springframework.context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ import org.springframework.util.ClassUtils; * @see #setCache * @see JndiObjectTargetSource */ -public class JndiObjectFactoryBean extends JndiObjectLocator implements FactoryBean, BeanClassLoaderAware { +public class JndiObjectFactoryBean extends JndiObjectLocator implements FactoryBean, BeanClassLoaderAware { private Class[] proxyInterfaces; @@ -232,7 +232,7 @@ public class JndiObjectFactoryBean extends JndiObjectLocator implements FactoryB return this.jndiObject; } - public Class getObjectType() { + public Class getObjectType() { if (this.proxyInterfaces != null) { if (this.proxyInterfaces.length == 1) { return this.proxyInterfaces[0]; diff --git a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/JndiRmiProxyFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/JndiRmiProxyFactoryBean.java index 09ad254355..0e718d72b3 100644 --- a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/JndiRmiProxyFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/JndiRmiProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.util.ClassUtils; /** - * Factory bean for RMI proxies from JNDI. + * {@link FactoryBean} for RMI proxies from JNDI. * *

Typically used for RMI-IIOP (CORBA), but can also be used for EJB home objects * (for example, a Stateful Session Bean home). In contrast to a plain JNDI lookup, @@ -61,7 +61,8 @@ import org.springframework.util.ClassUtils; * @see java.rmi.Remote * @see javax.rmi.PortableRemoteObject#narrow */ -public class JndiRmiProxyFactoryBean extends JndiRmiClientInterceptor implements FactoryBean, BeanClassLoaderAware { +public class JndiRmiProxyFactoryBean extends JndiRmiClientInterceptor + implements FactoryBean, BeanClassLoaderAware { private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); @@ -86,7 +87,7 @@ public class JndiRmiProxyFactoryBean extends JndiRmiClientInterceptor implements return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return getServiceInterface(); } diff --git a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiProxyFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiProxyFactoryBean.java index 4e779d9bb3..89f253e038 100644 --- a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiProxyFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.FactoryBean; /** - * FactoryBean for RMI proxies, supporting both conventional RMI services and - * RMI invokers. Exposes the proxied service for use as a bean reference, + * {@link FactoryBean} for RMI proxies, supporting both conventional RMI services + * and RMI invokers. Exposes the proxied service for use as a bean reference, * using the specified service interface. Proxies will throw Spring's unchecked * RemoteAccessException on remote invocation failure instead of RMI's RemoteException. * @@ -58,7 +58,7 @@ import org.springframework.beans.factory.FactoryBean; * @see org.springframework.remoting.caucho.BurlapProxyFactoryBean * @see org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean */ -public class RmiProxyFactoryBean extends RmiClientInterceptor implements FactoryBean, BeanClassLoaderAware { +public class RmiProxyFactoryBean extends RmiClientInterceptor implements FactoryBean, BeanClassLoaderAware { private Object serviceProxy; @@ -77,7 +77,7 @@ public class RmiProxyFactoryBean extends RmiClientInterceptor implements Factory return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return getServiceInterface(); } diff --git a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java index e87a08042a..bb551a908b 100644 --- a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; /** - * FactoryBean that locates a {@link java.rmi.registry.Registry} and + * {@link FactoryBean} that locates a {@link java.rmi.registry.Registry} and * exposes it for bean references. Can also create a local RMI registry * on the fly if none exists already. * @@ -60,7 +60,7 @@ import org.springframework.beans.factory.InitializingBean; * @see java.rmi.registry.Registry * @see java.rmi.registry.LocateRegistry */ -public class RmiRegistryFactoryBean implements FactoryBean, InitializingBean, DisposableBean { +public class RmiRegistryFactoryBean implements FactoryBean, InitializingBean, DisposableBean { protected final Log logger = LogFactory.getLog(getClass()); @@ -278,11 +278,11 @@ public class RmiRegistryFactoryBean implements FactoryBean, InitializingBean, Di } - public Object getObject() throws Exception { + public Registry getObject() throws Exception { return this.registry; } - public Class getObjectType() { + public Class getObjectType() { return (this.registry != null ? this.registry.getClass() : Registry.class); } diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java index baa5a58c59..98513a281e 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2002-2005 the original author or authors. - * + * Copyright 2002-2009 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,19 +22,14 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.scheduling.support.MethodInvokingRunnable; /** - * FactoryBean that exposes a TimerTask object that delegates - * job execution to a specified (static or non-static) method. - * Avoids the need to implement a one-line TimerTask that just - * invokes an existing business method. + * {@link FactoryBean} that exposes a {@link TimerTask} object which + * delegates job execution to a specified (static or non-static) method. + * Avoids the need to implement a one-line TimerTask that just invokes + * an existing business method. * - *

Derives from MethodInvokingRunnable to share common properties + *

Derives from {@link MethodInvokingRunnable} to share common properties * and behavior, effectively providing a TimerTask adapter for it. * - *

Often used to populate a ScheduledTimerTask object with a specific - * reflective method invocation. Note that you can alternatively populate - * a ScheduledTimerTask object with a plain MethodInvokingRunnable instance - * as well (as of Spring 1.2.4), without the need for this special FactoryBean. - * * @author Juergen Hoeller * @since 19.02.2004 * @see DelegatingTimerTask @@ -43,7 +38,7 @@ import org.springframework.scheduling.support.MethodInvokingRunnable; * @see org.springframework.scheduling.support.MethodInvokingRunnable * @see org.springframework.beans.factory.config.MethodInvokingFactoryBean */ -public class MethodInvokingTimerTaskFactoryBean extends MethodInvokingRunnable implements FactoryBean { +public class MethodInvokingTimerTaskFactoryBean extends MethodInvokingRunnable implements FactoryBean { private TimerTask timerTask; @@ -55,11 +50,11 @@ public class MethodInvokingTimerTaskFactoryBean extends MethodInvokingRunnable i } - public Object getObject() { + public TimerTask getObject() { return this.timerTask; } - public Class getObjectType() { + public Class getObjectType() { return TimerTask.class; } diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java index acc61a2be7..6fed79af6b 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java @@ -47,7 +47,7 @@ import org.springframework.util.StringUtils; * @see java.util.Timer * @see java.util.TimerTask */ -public class TimerFactoryBean implements FactoryBean, BeanNameAware, InitializingBean, DisposableBean { +public class TimerFactoryBean implements FactoryBean, BeanNameAware, InitializingBean, DisposableBean { protected final Log logger = LogFactory.getLog(getClass()); @@ -141,11 +141,11 @@ public class TimerFactoryBean implements FactoryBean, BeanNameAware, Initializin } - public Object getObject() { + public Timer getObject() { return this.timer; } - public Class getObjectType() { + public Class getObjectType() { return Timer.class; } diff --git a/org.springframework.context/src/main/java/org/springframework/ui/Model.java b/org.springframework.context/src/main/java/org/springframework/ui/Model.java index 1490d655a8..45d805307e 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/Model.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/Model.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public interface Model { /** * Add the supplied attribute to this Map using a * {@link org.springframework.core.Conventions#getVariableName generated name}. - *

Note: Empty {@link java.util.Collection Collections} are not added to + *

Note: Empty {@link java.util.Collection Collections} are not added to * the model when using this method because we cannot correctly determine * the true convention name. View code should check for null rather * than for empty collections as is already done by JSTL tags. diff --git a/org.springframework.context/src/main/java/org/springframework/ui/ModelMap.java b/org.springframework.context/src/main/java/org/springframework/ui/ModelMap.java index b1e4919ea5..d9dcdecc33 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/ModelMap.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/ModelMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.ui; import java.util.Collection; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; @@ -81,7 +80,7 @@ public class ModelMap extends LinkedHashMap { /** * Add the supplied attribute to this Map using a * {@link org.springframework.core.Conventions#getVariableName generated name}. - *

Note: Empty {@link Collection Collections} are not added to + *

Note: Empty {@link Collection Collections} are not added to * the model when using this method because we cannot correctly determine * the true convention name. View code should check for null rather * than for empty collections as is already done by JSTL tags. @@ -102,8 +101,8 @@ public class ModelMap extends LinkedHashMap { */ public ModelMap addAllAttributes(Collection attributeValues) { if (attributeValues != null) { - for (Iterator it = attributeValues.iterator(); it.hasNext();) { - addAttribute(it.next()); + for (Object attributeValue : attributeValues) { + addAttribute(attributeValue); } } return this; diff --git a/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java b/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java index ccda9a94f7..07467873b5 100644 --- a/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java +++ b/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,15 +23,14 @@ import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.FactoryBean; @SuppressWarnings("serial") -public class TestProxyFactoryBean extends AbstractSingletonProxyFactoryBean - implements FactoryBean, BeanFactoryAware { +public class TestProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware { @Override protected Object createMainInterceptor() { return new NoOpAdvice(); } - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { + public void setBeanFactory(BeanFactory beanFactory) { } } diff --git a/org.springframework.jms/src/main/java/org/springframework/jms/remoting/JmsInvokerProxyFactoryBean.java b/org.springframework.jms/src/main/java/org/springframework/jms/remoting/JmsInvokerProxyFactoryBean.java index a6fc5e9c91..678b6f30fb 100644 --- a/org.springframework.jms/src/main/java/org/springframework/jms/remoting/JmsInvokerProxyFactoryBean.java +++ b/org.springframework.jms/src/main/java/org/springframework/jms/remoting/JmsInvokerProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ import org.springframework.util.ClassUtils; * @see org.springframework.jms.remoting.JmsInvokerServiceExporter */ public class JmsInvokerProxyFactoryBean extends JmsInvokerClientInterceptor - implements FactoryBean, BeanClassLoaderAware { + implements FactoryBean, BeanClassLoaderAware { private Class serviceInterface; @@ -81,7 +81,7 @@ public class JmsInvokerProxyFactoryBean extends JmsInvokerClientInterceptor return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return this.serviceInterface; } diff --git a/org.springframework.transaction/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java b/org.springframework.transaction/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java index d9b4194f55..bf7f6920d7 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java +++ b/org.springframework.transaction/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ import org.springframework.beans.factory.InitializingBean; * @see javax.resource.cci.Connection#getLocalTransaction * @see org.springframework.jca.cci.connection.CciLocalTransactionManager */ -public class LocalConnectionFactoryBean implements FactoryBean, InitializingBean { +public class LocalConnectionFactoryBean implements FactoryBean, InitializingBean { private ManagedConnectionFactory managedConnectionFactory; @@ -126,7 +126,7 @@ public class LocalConnectionFactoryBean implements FactoryBean, InitializingBean return this.connectionFactory; } - public Class getObjectType() { + public Class getObjectType() { return (this.connectionFactory != null ? this.connectionFactory.getClass() : null); } diff --git a/org.springframework.transaction/src/main/java/org/springframework/jca/support/ResourceAdapterFactoryBean.java b/org.springframework.transaction/src/main/java/org/springframework/jca/support/ResourceAdapterFactoryBean.java index e0a955e5d3..ed1c3372f4 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/jca/support/ResourceAdapterFactoryBean.java +++ b/org.springframework.transaction/src/main/java/org/springframework/jca/support/ResourceAdapterFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ import org.springframework.util.Assert; * @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext) * @see javax.resource.spi.ResourceAdapter#stop() */ -public class ResourceAdapterFactoryBean implements FactoryBean, InitializingBean, DisposableBean { +public class ResourceAdapterFactoryBean implements FactoryBean, InitializingBean, DisposableBean { private ResourceAdapter resourceAdapter; @@ -124,11 +124,11 @@ public class ResourceAdapterFactoryBean implements FactoryBean, InitializingBean } - public Object getObject() { + public ResourceAdapter getObject() { return this.resourceAdapter; } - public Class getObjectType() { + public Class getObjectType() { return (this.resourceAdapter != null ? this.resourceAdapter.getClass() : ResourceAdapter.class); } diff --git a/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java b/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java index d51422916f..cea4242581 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java +++ b/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,7 +103,7 @@ import org.springframework.transaction.PlatformTransactionManager; * @see org.springframework.aop.framework.ProxyFactoryBean */ public class TransactionProxyFactoryBean extends AbstractSingletonProxyFactoryBean - implements FactoryBean, BeanFactoryAware { + implements BeanFactoryAware { private final TransactionInterceptor transactionInterceptor = new TransactionInterceptor(); @@ -174,8 +174,7 @@ public class TransactionProxyFactoryBean extends AbstractSingletonProxyFactoryBe if (this.transactionInterceptor.getTransactionManager() == null && beanFactory instanceof ListableBeanFactory) { ListableBeanFactory lbf = (ListableBeanFactory) beanFactory; - PlatformTransactionManager ptm = (PlatformTransactionManager) - BeanFactoryUtils.beanOfTypeIncludingAncestors(lbf, PlatformTransactionManager.class); + PlatformTransactionManager ptm = BeanFactoryUtils.beanOfTypeIncludingAncestors(lbf, PlatformTransactionManager.class); this.transactionInterceptor.setTransactionManager(ptm); } } diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java index cd39a07f6b..8546c1860b 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java @@ -375,19 +375,19 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator implemen /** * Handle the case where no request handler method was found for the particular HTTP request method. - * - *

The default implementation logs a warning, sends an HTTP 405 error and sets the "Allow" header. Alternatively, a - * fallback view could be chosen, or the HttpRequestMethodNotSupportedException could be rethrown as-is. - * - * @param ex the HttpRequestMethodNotSupportedException to be handled - * @param request current HTTP request + *

The default implementation logs a warning, sends an HTTP 405 error and sets the "Allow" header. + * Alternatively, a fallback view could be chosen, or the HttpRequestMethodNotSupportedException + * could be rethrown as-is. + * @param ex the HttpRequestMethodNotSupportedException to be handled + * @param request current HTTP request * @param response current HTTP response * @return a ModelAndView to render, or null if handled directly * @throws Exception an Exception that should be thrown as result of the servlet request */ - protected ModelAndView handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException ex, - HttpServletRequest request, - HttpServletResponse response) throws Exception { + protected ModelAndView handleHttpRequestMethodNotSupportedException( + HttpRequestMethodNotSupportedException ex, HttpServletRequest request, HttpServletResponse response) + throws Exception { + pageNotFoundLogger.warn(ex.getMessage()); response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); response.addHeader("Allow", StringUtils.arrayToDelimitedString(ex.getSupportedMethods(), ", ")); diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java index 8c18082451..04d24b5662 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java @@ -1,5 +1,5 @@ /* - * Copyright 2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import com.sun.syndication.feed.rss.Item; *

Application-specific view classes will extend this class. * The view will be held in the subclass itself, not in a template. * - *

Main entry points are the {@link #buildFeedMetadata(Map, WireFeed , HttpServletRequest)} + *

Main entry points are the {@link #buildFeedMetadata(Map, WireFeed , HttpServletRequest)} * and {@link #buildFeedItems(Map, HttpServletRequest, HttpServletResponse)}. * *

Thanks to Jettro Coenradie and Sergio Bossa for the original feed view prototype! diff --git a/org.springframework.web/src/main/java/org/springframework/remoting/caucho/BurlapProxyFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/remoting/caucho/BurlapProxyFactoryBean.java index 83a3912cbe..7e06907e61 100644 --- a/org.springframework.web/src/main/java/org/springframework/remoting/caucho/BurlapProxyFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/remoting/caucho/BurlapProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.FactoryBean; /** - * FactoryBean for Burlap proxies. Exposes the proxied service for - * use as a bean reference, using the specified service interface. + * {@link FactoryBean} for Burlap proxies. Exposes the proxied service + * for use as a bean reference, using the specified service interface. * *

Burlap is a slim, XML-based RPC protocol. * For information on Burlap, see the @@ -40,7 +40,7 @@ import org.springframework.beans.factory.FactoryBean; * @see org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean * @see org.springframework.remoting.rmi.RmiProxyFactoryBean */ -public class BurlapProxyFactoryBean extends BurlapClientInterceptor implements FactoryBean { +public class BurlapProxyFactoryBean extends BurlapClientInterceptor implements FactoryBean { private Object serviceProxy; @@ -56,7 +56,7 @@ public class BurlapProxyFactoryBean extends BurlapClientInterceptor implements F return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return getServiceInterface(); } diff --git a/org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianProxyFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianProxyFactoryBean.java index 01857e5159..f14ad7b2e6 100644 --- a/org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianProxyFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianProxyFactoryBean.java @@ -20,8 +20,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.FactoryBean; /** - * FactoryBean for Hessian proxies. Exposes the proxied service for - * use as a bean reference, using the specified service interface. + * {@link FactoryBean} for Hessian proxies. Exposes the proxied service + * for use as a bean reference, using the specified service interface. * *

Hessian is a slim, binary RPC protocol. * For information on Hessian, see the @@ -40,7 +40,7 @@ import org.springframework.beans.factory.FactoryBean; * @see org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean * @see org.springframework.remoting.rmi.RmiProxyFactoryBean */ -public class HessianProxyFactoryBean extends HessianClientInterceptor implements FactoryBean { +public class HessianProxyFactoryBean extends HessianClientInterceptor implements FactoryBean { private Object serviceProxy; @@ -56,7 +56,7 @@ public class HessianProxyFactoryBean extends HessianClientInterceptor implements return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return getServiceInterface(); } diff --git a/org.springframework.web/src/main/java/org/springframework/remoting/httpinvoker/HttpInvokerProxyFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/remoting/httpinvoker/HttpInvokerProxyFactoryBean.java index 325a7f35ac..d8a2be4d0f 100644 --- a/org.springframework.web/src/main/java/org/springframework/remoting/httpinvoker/HttpInvokerProxyFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/remoting/httpinvoker/HttpInvokerProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.FactoryBean; /** - * FactoryBean for HTTP invoker proxies. Exposes the proxied service for - * use as a bean reference, using the specified service interface. + * {@link FactoryBean} for HTTP invoker proxies. Exposes the proxied service + * for use as a bean reference, using the specified service interface. * *

The service URL must be an HTTP URL exposing an HTTP invoker service. * Optionally, a codebase URL can be specified for on-demand dynamic code download @@ -48,7 +48,7 @@ import org.springframework.beans.factory.FactoryBean; * @see org.springframework.remoting.caucho.BurlapProxyFactoryBean */ public class HttpInvokerProxyFactoryBean extends HttpInvokerClientInterceptor - implements FactoryBean { + implements FactoryBean { private Object serviceProxy; @@ -67,7 +67,7 @@ public class HttpInvokerProxyFactoryBean extends HttpInvokerClientInterceptor return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return getServiceInterface(); } diff --git a/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/JaxRpcPortProxyFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/JaxRpcPortProxyFactoryBean.java index 566630be74..d8f37520e3 100644 --- a/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/JaxRpcPortProxyFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/JaxRpcPortProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.util.ClassUtils; /** - * {@link org.springframework.beans.factory.FactoryBean} for a specific port of a - * JAX-RPC service. Exposes a proxy for the port, to be used for bean references. + * {@link FactoryBean} for a specific port of a JAX-RPC service. + * Exposes a proxy for the port, to be used for bean references. * Inherits configuration properties from {@link JaxRpcPortClientInterceptor}. * *

This factory is typically used with an RMI service interface. Alternatively, @@ -45,7 +45,7 @@ import org.springframework.util.ClassUtils; * @see LocalJaxRpcServiceFactoryBean */ public class JaxRpcPortProxyFactoryBean extends JaxRpcPortClientInterceptor - implements FactoryBean, BeanClassLoaderAware { + implements FactoryBean, BeanClassLoaderAware { private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); @@ -77,7 +77,7 @@ public class JaxRpcPortProxyFactoryBean extends JaxRpcPortClientInterceptor return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return getServiceInterface(); } diff --git a/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/LocalJaxRpcServiceFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/LocalJaxRpcServiceFactoryBean.java index a4e26be5b5..1559e077bc 100644 --- a/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/LocalJaxRpcServiceFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/remoting/jaxrpc/LocalJaxRpcServiceFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import org.springframework.beans.factory.InitializingBean; * @see JaxRpcPortProxyFactoryBean */ public class LocalJaxRpcServiceFactoryBean extends LocalJaxRpcServiceFactory - implements FactoryBean, InitializingBean { + implements FactoryBean, InitializingBean { private Service service; @@ -47,11 +47,11 @@ public class LocalJaxRpcServiceFactoryBean extends LocalJaxRpcServiceFactory } - public Object getObject() throws Exception { + public Service getObject() throws Exception { return this.service; } - public Class getObjectType() { + public Class getObjectType() { return (this.service != null ? this.service.getClass() : Service.class); } diff --git a/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortProxyFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortProxyFactoryBean.java index a85d844288..fa9cfd2c0f 100644 --- a/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortProxyFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.util.ClassUtils; * @see LocalJaxWsServiceFactoryBean */ public class JaxWsPortProxyFactoryBean extends JaxWsPortClientInterceptor - implements FactoryBean, BeanClassLoaderAware { + implements FactoryBean, BeanClassLoaderAware { private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); @@ -62,7 +62,7 @@ public class JaxWsPortProxyFactoryBean extends JaxWsPortClientInterceptor return this.serviceProxy; } - public Class getObjectType() { + public Class getObjectType() { return getServiceInterface(); } diff --git a/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactoryBean.java index ab18e3a3fe..91dc2902b6 100644 --- a/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,8 @@ import org.springframework.beans.factory.InitializingBean; * @see org.springframework.jndi.JndiObjectFactoryBean * @see JaxWsPortProxyFactoryBean */ -public class LocalJaxWsServiceFactoryBean extends LocalJaxWsServiceFactory implements FactoryBean, InitializingBean { +public class LocalJaxWsServiceFactoryBean extends LocalJaxWsServiceFactory + implements FactoryBean, InitializingBean { private Service service; @@ -44,11 +45,11 @@ public class LocalJaxWsServiceFactoryBean extends LocalJaxWsServiceFactory imple this.service = createJaxWsService(); } - public Object getObject() throws Exception { + public Service getObject() { return this.service; } - public Class getObjectType() { + public Class getObjectType() { return (this.service != null ? this.service.getClass() : Service.class); } diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextAttributeFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextAttributeFactoryBean.java index 55ed97f3ee..4d35f31c6e 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextAttributeFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextAttributeFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.web.context.ServletContextAware; /** - * FactoryBean that fetches a specific, existing ServletContext attribute. + * {@link FactoryBean} that fetches a specific, existing ServletContext attribute. * Exposes that ServletContext attribute when used as bean reference, * effectively making it available as named Spring bean instance. * @@ -36,7 +36,7 @@ import org.springframework.web.context.ServletContextAware; * @since 1.1.4 * @see ServletContextParameterFactoryBean */ -public class ServletContextAttributeFactoryBean implements FactoryBean, ServletContextAware { +public class ServletContextAttributeFactoryBean implements FactoryBean, ServletContextAware { private String attributeName; @@ -65,7 +65,7 @@ public class ServletContextAttributeFactoryBean implements FactoryBean, ServletC return this.attribute; } - public Class getObjectType() { + public Class getObjectType() { return (this.attribute != null ? this.attribute.getClass() : null); } diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextFactoryBean.java index 46d47276ee..1dba16785c 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.web.context.ServletContextAware; /** - * Simple FactoryBean that exposes the ServletContext for bean references. + * {@link FactoryBean} that exposes the ServletContext for bean references. * Can be used as alternative to implementing the ServletContextAware * callback interface. Allows for passing the ServletContext reference * to a constructor argument or any custom bean property. @@ -40,7 +40,7 @@ import org.springframework.web.context.ServletContextAware; * @see org.springframework.web.context.ServletContextAware * @see ServletContextAttributeFactoryBean */ -public class ServletContextFactoryBean implements FactoryBean, ServletContextAware { +public class ServletContextFactoryBean implements FactoryBean, ServletContextAware { private ServletContext servletContext; @@ -50,11 +50,11 @@ public class ServletContextFactoryBean implements FactoryBean, ServletContextAwa } - public Object getObject() { + public ServletContext getObject() { return this.servletContext; } - public Class getObjectType() { + public Class getObjectType() { return (this.servletContext != null ? this.servletContext.getClass() : ServletContext.class); } diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextParameterFactoryBean.java b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextParameterFactoryBean.java index ec6cb6e49b..b5dd06647d 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextParameterFactoryBean.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextParameterFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.web.context.ServletContextAware; /** - * FactoryBean that retrieves a specific ServletContext init parameter + * {@link FactoryBean} that retrieves a specific ServletContext init parameter * (that is, a "context-param" defined in web.xml). * Exposes that ServletContext init parameter when used as bean reference, * effectively making it available as named Spring bean instance. @@ -31,7 +31,7 @@ import org.springframework.web.context.ServletContextAware; * @since 1.2.4 * @see ServletContextAttributeFactoryBean */ -public class ServletContextParameterFactoryBean implements FactoryBean, ServletContextAware { +public class ServletContextParameterFactoryBean implements FactoryBean, ServletContextAware { private String initParamName; @@ -56,11 +56,11 @@ public class ServletContextParameterFactoryBean implements FactoryBean, ServletC } - public Object getObject() throws Exception { + public String getObject() { return this.paramValue; } - public Class getObjectType() { + public Class getObjectType() { return String.class; } diff --git a/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java b/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java index 2ec89e6c21..15f9855cf8 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java +++ b/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,28 +28,29 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * Servlet 2.3/2.4 {@link javax.servlet.Filter} that converts posted method parameters into HTTP methods, retrievable - * via {@link HttpServletRequest#getMethod()}. Since browsers currently only support GET and POST, a common technique - - * used by the Prototype library, for instance - is to use a normal POST with an additional hidden form field - * (_method) to pass the "real" HTTP method. This filter reads that parameter, and changes of {@link - * HttpServletRequestWrapper#getMethod()} accordingly. + * {@link javax.servlet.Filter} that converts posted method parameters into HTTP methods, + * retrievable via {@link HttpServletRequest#getMethod()}. Since browsers currently only + * support GET and POST, a common technique - used by the Prototype library, for instance - + * is to use a normal POST with an additional hidden form field (_method) + * to pass the "real" HTTP method. This filter reads that parameter, and changes of + * {@link HttpServletRequestWrapper#getMethod()} accordingly. * - *

The name of the request parameter defaults to _method, but can be changed via the {@link - * #setMethodParam(String) methodParam} property. + *

The name of the request parameter defaults to _method, but can be + * changed via the {@link #setMethodParam(String) methodParam} property. * * @author Arjen Poutsma * @since 3.0 */ public class HiddenHttpMethodFilter extends OncePerRequestFilter { - /** Default method parameter, i.e. _method. */ + /** Default method parameter: _method */ public static final String DEFAULT_METHOD_PARAM = "_method"; private String methodParam = DEFAULT_METHOD_PARAM; + /** * Set the parameter name to look for HTTP methods. - * * @see #DEFAULT_METHOD_PARAM */ public void setMethodParam(String methodParam) { @@ -59,8 +60,10 @@ public class HiddenHttpMethodFilter extends OncePerRequestFilter { protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - if ("POST".equals(request.getMethod()) && StringUtils.hasLength(request.getParameter(methodParam))) { - String method = request.getParameter(methodParam).toUpperCase(Locale.ENGLISH); + + String paramValue = request.getParameter(this.methodParam); + if ("POST".equals(request.getMethod()) && StringUtils.hasLength(paramValue)) { + String method = paramValue.toUpperCase(Locale.ENGLISH); HttpServletRequest wrapper = new HttpMethodRequestWrapper(method, request); filterChain.doFilter(wrapper, response); } @@ -69,21 +72,23 @@ public class HiddenHttpMethodFilter extends OncePerRequestFilter { } } + /** - * Simple {@link HttpServletRequest} wrapper that returns the supplied method for {@link - * HttpServletRequest#getMethod()}. + * Simple {@link HttpServletRequest} wrapper that returns the supplied method for + * {@link HttpServletRequest#getMethod()}. */ private static class HttpMethodRequestWrapper extends HttpServletRequestWrapper { private final String method; - private HttpMethodRequestWrapper(String method, HttpServletRequest request) { + public HttpMethodRequestWrapper(String method, HttpServletRequest request) { super(request); this.method = method; } public String getMethod() { - return method; + return this.method; } } + } diff --git a/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java b/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java index 73989331d0..dfe1318193 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java +++ b/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,12 +32,12 @@ import org.springframework.util.FileCopyUtils; import org.springframework.util.Md5HashUtils; /** - * Servlet 2.3/2.4 {@link javax.servlet.Filter} that generates an ETag value based on the content on the - * response. This ETag is compared to the If-None-Match header of the request. If these headers are equal, - * the resonse content is not sent, but rather a 304 "Not Modified" status. - *

- *

Since the ETag is based on the response content, the response (or {@link org.springframework.web.servlet.View}) - * is still rendered. As such, this filter only saves bandwith, not performance. + * {@link javax.servlet.Filter} that generates an ETag value based on the content + * on the response. This ETag is compared to the If-None-Match header of the request. + * If these headers are equal, the resonse content is not sent, but rather a 304 "Not Modified" status. + * + *

Since the ETag is based on the response content, the response (or {@link org.springframework.web.servlet.View}) + * is still rendered. As such, this filter only saves bandwidth, not server performance. * * @author Arjen Poutsma * @since 3.0 @@ -48,13 +48,15 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { private static String HEADER_IF_NONE_MATCH = "If-None-Match"; + @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - ShallowEtagResponseWrapper wrapper = new ShallowEtagResponseWrapper(response); - filterChain.doFilter(request, wrapper); - byte[] body = wrapper.toByteArray(); + ShallowEtagResponseWrapper responseWrapper = new ShallowEtagResponseWrapper(response); + filterChain.doFilter(request, responseWrapper); + + byte[] body = responseWrapper.toByteArray(); String responseETag = generateETagHeaderValue(body); response.setHeader(HEADER_ETAG, responseETag); @@ -76,11 +78,9 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { } /** - * Generates the ETag header value from the given response body bytes array. - *

- *

Default implementation generates an MD5 hash. - * - * @param bytes the + * Generate the ETag header value from the given response body byte array. + *

The default implementation generates an MD5 hash. + * @param bytes the response bdoy as byte array * @return the ETag header value * @see Md5HashUtils */ @@ -91,10 +91,11 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { return builder.toString(); } + /** - * {@link HttpServletRequest} wrapper that buffers all content written to the {@linkplain #getOutputStream() output - * stream} and {@linkplain #getWriter() writer}, and allows this content to be retrieved via a {@link #toByteArray() - * byte array}. + * {@link HttpServletRequest} wrapper that buffers all content written to the + * {@linkplain #getOutputStream() output stream} and {@linkplain #getWriter() writer}, + * and allows this content to be retrieved via a {@link #toByteArray() byte array}. */ private static class ShallowEtagResponseWrapper extends HttpServletResponseWrapper { @@ -109,24 +110,25 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { } @Override - public ServletOutputStream getOutputStream() throws IOException { - return outputStream; + public ServletOutputStream getOutputStream() { + return this.outputStream; } @Override public PrintWriter getWriter() throws IOException { - if (writer == null) { + if (this.writer == null) { String characterEncoding = getCharacterEncoding(); Writer targetWriter = (characterEncoding != null ? - new OutputStreamWriter(outputStream, characterEncoding) : new OutputStreamWriter(outputStream)); - writer = new PrintWriter(targetWriter); + new OutputStreamWriter(this.outputStream, characterEncoding) : + new OutputStreamWriter(this.outputStream)); + this.writer = new PrintWriter(targetWriter); } - return writer; + return this.writer; } @Override public void resetBuffer() { - content.reset(); + this.content.reset(); } @Override @@ -136,16 +138,16 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { } private byte[] toByteArray() { - return content.toByteArray(); + return this.content.toByteArray(); } + private class ResponseServletOutputStream extends ServletOutputStream { @Override public void write(int b) throws IOException { content.write(b); } - } } diff --git a/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java b/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java index 612b09d89b..ea3a0c7be7 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java +++ b/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java @@ -29,15 +29,16 @@ import java.util.regex.Pattern; import org.springframework.util.Assert; /** - * Represents a URI template. An URI template is a URI-like string that contained variables marked of in braces - * ({, }), which can be expanded to produce a URI. - *

- * See {@link #expand(Map)}, {@link #expand(String[])}, and {@link #match(String)} for example usages. + * Represents a URI template. An URI template is a URI-like String that contained variables + * marked of in braces ({, }), which can be expanded to produce a URI. + *

See {@link #expand(Map)}, {@link #expand(String[])}, and {@link #match(String)} for example usages. + * * @author Arjen Poutsma + * @since 3.0 * @see URI Templates * @since 3.0 */ -public final class UriTemplate { +public class UriTemplate { /** * Captures URI template variable names. @@ -49,15 +50,17 @@ public final class UriTemplate { */ private static final String VALUE_REGEX = "(.*)"; + private final List variableNames; private final Pattern matchPattern; private final String uriTemplate; + /** - * Constructs a new {@link UriTemplate} with the given string. - * @param uriTemplate the uri template string + * Construct a new {@link UriTemplate} with the given URI String. + * @param uriTemplate the URI template string */ public UriTemplate(String uriTemplate) { Parser parser = new Parser(uriTemplate); @@ -66,19 +69,20 @@ public final class UriTemplate { this.matchPattern = parser.getMatchPattern(); } + /** - * Returns the names of the variables in the template, in order. + * Return the names of the variables in the template, in order. * @return the template variable names */ - public List getVariableNames() { - return variableNames; + public final List getVariableNames() { + return this.variableNames; } /** - * Given the map of variables, expands this template into a URI string. The map keys represent variable names, the - * map values variable values. The order of variables is not significant. - *

- * Example: + * Given the Map of variables, expands this template into a URI. + * The Map keys represent variable names, the Map values variable values. + * The order of variables is not significant. + *

Example: *

 	 * UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
 	 * Map<String, String> uriVariables = new HashMap<String, String>();
@@ -87,57 +91,58 @@ public final class UriTemplate {
 	 * System.out.println(template.expand(uriVariables));
 	 * 
* will print:
http://example.com/hotels/1/bookings/42
- * @param uriVariables the map of uri variables - * @return the expanded uri - * @throws IllegalArgumentException if uriVariables is null; or if it does not contain - * values for all the variable names + * @param uriVariables the map of URI variables + * @return the expanded URI + * @throws IllegalArgumentException if uriVariables is null; + * or if it does not contain values for all the variable names */ public URI expand(Map uriVariables) { Assert.notNull(uriVariables, "'uriVariables' must not be null"); - String[] values = new String[variableNames.size()]; - for (int i = 0; i < variableNames.size(); i++) { - String name = variableNames.get(i); - Assert.isTrue(uriVariables.containsKey(name), "'uriVariables' has no value for [" + name + "]"); + String[] values = new String[this.variableNames.size()]; + for (int i = 0; i < this.variableNames.size(); i++) { + String name = this.variableNames.get(i); + if (!uriVariables.containsKey(name)) { + throw new IllegalArgumentException("'uriVariables' Map has no value for '" + name + "'"); + } values[i] = uriVariables.get(name); } return expand(values); } /** - * Given an array of variables, expands this template into a URI string. The array represent variable values. The - * order of variables is significant. - *

- * Example: - *

+	 * Given an array of variables, expand this template into a full URI.
+	 * The array represent variable values. The order of variables is significant.
+	 * 

Example: + *

 	 * will print: 
http://example.com/hotels/1/bookings/42
- * @param uriVariableValues the array of uri variables - * @return the expanded uri - * @throws IllegalArgumentException if uriVariables is null; or if it does not contain - * sufficient variables + * @param uriVariableValues the array of URI variables + * @return the expanded URI + * @throws IllegalArgumentException if uriVariables is null; + * or if it does not contain sufficient variables */ public URI expand(String... uriVariableValues) { Assert.notNull(uriVariableValues, "'uriVariableValues' must not be null"); - if (uriVariableValues.length != variableNames.size()) { - throw new IllegalArgumentException( - "Invalid amount of variables values in [" + uriTemplate + "]: expected " + variableNames.size() + - "; got " + uriVariableValues.length); + if (uriVariableValues.length != this.variableNames.size()) { + throw new IllegalArgumentException("Invalid amount of variables values in [" + + this.uriTemplate + "]: expected " + this.variableNames.size() + + "; got " + uriVariableValues.length); } - Matcher m = NAMES_PATTERN.matcher(uriTemplate); + Matcher matcher = NAMES_PATTERN.matcher(this.uriTemplate); StringBuffer buffer = new StringBuffer(); int i = 0; - while (m.find()) { + while (matcher.find()) { String uriVariable = uriVariableValues[i++]; - m.appendReplacement(buffer, uriVariable); + matcher.appendReplacement(buffer, uriVariable); } - m.appendTail(buffer); + matcher.appendTail(buffer); return encodeUri(buffer.toString()); } /** - * Indicates whether the given URI matches this template. + * Indicate whether the given URI matches this template. * @param uri the URI to match to * @return true if it matches; false otherwise */ @@ -145,16 +150,15 @@ public final class UriTemplate { if (uri == null) { return false; } - Matcher m = matchPattern.matcher(uri); - return m.matches(); + Matcher matcher = this.matchPattern.matcher(uri); + return matcher.matches(); } /** - * Matches the given URI to a map of variable values. Keys in the returned map are variable names, values are - * variable values, as occurred in the given URI. - *

- * Example: - *

+	 * Match the given URI to a map of variable values. Keys in the returned map are
+	 * variable names, values are variable values, as occurred in the given URI.
+	 * 

Example: + *

 	 * UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
 	 * System.out.println(template.match("http://example.com/hotels/1/bookings/42"));
 	 * 
@@ -164,18 +168,24 @@ public final class UriTemplate { */ public Map match(String uri) { Assert.notNull(uri, "'uri' must not be null"); - Map result = new LinkedHashMap(variableNames.size()); - Matcher m = matchPattern.matcher(uri); - if (m.find()) { - for (int i = 1; i <= m.groupCount(); i++) { - String name = variableNames.get(i - 1); - String value = m.group(i); + Map result = new LinkedHashMap(this.variableNames.size()); + Matcher matcher = this.matchPattern.matcher(uri); + if (matcher.find()) { + for (int i = 1; i <= matcher.groupCount(); i++) { + String name = this.variableNames.get(i - 1); + String value = matcher.group(i); result.put(name, value); } } return result; } + @Override + public String toString() { + return this.uriTemplate; + } + + private static URI encodeUri(String uri) { try { int idx = uri.indexOf(':'); @@ -190,41 +200,35 @@ public final class UriTemplate { } return result; } - catch (URISyntaxException e) { - throw new IllegalArgumentException("Could not create URI from [" + uri + "]"); + catch (URISyntaxException ex) { + throw new IllegalArgumentException("Could not create URI from [" + uri + "]: " + ex); } } - @Override - public String toString() { - return uriTemplate; - } - /** * Static inner class to parse uri template strings into a matching regular expression. */ private static class Parser { - private List variableNames = new LinkedList(); + private final List variableNames = new LinkedList(); - private StringBuilder patternBuilder = new StringBuilder(); + private final StringBuilder patternBuilder = new StringBuilder(); private Parser(String uriTemplate) { Assert.hasText(uriTemplate, "'uriTemplate' must not be null"); Matcher m = NAMES_PATTERN.matcher(uriTemplate); int end = 0; while (m.find()) { - patternBuilder.append(encodeAndQuote(uriTemplate, end, m.start())); - patternBuilder.append(VALUE_REGEX); - variableNames.add(m.group(1)); + this.patternBuilder.append(encodeAndQuote(uriTemplate, end, m.start())); + this.patternBuilder.append(VALUE_REGEX); + this.variableNames.add(m.group(1)); end = m.end(); } - patternBuilder.append(encodeAndQuote(uriTemplate, end, uriTemplate.length())); - - int lastIdx = patternBuilder.length() - 1; - if (lastIdx >= 0 && patternBuilder.charAt(lastIdx) == '/') { - patternBuilder.deleteCharAt(lastIdx); + this.patternBuilder.append(encodeAndQuote(uriTemplate, end, uriTemplate.length())); + int lastIdx = this.patternBuilder.length() - 1; + if (lastIdx >= 0 && this.patternBuilder.charAt(lastIdx) == '/') { + this.patternBuilder.deleteCharAt(lastIdx); } } @@ -238,13 +242,12 @@ public final class UriTemplate { private List getVariableNames() { - return Collections.unmodifiableList(variableNames); + return Collections.unmodifiableList(this.variableNames); } private Pattern getMatchPattern() { - return Pattern.compile(patternBuilder.toString()); + return Pattern.compile(this.patternBuilder.toString()); } - } }