[java-identity-provider COMMIT] in /trunk/idp-core/src/main/java/net/shibboleth/idp/service: AbstractServicableCompon...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Dec 4 10:07:40 EST 2013
Author: rdw
Date: Wed Dec 4 10:07:39 2013
New Revision: 4981
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4981&view=rev
Log:
IdP-330 Start to fill in the code for serviceable components and their loading and destruction via Spring.
Added:
trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractServicableComponent.java (with props)
Modified:
trunk/idp-core/src/main/java/net/shibboleth/idp/service/ReloadableSpringService.java
trunk/idp-core/src/main/java/net/shibboleth/idp/service/ServiceableComponent.java
Modified: trunk/idp-core/src/main/java/net/shibboleth/idp/service/ReloadableSpringService.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-core/src/main/java/net/shibboleth/idp/service/ReloadableSpringService.java?rev=4981&r1=4980&r2=4981&view=diff
==============================================================================
--- trunk/idp-core/src/main/java/net/shibboleth/idp/service/ReloadableSpringService.java (original)
+++ trunk/idp-core/src/main/java/net/shibboleth/idp/service/ReloadableSpringService.java Wed Dec 4 10:07:39 2013
@@ -17,53 +17,269 @@
package net.shibboleth.idp.service;
-import net.shibboleth.utilities.java.support.annotation.Duration;
-
-import org.springframework.context.Lifecycle;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.ThreadSafe;
+
+import net.shibboleth.idp.spring.SpringSupport;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.Resource;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
/**
* This class provides a reloading interface to a ServiceableComponent.
*
- * @param <T> The precise service being implemented.
+ * @param <T> The precise service being implemented.
*/
-public class ReloadableSpringService<T> implements Lifecycle{
+ at ThreadSafe
+public class ReloadableSpringService<T> extends AbstractReloadableService {
+
+ /** Class logger. */
+ private final Logger log = LoggerFactory.getLogger(ReloadableSpringService.class);
+
+ /** List of configuration resources for this service. */
+ private List<Resource> serviceConfigurations;
+
+ /** The class we are looking for. */
+ private final Class<T> theClaz;
+
+ /** Application context owning this engine. */
+ private ApplicationContext parentContext;
+
+ /** The last known good component. */
+ private ServiceableComponent<T> cachedComponent;
+
+ /** Did the last load fail? An optimization only. */
+ private boolean lastLoadFailed = true;
+
+ /**
+ * 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;
/**
* Constructor.
- *
+ *
* @param claz The interface being implemented.
- * @param resources the configuration.
- * @param reloadFrequency How frequently to reload.
- */
- public ReloadableSpringService(Class<T> claz, Resource[] resources, @Duration long reloadFrequency) {
- }
-
- /**
- * Get the serviceable component.
- * @param <S> the type returned.
- * @return the component (with reference).
- */
- public <S extends ServiceableComponent<T>> S getServiceableComponent() {
- return null;
- }
-
+ */
+ public ReloadableSpringService(Class<T> claz) {
+ theClaz = claz;
+ }
+
+ /**
+ * Gets the application context that is the parent to this service's context.
+ *
+ * @return application context that is the parent to this service's context
+ */
+ @Nullable public ApplicationContext getParentContext() {
+ return parentContext;
+ }
+
+ /**
+ * Sets the application context that is the parent to this service's context.
+ *
+ * This setting can not be changed after the service has been initialized.
+ *
+ * @param context context that is the parent to this service's context, may be null
+ */
+ public synchronized void setParentContext(@Nullable final ApplicationContext context) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ parentContext = context;
+ }
+
+ /**
+ * Gets an unmodifiable list of configurations for this service.
+ *
+ * @return unmodifiable list of configurations for this service
+ */
+ @Nonnull public List<Resource> getServiceConfigurations() {
+ return serviceConfigurations;
+ }
+
+ /**
[... 235 lines stripped ...]
More information about the commits
mailing list