[java-sp-server] branch main updated: Working auto-wired endpoint management as a service.
Scott Cantor
cantor.2 at osu.edu
Wed May 18 16:44:18 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-sp-server.
View the commit online:
http://git.shibboleth.net/view/?p=java-sp-server.git;a=commit;h=34016522513173413b1f32fd784722c7681d818a
The following commit(s) were added to refs/heads/main by this push:
new 3401652 Working auto-wired endpoint management as a service.
3401652 is described below
commit 34016522513173413b1f32fd784722c7681d818a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed May 18 12:44:13 2022 -0400
Working auto-wired endpoint management as a service.
---
.../net/shibboleth/sp/conf/global-system.xml | 28 +-------
.../{integration-system.xml => integration.xml} | 14 +++-
.../net/shibboleth/sp/conf/services-system.xml | 28 ++++++++
sp-conf/.classpath | 2 +-
sp-server-api/pom.xml | 12 +++-
.../sp/remoting/{Remoted.java => Endpoint.java} | 2 +-
.../sp/remoting/impl/RequestProcessor.java | 80 +++++++++++++---------
7 files changed, 102 insertions(+), 64 deletions(-)
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/global-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/global-system.xml
index ebd32b8..bbe35dd 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/global-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/global-system.xml
@@ -46,6 +46,8 @@
<import resource="functions.xml" />
<import resource="http-client.xml" />
<import resource="sealer.xml" />
+ <import resource="integration.xml" />
+ <import resource="services-system.xml" />
<bean id="systemPrereqs" class="org.springframework.beans.factory.config.MethodInvokingBean"
p:targetObject-ref="systemProperties" p:targetMethod="putAll">
@@ -134,30 +136,4 @@
class="org.opensaml.saml.common.binding.artifact.impl.StorageServiceSAMLArtifactMap"
p:storageService-ref="#{'%{sp.artifact.StorageService:shibboleth.StorageService}'.trim()}" />
- <!-- Root of the SP ApplicationContext tree as a reloadable service. -->
-
- <bean id="shibboleth.IntegrationService" class="net.shibboleth.ext.spring.service.ReloadableSpringService"
- c:claz="org.springframework.context.ApplicationContext"
- p:serviceConfigurations="#{getObject('%{sp.service.integration.resources:shibboleth.IntegrationResources}'.trim()) ?:
- getObject('shibboleth.DefaultIntegrationResources')}"
- p:failFast="%{sp.service.integration.failFast:%{sp.service.failFast:false}}"
- p:reloadCheckDelay="%{sp.service.integration.checkInterval:PT0S}"
- p:beanPostProcessors-ref="shibboleth.IdentifiableBeanPostProcessor"
- p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer">
- <constructor-arg name="strategy">
- <bean class="net.shibboleth.ext.spring.service.ApplicationContextServiceStrategy" />
- </constructor-arg>
- </bean>
- <util:list id="shibboleth.DefaultIntegrationResources">
- <value>classpath:/net/shibboleth/sp/conf/integration-system.xml</value>
- <value>classpath:/net/shibboleth/sp/conf/services-system.xml</value>
- </util:list>
-
- <bean id="shibboleth.LoggingService"
- class="%{sp.service.logging.class:net.shibboleth.ext.spring.service.LogbackLoggingService}"
- p:loggingConfiguration="%{sp.service.logging.resource:%{sp.home}/conf/logback.xml}"
- p:fallbackConfiguration="classpath:/logback.xml"
- p:reloadCheckDelay="%{sp.service.logging.checkInterval:PT0S}"
- p:failFast="%{sp.service.logging.failFast:%{sp.service.failFast:true}}" />
-
</beans>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/integration-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/integration.xml
similarity index 85%
rename from sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/integration-system.xml
rename to sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/integration.xml
index f5c54e6..4987520 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/integration-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/integration.xml
@@ -1,14 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:c="http://www.springframework.org/schema/c"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
- http://www.springframework.org/schema/integration/ip https://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
+ http://www.springframework.org/schema/integration/ip https://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd"
+
+ default-init-method="initialize"
+ default-destroy-method="destroy">
+ <!-- Bean name must be set to this. -->
<bean id="integrationConversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
@@ -43,6 +49,8 @@
ref="shibboleth.RequestProcessor"
method="execute" />
- <bean id="shibboleth.RequestProcessor" class="net.shibboleth.sp.remoting.impl.RequestProcessor" />
-
+ <bean id="shibboleth.RequestProcessor" class="net.shibboleth.sp.remoting.impl.RequestProcessor"
+ depends-on="shibboleth.LoggingService"
+ p:endpointManager-ref="shibboleth.ServiceProvider" />
+
</beans>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml
index 8f5820c..4afe72a 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml
@@ -16,5 +16,33 @@
These are beans that define reloadable services. The actual Spring resources that configure the
services are generally defined in the services.xml file edited by deployers.
-->
+
+ <bean id="shibboleth.LoggingService"
+ class="%{sp.service.logging.class:net.shibboleth.ext.spring.service.LogbackLoggingService}"
+ p:loggingConfiguration="%{sp.service.logging.resource:%{sp.home}/conf/logback.xml}"
+ p:fallbackConfiguration="classpath:/logback.xml"
+ p:reloadCheckDelay="%{sp.service.logging.checkInterval:PT0S}"
+ p:failFast="%{sp.service.logging.failFast:%{sp.service.failFast:true}}" />
+
+ <bean id="shibboleth.ServiceProvider" class="net.shibboleth.ext.spring.service.ReloadableSpringService"
+ c:claz="net.shibboleth.sp.remoting.EndpointManager"
+ p:serviceConfigurations-ref="ExtendedServiceProviderResources"
+ p:failFast="%{sp.service.provider.failFast:%{sp.service.failFast:false}}"
+ p:reloadCheckDelay="%{sp.service.provider.checkInterval:PT0S}"
+ p:beanPostProcessors-ref="shibboleth.IdentifiableBeanPostProcessor"
+ p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer" />
+
+ <!-- Auto-append system config file to resource set. -->
+ <bean id ="ExtendedServiceProviderResources" class="net.shibboleth.ext.spring.factory.CombiningListFactoryBean"
+ p:firstList="#{getObject('%{sp.service.provider.resources:shibboleth.ServiceProviderResources}'.trim()) ?:
+ getObject('shibboleth.DefaultServiceProviderResources')}" >
+ <property name="secondList">
+ <util:list >
+ <value>classpath:/net/shibboleth/sp/conf/endpoints-system.xml</value>
+ </util:list>
+ </property>
+ </bean>
+
+ <util:list id="shibboleth.DefaultServiceProviderResources" />
</beans>
diff --git a/sp-conf/.classpath b/sp-conf/.classpath
index 7929658..135508e 100644
--- a/sp-conf/.classpath
+++ b/sp-conf/.classpath
@@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry excluding="**" kind="src" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
diff --git a/sp-server-api/pom.xml b/sp-server-api/pom.xml
index 685d11d..1457934 100644
--- a/sp-server-api/pom.xml
+++ b/sp-server-api/pom.xml
@@ -33,7 +33,17 @@
<version>${spring-extensions.version}</version>
<scope>compile</scope>
</dependency>
-
+ <dependency>
+ <groupId>${spring.groupId}</groupId>
+ <artifactId>spring-beans</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>${spring.groupId}</groupId>
+ <artifactId>spring-context</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
<!-- provided dependencies -->
<dependency>
<groupId>${slf4j.groupId}</groupId>
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/remoting/Remoted.java b/sp-server-api/src/main/java/net/shibboleth/sp/remoting/Endpoint.java
similarity index 98%
rename from sp-server-api/src/main/java/net/shibboleth/sp/remoting/Remoted.java
rename to sp-server-api/src/main/java/net/shibboleth/sp/remoting/Endpoint.java
index d3a5210..710554a 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/remoting/Remoted.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/remoting/Endpoint.java
@@ -24,7 +24,7 @@ import net.shibboleth.utilities.java.support.ddf.DDF;
* Objects implement this interface to receive messages from SP agents and to support
* registration and deregistration with the integration service.
*/
-public interface Remoted {
+public interface Endpoint {
/**
* Gets the messaging address of this component to allow it to receive messages intended for it
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/RequestProcessor.java b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/RequestProcessor.java
index 51100ca..3adced6 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/RequestProcessor.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/RequestProcessor.java
@@ -14,25 +14,22 @@
package net.shibboleth.sp.remoting.impl;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.stream.Collectors;
-
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import net.shibboleth.sp.remoting.RemoteProcessingException;
-import net.shibboleth.sp.remoting.Remoted;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.sp.remoting.Endpoint;
+import net.shibboleth.sp.remoting.EndpointManager;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.ddf.DDF;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.service.ReloadableService;
+import net.shibboleth.utilities.java.support.service.ServiceableComponent;
/**
* Core request processing service called by Spring Integration to handle requests.
@@ -44,29 +41,32 @@ public class RequestProcessor extends AbstractIdentifiableInitializableComponent
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(RequestProcessor.class);
- /** Map of auto-wired message sinks. */
- @Nonnull @NonnullElements Map<String,Remoted> addressMap;
-
- /** Constructor. */
- public RequestProcessor() {
- addressMap = Collections.emptyMap();
- }
-
+ /** Address lookup service. */
+ @NonnullAfterInit ReloadableService<EndpointManager> service;
+
/**
- * Sets the remoted objects to register for messages.
+ * Sets the {@link EndpointManager} to use.
*
- * @param remotedObjects auto-wired objects to register as message sinks
+ * @param svc endpoint manager wrapped in a service component
*/
- @Autowired
- public void setRemotedObjects(@Nullable @NonnullElements Collection<Remoted> remotedObjects) {
+ public void setEndpointManager(@Nonnull final ReloadableService<EndpointManager> svc) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (remotedObjects != null) {
- addressMap = remotedObjects.stream().collect(Collectors.toMap(Remoted::getAddress, r -> r));
- } else {
- addressMap = Collections.emptyMap();
+ service = Constraint.isNotNull(svc, "EndpointManager service cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+
+ if (service == null) {
+ throw new ComponentInitializationException("EndpointManager service cannot be null");
}
}
+
+
+
/**
* Execute a remote request.
@@ -78,25 +78,41 @@ public class RequestProcessor extends AbstractIdentifiableInitializableComponent
* @throws RemoteProcessingException if an error is raised by the destination of the message
*/
@Nonnull public DDF execute(@Nonnull final DDF input) throws RemoteProcessingException {
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+
Constraint.isNotNull(input, "Input object cannot be null");
- log.trace("{}: Input message: {}", getId(), input.toString());
+ log.trace("Input message: {}", input.toString());
if (input.name() == null) {
- log.warn("{}: Input message lacked an address", getId());
+ log.warn("Input message lacked an address");
throw new RemoteProcessingException("Input message lacked an address");
}
- final Remoted remoted = addressMap.get(input.name());
- if (remoted == null) {
- log.warn("{}: No registered target for address {}", getId(), input.name());
+ final Endpoint endpoint;
+ ServiceableComponent<EndpointManager> component = null;
+ try {
+ component = service.getServiceableComponent();
+ if (null == component) {
+ log.error("Error accessing EndpointManager component: Invalid configuration");
+ throw new RemoteProcessingException("Error accessing EndpointManager component: Invalid configuration");
+ }
+ endpoint = component.getComponent().getEndpoint(input.name());
+ } finally {
+ if (null != component) {
+ component.unpinComponent();
+ }
+ }
+
+ if (endpoint == null) {
+ log.warn("No registered target for address {}", input.name());
throw new RemoteProcessingException("No registered target for address " + input.name());
}
- final DDF output = remoted.receive(input);
+ final DDF output = endpoint.receive(input);
Constraint.isNotNull(output, "Output object cannot be null");
- log.trace("{}: Output message: {}", getId(), output.toString());
+ log.trace("Output message: {}", output.toString());
return output;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list