INT-789, Fixed the schema file, added one more test

This commit is contained in:
Oleg Zhurakousky
2010-03-27 01:32:02 +00:00
parent 7381ee28cf
commit 7a72fbc9e7
4 changed files with 65 additions and 15 deletions

View File

@@ -95,10 +95,14 @@ final class GlobalChannelInterceptorBeanPostProcessor implements BeanPostProcess
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (channelPatternMatches(beanName)){
Assert.isTrue(bean instanceof AbstractMessageChannel, "channel interceptors can only be added to " +
"AbstractMessageChannel. Current implementation is: " + bean.getClass());
logger.debug("Applying global interceptors on channel '" + beanName + "'");
this.mergeInterceptorsToChannel((AbstractMessageChannel) bean, beanName);
if (bean instanceof AbstractMessageChannel){
logger.debug("Applying global interceptors on channel '" + beanName + "'");
this.mergeInterceptorsToChannel((AbstractMessageChannel) bean, beanName);
} else {
logger.warn("Attempt to add channel interceptors is unsuccessfull. Global channel interceptors " +
"can only be added to AbstractMessageChannel. Current implementation is: " + bean.getClass() +
" This might happen becouse you specified a single wild-card '*' in 'channel-name-pattern'");
}
}
return bean;
}
@@ -177,6 +181,9 @@ final class GlobalChannelInterceptorBeanPostProcessor implements BeanPostProcess
patterns = allAvailablePatters.toArray(new String[]{});
}
for (String channelPattern : patterns) {
if (channelPattern.trim().equals("*")){
return true;
}
Pattern p = Pattern.compile(channelPattern.trim());
Matcher m = p.matcher(beanName);
if (m.find()){

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.springframework.org/schema/integration"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
targetNamespace="http://www.springframework.org/schema/integration"
elementFormDefault="qualified" attributeFormDefault="unqualified">
@@ -1655,12 +1656,16 @@
</xsd:element>
<xsd:element name="channel-interceptor-chain">
<xsd:annotation>
<xsd:documentation>
Allows you to define channel interceptors to be applied globally
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="beans:ref" minOccurs="0" maxOccurs="unbounded"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="beans:bean"/>
<xsd:element ref="beans:ref"/>
<xsd:element ref="beans:bean"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="channel-name-pattern" type="xsd:string" use="required">