Hi,
I have a configuration object, that contains many nested pojos, e.g:
public class Configuration {
private OutputConfiguration outputConfiguration;
// More members...
public OutputConfiguration getOutputConfiguration() {
return outputConfiguration;
}
// Getters and setters...
}
public class OutputConfiguration {
private FileFormat fileFormat;
private EnumSet<DeliveryMethod> deliveryMethod;
private EmailAddress emailAddress;
private FtpConfiguration ftpConfiguration;
public FileFormat getFileFormat() {
return fileFormat;
}
// More getters and setters...
}
public enum FileFormat {
CHARACTER_SEPARATED,
FIXED_LENGTH,
XML
}
Depending on the file format, I would like to route my messages to different
Processors. They will in turn construct different files, that will be sent
to one or more remote clients. The method of transport will be depending on
the delivery method and its corresponding settings.
Given that the message contains the Configuration message, I would like
type-safe routing (there are a lot configuration options and manual
conversion to a key-value map will be error prone and bad from a maintenance
point of view).
Now the questions:
1. Do I better place the Configuration object in the Body or in the Header
(considering that I in the latter half of the process chain intend to add
the generated files to the Body)?
2. Depending on the answer of the first question, how can I write a type
safe choice()-statement? Ideally, I would like something like
from(direct:origin).choice()
...((Configuration)configuration).getOutputConfiguration().getFileFormat().isEqualsTo(FileFormat.CHARACTER_SEPARATED)
.to(direct:char_separated)
Alternatively using a bean
from(direct:origin).choice()
.when(bean(FileFormatExtractor.class,
"getFileType").isEqualTo(FileType.CHARACTER_SEPARATED))
.to(direct:char_separated);
Where the FileFormatExtractor is something like
public class FileFormatExtractor {
public FileFormat getFileFormat() {
// How can I access the configuration instance here?
return configuration.getOutputConfiguration().getFileFormat();
}
}
Thanks in advance,
Mattias
--
View this message in context:
http://old.nabble.com/Java-DSL-routing-according-to-hierarchical-pojo-configuration-object--tp28427245p28427245.html
Sent from the Camel - Users mailing list archive at Nabble.com.