[java-shib-shared] branch main updated: Copy in ReloadableService stub from SP.
Codeberg
noreply at shibboleth.net
Tue Nov 17 15:47:24 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
https://codeberg.org/Shibboleth/java-shib-shared/commit/586071508fda5e6ac5b2e7a421c51e1fb6e4a5f5
The following commit(s) were added to refs/heads/main by this push:
new 58607150 Copy in ReloadableService stub from SP.
58607150 is described below
commit 586071508fda5e6ac5b2e7a421c51e1fb6e4a5f5
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Nov 17 10:46:49 2026 -0500
Copy in ReloadableService stub from SP.
---
.../service/SupplierBackedReloadableService.java | 102 +++++++++++++++++++++
1 file changed, 102 insertions(+)
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/SupplierBackedReloadableService.java b/shib-service/src/main/java/net/shibboleth/shared/service/SupplierBackedReloadableService.java
new file mode 100644
index 00000000..a0cc4038
--- /dev/null
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/SupplierBackedReloadableService.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.shared.service;
+
+import java.time.Instant;
+import java.util.function.Supplier;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.shared.component.AbstractInitializableComponent;
+import net.shibboleth.shared.logic.Constraint;
+
+/**
+ * A "null" implementation of {@link ReloadableService} that obtains an instance of an
+ * object via a strategy and exposes it as though it were a component wrapped
+ * by a service by nulling the relevant methods and interfaces.
+ *
+ * @param <T> component type
+ */
+public class SupplierBackedReloadableService<T> extends AbstractInitializableComponent implements ReloadableService<T> {
+
+ /**
+ * The supplier of the component to expose.
+ */
+ @Nonnull private Supplier<T> componentSource;
+
+ /**
+ * Constructor.
+ *
+ * @param supplier source of component called when the component is requested
+ */
+ public SupplierBackedReloadableService(@Nonnull final Supplier<T> supplier) {
+ componentSource = Constraint.isNotNull(supplier, "Supplier cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public Instant getLastSuccessfulReloadInstant() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public Instant getLastReloadAttemptInstant() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public Throwable getReloadFailureCause() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public void reload() {
+ }
+
+ /** {@inheritDoc} */
+ @Nonnull public ServiceableComponent<T> getServiceableComponent() throws ServiceException {
+ final T component = componentSource.get();
+ if (component != null) {
+ return new ServiceableWrapper<>(component);
+ }
+ throw new ServiceException();
+ }
+
+ /**
+ * Dummy wrapper.
+ *
+ * @param <U> component type
+ */
+ private class ServiceableWrapper<U> implements ServiceableComponent<U> {
+
+ /** Wrapped component. */
+ @Nonnull private U component;
+
+ public ServiceableWrapper(@Nonnull final U comp) {
+ component = Constraint.isNotNull(comp, "Componnent cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Nonnull public U getComponent() {
+ return component;
+ }
+
+ /** {@inheritDoc} */
+ public void close() {
+ }
+
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list