You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/10/15 19:32:45 UTC
svn commit: r825578 - in /cxf/trunk:
common/common/src/main/java/org/apache/cxf/configuration/spring/
rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/
Author: dkulp
Date: Thu Oct 15 17:32:44 2009
New Revision: 825578
URL: http://svn.apache.org/viewvc?rev=825578&view=rev
Log:
[CXF-2454] Make sure id's are unique
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml
Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java?rev=825578&r1=825577&r2=825578&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java Thu Oct 15 17:32:44 2009
@@ -24,9 +24,12 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.apache.cxf.common.util.StringUtils;
import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.xml.ParserContext;
/**
@@ -86,17 +89,34 @@
}
String id = getIdOrName(element);
+ BeanDefinition container = ctx.getContainingBeanDefinition();
+ boolean noFactory = false;
+ if (StringUtils.isEmpty(id)) {
+ if (container == null) {
+ id = BeanDefinitionReaderUtils.generateBeanName(bean.getBeanDefinition(),
+ ctx.getRegistry(),
+ false);
+ } else {
+ id = BeanDefinitionReaderUtils.generateBeanName(bean.getBeanDefinition(),
+ ctx.getRegistry(),
+ true);
+ noFactory = true;
+ //inner bean, no need for the factory to be public at all
+ }
+ }
if (createdFromAPI) {
id = id + getSuffix();
}
if (FactoryBean.class.isAssignableFrom(getFactoryClass())) {
- AbstractBeanDefinition def = factoryBean.getRawBeanDefinition().cloneBeanDefinition();
- def.setBeanClass(getRawFactoryClass());
- def.setAbstract(factoriesAreAbstract);
- def.setLazyInit(true);
- ctx.getRegistry().registerBeanDefinition(id + getFactoryIdSuffix(),
- def);
+ if (!noFactory) {
+ AbstractBeanDefinition def = factoryBean.getRawBeanDefinition().cloneBeanDefinition();
+ def.setBeanClass(getRawFactoryClass());
+ def.setAbstract(factoriesAreAbstract);
+ def.setLazyInit(true);
+ ctx.getRegistry().registerBeanDefinition(id + getFactoryIdSuffix(),
+ def);
+ }
bean.getBeanDefinition().setAttribute("id", id);
} else {
String factoryId = id + getFactoryIdSuffix();
Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java?rev=825578&r1=825577&r2=825578&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java Thu Oct 15 17:32:44 2009
@@ -31,7 +31,25 @@
@Autowired(required = true)
Collection<org.apache.hello_world_soap_http.Greeter> greeters;
+ org.apache.hello_world_soap_http.Greeter greet1;
+ org.apache.hello_world_soap_http.Greeter greet2;
+
+
public int greeterCount() {
return greeters.size();
}
+
+ public void setGreet1(org.apache.hello_world_soap_http.Greeter g1) {
+ greet1 = g1;
+ }
+ public void setGreet2(org.apache.hello_world_soap_http.Greeter g1) {
+ greet2 = g1;
+ }
+ public org.apache.hello_world_soap_http.Greeter getGreet1() {
+ return greet1;
+ }
+ public org.apache.hello_world_soap_http.Greeter getGreet2() {
+ return greet2;
+ }
+
}
Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?rev=825578&r1=825577&r2=825578&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java Thu Oct 15 17:32:44 2009
@@ -324,6 +324,10 @@
assertTrue(sbc.getVersion() instanceof Soap12);
assertTrue("the soap configure should set isMtomEnabled to be true",
sbc.isMtomEnabled());
+
+ Greeter g1 = greeters.getGreet1();
+ Greeter g2 = greeters.getGreet2();
+ assertNotSame(g1, g2);
}
}
Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml?rev=825578&r1=825577&r2=825578&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml Thu Oct 15 17:32:44 2009
@@ -1,89 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jaxws="http://cxf.apache.org/jaxws"
- xmlns:soap="http://cxf.apache.org/bindings/soap"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:soap="http://cxf.apache.org/bindings/soap" xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
-
+
<context:annotation-config />
-
- <import resource="classpath:META-INF/cxf/cxf.xml"/>
- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
-
- <bean class="org.apache.cxf.jaxws.spring.ClientHolderBean" id="greeters" autowire="autodetect"/>
-
- <bean class="org.apache.cxf.transport.local.LocalTransportFactory" lazy-init="false">
- <property name="transportIds">
- <list>
- <value>http://cxf.apache.org/transports/local</value>
- <value>http://schemas.xmlsoap.org/soap/http</value>
- <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
- </list>
- </property>
- </bean>
-
- <bean id="saajIn" class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
- <bean id="saajOut" class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
-
- <jaxws:client id="client1"
- serviceClass="org.apache.hello_world_soap_http.Greeter"
- address="http://localhost:9000/foo"
- serviceName="s:SOAPService"
- xmlns:s="http://apache.org/hello_world_soap_http">
- <jaxws:inInterceptors>
- <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
- <ref bean="saajIn"/>
- </jaxws:inInterceptors>
- <jaxws:outInterceptors>
- <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
- <ref bean="saajOut"/>
- </jaxws:outInterceptors>
- <jaxws:conduitSelector>
- <bean class="org.apache.cxf.endpoint.NullConduitSelector"/>
- </jaxws:conduitSelector>
- <jaxws:dataBinding>
- <bean class="org.apache.cxf.databinding.source.SourceDataBinding"/>
- </jaxws:dataBinding>
- </jaxws:client>
-
- <jaxws:client id="wsdlLocation"
- serviceClass="org.apache.hello_world_soap_http.Greeter"
- serviceName="s:SOAPService"
- endpointName="s:SoapPort"
- xmlns:s="http://apache.org/hello_world_soap_http"
- address="http://localhost:8080/simpleWithAddress"
- wsdlLocation="wsdl/hello_world.wsdl"/>
-
- <jaxws:client id="inlineSoapBinding"
- serviceClass="org.apache.hello_world_soap_http.Greeter"
- address="http://localhost:9000/foo"
- serviceName="s:SOAPService"
- xmlns:s="http://apache.org/hello_world_soap_http">
- <jaxws:binding>
- <soap:soapBinding mtomEnabled="true" version="1.2"/>
- </jaxws:binding>
- </jaxws:client>
+
+ <import resource="classpath:META-INF/cxf/cxf.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+
+ <bean class="org.apache.cxf.jaxws.spring.ClientHolderBean" id="greeters"
+ autowire="autodetect">
+ <property name="greet1">
+ <jaxws:client
+ serviceClass="org.apache.hello_world_soap_http.Greeter" serviceName="s:SOAPService"
+ endpointName="s:SoapPort" xmlns:s="http://apache.org/hello_world_soap_http"
+ address="http://localhost:8080/simpleWithAddress" wsdlLocation="wsdl/hello_world.wsdl" />
+ </property>
+ <property name="greet2">
+ <jaxws:client
+ serviceClass="org.apache.hello_world_soap_http.Greeter" address="http://localhost:9000/foo"
+ serviceName="s:SOAPService" xmlns:s="http://apache.org/hello_world_soap_http"/>
+ </property>
+ </bean>
+
+ <bean class="org.apache.cxf.transport.local.LocalTransportFactory"
+ lazy-init="false">
+ <property name="transportIds">
+ <list>
+ <value>http://cxf.apache.org/transports/local</value>
+ <value>http://schemas.xmlsoap.org/soap/http</value>
+ <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="saajIn" class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor" />
+ <bean id="saajOut" class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
+
+ <jaxws:client id="client1"
+ serviceClass="org.apache.hello_world_soap_http.Greeter" address="http://localhost:9000/foo"
+ serviceName="s:SOAPService" xmlns:s="http://apache.org/hello_world_soap_http">
+ <jaxws:inInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
+ <ref bean="saajIn" />
+ </jaxws:inInterceptors>
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
+ <ref bean="saajOut" />
+ </jaxws:outInterceptors>
+ <jaxws:conduitSelector>
+ <bean class="org.apache.cxf.endpoint.NullConduitSelector" />
+ </jaxws:conduitSelector>
+ <jaxws:dataBinding>
+ <bean class="org.apache.cxf.databinding.source.SourceDataBinding" />
+ </jaxws:dataBinding>
+ </jaxws:client>
+
+ <jaxws:client id="wsdlLocation"
+ serviceClass="org.apache.hello_world_soap_http.Greeter" serviceName="s:SOAPService"
+ endpointName="s:SoapPort" xmlns:s="http://apache.org/hello_world_soap_http"
+ address="http://localhost:8080/simpleWithAddress" wsdlLocation="wsdl/hello_world.wsdl" />
+
+ <jaxws:client id="inlineSoapBinding"
+ serviceClass="org.apache.hello_world_soap_http.Greeter" address="http://localhost:9000/foo"
+ serviceName="s:SOAPService" xmlns:s="http://apache.org/hello_world_soap_http">
+ <jaxws:binding>
+ <soap:soapBinding mtomEnabled="true" version="1.2" />
+ </jaxws:binding>
+ </jaxws:client>
</beans>