Remove another interface from user API
This commit is contained in:
@@ -17,10 +17,8 @@
|
||||
package org.springframework.cloud.contract.stubrunner.server;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
|
||||
import org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierMessaging;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -37,12 +35,6 @@ public class StubRunnerBackupAutoConfiguration {
|
||||
return new NoOpContractVerifierMessaging();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ContractVerifierMessageBuilder<?> contractVerifierMessageBuilder() {
|
||||
return new NoOpContractVerifierMessageBuilder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ContractVerifierMessaging<Object> contractVerifierMessaging(
|
||||
ContractVerifierMessageExchange<Object> exchange) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.cloud.contract.verifier.messaging.camel;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Message;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
|
||||
@@ -36,13 +35,8 @@ public class ContractVerifierCamelConfiguration {
|
||||
|
||||
@Bean
|
||||
ContractVerifierMessageExchange<Message> contractVerifierMessageExchange(
|
||||
CamelContext context, ContractVerifierMessageBuilder<Message> builder) {
|
||||
return new ContractVerifierCamelMessaging(context, builder);
|
||||
}
|
||||
|
||||
@Bean
|
||||
ContractVerifierMessageBuilder<Message> contractVerifierMessageBuilder() {
|
||||
return new ContractVerifierCamelMessageBuilder();
|
||||
CamelContext context) {
|
||||
return new ContractVerifierCamelMessaging(context);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -20,15 +20,12 @@ import java.util.Map;
|
||||
|
||||
import org.apache.camel.Message;
|
||||
import org.apache.camel.impl.DefaultMessage;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ContractVerifierCamelMessageBuilder implements
|
||||
ContractVerifierMessageBuilder<Message> {
|
||||
public class ContractVerifierCamelMessageBuilder {
|
||||
|
||||
@Override
|
||||
public <T> Message create(T payload, Map<String, Object> headers) {
|
||||
DefaultMessage message = new DefaultMessage();
|
||||
message.setBody(payload);
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.apache.camel.impl.DefaultExchange;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -43,13 +42,11 @@ public class ContractVerifierCamelMessaging implements
|
||||
ContractVerifierCamelMessaging.class);
|
||||
|
||||
private final CamelContext context;
|
||||
private final ContractVerifierMessageBuilder<Message> builder;
|
||||
private final ContractVerifierCamelMessageBuilder builder = new ContractVerifierCamelMessageBuilder();
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("unchecked")
|
||||
public ContractVerifierCamelMessaging(CamelContext context, ContractVerifierMessageBuilder<Message> contractVerifierMessageBuilder) {
|
||||
public ContractVerifierCamelMessaging(CamelContext context) {
|
||||
this.context = context;
|
||||
this.builder = contractVerifierMessageBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.cloud.contract.verifier.messaging.integration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
|
||||
@@ -36,15 +35,8 @@ public class ContractVerifierIntegrationConfiguration<T> {
|
||||
|
||||
@Bean
|
||||
public ContractVerifierMessageExchange<Message<?>> contractVerifierMessageExchange(
|
||||
ApplicationContext applicationContext,
|
||||
ContractVerifierMessageBuilder<Message<?>> contractVerifierMessageBuilder) {
|
||||
return new ContractVerifierIntegrationMessaging(applicationContext,
|
||||
contractVerifierMessageBuilder);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ContractVerifierMessageBuilder<Message<?>> contractVerifierMessageBuilder() {
|
||||
return new ContractVerifierIntegrationMessageBuilder();
|
||||
ApplicationContext applicationContext) {
|
||||
return new ContractVerifierIntegrationMessaging(applicationContext);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -56,8 +48,7 @@ public class ContractVerifierIntegrationConfiguration<T> {
|
||||
|
||||
class ContractVerifierHelper extends ContractVerifierMessaging<Message<?>> {
|
||||
|
||||
public ContractVerifierHelper(
|
||||
ContractVerifierMessageExchange<Message<?>> exchange) {
|
||||
public ContractVerifierHelper(ContractVerifierMessageExchange<Message<?>> exchange) {
|
||||
super(exchange);
|
||||
}
|
||||
|
||||
@@ -66,4 +57,3 @@ class ContractVerifierHelper extends ContractVerifierMessaging<Message<?>> {
|
||||
return new ContractVerifierMessage(receive.getPayload(), receive.getHeaders());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.contract.verifier.messaging.integration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
@@ -26,10 +25,8 @@ import org.springframework.messaging.support.MessageBuilder;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ContractVerifierIntegrationMessageBuilder implements
|
||||
ContractVerifierMessageBuilder<Message<?>> {
|
||||
public class ContractVerifierIntegrationMessageBuilder {
|
||||
|
||||
@Override
|
||||
public <T> Message<T> create(T payload, Map<String, Object> headers) {
|
||||
return MessageBuilder.createMessage(payload, new MessageHeaders(headers));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -41,12 +40,11 @@ public class ContractVerifierIntegrationMessaging implements
|
||||
ContractVerifierIntegrationMessaging.class);
|
||||
|
||||
private final ApplicationContext context;
|
||||
private final ContractVerifierMessageBuilder<Message<?>> builder;
|
||||
private final ContractVerifierIntegrationMessageBuilder builder = new ContractVerifierIntegrationMessageBuilder();
|
||||
|
||||
@Autowired
|
||||
public ContractVerifierIntegrationMessaging(ApplicationContext context, ContractVerifierMessageBuilder<Message<?>> contractVerifierMessageBuilder) {
|
||||
public ContractVerifierIntegrationMessaging(ApplicationContext context) {
|
||||
this.context = context;
|
||||
this.builder = contractVerifierMessageBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
*
|
||||
* 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 org.springframework.cloud.contract.verifier.messaging;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Contract for creation of (@link ContractVerifierMessage}. You can create a message from
|
||||
* payload and headers or from some type (e.g. Spring Messaging Message).
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public interface ContractVerifierMessageBuilder<M> {
|
||||
|
||||
/**
|
||||
* Creates a {@link ContractVerifierMessage} from payload and headers
|
||||
*/
|
||||
<T> M create(T payload, Map<String, Object> headers);
|
||||
|
||||
}
|
||||
@@ -18,11 +18,8 @@ package org.springframework.cloud.contract.verifier.messaging.noop;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
|
||||
import org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierMessaging;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -40,12 +37,6 @@ public class NoOpContractVerifierAutoConfiguration {
|
||||
return new NoOpContractVerifierMessaging();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ContractVerifierMessageBuilder<?> contractVerifierMessageBuilder() {
|
||||
return new NoOpContractVerifierMessageBuilder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ContractVerifierMessaging<?> contractVerifierMessaging(
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
*
|
||||
* 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 org.springframework.cloud.contract.verifier.messaging.noop;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class NoOpContractVerifierMessageBuilder
|
||||
implements ContractVerifierMessageBuilder<Object> {
|
||||
|
||||
@Override
|
||||
public <T> Object create(T o, Map<String, Object> headers) {
|
||||
return o;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.contract.verifier.messaging.stream;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
|
||||
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
|
||||
@@ -38,15 +37,8 @@ public class ContractVerifierStreamAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
ContractVerifierMessageExchange<Message<?>> contractVerifierMessageExchange(
|
||||
ApplicationContext applicationContext,
|
||||
ContractVerifierMessageBuilder<Message<?>> contractVerifierMessageBuilder) {
|
||||
return new ContractVerifierStreamMessaging(applicationContext,
|
||||
contractVerifierMessageBuilder);
|
||||
}
|
||||
|
||||
@Bean
|
||||
ContractVerifierMessageBuilder<Message<?>> contractVerifierMessageBuilder() {
|
||||
return new ContractVerifierStreamMessageBuilder();
|
||||
ApplicationContext applicationContext) {
|
||||
return new ContractVerifierStreamMessaging(applicationContext);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.contract.verifier.messaging.stream;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
@@ -26,10 +25,8 @@ import org.springframework.messaging.support.MessageBuilder;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ContractVerifierStreamMessageBuilder implements
|
||||
ContractVerifierMessageBuilder<Message<?>> {
|
||||
public class ContractVerifierStreamMessageBuilder {
|
||||
|
||||
@Override
|
||||
public <T> Message<?> create(T payload, Map<String, Object> headers) {
|
||||
return MessageBuilder.createMessage(payload, new MessageHeaders(headers));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageBuilder;
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessageExchange;
|
||||
import org.springframework.cloud.stream.config.BindingProperties;
|
||||
import org.springframework.cloud.stream.config.ChannelBindingServiceProperties;
|
||||
@@ -34,20 +33,20 @@ import org.springframework.messaging.MessageChannel;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ContractVerifierStreamMessaging implements
|
||||
ContractVerifierMessageExchange<Message<?>> {
|
||||
public class ContractVerifierStreamMessaging
|
||||
implements ContractVerifierMessageExchange<Message<?>> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ContractVerifierStreamMessaging.class);
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(ContractVerifierStreamMessaging.class);
|
||||
|
||||
private final ApplicationContext context;
|
||||
private final MessageCollector messageCollector;
|
||||
private final ContractVerifierMessageBuilder<Message<?>> builder;
|
||||
private final ContractVerifierStreamMessageBuilder builder = new ContractVerifierStreamMessageBuilder();
|
||||
|
||||
@Autowired
|
||||
public ContractVerifierStreamMessaging(ApplicationContext context, ContractVerifierMessageBuilder<Message<?>> builder) {
|
||||
public ContractVerifierStreamMessaging(ApplicationContext context) {
|
||||
this.context = context;
|
||||
this.messageCollector = context.getBean(MessageCollector.class);
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,11 +57,13 @@ public class ContractVerifierStreamMessaging implements
|
||||
@Override
|
||||
public void send(Message<?> message, String destination) {
|
||||
try {
|
||||
MessageChannel messageChannel = context.getBean(resolvedDestination(destination), MessageChannel.class);
|
||||
MessageChannel messageChannel = context
|
||||
.getBean(resolvedDestination(destination), MessageChannel.class);
|
||||
messageChannel.send(message);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception occurred while trying to send a message [" + message + "] " +
|
||||
"to a channel with name [" + destination + "]", e);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Exception occurred while trying to send a message [" + message
|
||||
+ "] " + "to a channel with name [" + destination + "]", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -70,25 +71,32 @@ public class ContractVerifierStreamMessaging implements
|
||||
@Override
|
||||
public Message<?> receive(String destination, long timeout, TimeUnit timeUnit) {
|
||||
try {
|
||||
MessageChannel messageChannel = context.getBean(resolvedDestination(destination), MessageChannel.class);
|
||||
MessageChannel messageChannel = context
|
||||
.getBean(resolvedDestination(destination), MessageChannel.class);
|
||||
return messageCollector.forChannel(messageChannel).poll(timeout, timeUnit);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception occurred while trying to read a message from " +
|
||||
" a channel with name [" + destination + "]", e);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Exception occurred while trying to read a message from "
|
||||
+ " a channel with name [" + destination + "]", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String resolvedDestination(String destination) {
|
||||
ChannelBindingServiceProperties channelBindingServiceProperties = context.getBean(ChannelBindingServiceProperties.class);
|
||||
ChannelBindingServiceProperties channelBindingServiceProperties = context
|
||||
.getBean(ChannelBindingServiceProperties.class);
|
||||
String resolvedDestination = destination;
|
||||
for (Map.Entry<String, BindingProperties> entry : channelBindingServiceProperties.getBindings().entrySet()) {
|
||||
for (Map.Entry<String, BindingProperties> entry : channelBindingServiceProperties
|
||||
.getBindings().entrySet()) {
|
||||
if (entry.getValue().getDestination().equals(destination)) {
|
||||
log.debug("Found a channel named [{}] with destination [{}]", entry.getKey(), destination);
|
||||
log.debug("Found a channel named [{}] with destination [{}]",
|
||||
entry.getKey(), destination);
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
log.debug("No destination named [{}] was found. Assuming that the destination equals the channel name", destination);
|
||||
log.debug(
|
||||
"No destination named [{}] was found. Assuming that the destination equals the channel name",
|
||||
destination);
|
||||
return resolvedDestination;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user