tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r833120 - in /tomcat/trunk/java/org/apache/naming/factory/webservices: ServiceProxy.java ServiceRefFactory.java
Date Thu, 05 Nov 2009 18:41:30 GMT
Author: markt
Date: Thu Nov  5 18:41:30 2009
New Revision: 833120

URL: http://svn.apache.org/viewvc?rev=833120&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48135
Also add generics where possible and other Eclipse warnings

Modified:
    tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceProxy.java
    tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java

Modified: tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceProxy.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceProxy.java?rev=833120&r1=833119&r2=833120&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceProxy.java (original)
+++ tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceProxy.java Thu Nov  5 18:41:30
2009
@@ -57,7 +57,7 @@
     /**
      * PortComponentRef list
      */
-    private Hashtable portComponentRef = null;
+    private Hashtable<String,QName> portComponentRef = null;
 
     /**
      * Constructs a new ServiceProxy wrapping given Service instance.
@@ -103,10 +103,10 @@
     throws ServiceException {
         QName name = (QName) args[0];
         String nameString = name.getLocalPart();
-        Class serviceendpointClass = (Class) args[1];
+        Class<?> serviceendpointClass = (Class<?>) args[1];
 
-        for (Iterator ports = service.getPorts(); ports.hasNext();) {
-            QName portName = (QName) ports.next();
+        for (Iterator<QName> ports = service.getPorts(); ports.hasNext();) {
+            QName portName = ports.next();
             String portnameString = portName.getLocalPart();
             if (portnameString.equals(nameString)) {
                 return service.getPort(name, serviceendpointClass);
@@ -120,7 +120,7 @@
     /**
      * @param portComponentRef List
      */
-    public void setPortComponentRef(Hashtable portComponentRef) {
+    public void setPortComponentRef(Hashtable<String,QName> portComponentRef) {
         this.portComponentRef = portComponentRef;
     }
 
@@ -131,12 +131,12 @@
      */
     private Remote getProxyPortClass(Object[] args) 
     throws ServiceException {
-        Class serviceendpointClass = (Class) args[0];
+        Class<?> serviceendpointClass = (Class<?>) args[0];
 
         if (this.portComponentRef == null)
             return service.getPort(serviceendpointClass);
 
-        QName portname = (QName) this.portComponentRef.get(serviceendpointClass.getName());
+        QName portname = this.portComponentRef.get(serviceendpointClass.getName());
         if (portname != null) {
             return service.getPort(portname, serviceendpointClass);
         } else {

Modified: tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java?rev=833120&r1=833119&r2=833120&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java (original)
+++ tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java Thu Nov
 5 18:41:30 2009
@@ -31,7 +31,6 @@
 import java.util.Map;
 
 import javax.naming.Context;
-import javax.naming.InitialContext;
 import javax.naming.Name;
 import javax.naming.NamingException;
 import javax.naming.spi.ObjectFactory;
@@ -86,7 +85,7 @@
      * @param obj The reference object describing the webservice
      */
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-            Hashtable environment)
+            Hashtable<?,?> environment)
     throws Exception {
 
         if (obj instanceof ServiceRef) {
@@ -113,7 +112,8 @@
                 wsdlRefAddr = (String) tmp.getContent();
 
             // PortComponent
-            Hashtable portComponentRef = new Hashtable();
+            Hashtable<String,QName> portComponentRef =
+                new Hashtable<String,QName>();
 
             // Create QName object
             QName serviceQname = null;
@@ -129,7 +129,7 @@
                             serviceLocalPart);
                 }
             }
-            Class serviceInterfaceClass = null;
+            Class<?> serviceInterfaceClass = null;
 
             // Create service object
             if (serviceInterface == null) {
@@ -197,12 +197,12 @@
                     Definition def = reader.readWSDL((new URL(wsdlRefAddr)).toExternalForm());
 
                     javax.wsdl.Service wsdlservice = def.getService(serviceQname);
-                    Map ports = wsdlservice.getPorts();
+                    Map<String,?> ports = wsdlservice.getPorts();
                     Method m = serviceInterfaceClass.getMethod("setEndpointAddress",
                             new Class[] { java.lang.String.class,
                             java.lang.String.class });
-                    for (Iterator i = ports.keySet().iterator(); i.hasNext();) {
-                        String portName = (String) i.next();
+                    for (Iterator<String> i = ports.keySet().iterator(); i.hasNext();)
{
+                        String portName = i.next();
                         Port port = wsdlservice.getPort(portName);
                         String endpoint = getSOAPLocation(port);
                         m.invoke(service, new Object[] {port.getName(), endpoint });
@@ -234,16 +234,14 @@
             proxy.setPortComponentRef(portComponentRef);
 
             // Instantiate service with proxy class
-            Class[] interfaces = null;
-            Class[] serviceInterfaces = serviceInterfaceClass.getInterfaces();
-            if (serviceInterfaceClass != null) {
-                interfaces = new Class[serviceInterfaces.length + 1];
-                for (int i = 0; i < serviceInterfaces.length; i++) {
-                    interfaces[i] = serviceInterfaces[i];
-                }
-            } else {
-                interfaces = new Class[1];
+            Class<?>[] interfaces = null;
+            Class<?>[] serviceInterfaces = serviceInterfaceClass.getInterfaces();
+
+            interfaces = new Class[serviceInterfaces.length + 1];
+            for (int i = 0; i < serviceInterfaces.length; i++) {
+                interfaces[i] = serviceInterfaces[i];
             }
+
             interfaces[interfaces.length - 1] = javax.xml.rpc.Service.class;
             Object proxyInstance = null;
             try {
@@ -256,7 +254,7 @@
             if (((ServiceRef) ref).getHandlersSize() > 0) {
 
                 HandlerRegistry handlerRegistry = service.getHandlerRegistry();
-                ArrayList soaproles = new ArrayList();
+                ArrayList<String> soaproles = new ArrayList<String>();
 
                 while (((ServiceRef) ref).getHandlersSize() > 0) {
                     HandlerRef handler = ((ServiceRef) ref).getHandler();
@@ -266,7 +264,7 @@
                     tmp = handler.get(HandlerRef.HANDLER_CLASS);
                     if ((tmp == null) || (tmp.getContent() == null))
                         break;
-                    Class handlerClass = null;
+                    Class<?> handlerClass = null;
                     try {
                         handlerClass = tcl.loadClass((String) tmp.getContent());
                     } catch(ClassNotFoundException e) {
@@ -275,9 +273,9 @@
 
                     // Load all datas relative to the handler : SOAPHeaders, config init
element,
                     // portNames to be set on
-                    ArrayList headers = new ArrayList();
-                    Hashtable config = new Hashtable();
-                    ArrayList portNames = new ArrayList();
+                    ArrayList<QName> headers = new ArrayList<QName>();
+                    Hashtable<String,String> config = new Hashtable<String,String>();
+                    ArrayList<String> portNames = new ArrayList<String>();
                     for (int i = 0; i < handler.size(); i++)
                         if (HandlerRef.HANDLER_LOCALPART.equals(handler.get(i).getType()))
{
                             String localpart = "";
@@ -310,18 +308,18 @@
 
                     // Set the handlers informations
                     handlerref.setHandlerClass(handlerClass);
-                    handlerref.setHeaders((QName []) headers.toArray(new QName[headers.size()]));
+                    handlerref.setHeaders(headers.toArray(new QName[headers.size()]));
                     handlerref.setHandlerConfig(config);
 
                     if (!portNames.isEmpty()) {
-                        Iterator iter = portNames.iterator();
+                        Iterator<String> iter = portNames.iterator();
                         while (iter.hasNext())
-                            initHandlerChain(new QName((String) iter.next()), handlerRegistry,
+                            initHandlerChain(new QName(iter.next()), handlerRegistry,
                                     handlerref, soaproles);
                     } else {
-                        Enumeration e = portComponentRef.elements();
+                        Enumeration<QName> e = portComponentRef.elements();
                         while(e.hasMoreElements())
-                            initHandlerChain((QName) e.nextElement(), handlerRegistry,
+                            initHandlerChain(e.nextElement(), handlerRegistry,
                                     handlerref, soaproles);
                     }
                 }
@@ -341,9 +339,10 @@
      */
     private String getSOAPLocation(Port port) {
         String endpoint = null;
-        List extensions = port.getExtensibilityElements();
-        for (Iterator i = extensions.iterator(); i.hasNext();) {
-            ExtensibilityElement ext = (ExtensibilityElement) i.next();
+        List<ExtensibilityElement> extensions = port.getExtensibilityElements();
+        for (Iterator<ExtensibilityElement> i = extensions.iterator();
+                i.hasNext();) {
+            ExtensibilityElement ext = i.next();
             if (ext instanceof SOAPAddress) {
                 SOAPAddress addr = (SOAPAddress) ext;
                 endpoint = addr.getLocationURI();
@@ -354,7 +353,7 @@
 
 
     private void initHandlerChain(QName portName, HandlerRegistry handlerRegistry,
-            HandlerInfo handlerref, ArrayList soaprolesToAdd) {
+            HandlerInfo handlerref, ArrayList<String> soaprolesToAdd) {
         HandlerChain handlerList = (HandlerChain) handlerRegistry.getHandlerChain(portName);
         handlerList.add(handlerref);
         String[] soaprolesRegistered = handlerList.getRoles();
@@ -363,7 +362,7 @@
         for (i = 0;i < soaprolesRegistered.length; i++)
             soaproles[i] = soaprolesRegistered[i];
         for (int j = 0; j < soaprolesToAdd.size(); j++)
-            soaproles[i+j] = (String) soaprolesToAdd.get(j);
+            soaproles[i+j] = soaprolesToAdd.get(j);
         handlerList.setRoles(soaproles);
         handlerRegistry.setHandlerChain(portName, handlerList);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message