generified FactoryBeans and further Java 5 code style updates
This commit is contained in:
@@ -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.
|
||||
*
|
||||
* <p>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<Object>, 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Object>, 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 <code>null</code> 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;
|
||||
|
||||
@@ -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<Object>, 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <code>MyType xxx()</code> or <code>MyType xxx(MyIdType id)</code>
|
||||
* A {@link FactoryBean} implementation that takes an interface which must have one or more
|
||||
* methods with the signatures <code>MyType xxx()</code> or <code>MyType xxx(MyIdType id)</code>
|
||||
* (typically, <code>MyService getService()</code> or <code>MyService getService(String id)</code>)
|
||||
* 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<Object>, 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 {
|
||||
|
||||
Reference in New Issue
Block a user