You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2013/07/24 11:20:54 UTC
svn commit: r1506461 - in /cxf/branches/2.6.x-fixes: ./
rt/core/src/main/java/org/apache/cxf/configuration/blueprint/
rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/
Author: ffang
Date: Wed Jul 24 09:20:53 2013
New Revision: 1506461
URL: http://svn.apache.org/r1506461
Log:
Merged revisions 1506448 via svnmerge from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
................
r1506448 | ffang | 2013-07-24 17:05:20 +0800 (三, 24 7 2013) | 21 lines
Merged revisions 1506415,1506430-1506431,1506442 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1506415 | ffang | 2013-07-24 14:53:06 +0800 (三, 24 7 2013) | 1 line
[CXF-5148]add HTTPServerPolicyHolder for http:server blueprint configuration
........
r1506430 | ffang | 2013-07-24 15:55:19 +0800 (三, 24 7 2013) | 1 line
[CXF-5148]add holders for http:client blueprint configuration
........
r1506431 | ffang | 2013-07-24 16:02:53 +0800 (三, 24 7 2013) | 1 line
[CXF-5148]extract mapElementToHolder method to parent class
........
r1506442 | ffang | 2013-07-24 16:30:05 +0800 (三, 24 7 2013) | 1 line
[CXF-5148]add a util class to remove duplicated code
........
................
Added:
cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/AuthorizationPolicyHolder.java
- copied unchanged from r1506448, cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/AuthorizationPolicyHolder.java
cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPClientPolicyHolder.java
- copied unchanged from r1506448, cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPClientPolicyHolder.java
cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPServerPolicyHolder.java
- copied unchanged from r1506448, cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPServerPolicyHolder.java
cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HolderUtils.java
- copied unchanged from r1506448, cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HolderUtils.java
cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/ProxyAuthorizationPolicyHolder.java
- copied unchanged from r1506448, cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/ProxyAuthorizationPolicyHolder.java
Modified:
cxf/branches/2.6.x-fixes/ (props changed)
cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java
cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/branches/2.7.x-fixes:r1506448
Merged /cxf/trunk:r1506415-1506442
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java?rev=1506461&r1=1506460&r2=1506461&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java (original)
+++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java Wed Jul 24 09:20:53 2013
@@ -46,6 +46,7 @@ import org.apache.cxf.common.logging.Log
import org.apache.cxf.common.util.PackageUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.staxutils.StaxUtils;
import org.osgi.framework.Bundle;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.CollectionMetadata;
@@ -334,8 +335,34 @@ public abstract class AbstractBPBeanDefi
LOG.warning("Unable to parse property " + propertyName + " due to " + e);
}
}
+
+ protected void mapElementToHolder(ParserContext ctx, MutableBeanMetadata bean, Element parent, QName name,
+ String propertyName, Class<?> cls) {
+ Element data = DOMUtils.getFirstChildWithName(parent, name);
+ if (data == null) {
+ return;
+ }
+ MutableBeanMetadata ef = ctx.createMetadata(MutableBeanMetadata.class);
+
+ ef.setRuntimeClass(cls);
+
+ try {
+ // Print the DOM node
+
+ String xmlString = StaxUtils.toString(data);
+ ef.addProperty("parsedElement", createValue(ctx, xmlString));
+ ef.setInitMethod("init");
+
+ ef.setActivation(ComponentMetadata.ACTIVATION_EAGER);
+ bean.addProperty(propertyName, ef);
+
+ } catch (Exception e) {
+ throw new RuntimeException("Could not process configuration.", e);
+ }
+
+ }
- private synchronized JAXBContext getContext(Class<?> cls) {
+ protected synchronized JAXBContext getContext(Class<?> cls) {
if (jaxbContext == null || jaxbClasses == null || !jaxbClasses.contains(cls)) {
try {
Set<Class<?>> tmp = new HashSet<Class<?>>();
Modified: cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java?rev=1506461&r1=1506460&r2=1506461&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java (original)
+++ cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java Wed Jul 24 09:20:53 2013
@@ -30,19 +30,16 @@ import org.apache.aries.blueprint.Parser
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
import org.apache.cxf.configuration.jsse.TLSClientParametersConfig;
-import org.apache.cxf.configuration.security.AuthorizationPolicy;
import org.apache.cxf.configuration.security.CertificateConstraintsType;
import org.apache.cxf.configuration.security.CipherSuites;
import org.apache.cxf.configuration.security.FiltersType;
import org.apache.cxf.configuration.security.KeyManagersType;
-import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
import org.apache.cxf.configuration.security.SecureRandomParameters;
import org.apache.cxf.configuration.security.TLSClientParametersType;
import org.apache.cxf.configuration.security.TrustManagersType;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transport.http.MessageTrustDecider;
import org.apache.cxf.transport.http.auth.HttpAuthSupplier;
-import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.osgi.service.blueprint.reflect.Metadata;
public class HttpConduitBPBeanDefinitionParser extends AbstractBPBeanDefinitionParser {
@@ -56,13 +53,13 @@ public class HttpConduitBPBeanDefinition
bean.setRuntimeClass(HTTPConduit.class);
- mapElementToJaxbProperty(context, bean, element,
- new QName(HTTP_NS, "client"), "client", HTTPClientPolicy.class);
- mapElementToJaxbProperty(context, bean, element,
+ mapElementToHolder(context, bean, element,
+ new QName(HTTP_NS, "client"), "client", HTTPClientPolicyHolder.class);
+ mapElementToHolder(context, bean, element,
new QName(HTTP_NS, "proxyAuthorization"), "proxyAuthorization",
- ProxyAuthorizationPolicy.class);
- mapElementToJaxbProperty(context, bean, element,
- new QName(HTTP_NS, "authorization"), "authorization", AuthorizationPolicy.class);
+ ProxyAuthorizationPolicyHolder.class);
+ mapElementToHolder(context, bean, element,
+ new QName(HTTP_NS, "authorization"), "authorization", AuthorizationPolicyHolder.class);
parseAttributes(element, context, bean);
parseChildElements(element, context, bean);
@@ -72,6 +69,7 @@ public class HttpConduitBPBeanDefinition
return bean;
}
+
@Override
protected void processNameAttribute(Element element, ParserContext context, MutableBeanMetadata bean,
String val) {
@@ -172,4 +170,6 @@ public class HttpConduitBPBeanDefinition
bean.addProperty(elementName, createRef(ctx, beanref));
}
}
+
+
}
Modified: cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java?rev=1506461&r1=1506460&r2=1506461&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java (original)
+++ cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java Wed Jul 24 09:20:53 2013
@@ -19,18 +19,25 @@
package org.apache.cxf.transport.http.blueprint;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
import org.w3c.dom.Element;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.aries.blueprint.mutable.MutableValueMetadata;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
-import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
import org.osgi.service.blueprint.reflect.Metadata;
public class HttpDestinationBPBeanDefinitionParser extends AbstractBPBeanDefinitionParser {
+ private static final Logger LOG = LogUtils.getL7dLogger(HttpDestinationBPBeanDefinitionParser.class);
+
private static final String HTTP_NS =
"http://cxf.apache.org/transports/http/configuration";
@@ -39,12 +46,12 @@ public class HttpDestinationBPBeanDefini
bean.setRuntimeClass(AbstractHTTPDestination.class);
- mapElementToJaxbProperty(context, bean, element,
- new QName(HTTP_NS, "server"), "server", HTTPServerPolicy.class);
- mapElementToJaxbProperty(context, bean, element,
- new QName(HTTP_NS, "fixedParameterOrder"), "fixedParameterOrder", Boolean.class);
- mapElementToJaxbProperty(context, bean, element,
- new QName(HTTP_NS, "contextMatchStrategy"), "contextMatchStrategy", String.class);
+ mapElementToHolder(context, bean, element, new QName(HTTP_NS, "server"), "server",
+ HTTPServerPolicyHolder.class);
+ mapElementToJaxbProperty(context, bean, element, new QName(HTTP_NS, "fixedParameterOrder"),
+ "fixedParameterOrder", Boolean.class);
+ mapElementToJaxbProperty(context, bean, element, new QName(HTTP_NS, "contextMatchStrategy"),
+ "contextMatchStrategy", String.class);
parseAttributes(element, context, bean);
parseChildElements(element, context, bean);
@@ -59,4 +66,21 @@ public class HttpDestinationBPBeanDefini
String val) {
bean.setId(val);
}
+
+ @Override
+ protected void mapElementToJaxbProperty(ParserContext ctx,
+ MutableBeanMetadata bean, Element data,
+ String propertyName,
+ Class<?> c) {
+ try {
+ Unmarshaller unmarshaller = getContext(c).createUnmarshaller();
+ MutableValueMetadata value = ctx.createMetadata(MutableValueMetadata.class);
+ value.setStringValue(unmarshaller.unmarshal(data, c).getValue().toString());
+ bean.addProperty(propertyName, value);
+ } catch (JAXBException e) {
+ LOG.warning("Unable to parse property " + propertyName + " due to " + e);
+ }
+ }
+
+
}