axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ow...@apache.org
Subject cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers/jms WSIFDynamicProvider_Jms.java
Date Tue, 09 Jul 2002 09:44:09 GMT
owenb       2002/07/09 02:44:09

  Modified:    java/src/org/apache/wsif/providers/ejb
                        WSIFDynamicProvider_EJB.java
               java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFDynamicProvider_ApacheAxis.java
               java/src/org/apache/wsif/providers/soap/apachesoap
                        WSIFDynamicProvider_ApacheSOAP.java
               java/src/org/apache/wsif/providers/jms
                        WSIFDynamicProvider_Jms.java
  Log:
  - Added caching of supported binding and address namespaces
  - Changed from using ClassLoader.loadClass to Class.forName and wrapped calls
    in doPrivilege blocks
  
  Revision  Changes    Path
  1.3       +60 -25    xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFDynamicProvider_EJB.java
  
  Index: WSIFDynamicProvider_EJB.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFDynamicProvider_EJB.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFDynamicProvider_EJB.java	27 Jun 2002 10:44:48 -0000	1.2
  +++ WSIFDynamicProvider_EJB.java	9 Jul 2002 09:44:09 -0000	1.3
  @@ -57,6 +57,8 @@
   
   package org.apache.wsif.providers.ejb;
   
  +import java.security.AccessController;
  +import java.security.PrivilegedAction;
   import java.util.Iterator;
   import java.util.List;
   
  @@ -64,6 +66,7 @@
   import javax.wsdl.Definition;
   import javax.wsdl.Port;
   import javax.wsdl.Service;
  +
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.logging.Tr;
  @@ -83,9 +86,19 @@
   public class WSIFDynamicProvider_EJB implements WSIFProvider {
   
       private static final String ejb = "http://schemas.xmlsoap.org/wsdl/ejb/";
  +    private static String[] bindings = new String[0];
  +    private static String[] addresses = new String[0];
  +    private static boolean setUpBindings = false;
  +    private static boolean setUpAddresses = false;    
   
       public WSIFDynamicProvider_EJB() {
           Tr.entry(this);
  +        if (!setUpBindings) {
  +            setUpBindingNamespaceURIs();
  +        }
  +        if (!setUpAddresses) {
  +            setUpAddressNamespaceURIs();
  +        }        
           Tr.exit();
       }
   
  @@ -125,19 +138,8 @@
        */
       public String[] getBindingNamespaceURIs() {
           Tr.entry(this);
  -        // check if the ejb classes are available if not then we cannot
  -        // support ejb bindings!        
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("javax.ejb.EJBHome");
  -            String[] bindings = new String[] { ejb };
  -            Tr.exit(bindings);
  -            return bindings;
  -        } catch (ClassNotFoundException e) {
  -        	Tr.exception(e);
  -            Tr.exit(new String[0]);
  -            return new String[0];
  -        }
  +        Tr.exit(bindings);
  +        return bindings;
       }
   
       /**
  @@ -146,19 +148,52 @@
        */
       public String[] getAddressNamespaceURIs() {
           Tr.entry(this);
  -        // check if the ejb classes are available if not then we cannot
  -        // support ejb addresses!        
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("javax.ejb.EJBHome");
  -            String[] addresses = new String[] { ejb };
  -            Tr.exit(addresses);
  -            return addresses;
  -        } catch (ClassNotFoundException e) {
  -        	Tr.exception(e);
  -            Tr.exit(new String[0]);
  -            return new String[0];
  +        Tr.exit(addresses);
  +        return addresses;
  +    }
  +
  +    private void setUpBindingNamespaceURIs() {
  +        // check if the ejb classes are available, if not then we cannot
  +        // support ejb bindings!        
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "javax.ejb.EJBHome",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls != null) {
  +            bindings = new String[] { ejb };
           }
  +        setUpBindings = true;
       }
   
  +    private void setUpAddressNamespaceURIs() {
  +        // check if the ejb classes are available, if not then we cannot
  +        // support ejb addresses!        
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "javax.ejb.EJBHome",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +                
  +        if (cls != null) {
  +            addresses = new String[] { ejb };
  +        }
  +        setUpAddresses = true;
  +    }
   }
  
  
  
  1.3       +82 -35    xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFDynamicProvider_ApacheAxis.java
  
  Index: WSIFDynamicProvider_ApacheAxis.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFDynamicProvider_ApacheAxis.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFDynamicProvider_ApacheAxis.java	12 Jun 2002 10:27:25 -0000	1.2
  +++ WSIFDynamicProvider_ApacheAxis.java	9 Jul 2002 09:44:09 -0000	1.3
  @@ -57,6 +57,8 @@
   
   package org.apache.wsif.providers.soap.apacheaxis;
   
  +import java.security.AccessController;
  +import java.security.PrivilegedAction;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Vector;
  @@ -66,6 +68,7 @@
   import javax.wsdl.Port;
   import javax.wsdl.Service;
   import javax.wsdl.extensions.soap.SOAPBinding;
  +
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.base.WSIFServiceImpl;
  @@ -82,9 +85,19 @@
   public class WSIFDynamicProvider_ApacheAxis implements WSIFProvider {
       private static final String soap = "http://schemas.xmlsoap.org/wsdl/soap/";
       private static final String jms = "http://schemas.xmlsoap.org/wsdl/jms/";
  +    private static String[] bindings = new String[0];
  +    private static String[] addresses = new String[0];
  +    private static boolean setUpBindings = false;
  +    private static boolean setUpAddresses = false;
   
       public WSIFDynamicProvider_ApacheAxis() {
           Tr.entry(this);
  +        if (!setUpBindings) {
  +            setUpBindingNamespaceURIs();
  +        }
  +        if (!setUpAddresses) {
  +            setUpAddressNamespaceURIs();
  +        }        
           WSIFServiceImpl.addExtensionRegistry(
               new org.apache.wsif.wsdl.extensions.jms.JMSExtensionRegistry());
           Tr.exit();
  @@ -115,24 +128,12 @@
   
       /**
        * Returns the WSDL namespace URIs of any bindings this provider supports.
  -     * To make this provider dependent on the Aixs jar being available in the
  -     * classpath this attempts to load an Axis class and will return an string
  -     * array with no elements if an Axis class cannot be loaded.
  +     * @return an array of all binding namespaces supported by this provider
        */
       public String[] getBindingNamespaceURIs() {
           Tr.entry(this);
  -        // check if the axis classes are available if not then we cannot
  -        // support soap bindings!        
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("org.apache.axis.AxisEngine");
  -            String[] bindings = new String[] { soap };
  -            Tr.exit(bindings);
  -            return bindings;
  -        } catch (ClassNotFoundException e) {
  -            Tr.exit(new String[0]);
  -            return new String[0];
  -        }
  +        Tr.exit(bindings);
  +        return bindings;
       }
   
       /**
  @@ -141,30 +142,76 @@
        */
       public String[] getAddressNamespaceURIs() {
           Tr.entry(this);
  -        Vector v = new Vector();
  -        // check if the jms classes are available if not then we cannot
  -        // support jms addresses!
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("javax.jms.Queue");
  -            v.add(jms);
  -        } catch (ClassNotFoundException e) {
  -            // ignore
  +        Tr.exit(addresses);
  +        return addresses;
  +    }
  +
  +    private void setUpBindingNamespaceURIs() {
  +        // check if the axis classes are available, if not then we cannot
  +        // support soap bindings!        
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "org.apache.axis.AxisEngine",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls != null) {
  +            bindings = new String[] { soap };
           }
  -        // check if the axis classes are available if not then we cannot
  -        // support soap addresses!
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("org.apache.axis.AxisEngine");
  -            v.add(soap);
  -        } catch (ClassNotFoundException e) {
  -            // ignore            
  +        setUpBindings = true;
  +    }
  +
  +    private void setUpAddressNamespaceURIs() {
  +        Vector v = new Vector();
  +        // check if the jms classes are available, if not then we cannot
  +        // support jms addresses!        
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "javax.jms.Queue",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls != null) {
  +        	v.add(jms);
           }
  -        String[] addresses = new String[v.size()];
  +                        
  +        // check if the axis classes are available, if not then we cannot
  +        // support soap addresses!         
  +        Class cls2 =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "org.apache.axis.AxisEngine",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls2 != null) {
  +        	v.add(soap);
  +        }         
  +        addresses = null;
  +        addresses = new String[v.size()];
           for (int i = 0; i < v.size(); i++) {
               addresses[i] = (String) v.elementAt(i);
           }
  -        Tr.exit(addresses);
  -        return addresses;
  +        setUpAddresses = true;
       }
   }
  
  
  
  1.3       +86 -32    xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFDynamicProvider_ApacheSOAP.java
  
  Index: WSIFDynamicProvider_ApacheSOAP.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFDynamicProvider_ApacheSOAP.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFDynamicProvider_ApacheSOAP.java	12 Jun 2002 10:27:25 -0000	1.2
  +++ WSIFDynamicProvider_ApacheSOAP.java	9 Jul 2002 09:44:09 -0000	1.3
  @@ -57,6 +57,8 @@
   
   package org.apache.wsif.providers.soap.apachesoap;
   
  +import java.security.AccessController;
  +import java.security.PrivilegedAction;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Vector;
  @@ -66,6 +68,7 @@
   import javax.wsdl.Port;
   import javax.wsdl.Service;
   import javax.wsdl.extensions.soap.SOAPBinding;
  +
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.base.WSIFServiceImpl;
  @@ -88,14 +91,24 @@
   
       private static final String soap = "http://schemas.xmlsoap.org/wsdl/soap/";
       private static final String jms = "http://schemas.xmlsoap.org/wsdl/jms/";
  +    private static String[] bindings = new String[0];
  +    private static String[] addresses = new String[0];
  +    private static boolean setUpBindings = false;
  +    private static boolean setUpAddresses = false;
   
       public WSIFDynamicProvider_ApacheSOAP() {
           Tr.entry(this);
  +        if (!setUpBindings) {
  +            setUpBindingNamespaceURIs();
  +        }
  +        if (!setUpAddresses) {
  +            setUpAddressNamespaceURIs();
  +        }
           WSIFServiceImpl.addExtensionRegistry(
               new org.apache.wsif.wsdl.extensions.jms.JMSExtensionRegistry());
           Tr.exit();
       }
  -    
  +
       /**
        * Check if WSDL port has SOAP binding and if successful try
        * to create ApacheSOAP port instance.
  @@ -116,7 +129,12 @@
               if (o instanceof SOAPBinding) {
                   // if so try to create ApacheSOAP dynamic port instance
                   WSIFPort wp =
  -                    new WSIFPort_ApacheSOAP(def, service, port, typeMap, partSerializerName);
  +                    new WSIFPort_ApacheSOAP(
  +                        def,
  +                        service,
  +                        port,
  +                        typeMap,
  +                        partSerializerName);
                   Tr.exit(wp);
                   return wp;
               }
  @@ -153,18 +171,8 @@
        */
       public String[] getBindingNamespaceURIs() {
           Tr.entry(this);
  -        // check if the soap classes are available if not then we cannot
  -        // support soap bindings!        
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("org.apache.soap.Constants");
  -            String[] bindings = new String[] { soap };
  -            Tr.exit(bindings);
  -            return bindings;
  -        } catch (ClassNotFoundException e) {
  -            Tr.exit(new String[0]);
  -            return new String[0];
  -        }
  +        Tr.exit(bindings);
  +        return bindings;
       }
   
       /**
  @@ -173,30 +181,76 @@
        */
       public String[] getAddressNamespaceURIs() {
           Tr.entry(this);
  +        Tr.exit(addresses);
  +        return addresses;
  +    }
  +
  +    private void setUpBindingNamespaceURIs() {
  +        // check if the soap classes are available, if not then we cannot
  +        // support soap bindings!        
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "org.apache.soap.Constants",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls != null) {
  +            bindings = new String[] { soap };
  +        }
  +        setUpBindings = true;
  +    }
  +
  +    private void setUpAddressNamespaceURIs() {
           Vector v = new Vector();
  -        // check if the jms classes are available if not then we cannot
  +        // check if the jms classes are available, if not then we cannot
           // support jms addresses!        
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("javax.jms.Queue");
  -            v.add(jms);
  -        } catch (ClassNotFoundException e) {
  -            // ignore
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "javax.jms.Queue",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls != null) {
  +        	v.add(jms);
           }
  -        // check if the soap classes are available if not then we cannot
  +                        
  +        // check if the soap classes are available, if not then we cannot
           // support soap addresses!         
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("org.apache.soap.Constants");
  -            v.add(soap);
  -        } catch (ClassNotFoundException e) {
  -            // ignore            
  -        }
  -        String[] addresses = new String[v.size()];
  +        Class cls2 =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "org.apache.soap.Constants",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls2 != null) {
  +        	v.add(soap);
  +        }         
  +        addresses = null;
  +        addresses = new String[v.size()];
           for (int i = 0; i < v.size(); i++) {
               addresses[i] = (String) v.elementAt(i);
           }
  -        Tr.exit(addresses);
  -        return addresses;
  +        setUpAddresses = true;
       }
   }
  
  
  
  1.3       +60 -22    xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFDynamicProvider_Jms.java
  
  Index: WSIFDynamicProvider_Jms.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFDynamicProvider_Jms.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFDynamicProvider_Jms.java	12 Jun 2002 10:27:23 -0000	1.2
  +++ WSIFDynamicProvider_Jms.java	9 Jul 2002 09:44:09 -0000	1.3
  @@ -57,6 +57,8 @@
   
   package org.apache.wsif.providers.jms;
   
  +import java.security.AccessController;
  +import java.security.PrivilegedAction;
   import java.util.Iterator;
   import java.util.List;
   
  @@ -64,6 +66,7 @@
   import javax.wsdl.Definition;
   import javax.wsdl.Port;
   import javax.wsdl.Service;
  +
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.base.WSIFServiceImpl;
  @@ -80,9 +83,19 @@
   public class WSIFDynamicProvider_Jms implements WSIFProvider {
   
       private static final String jms = "http://schemas.xmlsoap.org/wsdl/jms/";
  +    private static String[] bindings = new String[0];
  +    private static String[] addresses = new String[0];
  +    private static boolean setUpBindings = false;
  +    private static boolean setUpAddresses = false;
   
       public WSIFDynamicProvider_Jms() {
           Tr.entry(this);
  +        if (!setUpBindings) {
  +            setUpBindingNamespaceURIs();
  +        }
  +        if (!setUpAddresses) {
  +            setUpAddressNamespaceURIs();
  +        }        
           // FormatExtensionRegistry is provided by default
           WSIFServiceImpl.addExtensionRegistry(
               new org.apache.wsif.wsdl.extensions.jms.JMSExtensionRegistry());
  @@ -126,18 +139,8 @@
        */
       public String[] getBindingNamespaceURIs() {
           Tr.entry(this);
  -        // check if the jms classes are available if not then we cannot
  -        // support jms bindings!
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("javax.jms.Queue");
  -            String[] bindings = new String[] { jms };
  -            Tr.exit(bindings);
  -            return bindings;
  -        } catch (ClassNotFoundException e) {
  -            Tr.exit(new String[0]);
  -            return new String[0];
  -        }
  +        Tr.exit(bindings);
  +        return bindings;
       }
   
       /**
  @@ -146,17 +149,52 @@
        */
       public String[] getAddressNamespaceURIs() {
           Tr.entry(this);
  -        // check if the jms classes are available if not then we cannot
  +        Tr.exit(addresses);
  +        return addresses;
  +    }
  +
  +    private void setUpBindingNamespaceURIs() {
  +        // check if the jms classes are available, if not then we cannot
  +        // support jms bindings!        
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "javax.jms.Queue",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +        if (cls != null) {
  +            bindings = new String[] { jms };
  +        }
  +        setUpBindings = true;
  +    }
  +
  +    private void setUpAddressNamespaceURIs() {
  +        // check if the jms classes are available, if not then we cannot
           // support jms addresses!        
  -        try {
  -            ClassLoader cl = this.getClass().getClassLoader();
  -            cl.loadClass("javax.jms.Queue");
  -            String[] addresses = new String[] { jms };
  -            Tr.exit(addresses);
  -            return addresses;
  -        } catch (ClassNotFoundException e) {
  -            Tr.exit(new String[0]);
  -            return new String[0];
  +        Class cls =
  +            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +            public Object run() {
  +                try {
  +                    return Class.forName(
  +                        "javax.jms.Queue",
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
  +                } catch (Throwable ignored) {
  +                }
  +                return null;
  +            }
  +        });
  +                
  +        if (cls != null) {
  +            addresses = new String[] { jms };
           }
  +        setUpAddresses = true;
       }
   }
  
  
  

Mime
View raw message