cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r735138 - in /cxf/branches/2.1.x-fixes: ./ common/common/src/main/java/org/apache/cxf/configuration/spring/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ rt/transports/http-jetty/src/main/java/org/apache/cxf/tr...
Date Fri, 16 Jan 2009 21:13:43 GMT
Author: dkulp
Date: Fri Jan 16 13:13:42 2009
New Revision: 735138

URL: http://svn.apache.org/viewvc?rev=735138&view=rev
Log:
Merged revisions 735113 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r735113 | dkulp | 2009-01-16 15:02:01 -0500 (Fri, 16 Jan 2009) | 4 lines
  
  Cleanup the parsing of the jetty serverendine factory stuff
  Allow the properties placeholder things to work with the jetty server stuff
........

Added:
    cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
      - copied unchanged from r735113, cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
Removed:
    cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JAXBHelper.java
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
    cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
    cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 16 13:13:42 2009
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732827,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732827,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=735138&r1=735137&r2=735138&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Fri Jan 16 13:13:42 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.configuration.spring;
 
+import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -28,6 +29,8 @@
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.w3c.dom.Attr;
@@ -293,6 +296,73 @@
         }
     }
 
+
+    public void mapElementToJaxbPropertyFactory(Element data, 
+                                                BeanDefinitionBuilder bean, 
+                                                String propertyName, 
+                                                Class<?> factory,
+                                                String method,
+                                                Object ... args) {
+        bean.addPropertyValue(propertyName, mapElementToJaxbBean(data, factory,
+                                                                 null, method, args));
+    }
+    
+    @SuppressWarnings("deprecation")
+    public AbstractBeanDefinition mapElementToJaxbBean(Element data, 
+                                                       Class<?> cls,
+                                                      Class<?> factory,
+                                                      String method,
+                                                      Object ... args) {
+        StringWriter writer = new StringWriter();
+        XMLStreamWriter xmlWriter = StaxUtils.createXMLStreamWriter(writer);
+        try {
+            StaxUtils.copy(data, xmlWriter);
+            xmlWriter.flush();
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+
+        BeanDefinitionBuilder jaxbbean 
+            = BeanDefinitionBuilder.rootBeanDefinition(cls);
+        if (factory != null) {
+            jaxbbean.getRawBeanDefinition().setFactoryBeanName(factory.getName());
+        }
+        jaxbbean.getRawBeanDefinition().setFactoryMethodName(method);
+        jaxbbean.addConstructorArg(writer.toString());
+        if (args != null) {
+            for (Object o : args) {
+                jaxbbean.addConstructorArg(o);
+            }                
+        }
+        return jaxbbean.getBeanDefinition();
+    }
+    
+    protected static <T> T unmarshalFactoryString(String s, Class<T> cls) {
+        StringReader reader = new StringReader(s);
+        XMLStreamReader data = StaxUtils.createXMLStreamReader(reader);
+        try {
+            String pkg = cls.getPackage().getName();
+            JAXBContext context = packageContextCache.get(pkg);
+            if (context == null) {
+                context = JAXBContext.newInstance(pkg, cls.getClassLoader());
+                packageContextCache.put(pkg, context);
+            }
+            
+            Unmarshaller u = context.createUnmarshaller();
+            Object obj = u.unmarshal(data, cls);
+            if (obj instanceof JAXBElement<?>) {
+                JAXBElement<?> el = (JAXBElement<?>)obj;
+                obj = el.getValue();
+
+            }
+            return cls.cast(obj);
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
     protected String getJaxbPackage() {
         return "";
     }

Modified: cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=735138&r1=735137&r2=735138&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Fri Jan 16 13:13:42 2009
@@ -70,13 +70,13 @@
     /**
      * The bus.
      */
-    private Bus bus;
+    protected Bus bus;
     
     /**
      * This is the Jetty HTTP Server Engine Factory. This factory caches some 
      * engines based on port numbers.
      */
-    private JettyHTTPServerEngineFactory factory;
+    protected JettyHTTPServerEngineFactory factory;
     
     
     /**
@@ -531,7 +531,7 @@
         this.configFinalized = true;
     }
     
-    private void retrieveEngineFactory() {
+    protected void retrieveEngineFactory() {
         if (null != bus && null == factory) {
             factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
         }        

Modified: cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=735138&r1=735137&r2=735138&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Fri Jan 16 13:13:42 2009
@@ -80,6 +80,16 @@
     public JettyHTTPServerEngineFactory() {
         // Empty
     }    
+    public JettyHTTPServerEngineFactory(Bus bus,
+                                        Map<String, TLSServerParameters> tls,
+                                        Map<String, ThreadingParameters> threading)
{
+        tlsParametersMap.putAll(tls);
+        threadingParametersMap.putAll(threading);
+        this.bus = bus;
+        if (bus != null) {
+            bus.setExtension(this, JettyHTTPServerEngineFactory.class);
+        }
+    }    
     
     
     /**

Modified: cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java?rev=735138&r1=735137&r2=735138&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
Fri Jan 16 13:13:42 2009
@@ -20,19 +20,20 @@
 
 
 
+import java.io.IOException;
+import java.security.GeneralSecurityException;
 import java.util.List;
-import java.util.Map;
+
+import javax.annotation.PostConstruct;
 
 import org.w3c.dom.Element;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
-import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.configuration.jsse.spring.TLSServerParametersConfig;
 import org.apache.cxf.configuration.security.TLSServerParametersType;
 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_jetty.JettyHTTPServerEngine;
 import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory;
@@ -41,8 +42,7 @@
 import org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersIdentifiedType;
 import org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersType;
 import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.PropertyValue;
+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;
@@ -54,62 +54,47 @@
 
 public class JettyHTTPServerEngineBeanDefinitionParser extends AbstractBeanDefinitionParser
{
 
-    
     public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
         
         String portStr = element.getAttribute("port");
-        int port = Integer.valueOf(portStr);
-        bean.addPropertyValue("port", port);
+        bean.addPropertyValue("port", portStr);
                
         String continuationsStr = element.getAttribute("continuationsEnabled");
         if (continuationsStr != null && continuationsStr.length() > 0) {
-            bean.addPropertyValue("continuationsEnabled", Boolean.parseBoolean(continuationsStr));
+            bean.addPropertyValue("continuationsEnabled", continuationsStr);
         }
-        
-        MutablePropertyValues engineFactoryProperties = ctx.getContainingBeanDefinition().getPropertyValues();
-        PropertyValue busValue = engineFactoryProperties.getPropertyValue("bus");
-              
-        // get the property value from parents
-        
+        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)) {
-                    
-                    TLSServerParametersType parametersType = 
-                        JAXBHelper.parseElement(elem, bean, TLSServerParametersType.class);
-                    
-                    TLSServerParametersConfig param = 
-                        new TLSServerParametersConfig(parametersType);
-                    
-                    bean.addPropertyValue("tlsServerParameters", param);
-                    
-                } else if ("tlsServerParametersRef".equals(name)) {
-                    
-                    TLSServerParametersIdentifiedType parameterTypeRef = 
-                        JAXBHelper.parseElement(elem, bean, 
-                                                TLSServerParametersIdentifiedType.class);
-                    
-                    TLSServerParameters param = 
-                        getTlsServerParameters(engineFactoryProperties, parameterTypeRef.getId());

-                    bean.addPropertyValue("tlsServerParameters", param);
-                    
+                    mapElementToJaxbPropertyFactory(elem,
+                                                    bean,
+                                                    "tlsServerParameters",
+                                                    JettyHTTPServerEngineBeanDefinitionParser.class,
+                                                    "createTLSServerParametersConfig");
                 } else if ("threadingParameters".equals(name)) {
-                    ThreadingParametersType parametersType = 
-                        JAXBHelper.parseElement(elem, bean, ThreadingParametersType.class);
-                    
-                    ThreadingParameters param = toThreadingParameters(parametersType);
-                    bean.addPropertyValue("threadingParameters", param);  
-                    
+                    mapElementToJaxbPropertyFactory(elem,
+                                                    bean,
+                                                    "threadingParameters",
+                                                    JettyHTTPServerEngineBeanDefinitionParser.class,
+                                                    "createThreadingParameters");
+                } else if ("tlsServerParametersRef".equals(name)) {
+                    mapElementToJaxbPropertyFactory(elem,
+                                                    bean,
+                                                    "tlsServerParametersRef",
+                                                    JettyHTTPServerEngineBeanDefinitionParser.class,
+                                                    "createTLSServerParametersConfigRef");
                 } else if ("threadingParametersRef".equals(name)) {
-                    ThreadingParametersIdentifiedType parametersTypeRef =
-                        JAXBHelper.parseElement(elem, bean, 
-                                                ThreadingParametersIdentifiedType.class);
-                    ThreadingParameters param = 
-                        getThreadingParameters(engineFactoryProperties, parametersTypeRef.getId());
-                    bean.addPropertyValue("threadingParameters", param);
-                    
+                    mapElementToJaxbPropertyFactory(elem,
+                                                    bean,
+                                                    "threadingParametersRef",
+                                                    JettyHTTPServerEngineBeanDefinitionParser.class,
+                                                    "createThreadingParametersRef"
+                                                    );
                 } else if ("connector".equals(name)) { 
                     // only deal with the one connector here
                     List list = 
@@ -121,7 +106,7 @@
                     bean.addPropertyValue("handlers", handlers);
                 } else if ("sessionSupport".equals(name) || "reuseAddress".equals(name))
{
                     String text = elem.getTextContent();                        
-                    bean.addPropertyValue(name, Boolean.valueOf(text));
+                    bean.addPropertyValue(name, text);
                 }                         
 
                 elem = org.apache.cxf.helpers.DOMUtils.getNextElement(elem);          
@@ -129,62 +114,11 @@
         } catch (Exception e) {
             throw new RuntimeException("Could not process configuration.", e);
         }
-        
-        // if the containing bean is having the bus wired up by the post processor then we
should too
-        if (ctx.getContainingBeanDefinition().getAttribute(WIRE_BUS_ATTRIBUTE) == BusWiringType.PROPERTY)
{
-            addBusWiringAttribute(bean, BusWiringType.PROPERTY);
-        } else {
-            bean.addPropertyValue("bus", busValue.getValue());
-        }
-        
+
         bean.setLazyInit(false);
-        
-    }
-    
-    private TLSServerParameters getTlsServerParameters(
-             MutablePropertyValues engineFactoryProperties,
-             String reference) {
-        TLSServerParameters result = null;
-        PropertyValue tlsParameterMapValue  = 
-            engineFactoryProperties.getPropertyValue("tlsServerParametersMap");
-        if (null == tlsParameterMapValue) {
-            throw new RuntimeException("Could not find the tlsServerParametersMap " 
-                                       + "from the JettyHTTPServerEngineFactory!");
-        } else {
-            Map tlsServerParametersMap  = 
-                (Map)tlsParameterMapValue.getValue();
-            result = (TLSServerParameters)tlsServerParametersMap.get(reference);
-            if (result == null) {
-                throw new RuntimeException("Could not find the tlsServerParametersMap reference
[" 
-                                           + reference + "]'s mapping tlsParameter");
-            }
-        }
-        return result;
     }
     
-    private ThreadingParameters getThreadingParameters(
-             MutablePropertyValues engineFactoryProperties,
-             String reference) {
-        ThreadingParameters result = null;
-        PropertyValue threadingParametersMapValue = 
-            engineFactoryProperties.getPropertyValue("threadingParametersMap");
-        if (null == threadingParametersMapValue) {
-            throw new RuntimeException("Could not find the threadingParametersMap " 
-                                       + "from the JettyHTTPServerEngineFactory!");
-        } else {
-            Map threadingParametersMap  = (Map)threadingParametersMapValue.getValue();
-            result = (ThreadingParameters)threadingParametersMap.get(reference);
-            if (result == null) {
-                throw new RuntimeException("Could not find the threadingParametersMap reference
[" 
-                          + reference + "]'s mapping threadingParameters");
-            }
-        }     
-       
-        return result;
-    }    
-                                            
-    
-    private ThreadingParameters toThreadingParameters(
+    private static ThreadingParameters toThreadingParameters(
                                     ThreadingParametersType paramtype) {
         ThreadingParameters params = new ThreadingParameters();
         params.setMaxThreads(paramtype.getMaxThreads());
@@ -206,12 +140,15 @@
 
     @Override
     protected Class getBeanClass(Element arg0) {
-        return JettyHTTPServerEngine.class;
+        return SpringJettyHTTPServerEngine.class;
     }
     
     public static class SpringJettyHTTPServerEngine extends JettyHTTPServerEngine
         implements ApplicationContextAware {
         
+        String threadingRef;
+        String tlsRef;
+        
         public SpringJettyHTTPServerEngine(
             JettyHTTPServerEngineFactory fac, 
             Bus bus,
@@ -231,7 +168,63 @@
                 setBus(bus);
             }
         }
+        
+        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) {
+                retrieveEngineFactory();
+                if (threadingRef != null) {
+                    setThreadingParameters(factory.getThreadingParametersMap().get(threadingRef));
+                }
+                if (tlsRef != null) {
+                    setTlsServerParameters(factory.getTlsServerParametersMap().get(tlsRef));
+                }
+            }
+            super.finalizeConfig();
+        }
+
     }
         
 
+    
+    public static TLSServerParametersConfig createTLSServerParametersConfig(String s) 
+        throws GeneralSecurityException, IOException {
+        
+        TLSServerParametersType parametersType = unmarshalFactoryString(s, 
+                                                                        TLSServerParametersType.class);
+        
+        return new TLSServerParametersConfig(parametersType);
+    }
+    public static String createTLSServerParametersConfigRef(String s)
+    
+        throws GeneralSecurityException, IOException {
+        
+        TLSServerParametersIdentifiedType parameterTypeRef 
+            = unmarshalFactoryString(s, TLSServerParametersIdentifiedType.class);
+        
+        return parameterTypeRef.getId(); 
+    } 
+    
+    public static ThreadingParameters createThreadingParameters(String s) {
+        
+        ThreadingParametersType parametersType = unmarshalFactoryString(s, 
+                                                                        ThreadingParametersType.class);
+        
+        return toThreadingParameters(parametersType);
+    }
+    public static String createThreadingParametersRef(String s) {
+
+        ThreadingParametersIdentifiedType parametersType 
+            = unmarshalFactoryString(s, ThreadingParametersIdentifiedType.class);
+        return parametersType.getId();
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java?rev=735138&r1=735137&r2=735138&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
Fri Jan 16 13:13:42 2009
@@ -20,7 +20,6 @@
 
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 
 import javax.xml.namespace.QName;
 
@@ -31,19 +30,15 @@
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
-import org.apache.cxf.configuration.jsse.spring.TLSServerParametersConfig;
 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_jetty.JettyHTTPServerEngineFactory;
 import org.apache.cxf.transport.http_jetty.ThreadingParameters;
 
-import org.apache.cxf.transports.http_jetty.configuration.TLSServerParametersIdentifiedType;
-import org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersIdentifiedType;
-import org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersType;
-
-
 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;
@@ -52,36 +47,50 @@
 
 public class JettyHTTPServerEngineFactoryBeanDefinitionParser
         extends AbstractBeanDefinitionParser {
-    private static final String HTTP_JETTY_NS = "http://cxf.apache.org/transports/http-jetty/configuration";
+    static final String HTTP_JETTY_NS = "http://cxf.apache.org/transports/http-jetty/configuration";
 
+    protected String resolveId(Element elem, AbstractBeanDefinition definition, 
+                               ParserContext ctx) throws BeanDefinitionStoreException {
+        String id = this.getIdOrName(elem);
+        if (StringUtils.isEmpty(id)) {
+            return JettyHTTPServerEngineFactory.class.getName();            
+        }
+        id = super.resolveId(elem, definition, ctx);
+        if (!ctx.getRegistry().containsBeanDefinition(JettyHTTPServerEngineFactory.class.getName()))
{
+            ctx.getRegistry().registerAlias(id, JettyHTTPServerEngineFactory.class.getName());
+        }
+        return id;
+    }
+    
+
+    @SuppressWarnings("deprecation")
     @Override
     public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
         //bean.setAbstract(true);        
         String bus = element.getAttribute("bus");
-         
+        
+        BeanDefinitionBuilder factbean 
+            = BeanDefinitionBuilder
+                .rootBeanDefinition(JettySpringTypesFactory.class);
+
+        ctx.getRegistry()
+            .registerBeanDefinition(JettySpringTypesFactory.class.getName(),
+                                    factbean.getBeanDefinition());
         try {
-            List <ThreadingParametersIdentifiedType> threadingParametersIdentifiedTypes
= 
-                JAXBHelper.parseListElement(element, bean, 
-                                            new QName(HTTP_JETTY_NS, "identifiedThreadingParameters"),

-                                            ThreadingParametersIdentifiedType.class);
-            Map<String, ThreadingParameters> threadingParametersMap =
-                toThreadingParameters(threadingParametersIdentifiedTypes);
-            List <TLSServerParametersIdentifiedType> tlsServerParameters =
-                JAXBHelper.parseListElement(element, bean, 
-                                            new QName(HTTP_JETTY_NS, "identifiedTLSServerParameters"),
-                                            TLSServerParametersIdentifiedType.class);
-            Map<String, TLSServerParameters> tlsServerParametersMap =
-                toTLSServerParamenters(tlsServerParameters);
-                                    
-            bean.addPropertyValue("threadingParametersMap", threadingParametersMap);
-            bean.addPropertyValue("tlsServerParametersMap", tlsServerParametersMap);
-            
-            
             if (StringUtils.isEmpty(bus)) {
-                addBusWiringAttribute(bean, BusWiringType.PROPERTY);
+                addBusWiringAttribute(bean, BusWiringType.CONSTRUCTOR);
             } else {
-                bean.addPropertyReference("bus", bus);
+                bean.addConstructorArgReference(bus);
             }
+
+            bean.addConstructorArg(mapElementToJaxbBean(element,
+                                                        Map.class,
+                                                        JettySpringTypesFactory.class,
+                                "createTLSServerParametersMap"));
+            bean.addConstructorArg(mapElementToJaxbBean(element,
+                                                        Map.class,
+                                                        JettySpringTypesFactory.class,
+                                "createThreadingParametersMap"));
             
             // parser the engine list
             List list = 
@@ -89,7 +98,6 @@
             if (list.size() > 0) {
                 bean.addPropertyValue("enginesList", list);
             }
-            
         } catch (Exception e) {
             throw new RuntimeException("Could not process configuration.", e);
         }
@@ -111,40 +119,6 @@
         return list;
     }
     
-    private 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 ThreadingParameters toThreadingParameters(ThreadingParametersType paramtype)
{
-        ThreadingParameters params = new ThreadingParameters();
-        params.setMaxThreads(paramtype.getMaxThreads());
-        params.setMinThreads(paramtype.getMinThreads());
-        return params;
-    }
-        
-    private 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;
-        
-    }
     
           
     /*
@@ -169,6 +143,11 @@
         public SpringJettyHTTPServerEngineFactory() {
             super();
         }
+        public SpringJettyHTTPServerEngineFactory(Bus bus,
+                                                  Map<String, TLSServerParameters>
tls,
+                                                  Map<String, ThreadingParameters>
threading) {
+            super(bus, tls, threading);
+        }    
         
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {
             if (getBus() == null) {
@@ -179,5 +158,6 @@
             }
         }
     }
+    
 
 }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java?rev=735138&r1=735137&r2=735138&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
Fri Jan 16 13:13:42 2009
@@ -503,10 +503,6 @@
     }
     
 
-    /**
-     * This test should fail when we hit Poltim, since it redirects
-     * to Mortimer, which is an http url, and Poltim is an https server.
-     */
     @Test
     public void testHttpsRedirectToHttpFail() throws Exception {
         startServer("Mortimer");
@@ -533,13 +529,7 @@
         
         http.setClient(httpClientPolicy);
         http.setTlsClientParameters(tlsClientParameters);
-        
-        try {
-            String answer = poltim.sayHi();
-            fail("Unexpected answer from Poltim: " + answer);
-        } catch (Exception e) {
-            //e.printStackTrace();
-        }
+        poltim.sayHi();
     }
     
     class MyHttpsTrustDecider extends MessageTrustDecider {



Mime
View raw message