cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject [5/6] cxf git commit: [CXF-6800]add http-undertow transport
Date Fri, 26 Feb 2016 03:50:55 GMT
http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngineFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngineFactory.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngineFactory.java
new file mode 100644
index 0000000..458cc10
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngineFactory.java
@@ -0,0 +1,341 @@
+/**
+ * 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_undertow;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.annotation.Resource;
+import javax.management.MBeanServer;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.jsse.TLSServerParameters;
+import org.apache.cxf.management.InstrumentationManager;
+
+
+/**
+ * This Bus Extension handles the configuration of network port
+ * numbers for use with "http" or "https". This factory 
+ * caches the UndertowHTTPServerEngines so that they may be 
+ * retrieved if already previously configured.
+ */
+@NoJSR250Annotations(unlessNull = "bus")
+public class UndertowHTTPServerEngineFactory {
+    
+    private static final Logger LOG =
+        LogUtils.getL7dLogger(UndertowHTTPServerEngineFactory.class);    
+    
+    private static final int FALLBACK_THREADING_PARAMS_KEY = 0;
+
+    /**
+     * This map holds references for allocated ports.
+     */
+    // Still use the static map to hold the port information
+    // in the same JVM
+    private static ConcurrentHashMap<Integer, UndertowHTTPServerEngine> portMap =
+        new ConcurrentHashMap<Integer, UndertowHTTPServerEngine>();
+    
+    
+   
+    private BusLifeCycleManager lifeCycleManager;
+    /**
+     * This map holds the threading parameters that are to be applied
+     * to new Engines when bound to the reference id.
+     */
+    private Map<String, ThreadingParameters> threadingParametersMap =
+        new TreeMap<String, ThreadingParameters>();
+
+    private ThreadingParameters fallbackThreadingParameters;
+    
+    /**
+     * This map holds TLS Server Parameters that are to be used to
+     * configure a subsequently created UndertowHTTPServerEngine.
+     */
+    private Map<String, TLSServerParameters> tlsParametersMap =
+        new TreeMap<String, TLSServerParameters>();
+    
+    
+    /**
+     * The bus.
+     */
+    private Bus bus;
+    
+    
+    public UndertowHTTPServerEngineFactory() {
+        // Empty
+    }    
+    public UndertowHTTPServerEngineFactory(Bus b) {
+        setBus(b);
+    }    
+    public UndertowHTTPServerEngineFactory(Bus b,
+                                        Map<String, TLSServerParameters> tls,
+                                        Map<String, ThreadingParameters> threading) {
+        tlsParametersMap.putAll(tls);
+        threadingParametersMap.putAll(threading);
+        setBus(b);
+    }    
+    
+    private static UndertowHTTPServerEngine getOrCreate(UndertowHTTPServerEngineFactory factory,
+                    String host,
+                    int port,
+                    TLSServerParameters tlsParams) throws IOException, GeneralSecurityException {
+        
+        UndertowHTTPServerEngine ref = portMap.get(port);
+        if (ref == null) {
+            ref = new UndertowHTTPServerEngine(host, port);
+            if (tlsParams != null) {
+                ref.setTlsServerParameters(tlsParams);
+            }
+            UndertowHTTPServerEngine tmpRef = portMap.putIfAbsent(port, ref);
+            ref.finalizeConfig();
+            if (tmpRef != null) {
+                ref = tmpRef;
+            }
+        }
+        return ref;
+    }
+    
+       
+    /**
+     * This call is used to set the bus. It should only be called once.
+     * @param bus
+     */
+    @Resource(name = "cxf")
+    public final void setBus(Bus bus) {
+        this.bus = bus;
+        if (bus != null) {
+            bus.setExtension(this, UndertowHTTPServerEngineFactory.class);
+            lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+            if (null != lifeCycleManager) {
+                lifeCycleManager.registerLifeCycleListener(new UndertowBusLifeCycleListener());
+            }        
+        }
+    }
+    private class UndertowBusLifeCycleListener implements BusLifeCycleListener {
+        public void initComplete() {
+            UndertowHTTPServerEngineFactory.this.initComplete();
+        }
+
+        public void preShutdown() {
+            UndertowHTTPServerEngineFactory.this.preShutdown();
+        }
+
+        public void postShutdown() {
+            UndertowHTTPServerEngineFactory.this.postShutdown();
+        }
+    }
+    
+    public Bus getBus() {
+        return bus;
+    }
+    
+    
+    /**
+     * This call sets TLSParametersMap for a UndertowHTTPServerEngine
+     * 
+     */
+    public void setTlsServerParametersMap(
+        Map<String, TLSServerParameters>  tlsParamsMap) {
+        
+        tlsParametersMap = tlsParamsMap;
+    }
+    
+    public Map<String, TLSServerParameters> getTlsServerParametersMap() {
+        return tlsParametersMap;
+    }
+    
+    public void setEnginesList(List<UndertowHTTPServerEngine> enginesList) {
+        for (UndertowHTTPServerEngine engine : enginesList) {
+            if (engine.getPort() == FALLBACK_THREADING_PARAMS_KEY) {
+                fallbackThreadingParameters = engine.getThreadingParameters();
+            }
+            portMap.putIfAbsent(engine.getPort(), engine);
+        }    
+    }
+    
+    /**
+     * This call sets the ThreadingParameters for a UndertowHTTPServerEngine
+     * 
+     */
+    public void setThreadingParametersMap(
+        Map<String, ThreadingParameters> threadingParamsMap) {
+        
+        threadingParametersMap = threadingParamsMap;
+    }
+    
+    public Map<String, ThreadingParameters> getThreadingParametersMap() {
+        return threadingParametersMap;
+    }
+    
+    /**
+     * This call sets TLSServerParameters for a UndertowHTTPServerEngine
+     * that will be subsequently created. It will not alter an engine
+     * that has already been created for that network port.
+     * @param host       if not null, server will listen on this address/host, 
+     *                   otherwise, server will listen on all local addresses.
+     * @param port       The network port number to bind to the engine.
+     * @param tlsParams  The tls server parameters. Cannot be null.
+     * @throws IOException 
+     * @throws GeneralSecurityException 
+     */
+    public void setTLSServerParametersForPort(
+        String host,
+        int port, 
+        TLSServerParameters tlsParams) throws GeneralSecurityException, IOException {
+        if (tlsParams == null) {
+            throw new IllegalArgumentException("tlsParams cannot be null");
+        }
+        UndertowHTTPServerEngine ref = retrieveUndertowHTTPServerEngine(port);
+        if (null == ref) {
+            getOrCreate(this, host, port, tlsParams);
+        } else {
+            ref.setTlsServerParameters(tlsParams);            
+        }
+    }
+
+    /**
+     * calls thru to {{@link #createUndertowHTTPServerEngine(String, int, String)} with 'null' for host value
+     */
+    public void setTLSServerParametersForPort(
+        int port, 
+        TLSServerParameters tlsParams) throws GeneralSecurityException, IOException {
+        setTLSServerParametersForPort(null, port, tlsParams);
+    }
+
+    /**
+     * This call retrieves a previously configured UndertowHTTPServerEngine for the
+     * given port. If none exists, this call returns null.
+     */
+    public synchronized UndertowHTTPServerEngine retrieveUndertowHTTPServerEngine(int port) {
+        return portMap.get(port);
+    }
+
+    /**
+     * This call creates a new UndertowHTTPServerEngine initialized for "http"
+     * or "https" on the given port. The determination of "http" or "https"
+     * will depend on configuration of the engine's bean name.
+     * 
+     * If an UndertowHTTPEngine already exists, or the port
+     * is already in use, a BindIOException will be thrown. If the 
+     * engine is being Spring configured for TLS a GeneralSecurityException
+     * may be thrown.
+     * 
+     * @param host if not null, server will listen on this host/address, otherwise
+     *        server will listen on all local addresses.
+     * @param port listen port for server
+     * @param protocol "http" or "https"
+     * @return
+     * @throws GeneralSecurityException
+     * @throws IOException
+     */
+    public synchronized UndertowHTTPServerEngine createUndertowHTTPServerEngine(String host, int port, 
+        String protocol) throws GeneralSecurityException, IOException {
+        LOG.fine("Creating Undertow HTTP Server Engine for port " + port + ".");        
+        UndertowHTTPServerEngine ref = getOrCreate(this, host, port, null);
+        // checking the protocol    
+        if (!protocol.equals(ref.getProtocol())) {
+            throw new IOException("Protocol mismatch for port " + port + ": "
+                        + "engine's protocol is " + ref.getProtocol()
+                        + ", the url protocol is " + protocol);
+        }
+
+        if (!(ref.isSetThreadingParameters()
+              || null == fallbackThreadingParameters)) {
+            if (LOG.isLoggable(Level.INFO)) {
+                final int min = fallbackThreadingParameters.getMinThreads();
+                final int max = fallbackThreadingParameters.getMaxThreads();
+                
+                LOG.log(Level.INFO,
+                        "FALLBACK_THREADING_PARAMETERS_MSG",
+                        new Object[] {port, min, max, ""});
+            }
+            ref.setThreadingParameters(fallbackThreadingParameters);
+        }
+                
+        return ref;
+    }
+
+    /**
+     * Calls thru to {{@link #createUndertowHTTPServerEngine(String, int, String)} with a 'null' host value
+     */
+    public synchronized UndertowHTTPServerEngine createUndertowHTTPServerEngine(int port, 
+        String protocol) throws GeneralSecurityException, IOException {
+        return createUndertowHTTPServerEngine(null, port, protocol);
+    }
+    
+    /**
+     * This method removes the Server Engine from the port map and stops it.
+     */
+    public static synchronized void destroyForPort(int port) {
+        UndertowHTTPServerEngine ref = portMap.remove(port);
+        if (ref != null) {
+            LOG.fine("Stopping Undertow HTTP Server Engine on port " + port + ".");
+            try {
+                ref.stop();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }            
+        }
+    }
+    
+    public MBeanServer getMBeanServer() {
+        if (bus != null && bus.getExtension(InstrumentationManager.class) != null) {
+            return bus.getExtension(InstrumentationManager.class).getMBeanServer();
+        }
+        return null;
+    }
+    
+    
+    public void initComplete() {
+        // do nothing here
+    }
+
+    public void postShutdown() {
+        // shut down the Undertow server in the portMap
+        // To avoid the CurrentModificationException, 
+        // do not use portMap.values directly       
+        UndertowHTTPServerEngine[] engines = 
+            portMap.values().toArray(new UndertowHTTPServerEngine[portMap.values().size()]);
+        for (UndertowHTTPServerEngine engine : engines) {
+            engine.shutdown();
+        }
+        // clean up the collections
+        threadingParametersMap.clear();
+        tlsParametersMap.clear();
+    }
+
+    public void preShutdown() {
+        // do nothing here 
+        // just let server registry to call the server stop first
+    }
+    
+
+        
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/HTTPUndertowTransportNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/HTTPUndertowTransportNamespaceHandler.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/HTTPUndertowTransportNamespaceHandler.java
new file mode 100644
index 0000000..60d5558
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/HTTPUndertowTransportNamespaceHandler.java
@@ -0,0 +1,83 @@
+/**
+ * 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_undertow.blueprint;
+
+import java.net.URL;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.aries.blueprint.Namespaces;
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.cxf.common.logging.LogUtils;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+@Namespaces("http://cxf.apache.org/transports/http-undertow/configuration")
+public class HTTPUndertowTransportNamespaceHandler implements NamespaceHandler {
+
+    public static final String UNDERTOW_TRANSPORT = "http://cxf.apache.org/transports/http-undertow/configuration";
+
+    private static final String UNDERTOW_ENGINE = "engine";
+
+    private static final String UNDERTOW_ENGINE_FACTORY = "engine-factory";
+
+    private static final Logger LOG = LogUtils.getL7dLogger(HTTPUndertowTransportNamespaceHandler.class);
+
+    public URL getSchemaLocation(String s) {
+        if (UNDERTOW_TRANSPORT.equals(s)) {
+            return getClass().getClassLoader().
+                getResource("schemas/configuration/http-undertow.xsd");
+        } else {
+            return null;
+        }
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Set<Class> getManagedClasses() {
+        return null;
+    }
+
+    public Metadata parse(Element element, ParserContext parserContext) {
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Parsing element {{" + element.getNamespaceURI() + "}}{" + element.getLocalName() + "}");
+        }
+
+        if (UNDERTOW_ENGINE.equals(element.getLocalName())) {
+            //This doesn't hit normal configs.
+            return new UndertowServerEngineParser().parse(element, parserContext);
+        } else if (UNDERTOW_ENGINE_FACTORY.equals(element.getLocalName())) {
+
+            return new UndertowServerEngineFactoryParser().parse(element, parserContext);
+        }
+
+        return null;
+    }
+
+    public ComponentMetadata decorate(Node node, 
+                                      ComponentMetadata componentMetadata, 
+                                      ParserContext parserContext) {
+        LOG.info("Decorating node " + node + " " + componentMetadata);
+        return componentMetadata;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java
new file mode 100644
index 0000000..3e5f5a4
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java
@@ -0,0 +1,234 @@
+/**
+ * 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_undertow.blueprint;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.common.jaxb.JAXBContextCache;
+import org.apache.cxf.common.jaxb.JAXBUtils;
+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.configuration.jsse.TLSServerParameters;
+import org.apache.cxf.configuration.jsse.TLSServerParametersConfig;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.transport.http_undertow.CXFUndertowHttpHandler;
+import org.apache.cxf.transport.http_undertow.ThreadingParameters;
+import org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine;
+import org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory;
+import org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType;
+import org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersIdentifiedType;
+import org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersType;
+import org.apache.cxf.transports.http_undertow.configuration.UndertowHTTPServerEngineConfigType;
+import org.apache.cxf.transports.http_undertow.configuration.UndertowHTTPServerEngineFactoryConfigType;
+
+
+public class UndertowHTTPServerEngineFactoryHolder {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(UndertowHTTPServerEngineFactoryHolder.class);
+
+    private String parsedElement;
+    private UndertowHTTPServerEngineFactory factory;
+    
+    private Map<String, List<CXFUndertowHttpHandler>> handlersMap;
+    
+    
+    private JAXBContext jaxbContext;
+    private Set<Class<?>> jaxbClasses;
+
+    public UndertowHTTPServerEngineFactoryHolder() {
+    }
+
+    public void init() {
+        try {
+            Element element = StaxUtils.read(new StringReader(parsedElement)).getDocumentElement();
+            
+            UndertowHTTPServerEngineFactoryConfigType config 
+                = (UndertowHTTPServerEngineFactoryConfigType) getJaxbObject(element,
+                    UndertowHTTPServerEngineFactoryConfigType.class);
+
+            factory = new UndertowHTTPServerEngineFactory();
+
+            Map<String, ThreadingParameters> threadingParametersMap 
+                = new TreeMap<String, ThreadingParameters>();
+
+            if (config.getIdentifiedThreadingParameters() != null) {
+                for (ThreadingParametersIdentifiedType threads : config.getIdentifiedThreadingParameters()) {
+                    ThreadingParameters rThreads = new ThreadingParameters();
+                    String id = threads.getId();
+                    rThreads.setMaxThreads(threads.getThreadingParameters().getMaxThreads());
+                    rThreads.setMinThreads(threads.getThreadingParameters().getMinThreads());
+                    rThreads.setWorkerIOThreads(threads.getThreadingParameters().getWorkerIOThreads());
+                    threadingParametersMap.put(id, rThreads);
+                }
+
+                factory.setThreadingParametersMap(threadingParametersMap);
+            }
+
+            //SSL
+            Map<String, TLSServerParameters> sslMap = new TreeMap<String, TLSServerParameters>();
+            if (config.getIdentifiedTLSServerParameters() != null) {
+
+                for (TLSServerParametersIdentifiedType t : config.getIdentifiedTLSServerParameters()) {
+                    try {
+                        TLSServerParameters parameter 
+                            = new TLSServerParametersConfig(t.getTlsServerParameters());
+                        sslMap.put(t.getId(), parameter);
+                    } catch (Exception e) {
+                        throw new RuntimeException("Could not configure TLS for id " + t.getId(), e);
+                    }
+                }
+                factory.setTlsServerParametersMap(sslMap);
+            }
+            //Engines
+
+            List<UndertowHTTPServerEngine> engineList = new ArrayList<UndertowHTTPServerEngine>();
+            for (UndertowHTTPServerEngineConfigType engine : config.getEngine()) {
+                UndertowHTTPServerEngine eng = new UndertowHTTPServerEngine();
+                
+                if (engine.getHandlers() != null && handlersMap != null) {
+                    List<CXFUndertowHttpHandler> handlers = handlersMap.get(engine.getPort().toString());
+                    if (handlers != null) {
+                        eng.setHandlers(handlers);
+                    } else {
+                        throw new RuntimeException("Could not find the handlers instance for engine with port"
+                            + engine.getPort().toString());
+                    }
+                }
+                
+                if (engine.isContinuationsEnabled() != null) {
+                    eng.setContinuationsEnabled(engine.isContinuationsEnabled());
+                }
+
+                
+                if (engine.getHost() != null && !StringUtils.isEmpty(engine.getHost())) {
+                    eng.setHost(engine.getHost());
+                }
+                if (engine.getMaxIdleTime() != null) {
+                    eng.setMaxIdleTime(engine.getMaxIdleTime());
+                }
+                if (engine.getPort() != null) {
+                    eng.setPort(engine.getPort());
+                }
+                
+                if (engine.getThreadingParameters() != null) {
+                    ThreadingParametersType threads = engine.getThreadingParameters();
+                    ThreadingParameters rThreads = new ThreadingParameters();
+                    rThreads.setMaxThreads(threads.getMaxThreads());
+                    rThreads.setMinThreads(threads.getMinThreads());
+                    rThreads.setWorkerIOThreads(threads.getWorkerIOThreads());
+                    eng.setThreadingParameters(rThreads);
+                }
+
+                
+                if (engine.getTlsServerParameters() != null) {
+                    TLSServerParameters parameter = null;
+                    try {
+                        parameter = new TLSServerParametersConfig(engine.getTlsServerParameters());
+                        eng.setTlsServerParameters(parameter);
+                    } catch (Exception e) {
+                        throw new RuntimeException("Could not configure TLS for engine on  " 
+                            + eng.getHost() + ":" + eng.getPort(), e);
+                    }
+                }
+                eng.finalizeConfig();
+
+                engineList.add(eng);
+            }
+            factory.setEnginesList(engineList);
+            //Unravel this completely.
+
+            factory.initComplete();
+        } catch (Exception e) {
+            throw new RuntimeException("Could not process configuration.", e);
+        }
+    }
+
+    public void destroy() {
+        // need to release the reference of the jaxb Classes
+        factory.postShutdown();
+        jaxbClasses.clear();
+        jaxbContext = null;
+    }
+
+    public String getParsedElement() {
+        return parsedElement;
+    }
+
+    public void setParsedElement(String parsedElement) {
+        this.parsedElement = parsedElement;
+    }
+    
+    
+    protected <T> T getJaxbObject(Element parent, Class<T> c) {
+
+        try {
+            JAXBElement<T> ele = JAXBUtils.unmarshall(getContext(c), parent, c);
+            return ele.getValue();
+        } catch (JAXBException e) {
+            LOG.warning("Unable to parse property due to " + e);
+            return null;
+        }
+    }
+
+    protected synchronized JAXBContext getContext(Class<?> cls) {
+        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 ? getClass().getClassLoader() : 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/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineFactoryParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineFactoryParser.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineFactoryParser.java
new file mode 100644
index 0000000..016ed0a
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineFactoryParser.java
@@ -0,0 +1,112 @@
+/**
+ * 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_undertow.blueprint;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.UUID;
+
+import org.w3c.dom.Element;
+
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.aries.blueprint.reflect.MapEntryImpl;
+import org.apache.aries.blueprint.reflect.MapMetadataImpl;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+
+public class UndertowServerEngineFactoryParser extends AbstractBPBeanDefinitionParser {
+
+    public static final String UNDERTOW_TRANSPORT = "http://cxf.apache.org/transports/http-undertow/configuration";
+
+    public static final String UNDERTOW_THREADING = "http://cxf.apache.org/configuration/parameterized-types";
+
+    public static String getIdOrName(Element elem) {
+        String id = elem.getAttribute("id");
+
+        if (null == id || "".equals(id)) {
+            String names = elem.getAttribute("name");
+            if (null != names) {
+                StringTokenizer st = new StringTokenizer(names, ",");
+                if (st.countTokens() > 0) {
+                    id = st.nextToken();
+                }
+            }
+        }
+        return id;
+    }
+
+    public Metadata parse(Element element, ParserContext context) {
+
+        //Endpoint definition
+        MutableBeanMetadata ef = context.createMetadata(MutableBeanMetadata.class);
+        if (!StringUtils.isEmpty(getIdOrName(element))) {
+            ef.setId(getIdOrName(element));
+        } else {
+            ef.setId("undertow.engine.factory-holder-" + UUID.randomUUID().toString());
+        }
+        ef.setRuntimeClass(UndertowHTTPServerEngineFactoryHolder.class);
+
+        // setup the HandlersMap property for the UndertowHTTPServerEngineFactoryHolder
+        
+        try {
+            // Print the DOM node
+            String xmlString = StaxUtils.toString(element);
+            ef.addProperty("parsedElement", createValue(context, xmlString));
+            ef.setInitMethod("init");
+            ef.setActivation(ComponentMetadata.ACTIVATION_EAGER);
+            ef.setDestroyMethod("destroy");
+            
+            // setup the EngineConnector
+            List<Element> engines = DOMUtils
+                .getChildrenWithName(element, HTTPUndertowTransportNamespaceHandler.UNDERTOW_TRANSPORT, "engine");
+            ef.addProperty("handlersMap", parseEngineHandlers(engines, ef, context));
+            return ef;
+        } catch (Exception e) {
+            throw new RuntimeException("Could not process configuration.", e);
+        }
+    }
+    
+       
+    protected Metadata parseEngineHandlers(List<Element> engines, ComponentMetadata enclosingComponent, 
+                                           ParserContext context) {
+        List<MapEntry> entries = new ArrayList<MapEntry>();
+        for (Element engine : engines) {
+            String port = engine.getAttribute("port");
+            ValueMetadata keyValue = createValue(context, port);
+            Element handlers = DOMUtils
+                .getFirstChildWithName(engine, HTTPUndertowTransportNamespaceHandler.UNDERTOW_TRANSPORT,
+                                       "handlers");
+            if (handlers != null) {
+                Metadata valValue = parseListData(context, enclosingComponent, handlers);
+                entries.add(new MapEntryImpl(keyValue, valValue));
+            }
+        }
+        return new MapMetadataImpl("java.lang.String", "java.util.List", entries);
+    }
+    
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineParser.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineParser.java
new file mode 100644
index 0000000..6b9c63b
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowServerEngineParser.java
@@ -0,0 +1,32 @@
+/**
+ * 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_undertow.blueprint;
+
+import org.w3c.dom.Element;
+
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+public class UndertowServerEngineParser extends AbstractBPBeanDefinitionParser {
+
+    public Metadata parse(Element element, ParserContext context) {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java
new file mode 100644
index 0000000..5f87db0
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java
@@ -0,0 +1,382 @@
+/**
+ * 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_undertow.osgi;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import javax.management.MBeanServer;
+
+import org.apache.cxf.bus.blueprint.BlueprintNameSpaceHandlerFactory;
+import org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer;
+import org.apache.cxf.configuration.jsse.TLSParameterJaxBUtils;
+import org.apache.cxf.configuration.jsse.TLSServerParameters;
+import org.apache.cxf.configuration.security.CertStoreType;
+import org.apache.cxf.configuration.security.CertificateConstraintsType;
+import org.apache.cxf.configuration.security.ClientAuthentication;
+import org.apache.cxf.configuration.security.CombinatorType;
+import org.apache.cxf.configuration.security.DNConstraintsType;
+import org.apache.cxf.configuration.security.FiltersType;
+import org.apache.cxf.configuration.security.KeyManagersType;
+import org.apache.cxf.configuration.security.KeyStoreType;
+import org.apache.cxf.configuration.security.SecureRandomParameters;
+import org.apache.cxf.configuration.security.TrustManagersType;
+import org.apache.cxf.transport.http_undertow.ThreadingParameters;
+import org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine;
+import org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory;
+import org.apache.cxf.transport.http_undertow.blueprint.HTTPUndertowTransportNamespaceHandler;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class HTTPUndertowTransportActivator 
+    implements BundleActivator, ManagedServiceFactory {
+    public static final String FACTORY_PID = "org.apache.cxf.http.undertow";
+    
+    BundleContext context; 
+    MBeanServer mbeans;
+    ServiceTracker mbeanServerTracker;
+    ServiceRegistration reg;
+    
+    UndertowHTTPServerEngineFactory factory = new UndertowHTTPServerEngineFactory() {
+        public MBeanServer getMBeanServer() {
+            return (MBeanServer)mbeanServerTracker.getService();
+        }
+    };
+    
+    public void start(BundleContext ctx) throws Exception {
+        this.context = ctx;
+        Properties servProps = new Properties();
+        servProps.put(Constants.SERVICE_PID, FACTORY_PID);  
+        reg = context.registerService(ManagedServiceFactory.class.getName(),
+                                       this, servProps);
+        
+        mbeanServerTracker = new ServiceTracker(ctx, MBeanServer.class.getName(), null);
+        BlueprintNameSpaceHandlerFactory nsHandlerFactory = new BlueprintNameSpaceHandlerFactory() {
+            
+            @Override
+            public Object createNamespaceHandler() {
+                return new HTTPUndertowTransportNamespaceHandler();
+            }
+        };
+        NamespaceHandlerRegisterer.register(context, nsHandlerFactory,
+                                            "http://cxf.apache.org/transports/http-undertow/configuration");  
+    }
+
+    public void stop(BundleContext ctx) throws Exception {
+        mbeanServerTracker.close();
+        reg.unregister();
+    }
+
+    public String getName() {
+        return FACTORY_PID;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void updated(String pid, @SuppressWarnings("rawtypes") Dictionary properties)
+        throws ConfigurationException {
+        if (pid == null) {
+            return;
+        }
+        int port = Integer.parseInt((String)properties.get("port"));
+        
+        String host = (String)properties.get("host");
+        try {
+            TLSServerParameters tls = createTlsServerParameters(properties);
+            if (tls != null) {
+                factory.setTLSServerParametersForPort(host, port, tls);
+            } else {
+                factory.createUndertowHTTPServerEngine(host, port, "http");
+            }
+            
+            UndertowHTTPServerEngine e = factory.retrieveUndertowHTTPServerEngine(port);
+            configure(e, properties);
+        } catch (GeneralSecurityException e) {
+            throw new ConfigurationException(null, null, e);
+        } catch (IOException e) {
+            throw new ConfigurationException(null, null, e);
+        }
+    }
+
+
+    private void configure(UndertowHTTPServerEngine e, Dictionary<String, String> properties) {
+        ThreadingParameters threading = createThreadingParameters(properties);
+        if (threading != null) {
+            e.setThreadingParameters(threading);
+        }
+        Enumeration<String> keys = properties.keys();
+        while (keys.hasMoreElements()) {
+            String k = keys.nextElement();
+            if ("continuationsEnabled".equals(k)) {
+                e.setContinuationsEnabled(Boolean.parseBoolean(properties.get(k)));
+            } else if ("maxIdleTime".equals(k)) {
+                e.setMaxIdleTime(Integer.parseInt(properties.get(k)));
+            } 
+        }
+    }
+
+    public void deleted(String pid) {
+    }
+
+    private ThreadingParameters createThreadingParameters(Dictionary<String, String> d) {
+        Enumeration<String> keys = d.keys();
+        ThreadingParameters p = null;
+        while (keys.hasMoreElements()) {
+            String k = keys.nextElement();
+            if (k.startsWith("threadingParameters.")) {
+                if (p == null) {
+                    p = new ThreadingParameters();
+                }
+                String v = d.get(k);
+                k = k.substring("threadingParameters.".length());
+                if ("minThreads".equals(k)) {
+                    p.setMinThreads(Integer.parseInt(v));
+                } else if ("maxThreads".equals(k)) {
+                    p.setMaxThreads(Integer.parseInt(v));
+                } else if ("workerIOThreads".equals(k)) {
+                    p.setWorkerIOThreads(Integer.parseInt(v));
+                }
+            }
+        }
+        return p;
+    }
+
+    private TLSServerParameters createTlsServerParameters(Dictionary<String, String> d) {
+        Enumeration<String> keys = d.keys();
+        TLSServerParameters p = null;
+        SecureRandomParameters srp = null;
+        KeyManagersType kmt = null;
+        TrustManagersType tmt = null;
+        while (keys.hasMoreElements()) {
+            String k = keys.nextElement();
+            if (k.startsWith("tlsServerParameters.")) {
+                if (p == null) {
+                    p = new TLSServerParameters();
+                }
+                String v = d.get(k);
+                k = k.substring("tlsServerParameters.".length());
+
+                if ("secureSocketProtocol".equals(k)) {
+                    p.setSecureSocketProtocol(v);
+                } else if ("jsseProvider".equals(k)) {
+                    p.setJsseProvider(v);
+                } else if ("certAlias".equals(k)) {
+                    p.setCertAlias(v);
+                } else if ("clientAuthentication.want".equals(k)) {
+                    if (p.getClientAuthentication() == null) {
+                        p.setClientAuthentication(new ClientAuthentication());
+                    }
+                    p.getClientAuthentication().setWant(Boolean.parseBoolean(v));
+                } else if ("clientAuthentication.required".equals(k)) {
+                    if (p.getClientAuthentication() == null) {
+                        p.setClientAuthentication(new ClientAuthentication());
+                    }
+                    p.getClientAuthentication().setRequired(Boolean.parseBoolean(v));
+                } else if (k.startsWith("certConstraints.")) {
+                    configureCertConstraints(p, k, v);
+                } else if (k.startsWith("secureRandomParameters.")) {
+                    srp = configureSecureRandom(srp, k, v);
+                } else if (k.startsWith("cipherSuitesFilter.")) {
+                    configureCipherSuitesFilter(p, k, v);
+                } else if (k.startsWith("cipherSuites")) {
+                    StringTokenizer st = new StringTokenizer(v, ",");
+                    while (st.hasMoreTokens()) {
+                        p.getCipherSuites().add(st.nextToken());
+                    }
+                }  else if (k.startsWith("excludeProtocols")) {
+                    StringTokenizer st = new StringTokenizer(v, ",");
+                    while (st.hasMoreTokens()) {
+                        p.getExcludeProtocols().add(st.nextToken());
+                    }
+                } else if (k.startsWith("trustManagers.")) {
+                    tmt = getTrustManagers(tmt,
+                                          k.substring("trustManagers.".length()),
+                                          v);
+                } else if (k.startsWith("keyManagers.")) {
+                    kmt = getKeyManagers(kmt,
+                                         k.substring("keyManagers.".length()),
+                                         v);
+                }
+            }
+        }
+        
+        try {
+            if (srp != null) {
+                p.setSecureRandom(TLSParameterJaxBUtils.getSecureRandom(srp));
+            }
+            if (kmt != null) {
+                p.setKeyManagers(TLSParameterJaxBUtils.getKeyManagers(kmt));
+            }
+            if (tmt != null) {
+                p.setTrustManagers(TLSParameterJaxBUtils.getTrustManagers(tmt));
+            }
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return p;
+    }
+
+    private void configureCipherSuitesFilter(TLSServerParameters p, String k, String v) {
+        k = k.substring("cipherSuitesFilter.".length());
+        StringTokenizer st = new StringTokenizer(v, ",");
+        FiltersType ft = p.getCipherSuitesFilter();
+        if (ft == null) {
+            ft = new FiltersType();
+            p.setCipherSuitesFilter(ft);
+        }
+        List<String> lst = "include".equals(k) ? ft.getInclude() : ft.getExclude();
+        while (st.hasMoreTokens()) {
+            lst.add(st.nextToken());
+        }
+    }
+
+    private SecureRandomParameters configureSecureRandom(SecureRandomParameters srp, String k, String v) {
+        k = k.substring("secureRandomParameters.".length());
+        if (srp == null) {
+            srp = new SecureRandomParameters();
+        }
+        if ("algorithm".equals(k)) {
+            srp.setAlgorithm(v);
+        } else if ("provider".equals(k)) {
+            srp.setProvider(v);
+        }
+        return srp;
+    }
+
+    private void configureCertConstraints(TLSServerParameters p, String k, String v) {
+        k = k.substring("certConstraints.".length());
+        CertificateConstraintsType cct = p.getCertConstraints();
+        if (cct == null) {
+            cct = new CertificateConstraintsType();
+            p.setCertConstraints(cct);
+        }
+        DNConstraintsType dnct = null;
+        if (k.startsWith("SubjectDNConstraints.")) {
+            dnct = cct.getSubjectDNConstraints();
+            if (dnct == null) {
+                dnct = new DNConstraintsType();
+                cct.setSubjectDNConstraints(dnct);
+            }
+            k = k.substring("SubjectDNConstraints.".length());
+        } else if (k.startsWith("IssuerDNConstraints.")) {
+            dnct = cct.getIssuerDNConstraints();
+            if (dnct == null) {
+                dnct = new DNConstraintsType();
+                cct.setIssuerDNConstraints(dnct);
+            }
+            k = k.substring("IssuerDNConstraints.".length());
+        }
+        if (dnct != null) {
+            if ("combinator".equals(k)) {
+                dnct.setCombinator(CombinatorType.fromValue(v));
+            } else if ("RegularExpression".equals(k)) {
+                dnct.getRegularExpression().add(k);
+            }
+        }
+    }
+
+    private KeyManagersType getKeyManagers(KeyManagersType keyManagers, String k, String v) {
+        if (keyManagers == null) {
+            keyManagers = new KeyManagersType();
+        }
+        if ("factoryAlgorithm".equals(k)) {
+            keyManagers.setFactoryAlgorithm(v);
+        } else if ("provider".equals(k)) {
+            keyManagers.setProvider(v);
+        } else if ("keyPassword".equals(k)) {
+            keyManagers.setKeyPassword(v);
+        } else if (k.startsWith("keyStore.")) {
+            keyManagers.setKeyStore(getKeyStore(keyManagers.getKeyStore(),
+                                                k.substring("keyStore.".length()),
+                                                v));
+        }
+        return keyManagers;
+    }
+
+    private KeyStoreType getKeyStore(KeyStoreType ks, String k, String v) {
+        if (ks == null) {
+            ks = new KeyStoreType();
+        }
+        if ("type".equals(k)) {
+            ks.setType(v);
+        } else if ("password".equals(k)) {
+            ks.setPassword(v);
+        } else if ("provider".equals(k)) {
+            ks.setProvider(v);
+        } else if ("url".equals(k)) {
+            ks.setUrl(v);
+        } else if ("file".equals(k)) {
+            ks.setFile(v);
+        } else if ("resource".equals(k)) {
+            ks.setResource(v);
+        }
+        return ks;
+    }
+
+    private TrustManagersType getTrustManagers(TrustManagersType tmt, String k, String v) {
+        if (tmt == null) {
+            tmt = new TrustManagersType();
+        }
+        if ("provider".equals(k)) {
+            tmt.setProvider(v);
+        } else if ("factoryAlgorithm".equals(k)) {
+            tmt.setFactoryAlgorithm(v);
+        } else if (k.startsWith("keyStore.")) {
+            tmt.setKeyStore(getKeyStore(tmt.getKeyStore(),
+                                        k.substring("keyStore.".length()),
+                                        v));
+        } else if (k.startsWith("certStore")) {
+            tmt.setCertStore(getCertStore(tmt.getCertStore(),
+                                          k.substring("certStore.".length()),
+                                          v));
+        }
+        return tmt;
+    }
+
+    private CertStoreType getCertStore(CertStoreType cs, String k, String v) {
+        if (cs == null) {
+            cs = new CertStoreType();
+        }
+        if ("file".equals(k)) {
+            cs.setFile(v);
+        } else if ("url".equals(k)) {
+            cs.setUrl(v);
+        } else if ("resource".equals(k)) {
+            cs.setResource(v);
+        }
+        return cs;
+    }
+
+
+    
+    
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/NamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/NamespaceHandler.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/NamespaceHandler.java
new file mode 100644
index 0000000..d8d6c92
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/NamespaceHandler.java
@@ -0,0 +1,30 @@
+/**
+ * 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_undertow.spring;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+public class NamespaceHandler extends NamespaceHandlerSupport {
+    public void init() {
+        registerBeanDefinitionParser("engine-factory", 
+                new UndertowHTTPServerEngineFactoryBeanDefinitionParser());
+        registerBeanDefinitionParser("engine",
+                                     new UndertowHTTPServerEngineBeanDefinitionParser());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java
new file mode 100644
index 0000000..48e608b
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java
@@ -0,0 +1,345 @@
+/**
+ * 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_undertow.spring;
+
+
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.xml.bind.JAXBContext;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.configuration.jsse.TLSServerParametersConfig;
+import org.apache.cxf.configuration.security.CertificateConstraintsType;
+import org.apache.cxf.configuration.security.CipherSuites;
+import org.apache.cxf.configuration.security.ClientAuthentication;
+import org.apache.cxf.configuration.security.ExcludeProtocols;
+import org.apache.cxf.configuration.security.FiltersType;
+import org.apache.cxf.configuration.security.IncludeProtocols;
+import org.apache.cxf.configuration.security.KeyManagersType;
+import org.apache.cxf.configuration.security.SecureRandomParameters;
+import org.apache.cxf.configuration.security.TLSServerParametersType;
+import org.apache.cxf.configuration.security.TrustManagersType;
+import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.transport.http_undertow.ThreadingParameters;
+import org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine;
+import org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory;
+import org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType;
+import org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersIdentifiedType;
+import org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersType;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+
+
+
+
+public class UndertowHTTPServerEngineBeanDefinitionParser extends AbstractBeanDefinitionParser {
+    private static final String SECURITY_NS =
+        "http://cxf.apache.org/configuration/security";
+
+    public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
+        
+        String portStr = element.getAttribute("port");
+        bean.addPropertyValue("port", portStr);
+        
+        String hostStr = element.getAttribute("host");
+        if (hostStr != null && !"".equals(hostStr.trim())) {
+            bean.addPropertyValue("host", hostStr);
+        }
+
+        String continuationsStr = element.getAttribute("continuationsEnabled");
+        if (continuationsStr != null && continuationsStr.length() > 0) {
+            bean.addPropertyValue("continuationsEnabled", continuationsStr);
+        }
+        
+        String maxIdleTimeStr = element.getAttribute("maxIdleTime");
+        if (maxIdleTimeStr != null && !"".equals(maxIdleTimeStr.trim())) {
+            bean.addPropertyValue("maxIdleTime", maxIdleTimeStr);
+        }
+        
+                
+        ValueHolder busValue = ctx.getContainingBeanDefinition()
+            .getConstructorArgumentValues().getArgumentValue(0, Bus.class);
+        bean.addPropertyValue("bus", busValue.getValue());
+        try {
+            Element elem = DOMUtils.getFirstElement(element);
+            while (elem != null) {
+                String name = elem.getLocalName();
+                if ("tlsServerParameters".equals(name)) {
+                    mapTLSServerParameters(elem, bean);
+                } else if ("threadingParameters".equals(name)) {
+                    mapElementToJaxbPropertyFactory(elem,
+                                                    bean,
+                                                    "threadingParameters",
+                                                    ThreadingParametersType.class,
+                                                    UndertowHTTPServerEngineBeanDefinitionParser.class,
+                                                    "createThreadingParameters");
+                } else if ("tlsServerParametersRef".equals(name)) {
+                    mapElementToJaxbPropertyFactory(elem,
+                                                    bean,
+                                                    "tlsServerParametersRef",
+                                                    TLSServerParametersIdentifiedType.class,
+                                                    UndertowHTTPServerEngineBeanDefinitionParser.class,
+                                                    "createTLSServerParametersConfigRef");
+                } else if ("threadingParametersRef".equals(name)) {
+                    mapElementToJaxbPropertyFactory(elem,
+                                                    bean,
+                                                    "threadingParametersRef",
+                                                    ThreadingParametersIdentifiedType.class,
+                                                    UndertowHTTPServerEngineBeanDefinitionParser.class,
+                                                    "createThreadingParametersRef"
+                                                    );
+                } else if ("handlers".equals(name)) {
+                    List<?> handlers = 
+                        ctx.getDelegate().parseListElement(elem, bean.getBeanDefinition());
+                    bean.addPropertyValue("handlers", handlers);
+                }
+                elem = org.apache.cxf.helpers.DOMUtils.getNextElement(elem);          
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("Could not process configuration.", e);
+        }
+
+        bean.setLazyInit(false);
+    }
+    
+    private void mapTLSServerParameters(Element e, BeanDefinitionBuilder bean) {
+        BeanDefinitionBuilder paramsbean 
+            = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.TLSServerParametersTypeInternal.class);
+        
+        // read the attributes
+        NamedNodeMap as = e.getAttributes();
+        for (int i = 0; i < as.getLength(); i++) {
+            Attr a = (Attr) as.item(i);
+            if (a.getNamespaceURI() == null) {
+                String aname = a.getLocalName();
+                if ("jsseProvider".equals(aname) 
+                    || "secureSocketProtocol".equals(aname)) {
+                    paramsbean.addPropertyValue(aname, a.getValue());
+                }
+            }
+        }
+        
+        // read the child elements
+        Node n = e.getFirstChild();
+        while (n != null) {
+            if (Node.ELEMENT_NODE != n.getNodeType() 
+                || !SECURITY_NS.equals(n.getNamespaceURI())) {
+                n = n.getNextSibling();
+                continue;
+            }
+            String ename = n.getLocalName();
+            // Schema should require that no more than one each of these exist.
+            String ref = ((Element)n).getAttribute("ref");
+
+            if ("keyManagers".equals(ename)) {
+                if (ref != null && ref.length() > 0) {
+                    paramsbean.addPropertyReference("keyManagersRef", ref);
+                } else {
+                    mapElementToJaxbProperty((Element)n, paramsbean, ename, 
+                                             KeyManagersType.class);
+                }
+            } else if ("trustManagers".equals(ename)) {
+                if (ref != null && ref.length() > 0) {
+                    paramsbean.addPropertyReference("trustManagersRef", ref);
+                } else {
+                    mapElementToJaxbProperty((Element)n, paramsbean, ename, 
+                                             TrustManagersType.class);
+                }
+            } else if ("cipherSuites".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         CipherSuites.class);
+            } else if ("cipherSuitesFilter".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         FiltersType.class);
+            } else if ("excludeProtocols".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         ExcludeProtocols.class);
+            } else if ("includeProtocols".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         IncludeProtocols.class);
+            } else if ("secureRandomParameters".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         SecureRandomParameters.class);
+            } else if ("clientAuthentication".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         ClientAuthentication.class);
+            } else if ("certConstraints".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         CertificateConstraintsType.class);
+            } else if ("certAlias".equals(ename)) {
+                paramsbean.addPropertyValue(ename, n.getTextContent());
+            }
+            n = n.getNextSibling();
+        }
+
+        BeanDefinitionBuilder jaxbbean 
+            = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.class);
+        jaxbbean.addConstructorArgValue(paramsbean.getBeanDefinition());
+        bean.addPropertyValue("tlsServerParameters", jaxbbean.getBeanDefinition());
+    }
+
+    private static ThreadingParameters toThreadingParameters(
+                                    ThreadingParametersType paramtype) {
+        ThreadingParameters params = new ThreadingParameters();
+        if (paramtype.getMaxThreads() != null) {
+            params.setMaxThreads(paramtype.getMaxThreads());
+        }
+        if (paramtype.getMinThreads() != null) {
+            params.setMinThreads(paramtype.getMinThreads());
+        }
+        if (paramtype.getWorkerIOThreads() != null) {
+            params.setWorkerIOThreads(paramtype.getWorkerIOThreads());
+        }
+            
+        return params;
+    }
+    
+       
+    /*
+     * We do not require an id from the configuration.
+     * 
+     * (non-Javadoc)
+     * @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser#shouldGenerateId()
+     */
+    @Override
+    protected boolean shouldGenerateId() {
+        return true;
+    }
+
+    @Override
+    protected Class<?> getBeanClass(Element arg0) {
+        return SpringUndertowHTTPServerEngine.class;
+    }
+    
+    @NoJSR250Annotations
+    public static class SpringUndertowHTTPServerEngine extends UndertowHTTPServerEngine
+        implements ApplicationContextAware, InitializingBean {
+        
+        String threadingRef;
+        String tlsRef;
+        Bus bus;
+        UndertowHTTPServerEngineFactory factory;
+        
+        public SpringUndertowHTTPServerEngine(
+            UndertowHTTPServerEngineFactory fac,
+            Bus b,
+            String host,
+            int port) {
+            super(host, port);
+            bus = b;
+            factory = fac;
+        }
+        
+        public SpringUndertowHTTPServerEngine() {
+            super();
+        }
+        
+        public void setBus(Bus b) {
+            bus = b;
+            if (null != bus && null == factory) {
+                factory = bus.getExtension(UndertowHTTPServerEngineFactory.class);
+            } 
+        }
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (bus == null) {
+                bus = BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx);
+            }
+        }
+        
+        public void setThreadingParametersRef(String s) {
+            threadingRef = s;
+        }
+        public void setTlsServerParametersRef(String s) {
+            tlsRef = s;
+        }
+        
+        @PostConstruct
+        public void finalizeConfig() 
+            throws GeneralSecurityException,
+                   IOException {
+            if (tlsRef != null || threadingRef != null) {
+
+                if (threadingRef != null) {
+                    setThreadingParameters(factory.getThreadingParametersMap().get(threadingRef));
+                }
+                if (tlsRef != null) {
+                    setTlsServerParameters(factory.getTlsServerParametersMap().get(tlsRef));
+                }
+            }
+            super.finalizeConfig();
+        }
+
+        public void afterPropertiesSet() throws Exception {
+            finalizeConfig();
+        }
+
+    }
+        
+
+    
+    public static TLSServerParametersConfig createTLSServerParametersConfig(String s, 
+                                                                            JAXBContext context) 
+        throws GeneralSecurityException, IOException {
+        
+        TLSServerParametersType parametersType = unmarshalFactoryString(s, context,
+                                                                        TLSServerParametersType.class);
+        
+        return new TLSServerParametersConfig(parametersType);
+    }
+    public static String createTLSServerParametersConfigRef(String s, JAXBContext context)
+    
+        throws GeneralSecurityException, IOException {
+        
+        TLSServerParametersIdentifiedType parameterTypeRef 
+            = unmarshalFactoryString(s, context, TLSServerParametersIdentifiedType.class);
+        
+        return parameterTypeRef.getId(); 
+    } 
+    
+    public static ThreadingParameters createThreadingParameters(String s, JAXBContext context) {
+        
+        ThreadingParametersType parametersType = unmarshalFactoryString(s, context,
+                                                                        ThreadingParametersType.class);
+        
+        return toThreadingParameters(parametersType);
+    }
+    public static String createThreadingParametersRef(String s, JAXBContext context) {
+        ThreadingParametersIdentifiedType parametersType 
+            = unmarshalFactoryString(s, context, ThreadingParametersIdentifiedType.class);
+        return parametersType.getId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineFactoryBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineFactoryBeanDefinitionParser.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineFactoryBeanDefinitionParser.java
new file mode 100644
index 0000000..4d69832
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineFactoryBeanDefinitionParser.java
@@ -0,0 +1,159 @@
+/**
+ * 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_undertow.spring;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.configuration.jsse.TLSServerParameters;
+import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
+import org.apache.cxf.configuration.spring.BusWiringType;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.transport.http_undertow.ThreadingParameters;
+import org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory;
+import org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType;
+import org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersIdentifiedType;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class UndertowHTTPServerEngineFactoryBeanDefinitionParser
+        extends AbstractBeanDefinitionParser {
+    static final String HTTP_UNDERTOW_NS = "http://cxf.apache.org/transports/http-undertow/configuration";
+
+    protected String resolveId(Element elem, AbstractBeanDefinition definition, 
+                               ParserContext ctx) throws BeanDefinitionStoreException {
+        String id = this.getIdOrName(elem);
+        if (StringUtils.isEmpty(id)) {
+            return UndertowHTTPServerEngineFactory.class.getName();            
+        }
+        id = super.resolveId(elem, definition, ctx);
+        if (!ctx.getRegistry().containsBeanDefinition(UndertowHTTPServerEngineFactory.class.getName())) {
+            ctx.getRegistry().registerAlias(id, UndertowHTTPServerEngineFactory.class.getName());
+        }
+        return id;
+    }
+    
+
+    @Override
+    public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
+         
+        String bus = element.getAttribute("bus");
+        
+        BeanDefinitionBuilder factbean 
+            = BeanDefinitionBuilder
+                .rootBeanDefinition(UndertowSpringTypesFactory.class);
+
+        ctx.getRegistry()
+            .registerBeanDefinition(UndertowSpringTypesFactory.class.getName(),
+                                    factbean.getBeanDefinition());
+        try {
+            if (StringUtils.isEmpty(bus)) {
+                addBusWiringAttribute(bean, BusWiringType.CONSTRUCTOR);
+            } else {
+                bean.addConstructorArgReference(bus);
+            }
+
+            bean.addConstructorArgValue(mapElementToJaxbBean(element,
+                                                        TLSServerParametersIdentifiedType.class,
+                                                        UndertowSpringTypesFactory.class,
+                                                        "createTLSServerParametersMap"));
+            bean.addConstructorArgValue(mapElementToJaxbBean(element,
+                                                        ThreadingParametersIdentifiedType.class,
+                                                        UndertowSpringTypesFactory.class,
+                                "createThreadingParametersMap"));
+            
+            // parser the engine list
+            List<Object> list = 
+                getRequiredElementsList(element, ctx, new QName(HTTP_UNDERTOW_NS, "engine"), bean);
+            if (list.size() > 0) {
+                bean.addPropertyValue("enginesList", list);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("Could not process configuration.", e);
+        }
+    }    
+    
+    private List<Object> getRequiredElementsList(Element parent, ParserContext ctx, QName name,
+                                         BeanDefinitionBuilder bean) {
+       
+        List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(parent, 
+                                                                     name.getNamespaceURI(), 
+                                                                     name.getLocalPart());
+        ManagedList<Object> list = new ManagedList<Object>(elemList.size());
+        list.setSource(ctx.extractSource(parent));
+        
+        for (Element elem : elemList) {
+            list.add(ctx.getDelegate().parsePropertySubElement(elem, bean.getBeanDefinition()));
+        }
+        return list;
+    }
+    
+    
+          
+    /*
+     * We do not require an id from the configuration.
+     * 
+     * (non-Javadoc)
+     * @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser#shouldGenerateId()
+     */
+    @Override
+    protected boolean shouldGenerateId() {
+        return true;
+    }
+
+    @Override
+    protected Class<?> getBeanClass(Element arg0) {
+        return SpringUndertowHTTPServerEngineFactory.class;
+    }
+    
+    @NoJSR250Annotations(unlessNull = "bus")
+    public static class SpringUndertowHTTPServerEngineFactory extends UndertowHTTPServerEngineFactory 
+        implements ApplicationContextAware {
+
+        public SpringUndertowHTTPServerEngineFactory() {
+            super();
+        }
+        public SpringUndertowHTTPServerEngineFactory(Bus bus,
+                                                  Map<String, TLSServerParameters> tls,
+                                                  Map<String, ThreadingParameters> threading) {
+            super(bus, tls, threading);
+        }    
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                setBus(BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java
new file mode 100644
index 0000000..7e88ed1
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java
@@ -0,0 +1,172 @@
+/**
+ * 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_undertow.spring;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+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 org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.configuration.jsse.TLSServerParameters;
+import org.apache.cxf.configuration.jsse.TLSServerParametersConfig;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.transport.http_undertow.ThreadingParameters;
+import org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType;
+import org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersIdentifiedType;
+import org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersType;
+
+@NoJSR250Annotations
+public final class UndertowSpringTypesFactory {
+    public UndertowSpringTypesFactory() {
+        
+    }
+    private static Map<String, ThreadingParameters> toThreadingParameters(
+        List <ThreadingParametersIdentifiedType> list) {
+        Map<String, ThreadingParameters> map = new TreeMap<String, ThreadingParameters>();
+        for (ThreadingParametersIdentifiedType t : list) {
+            ThreadingParameters parameter = 
+                toThreadingParameters(t.getThreadingParameters());
+            map.put(t.getId(), parameter);
+        } 
+        return map;
+    }
+    private static ThreadingParameters toThreadingParameters(ThreadingParametersType paramtype) {
+        ThreadingParameters params = new ThreadingParameters();
+        params.setMaxThreads(paramtype.getMaxThreads());
+        params.setMinThreads(paramtype.getMinThreads());
+        params.setWorkerIOThreads(paramtype.getWorkerIOThreads());
+        return params;
+    }
+        
+    private static Map<String, TLSServerParameters> toTLSServerParamenters(
+        List <TLSServerParametersIdentifiedType> list) {
+        Map<String, TLSServerParameters> map = new TreeMap<String, TLSServerParameters>();
+        for (TLSServerParametersIdentifiedType t : list) {
+            try {             
+                TLSServerParameters parameter = new TLSServerParametersConfig(t.getTlsServerParameters());
+                map.put(t.getId(), parameter);
+            } catch (Exception e) {
+                throw new RuntimeException(
+                        "Could not configure TLS for id " + t.getId(), e);
+            }
+            
+        }
+        return map;
+    }
+    public Map<String, ThreadingParameters> createThreadingParametersMap(String s,
+                                                                         JAXBContext ctx) 
+        throws Exception {
+        Document doc = StaxUtils.read(new StringReader(s));
+        List <ThreadingParametersIdentifiedType> threadingParametersIdentifiedTypes = 
+            UndertowSpringTypesFactory
+                .parseListElement(doc.getDocumentElement(), 
+                                  new QName(UndertowHTTPServerEngineFactoryBeanDefinitionParser.HTTP_UNDERTOW_NS,
+                                            "identifiedThreadingParameters"), 
+                                  ThreadingParametersIdentifiedType.class, ctx);
+        Map<String, ThreadingParameters> threadingParametersMap =
+            toThreadingParameters(threadingParametersIdentifiedTypes);
+        return threadingParametersMap;
+    }
+    
+    public Map<String, TLSServerParameters> createTLSServerParametersMap(String s,
+                                                                         JAXBContext ctx) 
+        throws Exception {
+        Document doc = StaxUtils.read(new StringReader(s));
+        
+        List <TLSServerParametersIdentifiedType> tlsServerParameters =
+            UndertowSpringTypesFactory
+                .parseListElement(doc.getDocumentElement(), 
+                                  new QName(UndertowHTTPServerEngineFactoryBeanDefinitionParser.HTTP_UNDERTOW_NS,
+                                            "identifiedTLSServerParameters"),
+                                  TLSServerParametersIdentifiedType.class,
+                                  ctx);
+        Map<String, TLSServerParameters> tlsServerParametersMap =
+            toTLSServerParamenters(tlsServerParameters);
+        return tlsServerParametersMap;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public static <V> List<V> parseListElement(Element parent, 
+                                           QName name, 
+                                           Class<?> c,
+                                           JAXBContext context) throws JAXBException {
+        List<V> list = new ArrayList<V>();
+        Node data = null;
+           
+        Unmarshaller u = context.createUnmarshaller();
+        Node node = parent.getFirstChild();           
+        while (node != null) {
+            if (node.getNodeType() == Node.ELEMENT_NODE && name.getLocalPart().equals(node.getLocalName())
+                && name.getNamespaceURI().equals(node.getNamespaceURI())) {
+                data = node;
+                Object obj = unmarshal(u, data, c);                
+                if (obj != null) {                    
+                    list.add((V) obj);
+                }
+            }
+            node = node.getNextSibling();
+        }
+        return list;
+    }
+    
+    
+
+    
+    
+    private static Object unmarshal(Unmarshaller u,
+                                     Node data, Class<?> c) {
+        if (u == null) {
+            return null;
+        }
+        
+        Object obj = null;        
+        try {
+            if (c != null) {
+                obj = u.unmarshal(data, c);
+            } else {
+                obj = u.unmarshal(data);
+            }
+
+            if (obj instanceof JAXBElement<?>) {
+                JAXBElement<?> el = (JAXBElement<?>)obj;
+                obj = el.getValue();
+            }
+           
+        } catch (JAXBException e) {
+            throw new RuntimeException("Could not parse configuration.", e);
+        }
+        
+        return obj; 
+        
+    }
+               
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/resources/META-INF/blueprint.handlers
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/resources/META-INF/blueprint.handlers b/rt/transports/http-undertow/src/main/resources/META-INF/blueprint.handlers
new file mode 100644
index 0000000..ca94a97
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/resources/META-INF/blueprint.handlers
@@ -0,0 +1,22 @@
+#
+#
+#    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.
+#
+#
+org.apache.cxf.transport.http_undertow.blueprint.HTTPUndertowTransportNamespaceHandler
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/e61a83d4/rt/transports/http-undertow/src/main/resources/META-INF/cxf/bus-extensions.txt
----------------------------------------------------------------------
diff --git a/rt/transports/http-undertow/src/main/resources/META-INF/cxf/bus-extensions.txt b/rt/transports/http-undertow/src/main/resources/META-INF/cxf/bus-extensions.txt
new file mode 100644
index 0000000..cba69a1
--- /dev/null
+++ b/rt/transports/http-undertow/src/main/resources/META-INF/cxf/bus-extensions.txt
@@ -0,0 +1,2 @@
+org.apache.cxf.transport.http_undertow.UndertowDestinationFactory::true
+org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory::true


Mime
View raw message