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/06/26 21:13:15 UTC
svn commit: r788820 - in /cxf/trunk: api/src/main/java/org/apache/cxf/
api/src/main/java/org/apache/cxf/message/
integration/jca/src/test/java/org/apache/cxf/jca/cxf/test/
rt/core/src/main/java/org/apache/cxf/bus/
rt/core/src/main/java/org/apache/cxf/b...
Author: dkulp
Date: Fri Jun 26 19:13:14 2009
New Revision: 788820
URL: http://svn.apache.org/viewvc?rev=788820&view=rev
Log:
Change <cxf:bus> processing to configure the existing bus, not create a
new one
Make Bus have properties so props (like schema-validation) can be
enabled globally
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java
cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/test/DummyBus.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
cxf/trunk/rt/core/src/main/resources/schemas/core.xsd
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java?rev=788820&r1=788819&r2=788820&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java Fri Jun 26 19:13:14 2009
@@ -19,6 +19,8 @@
package org.apache.cxf;
+import java.util.Map;
+
import org.apache.cxf.interceptor.InterceptorProvider;
/**
@@ -40,4 +42,9 @@
void shutdown(boolean wait);
void run();
+
+ void setProperty(String s, Object o);
+ Object getProperty(String s);
+ Map<String, Object> getProperties();
+
}
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java?rev=788820&r1=788819&r2=788820&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java Fri Jun 26 19:13:14 2009
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.Set;
+import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.interceptor.InterceptorChain;
import org.apache.cxf.service.Service;
@@ -143,6 +144,13 @@
}
}
+ if (val == null) {
+ Bus bus = ex.get(Bus.class);
+ if (bus != null) {
+ val = bus.getProperty(key);
+ }
+ }
+
return val;
}
Modified: cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/test/DummyBus.java
URL: http://svn.apache.org/viewvc/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/test/DummyBus.java?rev=788820&r1=788819&r2=788820&view=diff
==============================================================================
--- cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/test/DummyBus.java (original)
+++ cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/test/DummyBus.java Fri Jun 26 19:13:14 2009
@@ -20,6 +20,8 @@
+import java.util.Collections;
+import java.util.Map;
import java.util.ResourceBundle;
import org.apache.cxf.Bus;
@@ -119,4 +121,18 @@
DummyBus.initializeCount = count;
}
+
+ public Map<String, Object> getProperties() {
+ return Collections.emptyMap();
+ }
+
+
+ public Object getProperty(String s) {
+ return null;
+ }
+
+
+ public void setProperty(String s, Object o) {
+ }
+
}
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java?rev=788820&r1=788819&r2=788820&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java Fri Jun 26 19:13:14 2009
@@ -36,6 +36,7 @@
private BusState state;
private Collection<AbstractFeature> features;
private ExtensionFinder finder;
+ private Map<String, Object> properties = new ConcurrentHashMap<String, Object>();
public CXFBusImpl() {
this(null);
@@ -152,4 +153,21 @@
public interface ExtensionFinder {
<T> T findExtension(Class<T> cls);
}
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> map) {
+ properties.clear();
+ properties.putAll(map);
+ }
+
+ public Object getProperty(String s) {
+ return properties.get(s);
+ }
+
+ public void setProperty(String s, Object o) {
+ properties.put(s, o);
+ }
}
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java?rev=788820&r1=788819&r2=788820&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java Fri Jun 26 19:13:14 2009
@@ -19,7 +19,9 @@
package org.apache.cxf.bus.spring;
+import java.util.Collection;
import java.util.List;
+import java.util.Map;
import org.w3c.dom.Element;
@@ -27,6 +29,9 @@
import org.apache.cxf.bus.CXFBusImpl;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
+import org.apache.cxf.configuration.spring.BusWiringType;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.Interceptor;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
@@ -34,9 +39,18 @@
public BusDefinitionParser() {
super();
- setBeanClass(CXFBusImpl.class);
+ setBeanClass(BusConfig.class);
}
-
+ protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
+ String bus = element.getAttribute("bus");
+ if (StringUtils.isEmpty(bus)) {
+ addBusWiringAttribute(bean, BusWiringType.CONSTRUCTOR);
+ } else {
+ bean.addConstructorArgReference(bus);
+ }
+ super.doParse(element, ctx, bean);
+ }
+
@Override
protected void mapElement(ParserContext ctx,
BeanDefinitionBuilder bean,
@@ -47,14 +61,72 @@
|| "features".equals(name)) {
List list = ctx.getDelegate().parseListElement(e, bean.getBeanDefinition());
bean.addPropertyValue(name, list);
- }
+ } else if ("properties".equals(name)) {
+ Map map = ctx.getDelegate().parseMapElement(e, bean.getBeanDefinition());
+ bean.addPropertyValue("properties", map);
+ }
}
protected String getIdOrName(Element elem) {
String id = super.getIdOrName(elem);
if (StringUtils.isEmpty(id)) {
- id = Bus.DEFAULT_BUS_ID;
+ id = Bus.DEFAULT_BUS_ID + ".config";
}
return id;
}
+
+ public static class BusConfig {
+ CXFBusImpl bus;
+
+ public BusConfig(Bus b) {
+ bus = (CXFBusImpl)b;
+ }
+ public List<Interceptor> getOutFaultInterceptors() {
+ return bus.getOutFaultInterceptors();
+ }
+
+ public List<Interceptor> getInFaultInterceptors() {
+ return bus.getInFaultInterceptors();
+ }
+
+ public List<Interceptor> getInInterceptors() {
+ return bus.getInInterceptors();
+ }
+
+ public List<Interceptor> getOutInterceptors() {
+ return bus.getOutInterceptors();
+ }
+
+ public void setInInterceptors(List<Interceptor> interceptors) {
+ bus.setInInterceptors(interceptors);
+ }
+
+ public void setInFaultInterceptors(List<Interceptor> interceptors) {
+ bus.setInFaultInterceptors(interceptors);
+ }
+
+ public void setOutInterceptors(List<Interceptor> interceptors) {
+ bus.setOutInterceptors(interceptors);
+ }
+
+ public void setOutFaultInterceptors(List<Interceptor> interceptors) {
+ bus.setOutFaultInterceptors(interceptors);
+ }
+
+ public Collection<AbstractFeature> getFeatures() {
+ return bus.getFeatures();
+ }
+
+ public void setFeatures(Collection<AbstractFeature> features) {
+ bus.setFeatures(features);
+ }
+
+ public Map<String, Object> getProperties() {
+ return bus.getProperties();
+ }
+ public void setProperties(Map<String, Object> s) {
+ bus.setProperties(s);
+ }
+
+ }
}
Modified: cxf/trunk/rt/core/src/main/resources/schemas/core.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/resources/schemas/core.xsd?rev=788820&r1=788819&r2=788820&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/resources/schemas/core.xsd (original)
+++ cxf/trunk/rt/core/src/main/resources/schemas/core.xsd Fri Jun 26 19:13:14 2009
@@ -110,6 +110,11 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
+ <xsd:element name="properties" type="beans:mapType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>Specifies a map of properties that are passed to the bus.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
</xsd:all>
<xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
</xsd:complexType>