[java-shib-shared] 01/02: JSSH-5 ServiceableComponent should implement AutoClose
Rod Widdowson
rdw at steadingsoftware.com
Thu Sep 29 15:05:45 UTC 2022
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=b6d9e52d751c856706a866f2726a71841f9aa60f
commit b6d9e52d751c856706a866f2726a71841f9aa60f
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Sep 29 15:36:16 2022 +0100
JSSH-5 ServiceableComponent should implement AutoClose
https://shibboleth.atlassian.net/browse/JSSH-5
Recast ReloadableSpringService to be in terms of AbstractServiceableComponent
rather than ServiceableComponent.
---
.../spring/service/ClassBasedServiceStrategy.java | 17 ++++++++---------
.../shared/spring/service/ReloadableSpringService.java | 12 ++++++------
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java
index ae245301..07fe075a 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java
@@ -28,24 +28,23 @@ import org.springframework.context.ApplicationContext;
import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ServiceException;
-import net.shibboleth.shared.service.ServiceableComponent;
/**
- * Strategy to create {@link ServiceableComponent}s from the {@link ApplicationContext}.
+ * Strategy to create {@link AbstractServiceableComponent}s from the {@link ApplicationContext}.
*
- * @param <T> the service type to look for; defaults to {@link ServiceableComponent}
+ * @param <T> the service type to look for; defaults to {@link AbstractServiceableComponent}
*/
@SuppressWarnings("rawtypes")
-public class ClassBasedServiceStrategy<T> implements Function<ApplicationContext, ServiceableComponent<T>> {
+public class ClassBasedServiceStrategy<T> implements Function<ApplicationContext, AbstractServiceableComponent<T>> {
/** The class we are looking for. */
- @Nonnull private final Class<ServiceableComponent> serviceClaz;
+ @Nonnull private final Class<AbstractServiceableComponent> serviceClaz;
/**
* Constructor.
*/
public ClassBasedServiceStrategy() {
- serviceClaz = ServiceableComponent.class;
+ serviceClaz = AbstractServiceableComponent.class;
}
/**
@@ -54,13 +53,13 @@ public class ClassBasedServiceStrategy<T> implements Function<ApplicationContext
* @param serviceableClaz what to look for.
*/
public ClassBasedServiceStrategy(
- @ParameterName(name="serviceableClaz") final Class<ServiceableComponent> serviceableClaz) {
+ @ParameterName(name="serviceableClaz") final Class<AbstractServiceableComponent> serviceableClaz) {
serviceClaz = Constraint.isNotNull(serviceableClaz, "Serviceable Class cannot be null");
}
/** {@inheritDoc} */
- @Nullable public ServiceableComponent<T> apply(@Nullable final ApplicationContext appContext) {
- final Collection<ServiceableComponent> components =
+ @Nullable public AbstractServiceableComponent<T> apply(@Nullable final ApplicationContext appContext) {
+ final Collection<AbstractServiceableComponent> components =
appContext.getBeansOfType(serviceClaz).values();
if (components.size() == 0) {
diff --git a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java
index c2664f69..d4723d91 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java
@@ -89,7 +89,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
@Nonnull private final Class<T> theClaz;
/** How to summon up the {@link ServiceableComponent} from the {@link ApplicationContext}. */
- @Nonnull private final Function<ApplicationContext, ServiceableComponent<T>> serviceStrategy;
+ @Nonnull private final Function<ApplicationContext, AbstractServiceableComponent<T>> serviceStrategy;
/** Application context owning this engine. */
@Nullable private ApplicationContext parentContext;
@@ -98,7 +98,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
@Nullable private String beanName;
/** The last known good component. */
- @Nullable private ServiceableComponent<T> cachedComponent;
+ @Nullable private AbstractServiceableComponent<T> cachedComponent;
/** Did the last load fail? An optimization only. */
private boolean lastLoadFailed = true;
@@ -126,7 +126,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
*/
public ReloadableSpringService(@Nonnull @ParameterName(name="claz") final Class<T> claz,
@Nonnull @ParameterName(name="strategy")
- final Function<ApplicationContext,ServiceableComponent<T>> strategy) {
+ final Function<ApplicationContext,AbstractServiceableComponent<T>> strategy) {
theClaz = Constraint.isNotNull(claz, "Class cannot be null");
serviceStrategy = Constraint.isNotNull(strategy, "Strategy cannot be null");
factoryPostProcessors = Collections.emptyList();
@@ -373,7 +373,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
log.debug("{} New Application Context created for service '{}'", getLogPrefix(), getId());
- final ServiceableComponent<T> service;
+ final AbstractServiceableComponent<T> service;
try {
service = serviceStrategy.apply(appContext);
} catch (final Exception e) {
@@ -405,7 +405,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
// except the component will never be seen before we drop the lock and so
// there can be no inversion
//
- final ServiceableComponent<T> oldComponent;
+ final AbstractServiceableComponent<T> oldComponent;
synchronized (this) {
oldComponent = cachedComponent;
cachedComponent = service;
@@ -424,7 +424,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
/** {@inheritDoc} */
@Override protected void doDestroy() {
- final ServiceableComponent<T> oldComponent = cachedComponent;
+ final AbstractServiceableComponent<T> oldComponent = cachedComponent;
cachedComponent = null;
// And tear down. Note that we are synchronized on this right now
// and this will grab the lock - but that is OK because the ranking
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list