axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject cvs commit: xml-axis-wsif/java/src/org/apache/wsif/catalog Messages.properties
Date Tue, 23 Jul 2002 15:19:59 GMT
antelder    2002/07/23 08:19:59

  Modified:    java/src/org/apache/wsif/base WSIFServiceImpl.java
               java/src/org/apache/wsif/catalog Messages.properties
  Log:
  Change the mechanism used to locate the pluggable providers so that it does not use the
sun.misc.Service class.
  
  Revision  Changes    Path
  1.14      +63 -25    xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java
  
  Index: WSIFServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- WSIFServiceImpl.java	19 Jul 2002 15:46:29 -0000	1.13
  +++ WSIFServiceImpl.java	23 Jul 2002 15:19:59 -0000	1.14
  @@ -57,6 +57,7 @@
   
   package org.apache.wsif.base;
   
  +import java.io.IOException;
   import java.security.AccessController;
   import java.security.PrivilegedAction;
   import java.util.ArrayList;
  @@ -66,6 +67,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Properties;
   import java.util.Vector;
   
   import javax.wsdl.Binding;
  @@ -93,7 +95,6 @@
   import org.apache.wsif.WSIFMessageFactory;
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.WSIFService;
  -import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.compiler.schema.tools.Schema2Java;
   import org.apache.wsif.compiler.util.TypeMapping;
   import org.apache.wsif.compiler.util.Utils;
  @@ -136,8 +137,9 @@
       private WSIFDynamicTypeMap typeMap = new WSIFDynamicTypeMap();
       private boolean typeMapInitialised = false;
       private String preferredPort = null;
  -    private static final Class WSIF_DYNAMIC_PROVIDER_CLASS =
  -        org.apache.wsif.spi.WSIFProvider.class;
  +    public static final String PLUGABLE_PROVIDER_FILENAME = 
  +       "META-INF/services/org.apache.wsif.spi.WSIFProvider";
  +
       private Port chosenPort = null;
   
       /**
  @@ -595,29 +597,65 @@
        * @return    an array of WSIFProvider.
        */
       private static WSIFProvider[] getAllDynamicWSIFProviders() {
  +       if (!autoLoadProviders) {
  +          return new WSIFProvider[0];
  +       }
  +
  +       ArrayList al = (ArrayList) AccessController.doPrivileged(
  +          new PrivilegedAction() {
  +             public Object run() {
  +                return findPlugableProviders();
  +             }
  +          } );
  +          
  +       return (WSIFProvider[]) al.toArray( new WSIFProvider[al.size()] );
  +    }
  +
  +    private static ArrayList findPlugableProviders() {
  +       Class c;
  +       Object o;
  +       String className;
  +       ArrayList providers = new ArrayList();
  +
  +       ClassLoader loader = Thread.currentThread().getContextClassLoader();
  +       Properties p = new Properties();
  +       try {
  +          p.load( loader.getResourceAsStream( PLUGABLE_PROVIDER_FILENAME ) );
  +       } catch (Exception ex) {
  +          Trc.exception( ex );
  +          MessageLogger.log(
  +             "WSIF.0003W",
  +             "an error occured reading META-INF file: " + ex.getMessage() );
  +          return providers;
  +       }
  +       
  +       for (Iterator i=p.keySet().iterator(); i.hasNext(); ) {
  +          className = (String) i.next();
  +          try {
  +             c = Class.forName( className, true, loader );
  +             o = c.newInstance();
  +             if (o instanceof org.apache.wsif.spi.WSIFProvider) {
  +                providers.add( o );
  +             } else {
  +                MessageLogger.log(
  +                   "WSIF.0003W",
  +             	   "The provider class specified," + 
  +                   ( (o == null) ? null : o.getClass().getName() ) +
  +                   ", does not implement org.apache.wsif.spi.WSIFProvider" );
  +             }
  +          } catch (ClassNotFoundException ex) {
  +             MessageLogger.log(
  +                "WSIF.0003W",
  +                "cannot find class - " + ex.getMessage() );
  +          } catch (Exception ex) {
  +             Trc.exception( ex );
  +             MessageLogger.log(
  +                "WSIF.0003W",
  +                "an error occured instantiating class - " + ex.getMessage() );
  +          }
  +       }
   
  -        if (!autoLoadProviders) {
  -            return new WSIFProvider[0];
  -        }
  -
  -        ArrayList al =
  -            (ArrayList) AccessController.doPrivileged(new PrivilegedAction() {
  -            public Object run() {
  -                Iterator ps = sun.misc.Service.providers(WSIF_DYNAMIC_PROVIDER_CLASS);
  -                ArrayList al2 = new ArrayList();
  -                while (ps.hasNext()) {
  -                    Object obj = ps.next();
  -                    if (obj instanceof org.apache.wsif.spi.WSIFProvider)
  -                        al2.add(obj);
  -                    else
  -                        MessageLogger.log(
  -                            "WSIF.0003W",
  -                            (obj == null) ? null : obj.getClass().getName());
  -                }
  -                return al2;
  -            }
  -        });
  -        return (WSIFProvider[]) al.toArray(new WSIFProvider[al.size()]);
  +       return providers;
       }
   
       /**
  
  
  
  1.4       +5 -5      xml-axis-wsif/java/src/org/apache/wsif/catalog/Messages.properties
  
  Index: Messages.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/catalog/Messages.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Messages.properties	17 Jul 2002 13:13:45 -0000	1.3
  +++ Messages.properties	23 Jul 2002 15:19:59 -0000	1.4
  @@ -9,11 +9,11 @@
   # User Action:     Check that the location of the WSDL file is correct. Check that any
network connections required are available. 
   #                  Check that the WSDL file contains valid WSDL. 
   
  -WSIF.0003W=WSIF0003W: Invalid WSIF provider class found. The provider class specified,
{0}, does not implement org.apache.wsif.spi.WSIFProvider  
  -# Parameter(s):    {0} the class name of the provider found
  -# Description:     A provider class specified in a META-INF/services/org.apache.wsif.spi.WSIFProvider
file on the classpath is not an instance of org.apache.wsif.spi.WSIFProvider
  -# User Action:     Verify that all provider classes specified in META-INF/services/org.apache.wsif.spi.WSIFProvider
files on the classpath, implement org.apache.wsif.spi.WSIFProvider.
  -#                  Remove any that do not implement org.apache.wsif.spi.WSIFProvider
  +WSIF.0003W=WSIF0003W: An error occured finding plugagble providers: {0}  
  +# Parameter(s):    {0} specific details about the error
  +# Description:     There was a problem locating a WSIF pluggable provider using the J2SE
1.3 JAR file extensions to support service providers architecture. The WSIF trace file will
contain the full exception details.
  +# User Action:     Verify that a META-INF/services/org.apache.wsif.spi.WSIFProvider file
exists in a provider jar, that each class referenced in the META-INF file exists in the classpath,
and that each class implements org.apache.wsif.spi.WSIFProvider.
  +#                  The class in error will be ignored and WSIF will continue locating other
pluggable providers.
    
   WSIF.0004E=WSIF0004E: WSDL contains an operation type ''{0}'' which is not supported for
''{1}'' 
   # Parameter(s):    {0} name of the operation type specified 
  
  
  

Mime
View raw message