[java-identity-provider COMMIT] /trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractReloadableService.java

noreply at shibboleth.net noreply at shibboleth.net
Mon Mar 25 22:13:15 EDT 2013


Author: scantor
Date: Mon Mar 25 22:13:15 2013
New Revision: 4361

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4361&view=rev
Log:
Refactor content of initialize, validate, and start methods to fit expected lifecycle.

Modified:
    trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractReloadableService.java

Modified: trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractReloadableService.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractReloadableService.java?rev=4361&r1=4360&r2=4361&view=diff
==============================================================================
--- trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractReloadableService.java (original)
+++ trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractReloadableService.java Mon Mar 25 22:13:15 2013
@@ -28,7 +28,7 @@
 import net.shibboleth.idp.log.EventLogger;
 import net.shibboleth.idp.log.PerformanceEvent;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.component.ComponentValidationException;
 
 import org.joda.time.DateTime;
 import org.joda.time.chrono.ISOChronology;
@@ -133,14 +133,27 @@
     /** {@inheritDoc} */
     protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
-
+    }
+
+    /** {@inheritDoc} */
+    public void validate() throws ComponentValidationException {
+        super.validate();
+        if (reloadCheckDelay > 0 && reloadTaskTimer == null) {
+            throw new ComponentValidationException("Reload task timer cannot be null");
+        }
+    }
+    
+    /** {@inheritDoc} */
+    protected void doStart(@Nonnull final HashMap context) throws ServiceException {
+        super.doStart(context);
         if (reloadCheckDelay > 0) {
-            Constraint.isNotNull(reloadTaskTimer, "Reload task timer cannot be null");
             reloadTask = new ServiceReloadTask();
             reloadTaskTimer.schedule(reloadTask, reloadCheckDelay, reloadCheckDelay);
-        }
-    }
-
+        } else {
+            doReload(context);
+        }
+    }    
+    
     /**
      * {@inheritDoc}
      * 
@@ -190,9 +203,9 @@
     protected abstract boolean shouldReload();
 
     /** {@inheritDoc} */
-    protected void doPreStop(@Nonnull final HashMap context) throws ServiceException {
+    protected void doStop(@Nonnull final HashMap context) throws ServiceException {
         reloadTask.cancel();
-        super.doPreStop(context);
+        super.doStop(context);
     }
 
     /**



More information about the commits mailing list