You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andrea Silva (JIRA)" <ji...@apache.org> on 2014/10/24 13:18:33 UTC
[jira] [Updated] (CXF-6062) Interceptors added in Spring Bus
configuration are ignored
[ https://issues.apache.org/jira/browse/CXF-6062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrea Silva updated CXF-6062:
------------------------------
Description:
Given a basic spring bus configuration like the following:
{code}
...
<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<cxf:bus>
<cxf:inInterceptors>
<ref bean="logInbound"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="logOutbound"/>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="logOutbound"/>
</cxf:outFaultInterceptors>
<cxf:inFaultInterceptors>
<ref bean="logInbound"/>
</cxf:inFaultInterceptors>
</cxf:bus>
...
{code}
the logInbound and logOutbound interceptors are not added to the bus, when the spring configuration is parsed.
I think the problem is in BusDefinitionParser.java, more specifically in the setBus method of BusConfig class.
{code}
public void setBus(Bus bb) {
if (bus == bb) {
return;
}
bus = bb;
if (properties != null) {
bus.setProperties(properties);
properties = null;
}
if (!getInInterceptors().isEmpty()) {
bus.getInInterceptors().addAll(getInInterceptors());
}
if (!getOutInterceptors().isEmpty()) {
bus.getOutInterceptors().addAll(getOutInterceptors());
}
if (!getInFaultInterceptors().isEmpty()) {
bus.getInFaultInterceptors().addAll(getInFaultInterceptors());
}
if (!getOutFaultInterceptors().isEmpty()) {
bus.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
if (!StringUtils.isEmpty(id)) {
bus.setId(id);
}
if (features != null) {
bus.setFeatures(features);
features = null;
}
}
{code}
If the bus is assigned at the beginning of the method (bus = bb) no new Interceptor will be added as the getXYZInterceptors methods will return the interceptors already included in the bus.
{code}
public List<Interceptor<? extends Message>> getXYZInterceptors() {
if (bus != null) {
return bus.getXYZInterceptors();
}
return super.getXYZInterceptors();
}
{code}
A fix could be something along the line of:
{code}
public void setBus(Bus bb) {
if (bus == bb) {
return;
}
CXFBusImpl b = (CXFBusImpl)bb;
if (properties != null) {
b.setProperties(properties);
properties = null;
}
if (!getInInterceptors().isEmpty()) {
b.getInInterceptors().addAll(getInInterceptors());
}
if (!getOutInterceptors().isEmpty()) {
b.getOutInterceptors().addAll(getOutInterceptors());
}
if (!getInFaultInterceptors().isEmpty()) {
b.getInFaultInterceptors().addAll(getInFaultInterceptors());
}
if (!getOutFaultInterceptors().isEmpty()) {
b.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
if (!StringUtils.isEmpty(id)) {
b.setId(id);
}
if (features != null) {
b.setFeatures(features);
features = null;
}
bus = b;
}
{code}
was:
Given a basic spring bus configuration like the following:
{code}
...
<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<cxf:bus>
<cxf:inInterceptors>
<ref bean="logInbound"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="logOutbound"/>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="logOutbound"/>
</cxf:outFaultInterceptors>
<cxf:inFaultInterceptors>
<ref bean="logInbound"/>
</cxf:inFaultInterceptors>
</cxf:bus>
...
{code}
the logInbound and logOutbound interceptors are not added to the bus, when the spring configuration is parsed.
I think the problem is in BusDefinitionParser.java, more specifically in the setBus method of BusConfig class.
{code}
public void setBus(Bus bb) {
if (bus == bb) {
return;
}
bus = bb;
if (properties != null) {
bus.setProperties(properties);
properties = null;
}
if (!getInInterceptors().isEmpty()) {
bus.getInInterceptors().addAll(getInInterceptors());
}
if (!getOutInterceptors().isEmpty()) {
bus.getOutInterceptors().addAll(getOutInterceptors());
}
if (!getInFaultInterceptors().isEmpty()) {
bus.getInFaultInterceptors().addAll(getInFaultInterceptors());
}
if (!getOutFaultInterceptors().isEmpty()) {
bus.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
if (!StringUtils.isEmpty(id)) {
bus.setId(id);
}
if (features != null) {
bus.setFeatures(features);
features = null;
}
}
{code}
If the bus is assigned at the beginning of the method (bus = bb;) no new Interceptor will be added as the getXYZInterceptors methods will return the interceptors already included in the bus.
{code}
public List<Interceptor<? extends Message>> getXYZInterceptors() {
if (bus != null) {
return bus.getXYZInterceptors();
}
return super.getXYZInterceptors();
}
{code}
A fix could be something along the line of:
{code}
public void setBus(Bus bb) {
if (bus == bb) {
return;
}
CXFBusImpl b = (CXFBusImpl)bb;
if (properties != null) {
b.setProperties(properties);
properties = null;
}
if (!getInInterceptors().isEmpty()) {
b.getInInterceptors().addAll(getInInterceptors());
}
if (!getOutInterceptors().isEmpty()) {
b.getOutInterceptors().addAll(getOutInterceptors());
}
if (!getInFaultInterceptors().isEmpty()) {
b.getInFaultInterceptors().addAll(getInFaultInterceptors());
}
if (!getOutFaultInterceptors().isEmpty()) {
b.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
if (!StringUtils.isEmpty(id)) {
b.setId(id);
}
if (features != null) {
b.setFeatures(features);
features = null;
}
bus = b;
}
{code}
> Interceptors added in Spring Bus configuration are ignored
> -----------------------------------------------------------
>
> Key: CXF-6062
> URL: https://issues.apache.org/jira/browse/CXF-6062
> Project: CXF
> Issue Type: Bug
> Components: Bus
> Affects Versions: 3.0.2
> Reporter: Andrea Silva
> Priority: Critical
>
> Given a basic spring bus configuration like the following:
> {code}
> ...
> <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
> <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
>
> <cxf:bus>
> <cxf:inInterceptors>
> <ref bean="logInbound"/>
> </cxf:inInterceptors>
> <cxf:outInterceptors>
> <ref bean="logOutbound"/>
> </cxf:outInterceptors>
> <cxf:outFaultInterceptors>
> <ref bean="logOutbound"/>
> </cxf:outFaultInterceptors>
> <cxf:inFaultInterceptors>
> <ref bean="logInbound"/>
> </cxf:inFaultInterceptors>
> </cxf:bus>
> ...
> {code}
> the logInbound and logOutbound interceptors are not added to the bus, when the spring configuration is parsed.
> I think the problem is in BusDefinitionParser.java, more specifically in the setBus method of BusConfig class.
> {code}
> public void setBus(Bus bb) {
> if (bus == bb) {
> return;
> }
> bus = bb;
> if (properties != null) {
> bus.setProperties(properties);
> properties = null;
> }
> if (!getInInterceptors().isEmpty()) {
> bus.getInInterceptors().addAll(getInInterceptors());
> }
> if (!getOutInterceptors().isEmpty()) {
> bus.getOutInterceptors().addAll(getOutInterceptors());
> }
> if (!getInFaultInterceptors().isEmpty()) {
> bus.getInFaultInterceptors().addAll(getInFaultInterceptors());
> }
> if (!getOutFaultInterceptors().isEmpty()) {
> bus.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
> }
> if (!StringUtils.isEmpty(id)) {
> bus.setId(id);
> }
> if (features != null) {
> bus.setFeatures(features);
> features = null;
> }
> }
> {code}
> If the bus is assigned at the beginning of the method (bus = bb) no new Interceptor will be added as the getXYZInterceptors methods will return the interceptors already included in the bus.
> {code}
> public List<Interceptor<? extends Message>> getXYZInterceptors() {
> if (bus != null) {
> return bus.getXYZInterceptors();
> }
> return super.getXYZInterceptors();
> }
> {code}
> A fix could be something along the line of:
> {code}
> public void setBus(Bus bb) {
> if (bus == bb) {
> return;
> }
> CXFBusImpl b = (CXFBusImpl)bb;
> if (properties != null) {
> b.setProperties(properties);
> properties = null;
> }
> if (!getInInterceptors().isEmpty()) {
> b.getInInterceptors().addAll(getInInterceptors());
> }
> if (!getOutInterceptors().isEmpty()) {
> b.getOutInterceptors().addAll(getOutInterceptors());
> }
> if (!getInFaultInterceptors().isEmpty()) {
> b.getInFaultInterceptors().addAll(getInFaultInterceptors());
> }
> if (!getOutFaultInterceptors().isEmpty()) {
> b.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
> }
> if (!StringUtils.isEmpty(id)) {
> b.setId(id);
> }
> if (features != null) {
> b.setFeatures(features);
> features = null;
> }
> bus = b;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)