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/base WSIFServiceImpl.java
Date Thu, 25 Jul 2002 16:40:57 GMT
antelder    2002/07/25 09:40:57

  Modified:    java/src/org/apache/wsif/base WSIFServiceImpl.java
  Log:
  Fix plugable provider support to correctly choose the default soap provider
  
  Revision  Changes    Path
  1.17      +48 -23    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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- WSIFServiceImpl.java	25 Jul 2002 14:12:41 -0000	1.16
  +++ WSIFServiceImpl.java	25 Jul 2002 16:40:57 -0000	1.17
  @@ -57,6 +57,9 @@
   
   package org.apache.wsif.base;
   
  +import java.io.BufferedReader;
  +import java.io.IOException;
  +import java.io.InputStreamReader;
   import java.net.URL;
   import java.security.AccessController;
   import java.security.PrivilegedAction;
  @@ -67,7 +70,6 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  -import java.util.Properties;
   import java.util.Vector;
   
   import javax.wsdl.Binding;
  @@ -617,17 +619,16 @@
       }
   
       private static ArrayList findPlugableProviders() {
  -       URL u;
  -       Class c;
          Object o;
  -       String className;
  +       ArrayList classNames = new ArrayList();
          ArrayList providers = new ArrayList();
   
  +       // find all the class names mentioned in all the META-INF files
          ClassLoader loader = Thread.currentThread().getContextClassLoader();
  -       Properties p = new Properties();
  -   	   Enumeration e;
          try {
  -       	  e = loader.getResources( PLUGABLE_PROVIDER_FILENAME ); 
  +       	  for(Enumeration e = loader.getResources( PLUGABLE_PROVIDER_FILENAME ); e.hasMoreElements();
) {
  +             classNames.addAll( readMETAINFClassNames( (URL) e.nextElement() ) );
  +       	  } 
          } catch (Exception ex) {
             Trc.exception( ex );
             MessageLogger.log(
  @@ -636,23 +637,10 @@
             return providers;
          }
   
  -   	   while ( e.hasMoreElements() ) {
  +       // instantiate a provider for each of the named classes
  +       for (Iterator i=classNames.iterator(); i.hasNext(); ) {
             try {
  -             u = (URL) e.nextElement();
  -             p.load( u.openStream() );
  -          } catch (Exception ex) {
  -             Trc.exception( ex );
  -             MessageLogger.log(
  -                "WSIF.0003W",
  -                "an error occured reading META-INF file: " + ex.getMessage() );
  -          }
  -       }
  -
  -       for (Iterator i=p.keySet().iterator(); i.hasNext(); ) {
  -          className = (String) i.next();
  -          try {
  -             c = Class.forName( className, true, loader );
  -             o = c.newInstance();
  +             o = Class.forName( (String) i.next(), true, loader ).newInstance();
                if (o instanceof org.apache.wsif.spi.WSIFProvider) {
                   providers.add( o );
                } else {
  @@ -675,6 +663,43 @@
          }
   
          return providers;
  +    }
  +
  +    private static ArrayList readMETAINFClassNames(URL u) {
  +        ArrayList classNames = new ArrayList();
  +	    BufferedReader in = null;
  +        String inputLine;
  +        int i;
  +    	try {
  +	       in = new BufferedReader( new InputStreamReader( u.openStream() ) );
  +	       while ((inputLine = in.readLine()) != null) {
  +              i = inputLine.indexOf('#');
  +              if(i >= 0) {
  +                 inputLine = inputLine.substring(0, i);
  +              }
  +              inputLine = inputLine.trim();
  +              if (inputLine.length() > 0 ) {
  +                 classNames.add( inputLine );
  +              }
  +	       }
  +    	} catch (IOException ex) {
  +           Trc.exception( ex );
  +           MessageLogger.log(
  +              "WSIF.0003W",
  +              "an error occured reading META-INF '" + u + "' file: " + ex.getMessage()
);
  +    	} finally {
  +    		if ( in != null ) {
  +    		   try {
  +    		      in.close();
  +    		   } catch (IOException ex) {
  +                  Trc.exception( ex );
  +                  MessageLogger.log(
  +                     "WSIF.0003W",
  +                     "an error occured closing META-INF '" + u + "' file: " + ex.getMessage()
);
  +    		   }
  +    		}
  +    	}
  +    	return classNames; 
       }
   
       /**
  
  
  

Mime
View raw message