[java-opensaml] branch master updated: Eliminate redundant functional interface.
Scott Cantor
cantor.2 at osu.edu
Tue Oct 15 15:21:40 EDT 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=8fe05a03c13d7dac2ebd31a2f32d30b79087c6c6
The following commit(s) were added to refs/heads/master by this push:
new 8fe05a0 Eliminate redundant functional interface.
8fe05a0 is described below
commit 8fe05a03c13d7dac2ebd31a2f32d30b79087c6c6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Oct 15 15:21:34 2019 -0400
Eliminate redundant functional interface.
---
.../profile/action/MessageEncoderFactory.java | 41 ----------------------
.../profile/action/impl/EncodeMessage.java | 11 +++---
.../profile/action/impl/EncodeMessageTest.java | 8 ++---
3 files changed, 10 insertions(+), 50 deletions(-)
diff --git a/opensaml-profile-api/src/main/java/org/opensaml/profile/action/MessageEncoderFactory.java b/opensaml-profile-api/src/main/java/org/opensaml/profile/action/MessageEncoderFactory.java
deleted file mode 100644
index b992487..0000000
--- a/opensaml-profile-api/src/main/java/org/opensaml/profile/action/MessageEncoderFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 org.opensaml.profile.action;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.messaging.encoder.MessageEncoder;
-import org.opensaml.profile.context.ProfileRequestContext;
-
-/**
- * A component that returns a {@link MessageEncoder} instance based on the content of a profile request
- * context.
- */
-public interface MessageEncoderFactory {
-
- /**
- * Get the {@link MessageEncoder} to use.
- *
- * @param profileRequestContext current profile request context
- *
- * @return the encoder to use, or null
- */
- @Nullable MessageEncoder getMessageEncoder(@Nonnull final ProfileRequestContext profileRequestContext);
-
-}
\ No newline at end of file
diff --git a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
index 1deea7f..34a4b70 100644
--- a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
+++ b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
@@ -17,6 +17,8 @@
package org.opensaml.profile.action.impl;
+import java.util.function.Function;
+
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -32,7 +34,6 @@ import org.opensaml.messaging.handler.MessageHandlerException;
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;
@@ -55,8 +56,8 @@ public class EncodeMessage extends AbstractProfileAction {
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(EncodeMessage.class);
- /** The factory to use to obtain an encoder. */
- @NonnullAfterInit private MessageEncoderFactory encoderFactory;
+ /** The function to use to obtain an encoder. */
+ @NonnullAfterInit private Function<ProfileRequestContext,MessageEncoder> encoderFactory;
/**
* An optional {@link MessageHandler} instance to be invoked after
@@ -72,7 +73,7 @@ public class EncodeMessage extends AbstractProfileAction {
*
* @param factory factory to use
*/
- public void setMessageEncoderFactory(@Nonnull final MessageEncoderFactory factory) {
+ public void setMessageEncoderFactory(@Nonnull final Function<ProfileRequestContext,MessageEncoder> factory) {
encoderFactory = Constraint.isNotNull(factory, "MessageEncoderFactory cannot be null");
}
@@ -117,7 +118,7 @@ public class EncodeMessage extends AbstractProfileAction {
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- final MessageEncoder encoder = encoderFactory.getMessageEncoder(profileRequestContext);
+ final MessageEncoder encoder = encoderFactory.apply(profileRequestContext);
if (encoder == null) {
log.error("{} Unable to locate an outbound message encoder", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, EventIds.UNABLE_TO_ENCODE);
diff --git a/opensaml-profile-impl/src/test/java/org/opensaml/profile/action/impl/EncodeMessageTest.java b/opensaml-profile-impl/src/test/java/org/opensaml/profile/action/impl/EncodeMessageTest.java
index 6955879..4b67d1c 100644
--- a/opensaml-profile-impl/src/test/java/org/opensaml/profile/action/impl/EncodeMessageTest.java
+++ b/opensaml-profile-impl/src/test/java/org/opensaml/profile/action/impl/EncodeMessageTest.java
@@ -17,6 +17,8 @@
package org.opensaml.profile.action.impl;
+import java.util.function.Function;
+
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -29,7 +31,6 @@ import org.opensaml.messaging.encoder.MessageEncoder;
import org.opensaml.messaging.encoder.MessageEncodingException;
import org.opensaml.profile.action.ActionTestingSupport;
import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.action.MessageEncoderFactory;
import org.opensaml.profile.action.impl.EncodeMessage;
import org.opensaml.profile.context.ProfileRequestContext;
import org.testng.Assert;
@@ -139,11 +140,10 @@ public class EncodeMessageTest {
}
}
- private class MockEncoderFactory implements MessageEncoderFactory {
+ private class MockEncoderFactory implements Function<ProfileRequestContext,MessageEncoder> {
/** {@inheritDoc} */
- @Override
- @Nullable public MessageEncoder getMessageEncoder(@Nonnull final ProfileRequestContext profileRequestContext) {
+ @Nullable public MessageEncoder apply(@Nonnull final ProfileRequestContext profileRequestContext) {
return encoder;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list