public final class CompositeClientHttpRequestFactoryProcessor extends AbstractProcessor<CompositeClientHttpRequestFactoryProcessor.Input,java.lang.Void> implements HttpProcessor<CompositeClientHttpRequestFactoryProcessor.Input>
A processor that wraps several AbstractClientHttpRequestFactoryProcessors.
This makes it more convenient to configure multiple processors that modify MfClientHttpRequestFactory objects.
Consider the case where you need to:
In this case the !mapUri processor must execute before the !restrictUris processor but it is difficult to enforce this, the inputMapping and outputMapping must be carefully designed in order to do it. The following should work but compare it with the example below:
- !mapUri
mapping:
(http)://localhost(.*) : "$1://127.0.0.1$2"
outputMapper: {clientHttpRequestFactoryProvider: clientHttpRequestFactoryMapped}
- !forwardHeaders
all: true
inputMapper: {clientHttpRequestFactoryMapped :clientHttpRequestFactoryProvider}
outputMapper: {clientHttpRequestFactoryProvider: clientHttpRequestFactoryWithHeaders}
- !restrictUris
matchers: [!localMatch {}]
inputMapper: {clientHttpRequestFactoryWithHeaders:clientHttpRequestFactoryProvider}
The recommended way to write the above configuration is as follows:
- !configureHttpRequests
httpProcessors:
- !mapUri
mapping:
(http)://localhost(.*) : "$1://127.0.0.1$2"
- !forwardHeaders
all: true
- !restrictUris
matchers: [!localMatch {}]
[[examples=http_processors]]| Modifier and Type | Class and Description |
|---|---|
class |
CompositeClientHttpRequestFactoryProcessor.Input
The input.
|
AbstractProcessor.ContextProcessor.ExecutionContext| Modifier | Constructor and Description |
|---|---|
protected |
CompositeClientHttpRequestFactoryProcessor()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
MfClientHttpRequestFactory |
createFactoryWrapper(CompositeClientHttpRequestFactoryProcessor.Input input,
MfClientHttpRequestFactory requestFactory)
Create the
MfClientHttpRequestFactory to use. |
CompositeClientHttpRequestFactoryProcessor.Input |
createInputParameter()
Returns a new/clean instance of a parameter object.
|
java.lang.Void |
execute(CompositeClientHttpRequestFactoryProcessor.Input values,
Processor.ExecutionContext context)
Perform the process on the input attributes.
|
protected void |
extraValidation(java.util.List<java.lang.Throwable> validationErrors,
Configuration configuration)
Perform any extra validation a subclass may need to perform.
|
void |
setHttpProcessors(java.util.List<HttpProcessor> httpProcessors)
Sets all the http processors that will executed by this processor.
|
void |
toString(java.lang.StringBuilder builder,
int indent,
java.lang.String parent)
Create a string representing this processor.
|
checkCancelState, getInputMapperBiMap, getInputPrefix, getOutputMapperBiMap, getOutputPrefix, getOutputType, setInputMapper, setInputPrefix, setOutputMapper, setOutputPrefix, setPrefix, toString, validateclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetInputMapperBiMap, getInputPrefix, getOutputMapperBiMap, getOutputPrefix, getOutputTypevalidateprotected CompositeClientHttpRequestFactoryProcessor()
public void setHttpProcessors(java.util.List<HttpProcessor> httpProcessors)
httpProcessors - the sub processorspublic MfClientHttpRequestFactory createFactoryWrapper(CompositeClientHttpRequestFactoryProcessor.Input input, MfClientHttpRequestFactory requestFactory)
HttpProcessorMfClientHttpRequestFactory to use.createFactoryWrapper in interface HttpProcessor<CompositeClientHttpRequestFactoryProcessor.Input>input - extra parameters required to create the updated request factoryrequestFactory - the basic request factory. It should be unmodified and just wrapped with
a proxy class.protected void extraValidation(java.util.List<java.lang.Throwable> validationErrors,
Configuration configuration)
AbstractProcessorextraValidation in class AbstractProcessor<CompositeClientHttpRequestFactoryProcessor.Input,java.lang.Void>validationErrors - a list to add errors to so that all validation errors are reported as
one.configuration - the containing configuration@Nullable public CompositeClientHttpRequestFactoryProcessor.Input createInputParameter()
ProcessorValues object.
The way the properties will be looked up is to
Values object using the mapped
property name
HasDefaultValue annotation is on the field for
the property.
createInputParameter in interface Processor<CompositeClientHttpRequestFactoryProcessor.Input,java.lang.Void>@Nullable public java.lang.Void execute(CompositeClientHttpRequestFactoryProcessor.Input values, Processor.ExecutionContext context)
Processorexecute in interface Processor<CompositeClientHttpRequestFactoryProcessor.Input,java.lang.Void>values - A Java object whose public fields are populated from the Values object (which is used for transferring properties between
processors).context - The execution context for a print task.Values object. The key in the
Values
object is the name of the field or if there is a mapping in the Processor.getOutputMapperBiMap()
map, the mapped name. The key is determined in a similar way as for the input object.public void toString(java.lang.StringBuilder builder,
int indent,
java.lang.String parent)
ProcessortoString in interface Processor<CompositeClientHttpRequestFactoryProcessor.Input,java.lang.Void>toString in class AbstractProcessor<CompositeClientHttpRequestFactoryProcessor.Input,java.lang.Void>builder - the builder to add the string to.indent - the number of steps of indent for this nodeparent - the parent node's name