cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6481] Parsing httpj:engine simple elements directly
Date Wed, 08 Jul 2015 14:11:19 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 2d41042eb -> aa76bda0f


[CXF-6481] Parsing httpj:engine simple elements directly


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

Branch: refs/heads/master
Commit: aa76bda0f657d38e027e9248da7df723cc4cf8c2
Parents: 2d41042
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jul 8 15:10:52 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jul 8 15:10:52 2015 +0100

----------------------------------------------------------------------
 .../JettyHTTPServerEngineFactoryHolder.java     | 32 ++++++++++++----
 .../JettyServerEngineFactoryParser.java         | 39 +++++++++++++++-----
 2 files changed, 55 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/aa76bda0/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
index 348de38..21ea18d 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyHTTPServerEngineFactoryHolder.java
@@ -62,6 +62,9 @@ public class JettyHTTPServerEngineFactoryHolder {
     private Map<String, Connector> connectorMap;
     
     private Map<String, List<Handler>> handlersMap;
+    
+    private Map<String, Boolean> sessionSupportMap;
+    private Map<String, Boolean> reuseAddressMap;
 
     private JAXBContext jaxbContext;
     private Set<Class<?>> jaxbClasses;
@@ -134,7 +137,19 @@ public class JettyHTTPServerEngineFactoryHolder {
                             + engine.getPort().toString());
                     }
                 }
-
+                if (sessionSupportMap != null) {
+                    Boolean sessionSupport = sessionSupportMap.get(engine.getPort().toString());
+                    if (sessionSupport != null) {
+                        eng.setSessionSupport(sessionSupport);
+                    }    
+                }
+                if (reuseAddressMap != null) {
+                    Boolean reuseAddress = reuseAddressMap.get(engine.getPort().toString());
+                    if (reuseAddress != null) {
+                        eng.setReuseAddress(reuseAddress);
+                    }    
+                }
+                
                 if (engine.isContinuationsEnabled() != null) {
                     eng.setContinuationsEnabled(engine.isContinuationsEnabled());
                 }
@@ -148,12 +163,7 @@ public class JettyHTTPServerEngineFactoryHolder {
                 if (engine.getPort() != null) {
                     eng.setPort(engine.getPort());
                 }
-                if (engine.isReuseAddress() != null) {
-                    eng.setReuseAddress(engine.isReuseAddress());
-                }
-                if (engine.isSessionSupport() != null) {
-                    eng.setSessionSupport(engine.isSessionSupport());
-                }
+                
                 if (engine.getThreadingParameters() != null) {
                     ThreadingParametersType threads = engine.getThreadingParameters();
                     ThreadingParameters rThreads = new ThreadingParameters();
@@ -206,6 +216,14 @@ public class JettyHTTPServerEngineFactoryHolder {
         this.connectorMap = connectorMap;
     }
     
+    public void setSessionSupportMap(Map<String, Boolean> sessionMap) {
+        this.sessionSupportMap = sessionMap;
+    }
+    
+    public void setReuseAddressMap(Map<String, Boolean> reuseMap) {
+        this.reuseAddressMap = reuseMap;
+    }
+    
     public void setHandlersMap(Map<String, List<Handler>> handlersMap) {
         this.handlersMap = handlersMap;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/aa76bda0/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
index 8e8c470..0452846 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
@@ -79,21 +79,23 @@ public class JettyServerEngineFactoryParser extends AbstractBPBeanDefinitionPars
             ef.setInitMethod("init");
             ef.setActivation(ComponentMetadata.ACTIVATION_EAGER);
             ef.setDestroyMethod("destroy");
+            
             // setup the EngineConnector
-            ef.addProperty("connectorMap", parseEngineConnector(element, ef, context));
-            ef.addProperty("handlersMap", parseEngineHandlers(element, ef, context));
+            List<Element> engines = DOMUtils
+                .getChildrenWithName(element, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT,
"engine");
+            ef.addProperty("connectorMap", parseEngineConnector(engines, ef, context));
+            ef.addProperty("handlersMap", parseEngineHandlers(engines, ef, context));
+            ef.addProperty("sessionSupportMap", parseEngineBooleanProperty(engines, ef, context,
"sessionSupport"));
+            ef.addProperty("reuseAddressMap", parseEngineBooleanProperty(engines, ef, context,
"reuseAddress"));
             return ef;
         } catch (Exception e) {
             throw new RuntimeException("Could not process configuration.", e);
         }
     }
     
-    protected Metadata parseEngineConnector(Element element, ComponentMetadata enclosingComponent,
+    protected Metadata parseEngineConnector(List<Element> engines, ComponentMetadata
enclosingComponent,
                                             ParserContext context) {
         List<MapEntry> entries = new ArrayList<MapEntry>();
-        // create an empty map first
-        List<Element> engines = DOMUtils
-            .getChildrenWithName(element, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT,
"engine");
         for (Element engine : engines) {
             String port = engine.getAttribute("port");
             ValueMetadata keyValue = createValue(context, port);
@@ -110,11 +112,9 @@ public class JettyServerEngineFactoryParser extends AbstractBPBeanDefinitionPars
         return new MapMetadataImpl("java.lang.String", "org.eclipse.jetty.server.Connector",
entries);
     }
     
-    protected Metadata parseEngineHandlers(Element element, ComponentMetadata enclosingComponent,

+    protected Metadata parseEngineHandlers(List<Element> engines, ComponentMetadata
enclosingComponent, 
                                            ParserContext context) {
         List<MapEntry> entries = new ArrayList<MapEntry>();
-        List<Element> engines = DOMUtils
-            .getChildrenWithName(element, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT,
"engine");
         for (Element engine : engines) {
             String port = engine.getAttribute("port");
             ValueMetadata keyValue = createValue(context, port);
@@ -128,4 +128,25 @@ public class JettyServerEngineFactoryParser extends AbstractBPBeanDefinitionPars
         }
         return new MapMetadataImpl("java.lang.String", "java.util.List", entries);
     }
+    
+    protected Metadata parseEngineBooleanProperty(List<Element> engines, 
+                                                  ComponentMetadata enclosingComponent,
+                                                  ParserContext context,
+                                                  String propertyName) {
+        List<MapEntry> entries = new ArrayList<MapEntry>();
+        for (Element engine : engines) {
+            String port = engine.getAttribute("port");
+            ValueMetadata keyValue = createValue(context, port);
+            Element sessionSupport = DOMUtils
+                .getFirstChildWithName(engine, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT,
+                                       propertyName);
+            if (sessionSupport != null) {
+                String text = DOMUtils.getContent(sessionSupport);
+                ValueMetadata valValue = createValue(context, text);
+                entries.add(new MapEntryImpl(keyValue, valValue));
+            }
+        }
+
+        return new MapMetadataImpl("java.lang.String", "java.lang.Boolean", entries);
+    }
 }


Mime
View raw message