cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r735113 - in /cxf/trunk: 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/transport/http_jetty...
Date Fri, 16 Jan 2009 20:02:02 GMT
Author: dkulp
Date: Fri Jan 16 12:02:01 2009
New Revision: 735113

URL: http://svn.apache.org/viewvc?rev=735113&view=rev
Log:
Cleanup the parsing of the jetty serverendine factory stuff
Allow the properties placeholder things to work with the jetty server stuff


Added:
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
  (contents, props changed)
      - copied, changed from r735030, cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JAXBHelper.java
Removed:
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JAXBHelper.java
Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=735113&r1=735112&r2=735113&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Fri Jan 16 12:02:01 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/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=735113&r1=735112&r2=735113&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Fri Jan 16 12:02:01 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/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=735113&r1=735112&r2=735113&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Fri Jan 16 12:02:01 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/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java?rev=735113&r1=735112&r2=735113&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
Fri Jan 16 12:02:01 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/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java?rev=735113&r1=735112&r2=735113&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
Fri Jan 16 12:02:01 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 @@
             }
         }
     }
+    
 
 }

Copied: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
(from r735030, cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JAXBHelper.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java?p2=cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java&p1=cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JAXBHelper.java&r1=735030&r2=735113&rev=735113&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JAXBHelper.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
Fri Jan 16 12:02:01 2009
@@ -18,8 +18,11 @@
  */
 package org.apache.cxf.transport.http_jetty.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;
@@ -27,18 +30,85 @@
 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.springframework.beans.factory.support.BeanDefinitionBuilder;
 
-public final class JAXBHelper {
-    private JAXBHelper() {
+import org.apache.cxf.configuration.jsse.TLSServerParameters;
+import org.apache.cxf.configuration.jsse.spring.TLSServerParametersConfig;
+import org.apache.cxf.helpers.DOMUtils;
+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;
+
+public final class JettySpringTypesFactory {
+    public JettySpringTypesFactory() {
         
     }
+    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());
+        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)

+        throws Exception {
+        Document doc = DOMUtils.readXml(new StringReader(s));
+        List <ThreadingParametersIdentifiedType> threadingParametersIdentifiedTypes
= 
+            JettySpringTypesFactory
+                .parseListElement(doc.getDocumentElement(), 
+                                  new QName(JettyHTTPServerEngineFactoryBeanDefinitionParser.HTTP_JETTY_NS,
+                                            "identifiedThreadingParameters"), 
+                                  ThreadingParametersIdentifiedType.class);
+        Map<String, ThreadingParameters> threadingParametersMap =
+            toThreadingParameters(threadingParametersIdentifiedTypes);
+        return threadingParametersMap;
+    }
+    
+    public Map<String, TLSServerParameters> createTLSServerParametersMap(String s)

+        throws Exception {
+        Document doc = DOMUtils.readXml(new StringReader(s));
+        
+        List <TLSServerParametersIdentifiedType> tlsServerParameters =
+            JettySpringTypesFactory
+                .parseListElement(doc.getDocumentElement(), 
+                                  new QName(JettyHTTPServerEngineFactoryBeanDefinitionParser.HTTP_JETTY_NS,
+                                            "identifiedTLSServerParameters"),
+                                  TLSServerParametersIdentifiedType.class);
+        Map<String, TLSServerParameters> tlsServerParametersMap =
+            toTLSServerParamenters(tlsServerParameters);
+        return tlsServerParametersMap;
+    }
     
     @SuppressWarnings("unchecked")
     public static <V> List<V> parseListElement(Element parent, 
-                                           BeanDefinitionBuilder bean, 
                                            QName name, 
                                            Class<?> c) throws JAXBException {     
                          
         List<V> list = new ArrayList<V>();
@@ -52,13 +122,13 @@
         } else {
             context = JAXBContext.newInstance(pkg);
         }
-          
+        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(context, data, c);                
+                Object obj = unmarshal(u, data, c);                
                 if (obj != null) {                    
                     list.add((V) obj);
                 }
@@ -69,37 +139,17 @@
     }
     
     
-    public static <T> T parseElement(Element element, 
-                               BeanDefinitionBuilder bean, 
-                               Class<T> c) throws JAXBException {
-        if (null == element) {
-            return null;
-        }
-        JAXBContext context = null;
-        String pkg = "";
-        if (null != c && c.getPackage() != null) {
-            pkg = c.getPackage().getName();
-            context = JAXBContext.newInstance(pkg, c.getClassLoader());
-        } else {
-            context = JAXBContext.newInstance(pkg);
-        }
-        Object obj = unmarshal(context, element, c);
-        
-        return c.cast(obj);
-    }
+
     
     
-    private static Object unmarshal(JAXBContext context,
+    private static Object unmarshal(Unmarshaller u,
                                      Node data, Class<?> c) {
-        if (context == null) {
+        if (u == null) {
             return null;
         }
         
-        Object obj = null;
-        
+        Object obj = null;        
         try {
-            
-            Unmarshaller u = context.createUnmarshaller();
             if (c != null) {
                 obj = u.unmarshal(data, c);
             } else {

Propchange: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java?rev=735113&r1=735112&r2=735113&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
Fri Jan 16 12:02:01 2009
@@ -1056,15 +1056,7 @@
                 //ignore
             }
         }
-        
-        try {
-            Key key = crypto.getKeyStore().getCertificate(user).getPublicKey();
-            System.out.println(key);
-        } catch (KeyStoreException e1) {
-            // TODO Auto-generated catch block
-            e1.printStackTrace();
-        }
-        
+                
         if (StringUtils.isEmpty(user)) {
             policyNotAsserted(token, "No " + type + " username found.");
         }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java?rev=735113&r1=735112&r2=735113&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java Fri
Jan 16 12:02:01 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