axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Daniels <gdani...@allaire.com>
Subject RE: cvs commit: xml-axis/java/src/org/apache/axis/utils Admin.jav a
Date Fri, 09 Mar 2001 00:28:52 GMT
Cool-o!

> -----Original Message-----
> From: dug@apache.org [mailto:dug@apache.org]
> Sent: Thursday, March 08, 2001 7:24 PM
> To: xml-axis-cvs@apache.org
> Subject: cvs commit: xml-axis/java/src/org/apache/axis/utils 
> Admin.java
> 
> 
> dug         01/03/08 16:24:08
> 
>   Modified:    java/src/org/apache/axis/client AdminClient.java
>                java/src/org/apache/axis/handlers 
> HTTPActionHandler.java
>                java/src/org/apache/axis/utils Admin.java
>   Log:
>   Add a list option to admin.
>   
>   Revision  Changes    Path
>   1.11      +35 -55    
> xml-axis/java/src/org/apache/axis/client/AdminClient.java
>   
>   Index: AdminClient.java
>   ===================================================================
>   RCS file: 
> /home/cvs/xml-axis/java/src/org/apache/axis/client/AdminClient.java,v
>   retrieving revision 1.10
>   retrieving revision 1.11
>   diff -u -r1.10 -r1.11
>   --- AdminClient.java	2001/02/21 01:07:21	1.10
>   +++ AdminClient.java	2001/03/09 00:24:01	1.11
>   @@ -59,6 +59,8 @@
>    import java.io.*;
>    import java.util.*;
>    
>   +import org.apache.axis.utils.Options ;
>   +
>    /**
>     *
>     * @author Doug Davis (dug@us.ibm.com)
>   @@ -71,74 +73,52 @@
>    
>    public class AdminClient {
>      public static void main(String args[]) {
>   +    try {
>   +      Options opts = new Options( args );
>    
>   -    String hdr = "POST /axis/servlet/AxisServlet HTTP/1.0\n" +
>   -                 "Host: localhost:8080\n" +
>   -                 "Content-Type: text/xml;charset=utf-8\n" +
>   -                 "SOAPAction: AdminService\n";
>   +      Debug.setDebugLevel( opts.isFlagSet('d') );
>    
>   -    String msg = null ;
>   +      args = opts.getRemainingArgs();
>    
>   -    try {
>   -      /* Parse the command line  */
>   -      /***************************/
>   -      String  host    = "localhost" ;
>   -      String  servlet = "/axis/servlet/AxisServlet" ;
>   -      int     port    = 8080 ;
>   +      if ( args == null ) {
>   +        System.err.println( "Usage: AdminClient xml-files 
> | list" );
>   +        System.exit(1);
>   +      }
>    
>          for ( int i = 0 ; i < args.length ; i++ ) {
>   -        if ( args[i].charAt(0) == '-' )
>   -          switch( args[i].toLowerCase().charAt(1) ) {
>   -            case 'd': Debug.incDebugLevel();
>   -                      break ;
>   -            case 'h': if ( args[i].length() > 2 )
>   -                        host = args[i].substring(2);
>   -                      break ;
>   -            case 'l': if ( args[i].length() > 2 ) {
>   -                        URL tmpurl = new URL(args[i].substring(2));
>   -                        host = tmpurl.getHost();
>   -                        port = tmpurl.getPort();
>   -                        servlet = tmpurl.getFile();
>   -                      }
>   -                      break ;
>   -            case 'p': if ( args[i].length() > 2 )
>   -                        port = 
> Integer.parseInt(args[i].substring(2));
>   -                      break ;
>   -            case 's': if ( args[i].length() > 2 )
>   -                        servlet = args[i].substring(2);
>   -                      if ( servlet != null && 
> servlet.charAt(0) != '/' )
>   -                        servlet = "/" + servlet ;
>   -                      break ;
>   -            default: System.err.println( "Unknown option '" +
>   -                                         args[i].charAt(1) + "'" );
>   -                     System.exit(1);
>   -          }
>   +        InputStream input = null ;
>   +
>   +        if ( args[i].equals("list") ) {
>   +          System.out.println( "Doing a list" );
>   +          String str = "<list/>" ;
>   +          input = new ByteArrayInputStream( str.getBytes() );
>   +        }
>            else {
>   -          InputStream    input = null ;
>   -          long           length ;
>   -        
>              System.out.println( "Processing file: " + args[i] );
>              input = new FileInputStream( args[i] );
>   -
>   -          String          url = "http://" + host + ":" + 
> port + servlet ;
>   -          HTTPMessage     hMsg       = new HTTPMessage( 
> url, "AdminService" );
>   -          MessageContext  msgContext = new MessageContext();
>   -          Message         inMsg      = new Message( input, 
> "InputStream" );
>   -          Message         outMsg     = null ;
>   -          msgContext.setRequestMessage( inMsg );
>   -
>   -          hMsg.invoke( msgContext );
>   -
>   -          outMsg = msgContext.getResponseMessage();
>   -          input.close();
>   -          System.err.println( outMsg.getAs( "String" ) );
>            }
>   +
>   +        HTTPMessage     hMsg       = new HTTPMessage( 
> opts.getURL(), 
>   +                                                      
> "AdminService" );
>   +        MessageContext  msgContext = new MessageContext();
>   +        Message         inMsg      = new Message( input, 
> "InputStream" );
>   +        Message         outMsg     = null ;
>   +        msgContext.setRequestMessage( inMsg );
>   +
>   +        if ( opts.isFlagSet('t') > 0 ) hMsg.doLocal = true ;
>   +        hMsg.setUserID( opts.getUser() );
>   +        hMsg.setPassword( opts.getPassword() );
>   +
>   +        hMsg.invoke( msgContext );
>   +
>   +        outMsg = msgContext.getResponseMessage();
>   +        input.close();
>   +        System.err.println( outMsg.getAs( "String" ) );
>          }
>        }
>        catch( Exception e ) {
>          System.err.println( e );
>          e.printStackTrace( System.err );
>        }
>   -  };
>   -
>   +  }
>    };
>   
>   
>   
>   1.8       +7 -1      
> xml-axis/java/src/org/apache/axis/handlers/HTTPActionHandler.java
>   
>   Index: HTTPActionHandler.java
>   ===================================================================
>   RCS file: 
> /home/cvs/xml-axis/java/src/org/apache/axis/handlers/HTTPActio
> nHandler.java,v
>   retrieving revision 1.7
>   retrieving revision 1.8
>   diff -u -r1.7 -r1.8
>   --- HTTPActionHandler.java	2001/03/08 16:45:20	1.7
>   +++ HTTPActionHandler.java	2001/03/09 00:24:04	1.8
>   @@ -87,7 +87,13 @@
>            String URL = req.getServletPath();
>            Debug.Print(3, "URL: " + URL );
>    
>   -        if ( URL.endsWith(".jws") ) {
>   +        String   opt     = (String) getOption("JWSProcessor");
>   +        boolean  skipJWS = false ;
>   +        if ( opt != null && (opt.equals("0") || 
> opt.equalsIgnoreCase("NO") ||
>   +                             opt.equalsIgnoreCase("OFF")) )
>   +          skipJWS = true ;
>   +
>   +        if ( !skipJWS && URL.endsWith(".jws") ) {
>                String pathName = context.getRealPath( URL );
>                Debug.Print(2, "Path: " + pathName );
>                msgContext.setProperty( "JWSFileName", pathName );
>   
>   
>   
>   1.18      +90 -25    
> xml-axis/java/src/org/apache/axis/utils/Admin.java
>   
>   Index: Admin.java
>   ===================================================================
>   RCS file: 
> /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
>   retrieving revision 1.17
>   retrieving revision 1.18
>   diff -u -r1.17 -r1.18
>   --- Admin.java	2001/03/08 13:44:06	1.17
>   +++ Admin.java	2001/03/09 00:24:07	1.18
>   @@ -100,30 +100,76 @@
>        }
>      }
>    
>   -  public Document AdminService(MessageContext msgContext, 
> Document xml) {
>   +  public Document AdminService(MessageContext msgContext, 
> Document xml) 
>   +                  throws AxisFault
>   +  {
>        Debug.Print( 1, "Enter: Admin:AdminService" );
>        hr = 
> (HandlerRegistry)msgContext.getProperty(Constants.HANDLER_REGISTRY);
>        sr = 
> (HandlerRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
>   -    process( xml );
>   -    Element  root = new Element( "Admin" );
>   -    Document doc  = new Document(root);
>   -    root.addContent( "Done processing" );
>   +    Document doc = process( xml );
>        Debug.Print( 1, "Exit: Admin:AdminService" );
>        return( doc );
>      }
>    
>   -  public void process(Document doc) {
>   -    process( doc.getRootElement() );
>   +  public Document process(Document doc) throws AxisFault {
>   +    return( process( doc.getRootElement() ) );
>      }
>    
>   -  public void process(Element root) {
>   +  public Document process(Element root) throws AxisFault {
>   +    Document doc = null ;
>        try {
>          init();
>          ClassLoader   cl     = new AxisClassLoader();
>          String        action = root.getName();
>    
>   -      if ( !action.equals("deploy") && 
> !action.equals("undeploy") ) 
>   -        Error( "Root element must be 'deploy' or 'undeploy'" );
>   +      if ( !action.equals("deploy") && 
> !action.equals("undeploy") &&
>   +           !action.equals("list") )
>   +        throw new AxisFault( "Admin.error", 
>   +                             "Root element must be 
> 'deploy', 'undeploy' " +
>   +                             "or 'list'",
>   +                             null, null );
>   +
>   +      if ( action.equals("list") ) {
>   +        String[]   names ;
>   +        Handler    h ;
>   +        int        i, j ;
>   +        root = new Element("Admin");
>   +        doc = new Document(root);
>   +        Element    elem = null ;
>   +        Hashtable  opts = null ;
>   +
>   +        /* Process Handlers first */
>   +        /**************************/
>   +        for ( int loop = 0 ; loop < 2 ; loop++ ) {
>   +          if ( loop == 0 )
>   +            names = hr.list();
>   +          else
>   +            names = sr.list();
>   +
>   +          for( i = 0 ; i < names.length ; i++ ) {
>   +            h = hr.find(names[i]);
>   +            if ( loop == 1 ) 
>   +              elem = new Element( "service" );
>   +            else 
>   +              elem = new Element( "handler" );
>   +            elem.addAttribute( "class", h.getClass().getName() );
>   +            root.addContent( elem );
>   +            opts = h.getOptions();
>   +            if ( opts != null ) {
>   +              Enumeration e = opts.keys();
>   +              while ( e.hasMoreElements() ) {
>   +                String k = (String) e.nextElement();
>   +                Object v = opts.get(k);
>   +                Element e1 = new Element( "option" );
>   +                e1.addAttribute( "name", k );
>   +                e1.addAttribute( "value", v.toString() );
>   +                elem.addContent( e1 );
>   +              }
>   +            }
>   +          }
>   +        }
>   +        return( doc );
>   +      }
>      
>          List list = root.getChildren();
>          for ( int loop = 0 ; loop < list.size() ; loop++ ) {
>   @@ -142,7 +188,9 @@
>                hr.remove( name );
>              }
>              else
>   -            Error( "Unknown type: " + type );
>   +            throw new AxisFault( "Admin.error", 
>   +                                 "Unknown type; " + type, 
>   +                                 null, null );
>              continue ;
>            }
>      
>   @@ -193,7 +241,9 @@
>                  hName = st.nextToken();
>                  tmpH = hr.find( hName );
>                  if ( tmpH == null )
>   -                Error( "Unknown handler: " + hName );
>   +                throw new AxisFault( "Admin.error", 
>   +                                     "Unknown handler: " + hName,
>   +                                     null, null );
>                  c.addHandler( tmpH );
>                }
>                getOptions( elem, c );
>   @@ -217,7 +267,9 @@
>                  hName = st.nextToken();
>                  tmpH = hr.find( hName );
>                  if ( tmpH == null )
>   -                Error( "Unknown handler: " + hName );
>   +                throw new AxisFault( "Admin.error", 
>   +                                     "Unknown handler: " + hName,
>   +                                     null, null );
>                  c.addHandler( tmpH );
>                }
>              
>   @@ -230,7 +282,9 @@
>                  hName = st.nextToken();
>                  tmpH = hr.find( hName );
>                  if ( tmpH == null )
>   -                Error( "Unknown handler: " + hName );
>   +                throw new AxisFault( "Admin.error", 
>   +                                     "Unknown handler: " + hName,
>   +                                     null, null );
>                  c.addHandler( tmpH );
>                }
>                getOptions( elem, cc );
>   @@ -244,7 +298,9 @@
>              Chain                c  = null ;
>    
>              if ( pivot == null && input == null && output == null )
>   -            Error( "Services must be use targetted chains" );
>   +            throw new AxisFault( "Admin.error", 
>   +                                 "Services must use 
> targeted chains", 
>   +                                 null, null );
>    
>              cc = (SimpleTargetedChain) hr.find( name );
>    
>   @@ -259,7 +315,9 @@
>                  hName = st.nextToken();
>                  tmpH = hr.find( hName );
>                  if ( tmpH == null )
>   -                Error( "Unknown handler: " + hName );
>   +                throw new AxisFault( "Admin.error", 
>   +                                     "Unknown handler: " + hName,
>   +                                     null, null );
>                  c.addHandler( tmpH );
>                }
>              }
>   @@ -274,7 +332,9 @@
>                  hName = st.nextToken();
>                  tmpH = hr.find( hName );
>                  if ( tmpH == null )
>   -                Error( "Unknown handler: " + hName );
>   +                throw new AxisFault( "Admin.error", 
>   +                                     "Unknown handler: " + hName,
>   +                                     null, null );
>                  c.addHandler( tmpH );
>                }
>              }
>   @@ -283,18 +343,18 @@
>              sr.add( name, cc );
>            }
>            else 
>   -          Error( "Unknown type to " + action + ": " + type );
>   +          throw new AxisFault( "Admin.error", 
>   +                               "Unknown type to " + action 
> + ": " + type,
>   +                               null, null );
>          }
>   +      root = new Element( "Admin" );
>   +      doc  = new Document(root);
>   +      root.addContent( "Done processing" );
>        }
>        catch( Exception e ) {
>   -      e.printStackTrace( System.err );
>   -      System.exit( 1 );
>   +      throw new AxisFault( e );
>        }
>   -  }
>   -
>   -  public static void Error(String str) {
>   -    System.err.println( str );
>   -    System.exit( 1 );
>   +    return( doc );
>      }
>    
>      public static void main(String args[]) {
>   @@ -316,6 +376,7 @@
>          System.err.println( "  <chain name=a/>" );
>          System.err.println( "  <service name=a/>" );
>          System.err.println( "</undeploy>\n" );
>   +      System.err.println( "<list/>\n" );
>    
>          System.exit( 1 );
>        }
>   @@ -333,6 +394,10 @@
>    
>            admin.process( doc );
>          }
>   +    }
>   +    catch( AxisFault e ) {
>   +      e.dump();
>   +      System.exit(1);
>        }
>        catch( Exception e ) {
>          System.err.println( "Error processing '" + args[i] + "'" );
>   
>   
>   
> 

Mime
View raw message