Author: dkulp
Date: Wed Sep 7 16:20:25 2011
New Revision: 1166250
URL: http://svn.apache.org/viewvc?rev=1166250&view=rev
Log:
Merged revisions 1166248 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1166248 | dkulp | 2011-09-07 12:18:49 -0400 (Wed, 07 Sep 2011) | 1 line
[CXF-3162] Make it possible to set the bud.id used for JMX and OSGi
........
Modified:
cxf/branches/2.4.x-fixes/ (props changed)
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/blueprint/core.xsd
cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/core.xsd
cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/jmx/BusRegistrationTest.java
cxf/branches/2.4.x-fixes/rt/management/src/test/resources/managed-spring.xml
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java?rev=1166250&r1=1166249&r2=1166250&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
(original)
+++
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
Wed Sep 7 16:20:25 2011
@@ -24,6 +24,7 @@ import org.w3c.dom.Element;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
import org.osgi.service.blueprint.reflect.Metadata;
@@ -35,10 +36,14 @@ public class BusDefinitionParser
public Metadata parse(Element element, ParserContext context) {
String bname = element.hasAttribute("bus") ?
element.getAttribute("bus") : "cxf";
+ String id = element.hasAttribute("id") ? element.getAttribute("id") :
null;
MutableBeanMetadata cxfBean = getBus(context, bname);
parseAttributes(element, context, cxfBean);
parseChildElements(element, context, cxfBean);
context.getComponentDefinitionRegistry().removeComponentDefinition(bname);
+ if (!StringUtils.isEmpty(id)) {
+ cxfBean.addProperty("id", createValue(context, id));
+ }
return cxfBean;
}
Modified:
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java?rev=1166250&r1=1166249&r2=1166250&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
(original)
+++
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
Wed Sep 7 16:20:25 2011
@@ -37,6 +37,7 @@ import org.apache.cxf.interceptor.Abstra
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.message.Message;
import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.ApplicationContext;
@@ -52,11 +53,22 @@ public class BusDefinitionParser extends
protected void doParse(Element element, ParserContext ctx,
BeanDefinitionBuilder bean) {
String bus = element.getAttribute("bus");
if (StringUtils.isEmpty(bus)) {
+ bus = element.getAttribute("name");
+ }
+ if (StringUtils.isEmpty(bus)) {
addBusWiringAttribute(bean, BusWiringType.PROPERTY);
} else {
addBusWiringAttribute(bean, BusWiringType.PROPERTY, bus);
}
- element.removeAttribute("bus");
+ String id = element.getAttribute("id");
+ if (!StringUtils.isEmpty(id)) {
+ bean.addPropertyValue("id", id);
+ }
+ //element.removeAttribute("bus");
+ //element.removeAttribute("name");
+ //element.removeAttribute("id");
+
+
bean.addConstructorArgValue(bus);
bean.setLazyInit(false);
super.doParse(element, ctx, bean);
@@ -77,20 +89,28 @@ public class BusDefinitionParser extends
bean.addPropertyValue("properties", map);
}
}
-
- protected String getIdOrName(Element elem) {
- String id = super.getIdOrName(elem);
- if (StringUtils.isEmpty(id)) {
- id = Bus.DEFAULT_BUS_ID + ".config" + counter.getAndIncrement();
+ @Override
+ protected String resolveId(Element element, AbstractBeanDefinition
definition,
+ ParserContext ctx) {
+ String bus = element.getAttribute("bus");
+ if (StringUtils.isEmpty(bus)) {
+ bus = element.getAttribute("name");
}
- return id;
+ if (StringUtils.isEmpty(bus)) {
+ bus = Bus.DEFAULT_BUS_ID + ".config" + counter.getAndIncrement();
+ } else {
+ bus = bus + ".config";
+ }
+ return bus;
}
+
@NoJSR250Annotations
public static class BusConfig extends AbstractBasicInterceptorProvider
implements ApplicationContextAware {
CXFBusImpl bus;
String busName;
+ String id;
Collection<AbstractFeature> features;
Map<String, Object> properties;
@@ -120,6 +140,9 @@ public class BusDefinitionParser extends
if (!getOutFaultInterceptors().isEmpty()) {
b.setOutFaultInterceptors(getOutFaultInterceptors());
}
+ if (!StringUtils.isEmpty(id)) {
+ b.setId(id);
+ }
bus = b;
}
@@ -223,6 +246,10 @@ public class BusDefinitionParser extends
this.properties = s;
}
}
+
+ public void setId(String s) {
+ id = s;
+ }
}
Modified:
cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/blueprint/core.xsd
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/blueprint/core.xsd?rev=1166250&r1=1166249&r2=1166250&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/blueprint/core.xsd
(original)
+++
cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/blueprint/core.xsd
Wed Sep 7 16:20:25 2011
@@ -117,7 +117,24 @@
</xsd:element>
</xsd:all>
<xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
- <xsd:attribute name="bus" type="xsd:string" />
+ <xsd:attribute name="bus" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Name of the bus that is being configured. Defaults to "cxf",
but can
+ be used to specify a different bus to allow for multiple Bus
instances
+ within an application.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="id" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Unique identifier for the particular Bus instance. Mostly used
by the
+ JMX management and OSGi service registry to provide some level
of
+ persitent naming to the Bus instances. The default is "cxf" +
random number.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/core.xsd
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/core.xsd?rev=1166250&r1=1166249&r2=1166250&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/core.xsd
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/resources/schemas/core.xsd Wed
Sep 7 16:20:25 2011
@@ -117,7 +117,24 @@
</xsd:element>
</xsd:all>
<xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
- <xsd:attribute name="bus" type="xsd:string" />
+ <xsd:attribute name="bus" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Name of the bus that is being configured. Defaults to "cxf",
but can
+ be used to specify a different bus to allow for multiple Bus
instances
+ within an application.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="id" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Unique identifier for the particular Bus instance. Mostly used
by the
+ JMX management and OSGi service registry to provide some level
of
+ persitent naming to the Bus instances. The default is "cxf" +
random number.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Modified:
cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/jmx/BusRegistrationTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/jmx/BusRegistrationTest.java?rev=1166250&r1=1166249&r2=1166250&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/jmx/BusRegistrationTest.java
(original)
+++
cxf/branches/2.4.x-fixes/rt/management/src/test/java/org/apache/cxf/management/jmx/BusRegistrationTest.java
Wed Sep 7 16:20:25 2011
@@ -65,6 +65,7 @@ public class BusRegistrationTest extends
final SpringBusFactory factory = new SpringBusFactory();
serverBus = factory.createBus("managed-spring.xml");
+ assertEquals("CXF-Test-Bus", serverBus.getId());
serverIM = serverBus.getExtension(InstrumentationManager.class);
assertTrue("Instrumentation Manager should not be null", serverIM !=
null);
Thread t = new Thread(new Runnable() {
Modified:
cxf/branches/2.4.x-fixes/rt/management/src/test/resources/managed-spring.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/management/src/test/resources/managed-spring.xml?rev=1166250&r1=1166249&r2=1166250&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/management/src/test/resources/managed-spring.xml
(original)
+++
cxf/branches/2.4.x-fixes/rt/management/src/test/resources/managed-spring.xml
Wed Sep 7 16:20:25 2011
@@ -20,8 +20,12 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:im="http://cxf.apache.org/management"
+ xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+ http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <cxf:bus id="CXF-Test-Bus" bus="cxf"/>
<bean id="org.apache.cxf.management.InstrumentationManager"
class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
<property name="bus" ref="cxf" />