Introduce "Aware" superinterface
All existing *Aware interfaces have been refactored to extend this
new marker interface, serving two purposes:
* Easy access to a type hierarchy that can answer the question
"What *Aware interfaces are available?", without requiring
text-based searches. Also clearly excludes false positives like
TargetClassAware and ParamAware, which while similarly named,
are not semantically similar to traditional *Aware interfaces
in Spring.
* Minor potential performance improvements in
AbstractAutowireCapableBeanFactory and
ApplicationContextAwareProcessor. Both have blocks of sequential
instanceof checks in order to invoke any *Aware interface callback
methods. For a bean that implements none of these interfaces,
the whole sequence can be avoided by guarding first with
if (bean instanceof Aware) {
...
}
Implementors of custom *Aware-style interfaces (and presumably
the BeanPostProcessors that handle them), are encouraged to refactor to
extending this interface for consistency with the framework as well as
the points above.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
* Copyright 2002-2011 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,6 +18,8 @@ package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
|
||||
import org.springframework.beans.factory.Aware;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by any object that wishes to be notified
|
||||
* of the ServletConfig (typically determined by the WebApplicationContext)
|
||||
@@ -28,10 +30,11 @@ import javax.servlet.ServletConfig;
|
||||
* elsewhere, an exception will be thrown on bean creation.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 2.0
|
||||
* @see ServletContextAware
|
||||
*/
|
||||
public interface ServletConfigAware {
|
||||
public interface ServletConfigAware extends Aware {
|
||||
|
||||
/**
|
||||
* Set the ServletConfig that this object runs in.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
* Copyright 2002-2011 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,16 +18,19 @@ package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.Aware;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by any object that wishes to be notified
|
||||
* of the ServletContext (typically determined by the WebApplicationContext)
|
||||
* that it runs in.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 12.03.2004
|
||||
* @see ServletConfigAware
|
||||
*/
|
||||
public interface ServletContextAware {
|
||||
public interface ServletContextAware extends Aware {
|
||||
|
||||
/**
|
||||
* Set the ServletContext that this object runs in.
|
||||
|
||||
Reference in New Issue
Block a user