[java-opensaml COMMIT] in /trunk: opensaml-messaging-api/src/main/java/org/opensaml/messaging/pipeline/StaticPipeline...

noreply at shibboleth.net noreply at shibboleth.net
Wed May 6 18:59:31 EDT 2015


Author: putmanb
Date: Wed May  6 18:59:31 2015
New Revision: 4269

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4269&view=rev
Log:
Replace pipelineName property in favor of strategy function.
Add a static strategy function impl.

Added:
    trunk/opensaml-messaging-api/src/main/java/org/opensaml/messaging/pipeline/StaticPipelineNameStrategy.java   (with props)
Modified:
    trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/PipelineHttpSOAPClient.java

Modified: trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/PipelineHttpSOAPClient.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/PipelineHttpSOAPClient.java?rev=4269&r1=4268&r2=4269&view=diff
==============================================================================
--- trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/PipelineHttpSOAPClient.java	(original)
+++ trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/PipelineHttpSOAPClient.java	Wed May  6 18:59:31 2015
@@ -65,6 +65,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Function;
+
 /**
  * SOAP client that is based on {@link HttpClientMessagePipeline}.
  * 
@@ -84,8 +86,8 @@
     /** Factory for the client message pipeline. */
     private HttpClientMessagePipelineFactory<InboundMessageType, OutboundMessageType> pipelineFactory;
     
-    /** The name of the specific pipeline to resolve and use. */
-    private String pipelineName;
+    /** Strategy function used to resolve the pipeline name to exexute. */
+    private Function<InOutOperationContext<?, ?>, String> pipelineNameStrategy;
     
     /** Flag indicating whether presence of a pipeline factory instance is required at init time. 
      * Defaults to: <code>true</code>. */
@@ -121,7 +123,7 @@
     protected void doDestroy() {
         httpClient = null;
         pipelineFactory = null;
-        pipelineName = null;
+        pipelineNameStrategy = null;
         credentialsProvider = null;
         tlsTrustEngine = null;
         
@@ -178,20 +180,15 @@
     }
     
     /**
-     * Set the name of the pipeline to use.  Null may be specified.
-     * 
-     * <p>
-     * The effective pipeline name is resolved via {@link #resolvePipelineName(InOutOperationContext)}.
-     * </p>
-     * 
-     * 
-     * @param name the pipeline name, or null
-     */
-    public void setPipelineName(@Nullable final String name) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-        ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
-        
-        pipelineName = StringSupport.trimOrNull(name);
+     * Set the strategy function used to resolve the name of the pipeline to use.  Null may be specified.
+     * 
+     * @param function the strategy function, or null
+     */
+    public void setPipelineNameStrategy(@Nullable final Function<InOutOperationContext<?, ?>, String> function) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+        
+        pipelineNameStrategy = function;
     }
     
     /**
@@ -457,8 +454,11 @@
      * @return the pipeline name, may be null
      */
     @Nullable protected String resolvePipelineName(@Nonnull final InOutOperationContext operationContext) {
-        //TODO support dynamic resolution from operation context data/subcontext, perhaps via pluggable strategy.
-        return pipelineName;
+        if (pipelineNameStrategy != null) {
+            return pipelineNameStrategy.apply(operationContext);
+        } else {
+            return null;
+        }
     }
 
 }



More information about the commits mailing list