geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r516731 - in /geronimo/server/trunk/modules: geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/
Date Sat, 10 Mar 2007 15:29:28 GMT
Author: djencks
Date: Sat Mar 10 07:29:27 2007
New Revision: 516731

URL: http://svn.apache.org/viewvc?view=rev&rev=516731
Log:
GERONIMO-2935 Handler chain annotation support.  Refactored Tim's patch somewhat and made
some related simplifications

Added:
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java?view=diff&rev=516731&r1=516730&r2=516731
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
Sat Mar 10 07:29:27 2007
@@ -26,9 +26,12 @@
 import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
 import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
 import org.apache.geronimo.xbeans.javaee.JavaIdentifierType;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.xmlbeans.XmlException;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 public class AnnotationHelper {
     protected static String getInjectionJavaType(Method method, Field field) {
@@ -85,5 +88,19 @@
         injectionTarget.setInjectionTargetClass(qualifiedClass);
         injectionTarget.setInjectionTargetName(javaType);
 
+    }
+
+    /**
+     * Validate deployment descriptor
+     *
+     * @param annotatedApp the wrapped deployment descriptor
+     * @throws org.apache.geronimo.common.DeploymentException thrown if deployment descriptor
cannot be parsed
+     */
+    protected static void validateDD(AnnotatedApp annotatedApp) throws DeploymentException
{
+        try {
+            XmlBeansUtil.parse(annotatedApp.toString());
+        } catch (XmlException e) {
+            throw new DeploymentException("Result of processing web service refs invalid.",
e);
+        }
     }
 }

Added: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java?view=auto&rev=516731
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
(added)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
Sat Mar 10 07:29:27 2007
@@ -0,0 +1,293 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.j2ee.deployment.annotation;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import javax.jws.HandlerChain;
+import javax.xml.ws.WebServiceRef;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.xbeans.javaee.HandlerChainType;
+import org.apache.geronimo.xbeans.javaee.HandlerChainsDocument;
+import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
+import org.apache.geronimo.xbeans.javaee.PortComponentHandlerType;
+import org.apache.geronimo.xbeans.javaee.ServiceRefHandlerChainType;
+import org.apache.geronimo.xbeans.javaee.ServiceRefHandlerChainsType;
+import org.apache.geronimo.xbeans.javaee.ServiceRefHandlerType;
+import org.apache.geronimo.xbeans.javaee.ServiceRefType;
+import org.apache.xbean.finder.ClassFinder;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+
+
+/**
+ * Static helper class used to encapsulate all the functions related to the translation of
+ * <strong>@HandlerChain</strong> annotations to deployment descriptor tags.
The
+ * HandlerChainAnnotationHelper class can be used as part of the deployment of a module into
the
+ * Geronimo server. It performs the following major functions:
+ *
+ * <ol>
+ *      <li>Translates annotations into corresponding deployment descriptor elements
(so that the
+ *      actual deployment descriptor in the module can be updated or even created if necessary)
+ * </ol>
+ *
+ * <p><strong>Note(s):</strong>
+ * <ul>
+ *      <li>The user is responsible for invoking change to metadata-complete
+ *      <li>This helper class will validate any changes it makes to the deployment
descriptor. An
+ *      exception will be thrown if it fails to parse
+ * </ul>
+ *
+ * <p><strong>Remaining ToDo(s):</strong>
+ * <ul>
+ *      <li>None
+ * </ul>
+ *
+ * @version $Rev $Date
+ * @since 03-2007
+ */
+public final class HandlerChainAnnotationHelper extends AnnotationHelper {
+
+    // Private instance variables
+    private static final Log log = LogFactory.getLog(HandlerChainAnnotationHelper.class);
+
+    // Private constructor to prevent instantiation
+    private HandlerChainAnnotationHelper() {
+    }
+
+
+    /**
+     * Updates the deployment descriptor with handler chain info from HandlerChain annotations
+     *
+     * @param annotatedApp Wrapper around spec dd
+     * @param classFinder ClassFinder containing classes of interest
+     * @throws DeploymentException if parsing or validation error
+     */
+    public static void processAnnotations(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws DeploymentException {
+        if ( annotatedApp != null && classFinder.isAnnotationPresent(HandlerChain.class))
{
+            processHandlerChain(annotatedApp, classFinder);
+        }
+    }
+
+
+    /**
+     * Updates the deployment descriptor with handler chain info from HandlerChain annotations
+     *
+     * @param annotatedApp Wrapper around spec dd
+     * @param classFinder ClassFinder containing classes of interest
+     * @throws DeploymentException if parsing or validation error
+     */
+    private static void processHandlerChain(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws DeploymentException {
+        log.debug("processHandlerChain(): Entry: AnnotatedApp: " + annotatedApp.toString());
+
+        List<Class> classeswithHandlerChain = classFinder.findAnnotatedClasses(HandlerChain.class);
+        List<Method> methodswithHandlerChain = classFinder.findAnnotatedMethods(HandlerChain.class);
+        List<Field> fieldswithHandlerChain = classFinder.findAnnotatedFields(HandlerChain.class);
+
+        // Class-level annotation
+        for ( Class cls : classeswithHandlerChain ) {
+            HandlerChain handlerChain = (HandlerChain) cls.getAnnotation(HandlerChain.class);
+            if ( handlerChain != null ) {
+                addHandlerChain(annotatedApp, handlerChain, cls, null, null);
+            }
+        }
+
+        // Method-level annotation
+        for ( Method method : methodswithHandlerChain ) {
+            HandlerChain handlerChain = method.getAnnotation(HandlerChain.class);
+            if ( handlerChain != null ) {
+                addHandlerChain(annotatedApp, handlerChain, null, method, null);
+            }
+        }
+
+        // Field-level annotation
+        for ( Field field : fieldswithHandlerChain ) {
+            HandlerChain handlerChain = field.getAnnotation(HandlerChain.class);
+            if ( handlerChain != null ) {
+                addHandlerChain(annotatedApp, handlerChain, null, null, field);
+            }
+        }
+
+        // Validate deployment descriptor to ensure it's still okay
+        validateDD(annotatedApp);
+
+        log.debug("processHandlerChain(): Exit: AnnotatedApp: " + annotatedApp.toString());
+    }
+
+
+    /**
+     * Add to the deployment descriptor for a single @HandlerChain annotation. XMLBeans are
used to read and
+     * manipulate the deployment descriptor as necessary. The HandlerChain annotation(s)
will be
+     * converted to one of the following deployment descriptors:
+     *
+     * <ol>
+     *      <li><handler-chain> -- Associates the Web Service with an externally
defined handler
+     *      chain
+     * </ol>
+     *
+     * <p><strong>Note(s):</strong>
+     * <ul>
+     *      <li>If a field/method has the @HandlerChain annotation then The corresponding
+     *      <service-ref> is obtained via the @WebServiceRef annotation
+     * </ul>
+     *
+     * @param annotatedApp wrapper around spec dd
+     * @param annotation @HandlerChain annotation
+     * @param cls        Class name with the @HandlerChain annotation
+     * @param method     Method name with the @HandlerChain annotation
+     * @param field      Field name with the @HandlerChain annotation
+     */
+    private static void addHandlerChain(AnnotatedApp annotatedApp, final HandlerChain annotation,
Class cls, Method method, Field field) {
+        log.debug("addHandlerChain( " + annotatedApp.toString() + "," + '\n' +
+                           (cls != null ? cls.getName() : null) + "," + '\n' +
+                           (method != null ? method.getName() : null) + "," + '\n' +
+                           (field != null ? field.getName() : null) + " ): Entry");
+
+        //------------------------------------------------------------------------------------------
+        // HandlerChain members:
+        // -- name: Deprecated -- must be empty string
+        // -- file: Location of handler chain file in either absolute URL format or a relative
path
+        //          from the class file. Cannot be emptry string.
+        //------------------------------------------------------------------------------------------
+        String handlerChainFile = annotation.file();
+        log.debug("addHandlerChain(): handlerChainFile: " + handlerChainFile);
+
+        // Determine ServiceRef name
+        String serviceRefName;
+        WebServiceRef webServiceRef = null;
+        if ( method != null ) {
+            webServiceRef = method.getAnnotation(WebServiceRef.class);
+        }
+        else if ( field != null ) {
+            webServiceRef = field.getAnnotation(WebServiceRef.class);
+        }
+        if ( webServiceRef != null ) {
+            serviceRefName = webServiceRef.name();
+        }
+        else {
+            //TODO is this guaranteed to be ""? If so, simplify the code here
+            serviceRefName = annotation.name();
+        }
+        if ( serviceRefName.equals("") ) {
+            serviceRefName = getInjectionJavaType(method, field);
+        }
+        log.debug("addHandlerChain().serviceRefName : " + serviceRefName);
+
+        if (!serviceRefName.equals("") && !handlerChainFile.equals("")) {
+            try {
+                // Locate the handler chain XML file
+                URL url = null;
+                try {
+                    // Assume URL format first
+                    url = new URL(handlerChainFile);
+                }
+                catch (MalformedURLException mfe) {
+                    log.debug("addHandlerChain().MalformedURLException" );
+
+                    // Not URL format -- see if it's relative to the annotated class
+                    if (cls != null) {
+                        url = getURL(cls.getClass(), handlerChainFile);
+                    }
+                    else if (method != null) {
+                        url = getURL(method.getDeclaringClass(), handlerChainFile);
+                    }
+                    else if (field != null) {
+                        url = getURL(field.getDeclaringClass(), handlerChainFile);
+                    }
+                }
+
+                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();
+                                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());
+                                    }
+                                }
+                            }
+                            exists = true;
+                            break;
+                        }
+                    }
+                    if (exists) {
+                        log.debug("HandlerChainAnnotationHelper: <service-ref> entry
found: " + serviceRefName);
+                    }
+                    else {
+                        log.debug("HandlerChainAnnotationHelper: <service-ref> entry
NOT found: " + serviceRefName);
+                    }
+                }
+                else {
+                    log.debug("HandlerChainAnnotationHelper: Handler chain file NOT found:
" + handlerChainFile );
+                }
+            }
+            catch ( Exception anyException ) {
+                log.debug("HandlerChainAnnotationHelper: Exception caught while processing
<handler-chain>");
+            }
+        }
+        log.debug("addHandlerChain(): Exit");
+    }
+
+
+    private static URL getURL(Class clazz, String file) {
+        log.debug("getURL( " + clazz.getName() + ", " + file + " ): Entry");
+
+        URL url = clazz.getResource(file);
+        if (url == null) {
+            url = Thread.currentThread().getContextClassLoader().getResource(file);
+        }
+        if (url == null) {
+            String loc= clazz.getPackage().getName().replace('.', '/') + "/" + file;
+            url = Thread.currentThread().getContextClassLoader().getResource(loc);
+        }
+
+        log.debug("getURL(): Exit: url: " + url.toString() );
+        return url;
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java?view=diff&rev=516731&r1=516730&r2=516731
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
Sat Mar 10 07:29:27 2007
@@ -28,23 +28,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
-import org.apache.geronimo.xbeans.javaee.DescriptionType;
-import org.apache.geronimo.xbeans.javaee.EnvEntryType;
-import org.apache.geronimo.xbeans.javaee.EnvEntryTypeValuesType;
-import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
-import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
-import org.apache.geronimo.xbeans.javaee.JavaIdentifierType;
-import org.apache.geronimo.xbeans.javaee.JndiNameType;
-import org.apache.geronimo.xbeans.javaee.MessageDestinationRefType;
-import org.apache.geronimo.xbeans.javaee.MessageDestinationTypeType;
-import org.apache.geronimo.xbeans.javaee.ResAuthType;
-import org.apache.geronimo.xbeans.javaee.ResSharingScopeType;
-import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
-import org.apache.geronimo.xbeans.javaee.ResourceRefType;
-import org.apache.geronimo.xbeans.javaee.ServiceRefType;
-import org.apache.geronimo.xbeans.javaee.XsdAnyURIType;
-import org.apache.geronimo.xbeans.javaee.XsdStringType;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.xbean.finder.ClassFinder;
 
@@ -84,30 +67,18 @@
     private ResourceAnnotationHelper() {
     }
 
-
-    /**
-     * Determine if there are any annotations present
-     *
-     * @return true or false
-     */
-    public static boolean annotationsPresent(ClassFinder classFinder) {
-        if (classFinder.isAnnotationPresent(Resource.class)) return true;
-        if (classFinder.isAnnotationPresent(Resources.class)) return true;
-        return false;
-    }
-
     /**
-     * Process the annotations
-     *
-     * @return Updated deployment descriptor
+     * Update the deployment descriptor from Resource and Resources annotations
      * @throws Exception if parsing or validation error
      */
     public static void processAnnotations(AnnotatedApp annotatedApp, ClassFinder classFinder,
ResourceProcessor resourceProcessor) throws Exception {
         if (annotatedApp != null) {
-            if (!classFinder.isAnnotationPresent(Resource.class)
-                    && !classFinder.isAnnotationPresent(Resources.class)) return;
-            processResources(annotatedApp, classFinder, resourceProcessor);
-            processResource(annotatedApp, classFinder, resourceProcessor);
+            if (classFinder.isAnnotationPresent(Resources.class)) {
+                processResources(annotatedApp, classFinder, resourceProcessor);
+            }
+            if (classFinder.isAnnotationPresent(Resource.class)) {
+                processResource(annotatedApp, classFinder, resourceProcessor);
+            }
         }
     }
 
@@ -755,17 +726,4 @@
     }
     */
 
-    /**
-     * Validate deployment descriptor
-     *
-     * @param annotatedApp
-     * @throws Exception thrown if deployment descriptor cannot be parsed
-     */
-    private static void validateDD(AnnotatedApp annotatedApp) throws Exception {
-        log.debug("validateDD( " + annotatedApp.toString() + " ): Entry");
-
-        XmlBeansUtil.parse(annotatedApp.toString());
-
-        log.debug("validateDD(): Exit");
-    }
 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java?view=diff&rev=516731&r1=516730&r2=516731
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
Sat Mar 10 07:29:27 2007
@@ -35,7 +35,9 @@
 import org.apache.geronimo.xbeans.javaee.JndiNameType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.geronimo.xbeans.javaee.XsdAnyURIType;
+import org.apache.geronimo.common.DeploymentException;
 import org.apache.xbean.finder.ClassFinder;
+import org.apache.xmlbeans.XmlException;
 
 
 /**
@@ -73,28 +75,18 @@
     private WebServiceRefAnnotationHelper() {
     }
 
-
     /**
-     * Determine if there are any annotations present
-     *
-     * @return true or false
+     * Update the deployment descriptor from the WebServiceRef and WebServiceRefs annotations
+     * @throws DeploymentException if parsing or validation error
      */
-    public static boolean annotationsPresent(ClassFinder classFinder) {
-        if ( classFinder.isAnnotationPresent(WebServiceRef.class) ) return true;
-        if ( classFinder.isAnnotationPresent(WebServiceRefs.class) ) return true;
-        return false;
-    }
-
-    /**
-     * Process the annotations
-     *
-     * @return Updated deployment descriptor
-     * @throws Exception if parsing or validation error
-     */
-    public static void processAnnotations(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws Exception {
+    public static void processAnnotations(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws DeploymentException {
         if ( annotatedApp != null ) {
-            processWebServiceRefs(annotatedApp, classFinder);
-            processWebServiceRef(annotatedApp, classFinder);
+            if (classFinder.isAnnotationPresent(WebServiceRefs.class)) {
+                processWebServiceRefs(annotatedApp, classFinder);
+            }
+            if (classFinder.isAnnotationPresent(WebServiceRef.class)) {
+                processWebServiceRef(annotatedApp, classFinder);
+            }
         }
     }
 
@@ -104,9 +96,9 @@
      *
      * @param annotatedApp
      * @param classFinder
-     * @throws Exception
+     * @throws DeploymentException
      */
-    private static void processWebServiceRef(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws Exception {
+    private static void processWebServiceRef(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws DeploymentException {
         log.debug("processWebServiceRef(): Entry: AnnotatedApp: " + annotatedApp.toString());
 
         List<Class> classeswithWebServiceRef = classFinder.findAnnotatedClasses(WebServiceRef.class);
@@ -151,7 +143,7 @@
      * @param classFinder
      * @exception Exception
      */
-    private static void processWebServiceRefs(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws Exception {
+    private static void processWebServiceRefs(AnnotatedApp annotatedApp, ClassFinder classFinder)
throws DeploymentException {
         log.debug("processWebServiceRefs(): Entry");
 
         List<Class> classeswithWebServiceRefs = classFinder.findAnnotatedClasses(WebServiceRefs.class);
@@ -335,22 +327,6 @@
             }
         }
         log.debug("addWebServiceRef(): Exit");
-    }
-
-
-
-    /**
-     * Validate deployment descriptor
-     *
-     * @parama annotatedApp
-     * @throws Exception thrown if deployment descriptor cannot be parsed
-     */
-    private static void validateDD(AnnotatedApp annotatedApp) throws Exception {
-        log.debug("validateDD( " + annotatedApp.toString() + " ): Entry");
-
-        XmlBeansUtil.parse(annotatedApp.toString());
-
-        log.debug("validateDD(): Exit");
     }
 
 }

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java?view=diff&rev=516731&r1=516730&r2=516731
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
Sat Mar 10 07:29:27 2007
@@ -29,23 +29,16 @@
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.j2ee.deployment.annotation.WebServiceRefAnnotationHelper;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.WebModule;
-import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.deployment.annotation.HandlerChainAnnotationHelper;
+import org.apache.geronimo.j2ee.deployment.annotation.WebServiceRefAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.j2ee.annotation.Holder;
-import org.apache.geronimo.j2ee.annotation.Injection;
 import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.MultiParentClassLoader;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
-import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
-import org.apache.xbean.finder.ClassFinder;
-import org.apache.xbean.finder.UrlSet;
+import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -66,8 +59,8 @@
     private final Collection jaxwsBuilders;
 
     public SwitchingServiceRefBuilder(String[] eeNamespaces,
-                                      Collection jaxrpcBuilders,
-                                      Collection jaxwsBuilders) {
+            Collection jaxrpcBuilders,
+            Collection jaxwsBuilders) {
         super(null);
         this.jaxrpcBuilders = jaxrpcBuilders;
         this.jaxwsBuilders = jaxwsBuilders;
@@ -75,8 +68,8 @@
     }
 
     public void buildEnvironment(XmlObject specDD,
-                                 XmlObject plan,
-                                 Environment environment)
+            XmlObject plan,
+            Environment environment)
             throws DeploymentException {
         if (this.jaxrpcBuilders != null && !this.jaxrpcBuilders.isEmpty()) {
             mergeEnvironment(environment, getJAXRCPBuilder());
@@ -87,11 +80,11 @@
     }
 
     public void buildNaming(XmlObject specDD,
-                            XmlObject plan,
-                            Configuration localConfiguration,
-                            Configuration remoteConfiguration,
-                            Module module,
-                            Map componentContext) throws DeploymentException {
+            XmlObject plan,
+            Configuration localConfiguration,
+            Configuration remoteConfiguration,
+            Module module,
+            Map componentContext) throws DeploymentException {
 
         // Discover and process any @WebServiceRef annotations (if !metadata-complete)
         if ((module != null) && (module.getClassFinder() != null)) {
@@ -135,9 +128,9 @@
                         componentContext);
             } else {
                 throw new DeploymentException(serviceInterfaceName
-                                              + " does not extend "
-                                              + jaxrpcClass.getName() + " or "
-                                              + jaxwsClass.getName());
+                        + " does not extend "
+                        + jaxrpcClass.getName() + " or "
+                        + jaxwsClass.getName());
             }
         }
     }
@@ -179,7 +172,7 @@
             return cl.loadClass(name);
         } catch (ClassNotFoundException e) {
             throw new DeploymentException("Could not load service class "
-                                          + name, e);
+                    + name, e);
         }
     }
 
@@ -199,14 +192,9 @@
     private void processAnnotations(Module module) throws DeploymentException {
 
         // Process all the annotations for this naming builder type
-        if (WebServiceRefAnnotationHelper.annotationsPresent(module.getClassFinder())) {
-            try {
-                WebServiceRefAnnotationHelper.processAnnotations(module.getAnnotatedApp(),
module.getClassFinder());
-            }
-            catch (Exception e) {
-                log.warn("Unable to process @WebServiceRef annotations for module" + module.getName(),
e);
-            }
-        }
+        //At the moment the only exception thrown is if the resulting doc is not valid. 
Bail now.
+        WebServiceRefAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
+        HandlerChainAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
     }
 
     public QNameSet getSpecQNameSet() {
@@ -228,8 +216,8 @@
         infoBuilder.addReference("JAXWSBuilder", ServiceRefBuilder.class,
                 NameFactory.MODULE_BUILDER);
 
-        infoBuilder.setConstructor(new String[] { "eeNamespaces",
-                "JAXRPCBuilder", "JAXWSBuilder" });
+        infoBuilder.setConstructor(new String[]{"eeNamespaces",
+                "JAXRPCBuilder", "JAXWSBuilder"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }



Mime
View raw message