cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [2/3] git commit: Update the Blueprint parsing for JAXB objects to allow propertly placeholders.
Date Fri, 21 Mar 2014 21:13:39 GMT
Update the Blueprint parsing for JAXB objects to allow propertly placeholders.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/545a6fca
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/545a6fca
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/545a6fca

Branch: refs/heads/2.7.x-fixes
Commit: 545a6fcaf9d503d4e0b08bb4ce4cba12893b7b2c
Parents: 6bb263b
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Mar 21 17:07:54 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Mar 21 17:11:27 2014 -0400

----------------------------------------------------------------------
 .../AbstractBPBeanDefinitionParser.java         | 107 ++++++++++++-------
 .../blueprint/AuthorizationPolicyHolder.java    |  76 -------------
 .../http/blueprint/HTTPClientPolicyHolder.java  |  99 -----------------
 .../http/blueprint/HTTPServerPolicyHolder.java  |  86 ---------------
 .../transport/http/blueprint/HolderUtils.java   |  90 ----------------
 .../HttpConduitBPBeanDefinitionParser.java      |  23 ++--
 .../HttpDestinationBPBeanDefinitionParser.java  |  28 +----
 .../ProxyAuthorizationPolicyHolder.java         |  78 --------------
 8 files changed, 87 insertions(+), 500 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
b/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
index f58eada..d2b57de 100644
--- a/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
+++ b/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
@@ -18,15 +18,21 @@
  */
 package org.apache.cxf.configuration.blueprint;
 
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.logging.Logger;
 
 import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -42,7 +48,6 @@ import org.apache.aries.blueprint.mutable.MutableValueMetadata;
 import org.apache.cxf.bus.blueprint.BlueprintBus;
 import org.apache.cxf.common.jaxb.JAXBContextCache;
 import org.apache.cxf.common.jaxb.JAXBContextCache.CachedContextAndSchemas;
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
@@ -61,8 +66,6 @@ public abstract class AbstractBPBeanDefinitionParser {
     private static final String XMLNS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
     private static final String COMPONENT_ID = "component-id";
 
-    private static final Logger LOG = LogUtils.getL7dLogger(AbstractBPBeanDefinitionParser.class);
-
     private JAXBContext jaxbContext;
     private Set<Class<?>> jaxbClasses;
 
@@ -321,46 +324,78 @@ public abstract class AbstractBPBeanDefinitionParser {
 
         mapElementToJaxbProperty(ctx, bean, data, propertyName, c);
     }
+    
+    public static class JAXBBeanFactory {
+        final JAXBContext ctx;
+        final Class<?> cls;
+        public JAXBBeanFactory(JAXBContext c, Class<?> c2) {
+            ctx = c;
+            cls = c2;
+        }
+        
+        
+        public Object createJAXBBean(String v) {
+            XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(v));
+            try {
+                return ctx.createUnmarshaller().unmarshal(reader, cls);
+            } catch (JAXBException e) {
+                throw new RuntimeException(e);
+            } finally {
+                try {
+                    reader.close();
+                } catch (XMLStreamException e) {
+                    //ignore
+                }
+            }
+        }
+    }
 
     protected void mapElementToJaxbProperty(ParserContext ctx,
-                                            MutableBeanMetadata bean, Element data, 
+                                            MutableBeanMetadata bean, 
+                                            Element data, 
                                             String propertyName, 
-                                            Class<?> c) {
+                                            Class<?> c) {   
         try {
-            Unmarshaller unmarshaller = getContext(c).createUnmarshaller();
-            MutablePassThroughMetadata value = ctx.createMetadata(MutablePassThroughMetadata.class);
-            value.setObject(unmarshaller.unmarshal(data, c).getValue());
-            bean.addProperty(propertyName, value);
+            XMLStreamWriter xmlWriter = null;
+            try {
+                StringWriter writer = new StringWriter();
+                xmlWriter = StaxUtils.createXMLStreamWriter(writer);
+                StaxUtils.copy(data, xmlWriter);
+                xmlWriter.flush();
+    
+                
+                MutableBeanMetadata factory = ctx.createMetadata(MutableBeanMetadata.class);
+                factory.setClassName(c.getName());
+                factory.setFactoryComponent(createPassThrough(ctx, new JAXBBeanFactory(getContext(c),
c)));
+                factory.setFactoryMethod("createJAXBBean");
+                factory.addArgument(createValue(ctx, writer.toString()), String.class.getName(),
0);
+                bean.addProperty(propertyName, factory);
+
+            } catch (Exception ex) {                
+                Unmarshaller u = getContext(c).createUnmarshaller();
+                Object obj;
+                if (c != null) {
+                    obj = u.unmarshal(data, c);
+                } else {
+                    obj = u.unmarshal(data);
+                }
+                if (obj instanceof JAXBElement<?>) {
+                    JAXBElement<?> el = (JAXBElement<?>)obj;
+                    obj = el.getValue();
+                }
+                if (obj != null) {
+                    MutablePassThroughMetadata value = ctx.createMetadata(MutablePassThroughMetadata.class);
+                    value.setObject(obj);
+                    bean.addProperty(propertyName, value);
+                }
+            } finally {
+                StaxUtils.close(xmlWriter);
+            }
         } catch (JAXBException e) {
-            LOG.warning("Unable to parse property " + propertyName + " due to " + e);
+            throw new RuntimeException("Could not parse configuration.", 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);
-        }
-
-    }
 
     protected synchronized JAXBContext getContext(Class<?> cls) {
         if (jaxbContext == null || jaxbClasses == null || !jaxbClasses.contains(cls)) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/AuthorizationPolicyHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/AuthorizationPolicyHolder.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/AuthorizationPolicyHolder.java
deleted file mode 100644
index b2100af..0000000
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/AuthorizationPolicyHolder.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.transport.http.blueprint;
-
-import java.io.ByteArrayInputStream;
-import java.util.Set;
-import javax.xml.bind.JAXBContext;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Element;
-
-
-import org.apache.cxf.configuration.security.AuthorizationPolicy;
-
-public class AuthorizationPolicyHolder extends AuthorizationPolicy {
-    
-    private String parsedElement;
-    private AuthorizationPolicy authorizationPolicy;
-
-    private JAXBContext jaxbContext;
-    private Set<Class<?>> jaxbClasses;
-
-    public AuthorizationPolicyHolder() {
-    }
-
-    public void init() {
-        try {
-
-            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
-            docFactory.setNamespaceAware(true);
-
-            Element element = docFactory.newDocumentBuilder()
-                .parse(new ByteArrayInputStream(parsedElement.getBytes())).getDocumentElement();
-
-            authorizationPolicy = (AuthorizationPolicy)HolderUtils.getJaxbObject(
-                                      element, AuthorizationPolicy.class,
-                                      jaxbContext, jaxbClasses, getClass().getClassLoader());
-            this.setAuthorization(authorizationPolicy.getAuthorization());
-            this.setAuthorizationType(authorizationPolicy.getAuthorizationType());
-            this.setPassword(authorizationPolicy.getPassword());
-            this.setUserName(authorizationPolicy.getUserName());
-            
-        } catch (Exception e) {
-            throw new RuntimeException("Could not process configuration.", e);
-        }
-    }
-
-    public void destroy() {
-        
-    }
-
-    public String getParsedElement() {
-        return parsedElement;
-    }
-
-    public void setParsedElement(String parsedElement) {
-        this.parsedElement = parsedElement;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPClientPolicyHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPClientPolicyHolder.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPClientPolicyHolder.java
deleted file mode 100644
index a7dd3b9..0000000
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPClientPolicyHolder.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.transport.http.blueprint;
-
-import java.io.ByteArrayInputStream;
-import java.util.Set;
-import javax.xml.bind.JAXBContext;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Element;
-
-import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
-
-
-public class HTTPClientPolicyHolder extends HTTPClientPolicy {
-    
-    private String parsedElement;
-    private HTTPClientPolicy clientPolicy;
-
-    private JAXBContext jaxbContext;
-    private Set<Class<?>> jaxbClasses;
-
-    public HTTPClientPolicyHolder() {
-    }
-
-    public void init() {
-        try {
-
-            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
-            docFactory.setNamespaceAware(true);
-
-            Element element = docFactory.newDocumentBuilder()
-                .parse(new ByteArrayInputStream(parsedElement.getBytes())).getDocumentElement();
-
-            clientPolicy = (HTTPClientPolicy)HolderUtils.getJaxbObject(element, HTTPClientPolicy.class,
-                                                           jaxbContext, jaxbClasses, getClass().getClassLoader());
-            
-            this.setAccept(clientPolicy.getAccept());
-            this.setAcceptEncoding(clientPolicy.getAcceptEncoding());
-            this.setAcceptLanguage(clientPolicy.getAcceptLanguage());
-            this.setAllowChunking(clientPolicy.isAllowChunking());
-            this.setAsyncExecuteTimeout(clientPolicy.getAsyncExecuteTimeout());
-            this.setAsyncExecuteTimeoutRejection(clientPolicy.isAsyncExecuteTimeoutRejection());
-            this.setAutoRedirect(clientPolicy.isAutoRedirect());
-            this.setBrowserType(clientPolicy.getBrowserType());
-            this.setCacheControl(clientPolicy.getCacheControl());
-            this.setChunkingThreshold(clientPolicy.getChunkingThreshold());
-            this.setConnection(clientPolicy.getConnection());
-            this.setConnectionTimeout(clientPolicy.getConnectionTimeout());
-            this.setContentType(clientPolicy.getContentType());
-            this.setCookie(clientPolicy.getCookie());
-            this.setDecoupledEndpoint(clientPolicy.getDecoupledEndpoint());
-            this.setHost(clientPolicy.getHost());
-            this.setMaxRetransmits(clientPolicy.getMaxRetransmits());
-            this.setNonProxyHosts(clientPolicy.getNonProxyHosts());
-            this.setProxyServer(clientPolicy.getProxyServer());
-            // need to check if the property is set to avoid NPE
-            if (clientPolicy.isSetProxyServerPort()) {
-                this.setProxyServerPort(clientPolicy.getProxyServerPort());
-            }
-            this.setProxyServerType(clientPolicy.getProxyServerType());
-            this.setReceiveTimeout(clientPolicy.getReceiveTimeout());
-            this.setReferer(clientPolicy.getReferer());
-            
-        } catch (Exception e) {
-            throw new RuntimeException("Could not process configuration.", e);
-        }
-    }
-
-    public void destroy() {
-        
-    }
-
-    public String getParsedElement() {
-        return parsedElement;
-    }
-
-    public void setParsedElement(String parsedElement) {
-        this.parsedElement = parsedElement;
-    }
-
-        
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPServerPolicyHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPServerPolicyHolder.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPServerPolicyHolder.java
deleted file mode 100644
index 026b6e3..0000000
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HTTPServerPolicyHolder.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.transport.http.blueprint;
-
-import java.io.ByteArrayInputStream;
-import java.util.Set;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Element;
-
-import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
-
-
-public class HTTPServerPolicyHolder extends HTTPServerPolicy {
-    
-    private String parsedElement;
-    private HTTPServerPolicy serverPolicy;
-
-    private JAXBContext jaxbContext;
-    private Set<Class<?>> jaxbClasses;
-
-    public HTTPServerPolicyHolder() {
-    }
-
-    public void init() {
-        try {
-
-            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
-            docFactory.setNamespaceAware(true);
-
-            Element element = docFactory.newDocumentBuilder()
-                .parse(new ByteArrayInputStream(parsedElement.getBytes())).getDocumentElement();
-
-            serverPolicy = (HTTPServerPolicy)HolderUtils.getJaxbObject(
-                               element, HTTPServerPolicy.class,
-                               jaxbContext, jaxbClasses, getClass().getClassLoader());
-            this.setCacheControl(serverPolicy.getCacheControl());
-            this.setContentEncoding(serverPolicy.getContentEncoding());
-            this.setContentLocation(serverPolicy.getContentLocation());
-            this.setContentType(serverPolicy.getContentType());
-            this.setHonorKeepAlive(serverPolicy.isHonorKeepAlive());
-            this.setKeepAliveParameters(serverPolicy.getKeepAliveParameters());
-            this.setReceiveTimeout(serverPolicy.getReceiveTimeout());
-            this.setRedirectURL(serverPolicy.getRedirectURL());
-            this.setServerType(serverPolicy.getServerType());
-            this.setSuppressClientReceiveErrors(serverPolicy.isSuppressClientReceiveErrors());
-            this.setSuppressClientSendErrors(serverPolicy.isSuppressClientSendErrors());
-            
-        } catch (Exception e) {
-            throw new RuntimeException("Could not process configuration.", e);
-        }
-    }
-
-    public void destroy() {
-        
-    }
-
-    public String getParsedElement() {
-        return parsedElement;
-    }
-
-    public void setParsedElement(String parsedElement) {
-        this.parsedElement = parsedElement;
-    }
-
-    
-       
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HolderUtils.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HolderUtils.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HolderUtils.java
deleted file mode 100644
index a6cb06b..0000000
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HolderUtils.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.transport.http.blueprint;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-
-import org.w3c.dom.Element;
-
-import org.apache.cxf.common.jaxb.JAXBContextCache;
-import org.apache.cxf.common.util.PackageUtils;
-
-public final class HolderUtils {
-    
-    private HolderUtils() {
-        
-    }
-    
-    
-    public static Object getJaxbObject(Element parent, Class<?> c, 
-                                       JAXBContext jaxbContext, 
-                                       Set<Class<?>> jaxbClasses,
-                                       ClassLoader cl) {
-
-        try {
-            Unmarshaller umr = getContext(c, jaxbContext, jaxbClasses, cl).createUnmarshaller();
-            JAXBElement<?> ele = (JAXBElement<?>) umr.unmarshal(parent, c);
-
-            return ele.getValue();
-        } catch (JAXBException e) {
-            return null;
-        }
-    }
-
-    public static synchronized JAXBContext getContext(Class<?> cls, 
-                                                      JAXBContext jaxbContext, 
-                                                      Set<Class<?>> jaxbClasses,
-                                                      ClassLoader cl) {
-        if (jaxbContext == null || jaxbClasses == null || !jaxbClasses.contains(cls)) {
-            try {
-                Set<Class<?>> tmp = new HashSet<Class<?>>();
-                if (jaxbClasses != null) {
-                    tmp.addAll(jaxbClasses);
-                }
-                JAXBContextCache.addPackage(tmp, PackageUtils.getPackageName(cls), 
-                                            cls == null ? cl : cls.getClassLoader());
-                if (cls != null) {
-                    boolean hasOf = false;
-                    for (Class<?> c : tmp) {
-                        if (c.getPackage() == cls.getPackage() && "ObjectFactory".equals(c.getSimpleName()))
{
-                            hasOf = true;
-                        }
-                    }
-                    if (!hasOf) {
-                        tmp.add(cls);
-                    }
-                }
-                JAXBContextCache.scanPackages(tmp);
-                JAXBContextCache.CachedContextAndSchemas ccs 
-                    = JAXBContextCache.getCachedContextAndSchemas(tmp, null, null, null,
false);
-                jaxbClasses = ccs.getClasses();
-                jaxbContext = ccs.getContext();
-            } catch (JAXBException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return jaxbContext;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java
index db8c285..4e51e44 100755
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpConduitBPBeanDefinitionParser.java
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.transport.http.blueprint;
 
-import javax.xml.namespace.QName;
 
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
@@ -30,21 +29,22 @@ import org.apache.aries.blueprint.ParserContext;
 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 {
-    private static final String HTTP_NS =
-        "http://cxf.apache.org/transports/http/configuration";
     private static final String SECURITY_NS =
         "http://cxf.apache.org/configuration/security";
 
@@ -52,14 +52,6 @@ public class HttpConduitBPBeanDefinitionParser extends AbstractBPBeanDefinitionP
         MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
         
         bean.setRuntimeClass(HTTPConduit.class);
-
-        mapElementToHolder(context, bean, element,
-                new QName(HTTP_NS, "client"), "client", HTTPClientPolicyHolder.class);
-        mapElementToHolder(context, bean, element,
-                new QName(HTTP_NS, "proxyAuthorization"), "proxyAuthorization", 
-                ProxyAuthorizationPolicyHolder.class);
-        mapElementToHolder(context, bean, element,
-                new QName(HTTP_NS, "authorization"), "authorization", AuthorizationPolicyHolder.class);
         
         parseAttributes(element, context, bean);
         parseChildElements(element, context, bean);
@@ -84,6 +76,15 @@ public class HttpConduitBPBeanDefinitionParser extends AbstractBPBeanDefinitionP
             mapBeanOrClassElement(ctx, bean, el, MessageTrustDecider.class);
         } else if ("authSupplier".equals(name)) {
             mapBeanOrClassElement(ctx, bean, el, HttpAuthSupplier.class);
+        } else if ("client".equals(name)) {
+            mapElementToJaxbProperty(ctx, bean, el, name, 
+                                     HTTPClientPolicy.class);
+        } else if ("proxyAuthorization".equals(name)) {
+            mapElementToJaxbProperty(ctx, bean, el, name, 
+                                     ProxyAuthorizationPolicy.class);
+        } else if ("authorization".equals(name)) {
+            mapElementToJaxbProperty(ctx, bean, el, name, 
+                                     AuthorizationPolicy.class);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java
index e0004fc..b0371e6 100755
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/HttpDestinationBPBeanDefinitionParser.java
@@ -19,24 +19,19 @@
 
 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";
@@ -46,8 +41,8 @@ public class HttpDestinationBPBeanDefinitionParser extends AbstractBPBeanDefinit
         
         bean.setRuntimeClass(AbstractHTTPDestination.class);
 
-        mapElementToHolder(context, bean, element, new QName(HTTP_NS, "server"), "server",

-                           HTTPServerPolicyHolder.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"),
@@ -66,21 +61,6 @@ public class HttpDestinationBPBeanDefinitionParser extends AbstractBPBeanDefinit
                                         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);
-        }
-    }
-    
+        
     
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/545a6fca/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/ProxyAuthorizationPolicyHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/ProxyAuthorizationPolicyHolder.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/ProxyAuthorizationPolicyHolder.java
deleted file mode 100644
index 1978644..0000000
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/blueprint/ProxyAuthorizationPolicyHolder.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.transport.http.blueprint;
-
-import java.io.ByteArrayInputStream;
-import java.util.Set;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Element;
-
-import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
-
-public class ProxyAuthorizationPolicyHolder extends ProxyAuthorizationPolicy {
-    
-    private String parsedElement;
-    private ProxyAuthorizationPolicy proxyAuthorizationPolicy;
-
-    private JAXBContext jaxbContext;
-    private Set<Class<?>> jaxbClasses;
-
-    public ProxyAuthorizationPolicyHolder() {
-    }
-
-    public void init() {
-        try {
-
-            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
-            docFactory.setNamespaceAware(true);
-
-            Element element = docFactory.newDocumentBuilder()
-                .parse(new ByteArrayInputStream(parsedElement.getBytes())).getDocumentElement();
-
-            proxyAuthorizationPolicy = (ProxyAuthorizationPolicy)HolderUtils.getJaxbObject(
-                                           element, ProxyAuthorizationPolicy.class,
-                                           jaxbContext, jaxbClasses, getClass().getClassLoader());
-            this.setAuthorization(proxyAuthorizationPolicy.getAuthorization());
-            this.setAuthorizationType(proxyAuthorizationPolicy.getAuthorizationType());
-            this.setPassword(proxyAuthorizationPolicy.getPassword());
-            this.setUserName(proxyAuthorizationPolicy.getUserName());
-            
-        } catch (Exception e) {
-            throw new RuntimeException("Could not process configuration.", e);
-        }
-    }
-
-    public void destroy() {
-        
-    }
-
-    public String getParsedElement() {
-        return parsedElement;
-    }
-
-    public void setParsedElement(String parsedElement) {
-        this.parsedElement = parsedElement;
-    }
-
-   
-    
-}


Mime
View raw message