cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r451542 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/handler/ main/resources/schemas/configuration/ test/java/org/apache/cxf/jaxws/handler/ test/resources/
Date Sat, 30 Sep 2006 05:05:15 GMT
Author: jliu
Date: Fri Sep 29 22:05:15 2006
New Revision: 451542

URL: http://svn.apache.org/viewvc?view=rev&rev=451542
Log:
Using schema specified by JSR181 Appendix B to process handler cfg file from @HandlerChain
annotations

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
Removed:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/configuration/javaee_web_services_1_2.xsd
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java?view=diff&rev=451542&r1=451541&r2=451542
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
Fri Sep 29 22:05:15 2006
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxws.handler;
 
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.ResourceBundle;
@@ -26,17 +27,16 @@
 import java.util.logging.Logger;
 
 import javax.jws.HandlerChain;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.Handler;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.configuration.spring.ConfigurerImpl;
-import org.apache.cxf.configuration.spring.JaxbClassPathXmlApplicationContext;
 import org.apache.cxf.jaxws.javaee.HandlerChainType;
-import org.apache.cxf.jaxws.javaee.HandlerConfigBean;
-import org.springframework.context.ApplicationContext;
+import org.apache.cxf.jaxws.javaee.HandlerChainsType;
 
 public class AnnotationHandlerChainBuilder extends HandlerChainBuilder {
 
@@ -56,7 +56,6 @@
      * @return
      */
     public List<Handler> buildHandlerChainFromClass(Class<?> clz, List<Handler>
existingHandlers) {
-
         LOG.fine("building handler chain");
         HandlerChainAnnotation hcAnn = findHandlerChainAnnotation(clz);
         List<Handler> chain = null;
@@ -65,21 +64,26 @@
             chain = new ArrayList<Handler>();
         } else {
             hcAnn.validate();
-            String handlerFile = hcAnn.getFileName();
-
-            // This Configurer needs to be different from system configurer as
-            // it is only aware of handler configure file.
-            ApplicationContext ac = new JaxbClassPathXmlApplicationContext(new String[] {
-                handlerFile,
-                "META-INF/cxf/cxf-property-editors.xml"});
-            Configurer configurer = new ConfigurerImpl(ac);
-
-            HandlerConfigBean hcb = new HandlerConfigBean();
-            configurer.configureBean(hcb);
-            HandlerChainType hc = hcb.getJaxwshandler();
 
-            if (null == hc) {
-                throw new WebServiceException(BUNDLE.getString("CHAIN_NOT_SPECIFIED_EXC"));
+            HandlerChainType hc = null;
+            try {
+                JAXBContext jc = JAXBContext
+                        .newInstance(org.apache.cxf.jaxws.javaee.ObjectFactory.class);
+                Unmarshaller u = jc.createUnmarshaller();                
+                URL handlerFileURL  = clz.getResource(hcAnn.getFileName()); 
+                JAXBElement<?> o = (JAXBElement<?>)u.unmarshal(handlerFileURL);
+
+                HandlerChainsType handlerChainsType = (HandlerChainsType) o.getValue();
+
+                if (null == handlerChainsType || handlerChainsType.getHandlerChain().size()
== 0) {
+                    throw new WebServiceException(BUNDLE
+                            .getString("CHAIN_NOT_SPECIFIED_EXC"));
+                }
+                //We expect only one HandlerChainType here
+                hc = (HandlerChainType) handlerChainsType.getHandlerChain().iterator().next();
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new WebServiceException(BUNDLE.getString("CHAIN_NOT_SPECIFIED_EXC"),
e);
             }
 
             chain = buildHandlerChain(hc, clz.getClassLoader());

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/configuration/javaee_web_services_1_2.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/configuration/javaee_web_services_1_2.xsd?view=diff&rev=451542&r1=451541&r2=451542
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/configuration/javaee_web_services_1_2.xsd
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/configuration/javaee_web_services_1_2.xsd
Fri Sep 29 22:05:15 2006
@@ -747,16 +747,13 @@
     <xsd:attribute name="id" type="xsd:ID"/>
   </xsd:complexType>
 
-  <xsd:element name="jaxwshandler" type="javaee:handler-chainType"/>
-  <xsd:complexType name="HandlerConfigBean">        
-    <xsd:annotation>
-      <xsd:appinfo>                
-        <cfg:configurable/>
-      </xsd:appinfo>
-    </xsd:annotation>
-    <xsd:sequence>
-      <xsd:element ref="javaee:jaxwshandler"/>
-    </xsd:sequence>
-  </xsd:complexType>
+  <element name="handler-chains" type="javaee:handler-chainsType">
+      <annotation>
+          <documentation>
+           The handler-chains element is the root element for defining handlerchains.
+          </documentation>
+      </annotation>
+  </element>
+  
 </xsd:schema>
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java?view=diff&rev=451542&r1=451541&r2=451542
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java
Fri Sep 29 22:05:15 2006
@@ -37,7 +37,6 @@
 
     public void testFindHandlerChainAnnotation() {
         HandlerTestImpl handlerTestImpl = new HandlerTestImpl();
-        System.out.println(TestLogicalHandler.class.getName());
         AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
         List<Handler> handlers = chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass());
         assertNotNull(handlers);

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml?view=auto&rev=451542
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
Fri Sep 29 22:05:15 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--Sample XML file generated by XMLSPY v2004 rel. 4 U (http://www.xmlspy.com)-->
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cfg="http://cxf.apache.org/configuration/cfg"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+C:\svn\cxf\trunk\rt\frontend\jaxws\src\main\resources\schemas\configuration\javaee_web_services_1_2.xsd"
id="ID000042">
+    <handler-chain>
+	<handler>
+		<handler-name>lh1</handler-name>
+		<handler-class>org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilderTest$TestLogicalHandler</handler-class>
+		<init-param>
+			<param-name>token</param-name>
+			<param-value>String</param-value>
+		</init-param>
+	</handler>
+	<handler>
+		<handler-name>lh2</handler-name>
+		<handler-class>org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilderTest$TestLogicalHandler</handler-class>
+		<init-param>
+			<param-name>token</param-name>
+			<param-value>String</param-value>
+		</init-param>
+	</handler>
+    </handler-chain>
+</handler-chains>
\ No newline at end of file



Mime
View raw message