[utilities COMMIT] in /spring-extensions/trunk/src: main/java/net/shibboleth/ext/spring/service/ReloadableSpringServi...
noreply at shibboleth.net
noreply at shibboleth.net
Tue Nov 18 23:41:06 EST 2014
Author: scantor
Date: Tue Nov 18 23:41:06 2014
New Revision: 685
URL: http://svn.shibboleth.net/view/utilities?rev=685&view=rev
Log:
Add support for BeanFactoryPostProcessor injection to SpringSupport and Service APIs.
Modified:
spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java
spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java
spring-extensions/trunk/src/test/java/net/shibboleth/ext/spring/service/ReloadableSpringServiceTest.java
Modified: spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java
URL: http://svn.shibboleth.net/view/utilities/spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java?rev=685&r1=684&r2=685&view=diff
==============================================================================
--- spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java (original)
+++ spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java Tue Nov 18 23:41:06 2014
@@ -27,6 +27,7 @@
import net.shibboleth.ext.spring.util.SpringSupport;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -39,6 +40,7 @@
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -69,13 +71,16 @@
BeanNameAware, Lifecycle {
/** Class logger. */
- private final Logger log = LoggerFactory.getLogger(ReloadableSpringService.class);
+ @Nonnull private final Logger log = LoggerFactory.getLogger(ReloadableSpringService.class);
/** List of configuration resources for this service. */
- private List<Resource> serviceConfigurations;
+ @Nullable @NonnullElements private List<Resource> serviceConfigurations;
+
+ /** List of bean factory post processors for this service's content. */
+ @Nonnull @NonnullElements private List<BeanFactoryPostProcessor> factoryPostProcessors;
/** List of bean post processors for this service's content. */
- private List<BeanPostProcessor> postProcessors;
+ @Nonnull @NonnullElements private List<BeanPostProcessor> postProcessors;
/** The class we are looking for. */
@Nonnull private final Class<T> theClaz;
@@ -84,13 +89,13 @@
@Nonnull private final Function<GenericApplicationContext, ServiceableComponent> serviceStrategy;
/** Application context owning this engine. */
- private ApplicationContext parentContext;
+ @Nullable private ApplicationContext parentContext;
/** The bean name. */
- private String beanName;
+ @Nullable private String beanName;
/** The last known good component. */
- private ServiceableComponent<T> cachedComponent;
+ @Nullable private ServiceableComponent<T> cachedComponent;
/** Did the last load fail? An optimization only. */
private boolean lastLoadFailed = true;
@@ -99,7 +104,7 @@
* Time, in milliseconds, when the service configuration for the given index was last observed to have changed. -1
* indicates the configuration resource did not exist.
*/
- private long[] resourceLastModifiedTimes;
+ @Nullable private long[] resourceLastModifiedTimes;
/**
* Constructor.
@@ -120,6 +125,7 @@
@Nonnull Function<GenericApplicationContext, ServiceableComponent> strategy) {
theClaz = Constraint.isNotNull(claz, "Class cannot be null");
serviceStrategy = Constraint.isNotNull(strategy, "Strategy cannot be null");
+ factoryPostProcessors = Collections.emptyList();
postProcessors = Collections.emptyList();
}
@@ -202,6 +208,19 @@
}
/**
+ * Set the list of bean factory post processors for this service.
+ *
+ * @param processors bean factory post processors to apply
+ */
+ public void setBeanFactoryPostProcessors(
+ @Nonnull @NonnullElements final List<BeanFactoryPostProcessor> processors) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+
+ factoryPostProcessors = Lists.newArrayList(Collections2.filter(processors, Predicates.notNull()));
+ }
+
+ /**
[... 143 lines stripped ...]
More information about the commits
mailing list