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:
Chris Beams
2011-01-03 10:13:57 +00:00
parent b3ff9be78f
commit 5e6912302a
21 changed files with 144 additions and 62 deletions

View File

@@ -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.
@@ -17,6 +17,7 @@
package org.springframework.scheduling.quartz;
import org.quartz.SchedulerContext;
import org.springframework.beans.factory.Aware;
/**
* Callback interface to be implemented by Spring-managed
@@ -27,11 +28,12 @@ import org.quartz.SchedulerContext;
* that are passed in via Spring's SchedulerFactoryBean.
*
* @author Juergen Hoeller
* @author Chris Beams
* @since 2.0
* @see org.quartz.spi.JobFactory
* @see SchedulerFactoryBean#setJobFactory
*/
public interface SchedulerContextAware {
public interface SchedulerContextAware extends Aware {
/**
* Set the SchedulerContext of the current Quartz Scheduler.