geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r594405 - in /geronimo/server/trunk/plugins/j2ee: geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/ geronimo-j2ee-builder/...
Date Tue, 13 Nov 2007 02:57:42 GMT
Author: gawor
Date: Mon Nov 12 18:57:40 2007
New Revision: 594405

URL: http://svn.apache.org/viewvc?rev=594405&view=rev
Log:
handlerChains in DD overwrite HandlerChain annotation. Also, simplified HandlerChain processing.
(GERONIMO-3598)

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-expected.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-src.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/webservice-ref-expected.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
Mon Nov 12 18:57:40 2007
@@ -208,46 +208,12 @@
                 }
 
                 if (url != null) {
-                    // Bind the XML handler chain file to an XMLBeans document
-                    XmlObject xml = XmlBeansUtil.parse(url, null);
-                    HandlerChainsDocument hcd = (HandlerChainsDocument) XmlBeansUtil.typedCopy(xml,
HandlerChainsDocument.type);
-                    HandlerChainsType handlerChains = hcd.getHandlerChains();
-
                     // Find the <service-ref> entry this handler chain belongs to and
insert it
                     ServiceRefType[] serviceRefs = annotatedApp.getServiceRefArray();
                     boolean exists = false;
                     for ( ServiceRefType serviceRef : serviceRefs ) {
-                        if ( serviceRef.getServiceRefName().getStringValue().trim().equals(serviceRefName)
) {
-                            ServiceRefHandlerChainsType serviceRefHandlerChains = serviceRef.addNewHandlerChains();
-                            for (HandlerChainType handlerChain : handlerChains.getHandlerChainArray())
{
-                                ServiceRefHandlerChainType serviceRefHandlerChain = serviceRefHandlerChains.addNewHandlerChain();
-                                if (handlerChain.getPortNamePattern() != null) {
-                                    serviceRefHandlerChain.setPortNamePattern(handlerChain.getPortNamePattern());
-                                }
-                                if (handlerChain.getServiceNamePattern() != null) {
-                                    serviceRefHandlerChain.setServiceNamePattern(handlerChain.getServiceNamePattern());
-                                }
-                                if (handlerChain.getProtocolBindings() != null) {
-                                    serviceRefHandlerChain.setProtocolBindings(handlerChain.getProtocolBindings());
-                                }
-                                for ( PortComponentHandlerType handler : handlerChain.getHandlerArray())
{
-                                    ServiceRefHandlerType serviceRefHandler = serviceRefHandlerChain.addNewHandler();
-                                    serviceRefHandler.setHandlerName(handler.getHandlerName());
-                                    serviceRefHandler.setHandlerClass(handler.getHandlerClass());
-                                    if (handler.getDescriptionArray().length>0) {
-                                        serviceRefHandler.setDescriptionArray(handler.getDescriptionArray());
-                                    }
-                                    if (handler.getInitParamArray().length>0) {
-                                        serviceRefHandler.setInitParamArray(handler.getInitParamArray());
-                                    }
-                                    if (handler.getSoapHeaderArray().length>0) {
-                                        serviceRefHandler.setSoapHeaderArray(handler.getSoapHeaderArray());
-                                    }
-                                    if (handler.getSoapRoleArray().length>0) {
-                                        serviceRefHandler.setSoapRoleArray(handler.getSoapRoleArray());
-                                    }
-                                }
-                            }
+                        if ( serviceRef.getServiceRefName().getStringValue().trim().equals(serviceRefName)
&& !serviceRef.isSetHandlerChains()) {
+                            insertHandlers(serviceRef, url);
                             exists = true;
                             break;
                         }
@@ -285,6 +251,67 @@
 
         log.debug("getURL(): Exit: url: " + (url != null ? url.toString() : null) );
         return url;
+    }
+    
+    public static void insertHandlers(ServiceRefType serviceRef, HandlerChain annotation,
Class clazz) {
+        String handlerChainFile = annotation.file();
+        log.debug("handlerChainFile: " + handlerChainFile);
+        if (handlerChainFile == null || handlerChainFile.trim().length() == 0) {
+            return;
+        }
+        URL url = null;
+        try {
+            // Assume URL format first
+            url = new URL(handlerChainFile);
+        } catch (MalformedURLException mfe) {
+            // Not URL format -- see if it's relative to the annotated class
+            url = getURL(clazz, handlerChainFile);
+        }
+        if (url != null) {
+            try {
+                insertHandlers(serviceRef, url);
+            } catch (Exception e) {
+                log.debug("Error while processing <handler-chain>", e);
+            }
+        }
+    }
+    
+    public static void insertHandlers(ServiceRefType serviceRef, URL url) throws Exception
{
+        // Bind the XML handler chain file to an XMLBeans document
+        XmlObject xml = XmlBeansUtil.parse(url, null);
+        HandlerChainsDocument hcd = (HandlerChainsDocument) XmlBeansUtil.typedCopy(xml, HandlerChainsDocument.type);
+        HandlerChainsType handlerChains = hcd.getHandlerChains();
+        
+        ServiceRefHandlerChainsType serviceRefHandlerChains = serviceRef.addNewHandlerChains();
+        for (HandlerChainType handlerChain : handlerChains.getHandlerChainArray()) {
+            ServiceRefHandlerChainType serviceRefHandlerChain = serviceRefHandlerChains.addNewHandlerChain();
+            if (handlerChain.getPortNamePattern() != null) {
+                serviceRefHandlerChain.setPortNamePattern(handlerChain.getPortNamePattern());
+            }
+            if (handlerChain.getServiceNamePattern() != null) {
+                serviceRefHandlerChain.setServiceNamePattern(handlerChain.getServiceNamePattern());
+            }
+            if (handlerChain.getProtocolBindings() != null) {
+                serviceRefHandlerChain.setProtocolBindings(handlerChain.getProtocolBindings());
+            }
+            for ( PortComponentHandlerType handler : handlerChain.getHandlerArray()) {
+                ServiceRefHandlerType serviceRefHandler = serviceRefHandlerChain.addNewHandler();
+                serviceRefHandler.setHandlerName(handler.getHandlerName());
+                serviceRefHandler.setHandlerClass(handler.getHandlerClass());
+                if (handler.getDescriptionArray().length>0) {
+                    serviceRefHandler.setDescriptionArray(handler.getDescriptionArray());
+                }
+                if (handler.getInitParamArray().length>0) {
+                    serviceRefHandler.setInitParamArray(handler.getInitParamArray());
+                }
+                if (handler.getSoapHeaderArray().length>0) {
+                    serviceRefHandler.setSoapHeaderArray(handler.getSoapHeaderArray());
+                }
+                if (handler.getSoapRoleArray().length>0) {
+                    serviceRefHandler.setSoapRoleArray(handler.getSoapRoleArray());
+                }
+            }
+        }
     }
 
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
Mon Nov 12 18:57:40 2007
@@ -23,6 +23,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import javax.jws.HandlerChain;
 import javax.xml.ws.WebServiceClient;
 import javax.xml.ws.WebServiceRef;
 import javax.xml.ws.WebServiceRefs;
@@ -329,6 +330,34 @@
             }
         }
 
+        // handler-chains
+        if (!serviceRef.isSetHandlerChains()) {
+            HandlerChain handlerChain = null;
+            Class annotatedClass = null;
+            if (method != null) {
+                handlerChain = method.getAnnotation(HandlerChain.class);
+                annotatedClass = method.getDeclaringClass();
+            } else if (field != null) {
+                handlerChain = field.getAnnotation(HandlerChain.class);
+                annotatedClass = field.getDeclaringClass();
+            }
+            
+            // if not specified on method or field, try to get it from Service class
+            if (handlerChain == null) {
+                if (Object.class.equals(webServiceRefValue)) {
+                    handlerChain = (HandlerChain) webServiceRefType.getAnnotation(HandlerChain.class);
+                    annotatedClass = webServiceRefType;
+                } else {
+                    handlerChain = (HandlerChain) webServiceRefValue.getAnnotation(HandlerChain.class);
+                    annotatedClass = webServiceRefValue;
+                }
+            }
+            
+            if (handlerChain != null) {
+                HandlerChainAnnotationHelper.insertHandlers(serviceRef, handlerChain, annotatedClass);
+            }
+        }
+        
         if (method != null || field != null) {
             configureInjectionTarget(serviceRef.addNewInjectionTarget(), method, field);
         }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
Mon Nov 12 18:57:40 2007
@@ -113,7 +113,7 @@
 
         List<Method> annotatedMethods = classFinder.findAnnotatedMethods(HandlerChain.class);
         assertNotNull(annotatedMethods);
-        assertEquals(2, annotatedMethods.size());
+        assertEquals(3, annotatedMethods.size());
         assertTrue(annotatedMethods.contains(HandlerChainAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod1",
new Class[]{String.class})));
         assertTrue(annotatedMethods.contains(HandlerChainAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod2",
new Class[]{int.class})));
 
@@ -233,7 +233,7 @@
 
         List<Method> annotatedMethods = classFinder.findAnnotatedMethods(WebServiceRef.class);
         assertNotNull(annotatedMethods);
-        assertEquals(4, annotatedMethods.size());
+        assertEquals(5, annotatedMethods.size());
         assertTrue(annotatedMethods.contains(WebServiceRefAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod1",
new Class[]{boolean.class})));
         assertTrue(annotatedMethods.contains(WebServiceRefAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod2",
new Class[]{String.class})));
         assertTrue(annotatedMethods.contains(HandlerChainAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod1",
new Class[]{String.class})));

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationTest.java?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationTest.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationTest.java
Mon Nov 12 18:57:40 2007
@@ -60,5 +60,13 @@
     @HandlerChain(file = "annotation/handlers5.xml")
     public void setAnnotatedMethod2(int ii) {
     }
-
+    
+    @WebServiceRef(name = "WebServiceRef100",
+            value = javax.xml.ws.Service.class,
+            wsdlLocation = "WEB-INF/wsdl/WebServiceRef4.wsdl",
+            mappedName = "mappedName")
+    @HandlerChain(file = "annotation/handlers5.xml")
+    public void setAnnotatedMethod3(int ii) {
+    }
+    
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-expected.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-expected.xml?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-expected.xml
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-expected.xml
Mon Nov 12 18:57:40 2007
@@ -101,5 +101,17 @@
             <injection-target-name>annotatedField2</injection-target-name>
         </injection-target>
     </service-ref>
-
+    <service-ref>
+        <service-ref-name>WebServiceRef100</service-ref-name>
+        <service-interface>int</service-interface>
+        <service-ref-type>int</service-ref-type>
+        <handler-chains>
+            <handler-chain>
+                <handler>
+                    <handler-name>MyHandler</handler-name>
+                    <handler-class>org.apache.handler.WebServiceHandler3</handler-class>
+                </handler>
+            </handler-chain>
+        </handler-chains>
+    </service-ref>
 </web-app>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-src.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-src.xml?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-src.xml
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-src.xml
Mon Nov 12 18:57:40 2007
@@ -77,5 +77,17 @@
             <injection-target-name>annotatedField2</injection-target-name>
         </injection-target>
     </service-ref>
-
+    <service-ref>
+        <service-ref-name>WebServiceRef100</service-ref-name>
+        <service-interface>int</service-interface>
+        <service-ref-type>int</service-ref-type>
+        <handler-chains>
+            <handler-chain>
+                <handler>
+                    <handler-name>MyHandler</handler-name>
+                    <handler-class>org.apache.handler.WebServiceHandler3</handler-class>
+                </handler>
+            </handler-chain>
+        </handler-chains>
+    </service-ref>
 </web-app>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/webservice-ref-expected.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/webservice-ref-expected.xml?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/webservice-ref-expected.xml
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/webservice-ref-expected.xml
Mon Nov 12 18:57:40 2007
@@ -41,6 +41,14 @@
         <service-interface>javax.xml.ws.Service</service-interface>
         <service-ref-type>java.lang.String</service-ref-type>
         <wsdl-file>WEB-INF/wsdl/WebServiceRef3.wsdl</wsdl-file>
+        <handler-chains>
+            <handler-chain>
+                <handler>
+                    <handler-name>WebService3</handler-name>
+                    <handler-class>org.apache.handler.WebServiceHandler3</handler-class>
+                </handler>
+            </handler-chain>
+        </handler-chains>
         <mapped-name>mappedName</mapped-name>
         <injection-target>
             <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.HandlerChainAnnotationTest</injection-target-class>
@@ -52,6 +60,14 @@
         <service-interface>javax.xml.ws.Service</service-interface>
         <service-ref-type>int</service-ref-type>
         <wsdl-file>WEB-INF/wsdl/WebServiceRef4.wsdl</wsdl-file>
+        <handler-chains>
+            <handler-chain>
+                <handler>
+                    <handler-name>WebService2</handler-name>
+                    <handler-class>org.apache.handler.WebServiceHandler2</handler-class>
+                </handler>
+            </handler-chain>
+        </handler-chains>
         <mapped-name>mappedName</mapped-name>
         <injection-target>
             <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.HandlerChainAnnotationTest</injection-target-class>
@@ -59,6 +75,25 @@
         </injection-target>
     </service-ref>
     <service-ref>
+        <service-ref-name>WebServiceRef100</service-ref-name>
+        <service-interface>javax.xml.ws.Service</service-interface>
+        <service-ref-type>int</service-ref-type>
+        <wsdl-file>WEB-INF/wsdl/WebServiceRef4.wsdl</wsdl-file>
+        <handler-chains>
+            <handler-chain>
+                <handler>
+                    <handler-name>WebService2</handler-name>
+                    <handler-class>org.apache.handler.WebServiceHandler2</handler-class>
+                </handler>
+            </handler-chain>
+        </handler-chains>
+        <mapped-name>mappedName</mapped-name>
+        <injection-target>
+            <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.HandlerChainAnnotationTest</injection-target-class>
+            <injection-target-name>annotatedMethod3</injection-target-name>
+        </injection-target>
+    </service-ref>
+    <service-ref>
         <service-ref-name>WebServiceRef14</service-ref-name>
         <service-interface>boolean</service-interface>
         <service-ref-type>boolean</service-ref-type>
@@ -85,6 +120,14 @@
         <service-interface>javax.xml.ws.Service</service-interface>
         <service-ref-type>int</service-ref-type>
         <wsdl-file>WEB-INF/wsdl/WebServiceRef1.wsdl</wsdl-file>
+        <handler-chains>
+            <handler-chain>
+                <handler>
+                    <handler-name>WebService5</handler-name>
+                    <handler-class>org.apache.handler.WebServiceHandler5</handler-class>
+                </handler>
+            </handler-chain>
+        </handler-chains>
         <mapped-name>mappedName</mapped-name>
         <injection-target>
             <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.HandlerChainAnnotationTest</injection-target-class>
@@ -96,6 +139,14 @@
         <service-interface>javax.xml.ws.Service</service-interface>
         <service-ref-type>boolean</service-ref-type>
         <wsdl-file>WEB-INF/wsdl/WebServiceRef2.wsdl</wsdl-file>
+        <handler-chains>
+            <handler-chain>
+                <handler>
+                    <handler-name>WebService4</handler-name>
+                    <handler-class>org.apache.handler.WebServiceHandler4</handler-class>
+                </handler>
+            </handler-chain>
+        </handler-chains>
         <mapped-name>mappedName</mapped-name>
         <injection-target>
             <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.HandlerChainAnnotationTest</injection-target-class>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java?rev=594405&r1=594404&r2=594405&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
Mon Nov 12 18:57:40 2007
@@ -205,7 +205,6 @@
         //At the moment the only exception thrown is if the resulting doc is not valid. 
Bail now.
         try {
             WebServiceRefAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
-            HandlerChainAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
             ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder(),
ServiceRefProcessor.INSTANCE);
         }
         catch (Exception e) {



Mime
View raw message