@@ -266,6 +266,8 @@ protected RootBeanDefinition parseProcessTask(Element element, ParserContext par
266266
267267 handleListenersElement (element , bd , parserContext );
268268
269+ handleRetryListenersElement (element , bd , parserContext );
270+
269271 handleStreamsElement (element , bd , parserContext );
270272
271273 bd .setRole (BeanDefinition .ROLE_SUPPORT );
@@ -299,47 +301,68 @@ private void handleListenersElement(Element element, RootBeanDefinition bd, Pars
299301 DomUtils .getChildElementByTagName (element , "listeners" );
300302 if (listenersElement != null ) {
301303 List <BeanReference > listenerBeans = new ArrayList <BeanReference >();
302- List <Element > listenerElements =
303- DomUtils .getChildElementsByTagName (listenersElement , "listener" );
304- if (listenerElements != null ) {
305- for (Element listenerElement : listenerElements ) {
306- String id = listenerElement .getAttribute ("id" );
307- String listenerRef = listenerElement .getAttribute ("ref" );
308- String className = listenerElement .getAttribute ("class" );
309- if ((StringUtils .hasText (id ) || StringUtils .hasText (className ))
310- && StringUtils .hasText (listenerRef )) {
311- NamedNodeMap attributeNodes = listenerElement .getAttributes ();
312- StringBuilder attributes = new StringBuilder ();
313- for (int i = 0 ; i < attributeNodes .getLength (); i ++) {
314- if (i > 0 ) {
315- attributes .append (" " );
316- }
317- attributes .append (attributeNodes .item (i ));
318- }
319- throw new BeanCreationException ("Both 'id' or 'ref' plus 'class' specified; use 'class' with an optional 'id' or just 'ref' for <" +
320- listenerElement .getTagName () + "> element with attributes: " + attributes );
321- }
322- if (StringUtils .hasText (listenerRef )) {
323- BeanReference bean = new RuntimeBeanReference (listenerRef );
324- listenerBeans .add (bean );
325- }
326- else if (StringUtils .hasText (className )) {
327- RootBeanDefinition beanDef = new RootBeanDefinition (className , null , null );
328- if (!StringUtils .hasText (id )) {
329- id = parserContext .getReaderContext ().generateBeanName (beanDef );
304+ handleListenerElements (parserContext , listenersElement ,
305+ listenerBeans );
306+ ManagedList arguments = new ManagedList ();
307+ arguments .addAll (listenerBeans );
308+ bd .getPropertyValues ().addPropertyValue ("listeners" , arguments );
309+ }
310+ }
311+
312+ @ SuppressWarnings ("unchecked" )
313+ private void handleRetryListenersElement (Element element , RootBeanDefinition bd , ParserContext parserContext ) {
314+ Element retryListenersElement =
315+ DomUtils .getChildElementByTagName (element , "retry-listeners" );
316+ if (retryListenersElement != null ) {
317+ List <BeanReference > retryListenerBeans = new ArrayList <BeanReference >();
318+ handleListenerElements (parserContext , retryListenersElement ,
319+ retryListenerBeans );
320+ ManagedList arguments = new ManagedList ();
321+ arguments .addAll (retryListenerBeans );
322+ bd .getPropertyValues ().addPropertyValue ("retryListeners" , arguments );
323+ }
324+ }
325+
326+ @ SuppressWarnings ("unchecked" )
327+ private void handleListenerElements (ParserContext parserContext ,
328+ Element element , List <BeanReference > beans ) {
329+ List <Element > listenerElements =
330+ DomUtils .getChildElementsByTagName (element , "listener" );
331+ if (listenerElements != null ) {
332+ for (Element listenerElement : listenerElements ) {
333+ String id = listenerElement .getAttribute ("id" );
334+ String listenerRef = listenerElement .getAttribute ("ref" );
335+ String className = listenerElement .getAttribute ("class" );
336+ if ((StringUtils .hasText (id ) || StringUtils .hasText (className ))
337+ && StringUtils .hasText (listenerRef )) {
338+ NamedNodeMap attributeNodes = listenerElement .getAttributes ();
339+ StringBuilder attributes = new StringBuilder ();
340+ for (int i = 0 ; i < attributeNodes .getLength (); i ++) {
341+ if (i > 0 ) {
342+ attributes .append (" " );
330343 }
331- parserContext .getRegistry ().registerBeanDefinition (id , beanDef );
332- BeanReference bean = new RuntimeBeanReference (id );
333- listenerBeans .add (bean );
344+ attributes .append (attributeNodes .item (i ));
334345 }
335- else {
336- throw new BeanCreationException ("Neither 'ref' or 'class' specified for <" + listenerElement .getTagName () + "> element" );
346+ throw new BeanCreationException ("Both 'id' or 'ref' plus 'class' specified; use 'class' with an optional 'id' or just 'ref' for <" +
347+ listenerElement .getTagName () + "> element with attributes: " + attributes );
348+ }
349+ if (StringUtils .hasText (listenerRef )) {
350+ BeanReference bean = new RuntimeBeanReference (listenerRef );
351+ beans .add (bean );
352+ }
353+ else if (StringUtils .hasText (className )) {
354+ RootBeanDefinition beanDef = new RootBeanDefinition (className , null , null );
355+ if (!StringUtils .hasText (id )) {
356+ id = parserContext .getReaderContext ().generateBeanName (beanDef );
337357 }
358+ parserContext .getRegistry ().registerBeanDefinition (id , beanDef );
359+ BeanReference bean = new RuntimeBeanReference (id );
360+ beans .add (bean );
361+ }
362+ else {
363+ throw new BeanCreationException ("Neither 'ref' or 'class' specified for <" + listenerElement .getTagName () + "> element" );
338364 }
339365 }
340- ManagedList arguments = new ManagedList ();
341- arguments .addAll (listenerBeans );
342- bd .getPropertyValues ().addPropertyValue ("listeners" , arguments );
343366 }
344367 }
345368
0 commit comments