Dear members
I detected an errata in the documentation since the API has changed.
In section
6.3.1. Chaining ItemProcessors
Has this example
When I run this example I get this errorCode:<bean id="compositeItemProcessor" class="org.springframework.batch.item.support.CompositeItemProcessor"> <property name="itemProcessors"> <list> <bean class="..FooProcessor" /> <bean class="..BarProcessor" /> </list> </property> </bean>
I recall clearly that this work before, Therefore I checked the API forCode:Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'itemProcessors' of bean class [org.springframework.batch.item.support.CompositeItemProcessor]: Bean property 'itemProcessors' is not writable or has an invalid setter method. Does the parameter type of the setter match the re turn type of the getter? .....
CompositeItemProcessor<I,O>
and well such method not appear
My unique change was the version release
For spring-batch-2.0.1.RELEASE\ in
spring-batch-infrastructure-2.0.1.RELEASE-sources.jar\org\springframework\batch\item\support\
we have
But in spring-batch-2.1.0.RELEASE inCode:@SuppressWarnings("unchecked") public class CompositeItemProcessor<I, O> implements ItemProcessor<I, O>, InitializingBean { private List<ItemProcessor> itemProcessors; public O process(I item) throws Exception { Object result = item; for(ItemProcessor transformer: itemProcessors){ if(result == null){ return null; } result = transformer.process(result); } return (O) result; } public void afterPropertiesSet() throws Exception { Assert.notEmpty(itemProcessors); } /** * @param itemProcessors will be chained to produce a composite * transformation. */ public void setItemProcessors(List<ItemProcessor> itemProcessors) { this.itemProcessors = itemProcessors; } }
spring-batch-infrastructure-2.1.0.RELEASE-sources.jar\org\springframework\batch\item\support
We have instead
How you can see the variable name changed from itemProcessors to delegates through the versions from "spring-batch-2.0.1.RELEASE" to "spring-batch-2.1.0.RELEASE"Code:public class CompositeItemProcessor<I, O> implements ItemProcessor<I, O>, InitializingBean { private List<ItemProcessor<Object, Object>> delegates; @SuppressWarnings("unchecked") public O process(I item) throws Exception { Object result = item; for (ItemProcessor<Object, Object> delegate : delegates) { if (result == null) { return null; } result = delegate.process(result); } return (O) result; } public void afterPropertiesSet() throws Exception { Assert.notNull(delegates, "The 'delgates' may not be null"); Assert.notEmpty(delegates, "The 'delgates' may not be empty"); } public void setDelegates(List<ItemProcessor<Object, Object>> delegates) { this.delegates = delegates; } }
Consider too the title of the actual and unique API for Spring Batch
Spring Batch 2.1.0.CI-SNAPSHOT API , It is not updated anymore
Therefore same appreciation for our documentation sample
The other error in Spring batch documentation is about the poincut expression used in two places , for the section
8.6. Declarative Iteration
shown
and for the section 9.5. Declarative Retry shownCode:<aop:config> <aop:pointcut id="transactional" expression="execution(* com...*Service.processMessage(..))" /> <aop:advisor pointcut-ref="transactional" advice-ref="retryAdvice" order="-1"/> </aop:config>
Both are wrong, because * com...* has three points and must be two * com..*Code:<aop:config> <aop:pointcut id="transactional" expression="execution(* com...*Service.remoteCall(..))" /> <aop:advisor pointcut-ref="transactional" advice-ref="retryAdvice" order="-1"/> </aop:config>
I going to arise an JIRA for these situations
Best Regards
-Manuel


Reply With Quote