geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1090800 - /geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
Date Sun, 10 Apr 2011 13:51:47 GMT
Author: xuhaihong
Date: Sun Apr 10 13:51:47 2011
New Revision: 1090800

URL: http://svn.apache.org/viewvc?rev=1090800&view=rev
Log:
No function change, refract codes a bit

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
  (contents, props changed)

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=1090800&r1=1090799&r2=1090800&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
Sun Apr 10 13:51:47 2011
@@ -20,6 +20,7 @@ package org.apache.geronimo.naming.deplo
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -95,44 +96,37 @@ public class SwitchingServiceRefBuilder 
             processAnnotations(specDD, module);
         }
 
-        Bundle bundle = module.getEarContext().getDeploymentBundle();
-        Class jaxrpcClass = null;
-        Class jaxwsClass = null;
-
         Collection<ServiceRef> serviceRefs = specDD.getServiceRef();
 
         XmlObject[] gerServiceRefsUntyped = plan == null ? NO_REFS : plan
                 .selectChildren(GER_SERVICE_REF_QNAME_SET);
-        Map serviceRefMap = mapServiceRefs(gerServiceRefsUntyped);
-
-        for (ServiceRef serviceRef : serviceRefs) {
-            if (jaxrpcClass == null) {
-                jaxrpcClass = loadClass("javax.xml.rpc.Service", bundle);
-            }
-            if (jaxwsClass == null) {
-                jaxwsClass = loadClass("javax.xml.ws.Service", bundle);
-            }
+        Map<String, GerServiceRefType> serviceRefMap = mapServiceRefs(gerServiceRefsUntyped);
 
-            String name = getStringValue(serviceRef.getServiceRefName());
-            GerServiceRefType gerServiceRefType = (GerServiceRefType) serviceRefMap.get(name);
-            serviceRefMap.remove(name);
-
-            String serviceInterfaceName = serviceRef.getServiceInterface();
-            Class serviceInterfaceClass = loadClass(serviceInterfaceName, bundle);
-
-            if (jaxrpcClass.isAssignableFrom(serviceInterfaceClass)) {
-                // class jaxrpc handler
-                ServiceRefBuilder jaxrpcBuilder = getJAXRCPBuilder();
-                jaxrpcBuilder.buildNaming(serviceRef, gerServiceRefType, module, sharedContext);
-            } else if (jaxwsClass.isAssignableFrom(serviceInterfaceClass)) {
-                // call jaxws handler
-                ServiceRefBuilder jaxwsBuilder = getJAXWSBuilder();
-                jaxwsBuilder.buildNaming(serviceRef, gerServiceRefType, module, sharedContext);
-            } else {
-                throw new DeploymentException(serviceInterfaceName
-                        + " does not extend "
-                        + jaxrpcClass.getName() + " or "
-                        + jaxwsClass.getName());
+        if (serviceRefs.size() > 0) {
+            Bundle bundle = module.getEarContext().getDeploymentBundle();
+            Class<?> jaxrpcClass = loadClass("javax.xml.rpc.Service", bundle);
+            Class<?> jaxwsClass = loadClass("javax.xml.ws.Service", bundle);
+
+            for (ServiceRef serviceRef : serviceRefs) {
+
+                String name = getStringValue(serviceRef.getServiceRefName());
+                GerServiceRefType gerServiceRefType = serviceRefMap.get(name);
+                serviceRefMap.remove(name);
+
+                String serviceInterfaceName = serviceRef.getServiceInterface();
+                Class<?> serviceInterfaceClass = loadClass(serviceInterfaceName, bundle);
+
+                if (jaxrpcClass.isAssignableFrom(serviceInterfaceClass)) {
+                    // class jaxrpc handler
+                    ServiceRefBuilder jaxrpcBuilder = getJAXRCPBuilder();
+                    jaxrpcBuilder.buildNaming(serviceRef, gerServiceRefType, module, sharedContext);
+                } else if (jaxwsClass.isAssignableFrom(serviceInterfaceClass)) {
+                    // call jaxws handler
+                    ServiceRefBuilder jaxwsBuilder = getJAXWSBuilder();
+                    jaxwsBuilder.buildNaming(serviceRef, gerServiceRefType, module, sharedContext);
+                } else {
+                    throw new DeploymentException(serviceInterfaceName + " does not extend
" + jaxrpcClass.getName() + " or " + jaxwsClass.getName());
+                }
             }
         }
 
@@ -182,17 +176,17 @@ public class SwitchingServiceRefBuilder 
         }
     }
 
-    private static Map mapServiceRefs(XmlObject[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
+    private Map<String, GerServiceRefType> mapServiceRefs(XmlObject[] refs) {
+        if (refs != null && refs.length > 0) {
+            Map<String, GerServiceRefType> refMap = new HashMap<String, GerServiceRefType>();
             for (int i = 0; i < refs.length; i++) {
-                GerServiceRefType ref = (GerServiceRefType) refs[i].copy()
-                        .changeType(GerServiceRefType.type);
+                GerServiceRefType ref = (GerServiceRefType) refs[i].copy().changeType(GerServiceRefType.type);
                 String serviceRefName = ref.getServiceRefName().trim();
                 refMap.put(serviceRefName, ref);
             }
+            return refMap;
         }
-        return refMap;
+        return Collections.<String, GerServiceRefType> emptyMap();
     }
 
     private void processAnnotations(JndiConsumer specDD, Module module) throws DeploymentException
{
@@ -293,7 +287,7 @@ public class SwitchingServiceRefBuilder 
                         if (method != null || field != null) {
                             serviceRef.getInjectionTarget().add(configureInjectionTarget(method,
field));
                         }
-                        
+
                         // mappedName
                         if (serviceRef.getMappedName() == null && annotation.mappedName().trim().length()
> 0) {
                             serviceRef.setMappedName(annotation.mappedName().trim());

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message