[java-opensaml COMMIT] in /trunk: opensaml-profile-api/src/main/java/org/opensaml/profile/action/MessageEncoderFactor...

noreply at shibboleth.net noreply at shibboleth.net
Sat Feb 22 20:02:00 EST 2014


Author: scantor
Date: Sat Feb 22 20:02:00 2014
New Revision: 3642

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3642&view=rev
Log:
IDP-219 - rework message encoding to use OpenSAML action, move Spring lookup to a factory

Added:
    trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/MessageEncoderFactory.java   (with props)
Modified:
    trunk/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
    trunk/opensaml-profile-impl/src/test/java/org/opensaml/profile/action/impl/EncodeMessageTest.java

Modified: trunk/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java?rev=3642&r1=3641&r2=3642&view=diff
==============================================================================
--- trunk/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java (original)
+++ trunk/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java Sat Feb 22 20:02:00 2014
@@ -20,6 +20,7 @@
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
@@ -32,6 +33,7 @@
 import org.opensaml.profile.action.AbstractProfileAction;
 import org.opensaml.profile.action.ActionSupport;
 import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.action.MessageEncoderFactory;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,88 +41,92 @@
 /**
  * Action that encodes an outbound response from the outbound {@link MessageContext}. 
  * 
- * <p>
- * If the supplied instance of {@link MessageEncoder} is not already initialized, this action will
- * handle supplying the message context to encode via {@link MessageEncoder#setMessageContext(MessageContext)}, 
- * followed by invoking {@link MessageEncoder#initialize()}. If the encoder is already initialized,
- * these operations will be skipped.
- * </p>
+ * <p>The {@link MessageEncoderFactory} is used to obtain a new {@link MessageEncoder} to
+ * use, and the encoder is destroyed upon completion.</p>
  *
  * 
  * @event {@link EventIds#PROCEED_EVENT_ID}
  * @event {@link EventIds#INVALID_MSG_CTX}
  * @event {@link EventIds#UNABLE_TO_ENCODE}
  * 
- * @post If ProfileRequestContext.getOutboundMessageContext() != null, it will be injected and
- * encoded.
- * @post The injected {@link MessageEncoder} is destroyed.
+ * @post If ProfileRequestContext.getOutboundMessageContext() != null, it will be injected and encoded.
  */
 public class EncodeMessage extends AbstractProfileAction {
 
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(EncodeMessage.class);
 
-    /** The {@link MessageEncoder} instance used to encode the outgoing message. */
-    @Nonnull private final MessageEncoder encoder;
+    /** The factory to use to obtain an encoder. */
+    @NonnullAfterInit private MessageEncoderFactory encoderFactory;
     
     /**
      * An optional {@link MessageHandler} instance to be invoked after 
      * {@link MessageEncoder#prepareContext()} and prior to {@link MessageEncoder#encode()}.
      */
-    @Nullable private final MessageHandler messageHandler;
+    @Nullable private MessageHandler messageHandler;
     
     /** The outbound MessageContext to encode. */
     @Nullable private MessageContext msgContext;
-
+    
     /**
-     * Constructor.
+     * Set the encoder factory to use.
      * 
-     * 
-     * @param messageEncoder the {@link MessageEncoder} used for the outbound response
+     * @param factory   factory to use
      */
-    public EncodeMessage(@Nonnull final MessageEncoder messageEncoder) {
-        this(messageEncoder, null);
+    public void setMessageEncoderFactory(@Nonnull final MessageEncoderFactory factory) {
+        encoderFactory = Constraint.isNotNull(factory, "MessageEncoderFactory cannot be null");
     }
     
     /**
-     * Constructor.
-     * 
-     * <p>
-     * The supplied {@link MessageHandler} will be invoked on the {@link MessageContext} after 
+     * <p>The supplied {@link MessageHandler} will be invoked on the {@link MessageContext} after 
      * {@link MessageEncoder#prepareContext()}, and prior to invoking {@link MessageEncoder#encode()}.
      * Its use is optional and primarily used for transport/binding-specific message handling, 
      * as opposed to more generalized message handling operations which would typically be invoked 
-     * earlier than this action.  For more details see {@link MessageEncoder}.
-     * </p>
+     * earlier than this action. For more details see {@link MessageEncoder}.</p>
      * 

[... 171 lines stripped ...]


More information about the commits mailing list