[java-shib-shared] branch dev/thymeleaf updated: IDP-2230 - Replace hardwired ViewResolver beans with autowiring

Scott Cantor cantor.2 at osu.edu
Mon Feb 5 16:09:06 UTC 2024


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch dev/thymeleaf
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=f583fae43e5eb1a3c21b52e12843c3acdda3de31

The following commit(s) were added to refs/heads/dev/thymeleaf by this push:
     new f583fae4 IDP-2230 - Replace hardwired ViewResolver beans with autowiring
f583fae4 is described below

commit f583fae43e5eb1a3c21b52e12843c3acdda3de31
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Feb 5 11:09:00 2024 -0500

    IDP-2230 - Replace hardwired ViewResolver beans with autowiring
    
    https://shibboleth.atlassian.net/browse/IDP-2230
    
    Add factory bean for ViewResolvers.
---
 .../spring/factory/ViewResolversFactoryBean.java   | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/shib-spring/src/main/java/net/shibboleth/shared/spring/factory/ViewResolversFactoryBean.java b/shib-spring/src/main/java/net/shibboleth/shared/spring/factory/ViewResolversFactoryBean.java
new file mode 100644
index 00000000..4c7135f5
--- /dev/null
+++ b/shib-spring/src/main/java/net/shibboleth/shared/spring/factory/ViewResolversFactoryBean.java
@@ -0,0 +1,73 @@
+/*
+ * 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.spring.factory;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.servlet.ViewResolver;
+
+import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.primitive.LoggerFactory;
+
+/**
+ * Class used for auto-wiring {@link ViewResolver} beans for Spring Web Flow.
+ * 
+ * @since 9.1.0
+ */
+public class ViewResolversFactoryBean extends AbstractFactoryBean<List<ViewResolver>> {
+
+    /** Class logger. */
+    @Nonnull private Logger log = LoggerFactory.getLogger(ViewResolversFactoryBean.class);
+
+    /** Underlying collection. */
+    @Nonnull private List<ViewResolver> resolvers;
+    
+    /**
+     * Auto-wiring point for resolvers.
+     * 
+     * @param freeObjects free-standing objects
+     */
+    @Autowired
+    public ViewResolversFactoryBean(@Nullable final List<ViewResolver> freeObjects) {
+        if (freeObjects != null) {
+            resolvers = CollectionSupport.copyToList(freeObjects);
+        } else {
+            resolvers = CollectionSupport.emptyList();
+        }
+        
+        log.debug("Registered ViewResolvers: {}",
+                resolvers.stream().map(Object::getClass).map(Class::getName).collect(Collectors.toUnmodifiableList()));
+    }
+    
+    /** {@inheritDoc} */
+    @Override
+    @SuppressWarnings("rawtypes")
+    @Nullable public Class<List> getObjectType() {
+        return List.class;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    @Nullable protected List<ViewResolver> createInstance() throws Exception {
+        return CollectionSupport.copyToList(resolvers);
+    }
+    
+}
\ 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