Apache camel 在Camel中初始化bean的最佳方法
在Camel中初始化bean的最佳方法是什么(人类可读的和运行时最快的(比如编译的))呢 我需要一个bean将其发送到JPA端点。输入是根据CSV创建的地图。看起来像是一个琐碎的任务,但我刚刚开始与骆驼,请帮助 目前,我已经成功地将一个映射转换为一个更复杂的映射,该映射具有与我的bean相同的结构。我可以编写自己的代码来遍历它,实例化列表和列表成员,使用ApacheBeanutils,但我认为应该有一种更快的方法来直接从原始映射初始化bean,而无需创建中间映射 以下是我目前拥有的:Apache camel 在Camel中初始化bean的最佳方法,apache-camel,beanshell,Apache Camel,Beanshell,在Camel中初始化bean的最佳方法是什么(人类可读的和运行时最快的(比如编译的))呢 我需要一个bean将其发送到JPA端点。输入是根据CSV创建的地图。看起来像是一个琐碎的任务,但我刚刚开始与骆驼,请帮助 目前,我已经成功地将一个映射转换为一个更复杂的映射,该映射具有与我的bean相同的结构。我可以编写自己的代码来遍历它,实例化列表和列表成员,使用ApacheBeanutils,但我认为应该有一种更快的方法来直接从原始映射初始化bean,而无需创建中间映射 以下是我目前拥有的: &
<route id="AgencyCsvInput" errorHandlerRef="agencyDeadLetters">
<from uri="direct:agencyCsvInput"/>
<split streaming="true">
<method ref="csvSplitter" method="tokenizeReader"/> <!-- prepends the first line of file for every subsequent line -->
<log message="splitted: ${body}" loggingLevel="DEBUG"/>
<setHeader headerName="inputRegistryLines">
<simple>${body}</simple>
</setHeader>
<unmarshal>
<csv delimiter=";" useMaps="true" />
</unmarshal>
<log message="unmarshalled: size: ${body.size()}, ${body}" loggingLevel="DEBUG"/>
<filter>
<simple>${body.size()} == 1</simple><!-- be sure to have spaces around an operator -->
<log message="filtered: listItem: ${body[0]['PATRONYMIC']}, list: ${body}" loggingLevel="DEBUG"/>
<setProperty propertyName="parser">
<simple>ref:patternParser</simple>
</setProperty>
<transform>
<spel><![CDATA[#{
{
dateOpen: properties['parser'].date(body[0]['ACTIVATION_DATE'], 'dd.MM.yyyy H:mm'),
balances: {
balance: {
{
typeCd: 'loanAmount',
amount: properties['parser'].comma(body[0]['GRANTED_CREDIT']),
currencyCd: body[0]['CURRENCY']
},
{
typeCd: 'fee',
amount: properties['parser'].comma(body[0]['Коммиссии']),
currencyCd: body[0]['CURRENCY'],
comment: 'Коммиссии'
},
{
typeCd: 'fine',
amount: properties['parser'].comma(body[0]['Пени']),
currencyCd: body[0]['CURRENCY'],
comment: 'Пени'
},
{
typeCd: 'penalty',
amount: properties['parser'].comma(body[0]['Штрафы']),
currencyCd: body[0]['CURRENCY'],
comment: 'Штрафы'
}
}
},
persons: {
{
typeCd: 'mainParty',
person: {
{
typeCd: 'individual',
names: {
name: {
{
typeCd: 'currentName',
lastName: body[0]['LAST_NAME'],
firstName: body[0]['FIRST_NAME'],
middleName: body[0]['PATRONYMIC']
}
}
},
birthDate: properties['parser'].date(body[0]['BIRTH_DATE'], 'dd.MM.yyyy H:mm'),
contacts: {
contact: {
{
typeCd: 'residentialAddress',
technologyCd: 'physical',
relationCd: 'home',
address: body[0]['COMMENTS']
},
{
typeCd: 'officeAddress',
technologyCd: 'physical',
relationCd: 'work',
address: body[0]['COMMENTS_WORK']
}
}
}
}
}
}
}
}
}]]></spel>
</transform>
<log message="transformed: ${body}" loggingLevel="DEBUG"/>
<to uri="direct:objectToDb"/>
</filter>
</split>
</route>
result = new myBean();
result.dateOpen = properties['parser'].date(body[0]['ACTIVATION_DATE'], 'dd.MM.yyyy H:mm');
balances = new Balances();
result.balances = balances;
balance = new List<Balance>();
reallyBalance = new Balance();
balance.add(balance);
reallyBalance.typeCd="loanAmount";
....
bean = new MyBean(){dateOpen= properties['parser'].date(body[0]['ACTIVATION_DATE'], 'dd.MM.yyyy H:mm')....};