cvs commit: xml-soap/java/src/org/apache/soap/server DefaultConfigManager.java ServiceManager.java XMLConfigManager.java

[email protected]
Newsgroups gmane.text.xml.soap.devel
Message-ID <[email protected]>
snichol     2003/06/20 22:24:08

  Modified:    java/src/org/apache/soap/server DefaultConfigManager.java
                        ServiceManager.java XMLConfigManager.java
  Log:
  Distinguish between the inability to open a config file ("assume fresh
  start") and the inability to read its contents (throw exception).  For
  SOAPException, chain original exception.
  
  Revision  Changes    Path
  1.9       +17 -7     xml-soap/java/src/org/apache/soap/server/DefaultConfigManager.java
  
  Index: DefaultConfigManager.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/DefaultConfigManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultConfigManager.java	6 Apr 2001 13:03:51 -0000	1.8
  +++ DefaultConfigManager.java	21 Jun 2003 05:24:08 -0000	1.9
  @@ -72,6 +72,7 @@
    *
    * @author Dug ([email protected])
    * @author <a href="mailto:[email protected]">Magnus Thor Torfason</a>
  + * @author Scott Nichol ([email protected])
    *
    * With the introduction of a ConfigManager, the notion of a SOAP
    * configuration file was also introduced.  The SOAP server will now
  @@ -118,19 +119,28 @@
      */
     public void loadRegistry() throws SOAPException {
       // load in a serialized thing
  +    ObjectInputStream is;
       dds = null ;
       try {
         File file = ServerHTTPUtils.getFileFromNameAndContext(filename,
                                                               context);
         FileInputStream fis = new FileInputStream (file);
  -      ObjectInputStream is = new ObjectInputStream (fis);
  -
  -      dds = (Hashtable) is.readObject ();
  -      is.close ();
  +      is = new ObjectInputStream (fis);
       } catch(Exception e) {
         dds = new Hashtable ();
         System.err.println ("SOAP Service Manager: Unable to read '" +
                             filename +  "': assuming fresh start");
  +      return;
  +    }
  +    
  +    try {
  +      dds = (Hashtable) is.readObject ();
  +      is.close ();
  +    } catch (Exception e) {
  +      dds = new Hashtable ();
  +      throw new SOAPException(Constants.FAULT_CODE_SERVER,
  +        "Error loading services registry from '" + filename + "': "
  +        + e.getMessage(), e);
       }
     }
   
  @@ -150,7 +160,7 @@
       } catch (Exception e) {
         throw new SOAPException (Constants.FAULT_CODE_SERVER,
                                  "Error saving services registry: " +
  -                               e.getMessage ());
  -    };
  +                               e.getMessage (), e);
  +    }
     }
  -};
  +}
  
  
  
  1.20      +1 -0      xml-soap/java/src/org/apache/soap/server/ServiceManager.java
  
  Index: ServiceManager.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/ServiceManager.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ServiceManager.java	21 Nov 2002 16:36:57 -0000	1.19
  +++ ServiceManager.java	21 Jun 2003 05:24:08 -0000	1.20
  @@ -242,6 +242,7 @@
         configMgr.init();
       }
       catch( SOAPException e ) {
  +      // TODO: also propagate the exception so that the client sees a fault
         e.printStackTrace();
       }
     }
  
  
  
  1.5       +20 -14    xml-soap/java/src/org/apache/soap/server/XMLConfigManager.java
  
  Index: XMLConfigManager.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/XMLConfigManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLConfigManager.java	21 Nov 2002 16:36:57 -0000	1.4
  +++ XMLConfigManager.java	21 Jun 2003 05:24:08 -0000	1.5
  @@ -81,6 +81,7 @@
    * An <code>XMLConfigManager</code> ...
    *
    * @author <a href="mailto:[email protected]">Magnus Thor Torfason</a>
  + * @author Scott Nichol ([email protected])
    *
    * This class should be almost identical in function to the
    * DefaultConfigManager.
  @@ -118,22 +119,27 @@
      * should be represented as a list of deployment descriptor elements.
      */
     public void loadRegistry() throws SOAPException {
  +    FileReader rd;
       dds = null ;
  +
       try {
         File file = ServerHTTPUtils.getFileFromNameAndContext(filename,
           context);
  -      FileReader rd = new FileReader (file);
  +      rd = new FileReader (file);
  +    } catch(Exception e) {
  +      dds = new Hashtable ();
  +      System.err.println ("SOAP Service Manager: Unable to read '" +
  +        filename +  "': assuming fresh start");
  +      return;
  +    }
  +
  +    try {
         Document doc = null;
         Element root = null;
   
  -      try {
  -        doc  = XMLParserUtils.parse(rd);
  -        root = doc.getDocumentElement();
  -      } catch (Exception e) {
  -        e.printStackTrace();
  -        throw new SOAPException(Constants.FAULT_CODE_SERVER,e.getMessage());
  -      }
  -
  +      doc  = XMLParserUtils.parse(rd);
  +      rd.close();
  +      root = doc.getDocumentElement();
         NodeList deploymentElements = root.getElementsByTagNameNS(
                 Constants.NS_URI_XML_SOAP_DEPLOYMENT, "service");
   
  @@ -146,10 +152,11 @@
           String  id = dd.getID();
           dds.put( id, dd );
         }
  -    } catch(Exception e) {
  +    } catch (Exception e) {
         dds = new Hashtable ();
  -      System.err.println ("SOAP Service Manager: Unable to read '" +
  -        filename +  "': assuming fresh start");
  +      throw new SOAPException(Constants.FAULT_CODE_SERVER,
  +        "Error loading services registry from '" + filename + "': "
  +        + e.getMessage(), e);
       }
     }
   
  @@ -176,8 +183,7 @@
         pw.close ();
       } catch (Exception e) {
         throw new SOAPException (Constants.FAULT_CODE_SERVER,
  -        "Error saving services registry: " +
  -        e.getMessage ());
  +        "Error saving services registry: " + e.getMessage (), e);
       }
     }
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.