[java-shib-shared] branch main updated: JSSH-5 ServiceableComponent should implement AutoClose

Rod Widdowson rdw at steadingsoftware.com
Fri Nov 25 16:42:46 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=f10564802c5d6dcf9b417ca051ecd6a63b1618b6

The following commit(s) were added to refs/heads/main by this push:
     new f1056480 JSSH-5 ServiceableComponent should implement AutoClose
f1056480 is described below

commit f10564802c5d6dcf9b417ca051ecd6a63b1618b6
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Nov 25 16:39:54 2022 +0000

    JSSH-5 ServiceableComponent should implement AutoClose
    
    https://shibboleth.atlassian.net/browse/JSSH-5
    
    Some tidy of the new SpringServiceableComponent.
    
    If the object we are encapsulated it named then give it our name
    If the object is desroyable then destroy it when we do.
    These make the teasing apart of the components from thier
    servicable homologs easier.
    
    Also javadoc.
---
 .../service/impl/SpringServiceableComponent.java   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/shib-service/src/main/java/net/shibboleth/shared/spring/service/impl/SpringServiceableComponent.java b/shib-service/src/main/java/net/shibboleth/shared/spring/service/impl/SpringServiceableComponent.java
index 31eacbeb..52410203 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/spring/service/impl/SpringServiceableComponent.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/spring/service/impl/SpringServiceableComponent.java
@@ -18,7 +18,11 @@
 package net.shibboleth.shared.spring.service.impl;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.component.IdentifiableComponent;
+import net.shibboleth.shared.component.InitializableComponent;
 import net.shibboleth.shared.service.ServiceableComponent;
 import net.shibboleth.shared.spring.service.AbstractServiceableComponent;
 
@@ -28,11 +32,23 @@ import net.shibboleth.shared.spring.service.AbstractServiceableComponent;
  */
 public class SpringServiceableComponent<T> extends AbstractServiceableComponent<T> {
 
+    /** The component we are encapsulating. */
     @Nonnull final T theComponent;
     
     
+    /**
+     * Constructor.
+     *
+     * @param what the object we are wrapping.
+     */
     public SpringServiceableComponent(final @Nonnull T what) {
         theComponent = what;
+        if (what instanceof IdentifiableComponent) {
+            @Nullable final String id = ((IdentifiableComponent) what).getId();
+            if (id != null) {
+                setId(id);
+            }
+        }
     }
     
     /** {@inheritDoc} */
@@ -42,4 +58,13 @@ public class SpringServiceableComponent<T> extends AbstractServiceableComponent<
         return theComponent;
     }
 
+    /** {@inheritDoc} */
+    @Override
+    protected void doInitialize() throws ComponentInitializationException {
+        pinComponent();
+        if (theComponent instanceof InitializableComponent) {
+            ((InitializableComponent)theComponent).initialize();
+        }
+        unpinComponent();
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list