commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/jelly SessionTag.java HttpTag.java SuiteTag.java
Date Mon, 08 Jul 2002 01:44:44 GMT
dion        2002/07/07 18:44:44

  Modified:    latka/src/java/org/apache/commons/latka/jelly
                        SessionTag.java HttpTag.java SuiteTag.java
  Log:
  Refactored host, proxy etc into Session
  
  Revision  Changes    Path
  1.6       +127 -9    jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SessionTag.java
  
  Index: SessionTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SessionTag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SessionTag.java	6 Jul 2002 07:36:49 -0000	1.5
  +++ SessionTag.java	8 Jul 2002 01:44:43 -0000	1.6
  @@ -62,6 +62,7 @@
   package org.apache.commons.latka.jelly;
   
   import org.apache.commons.httpclient.HttpMultiClient;
  +import org.apache.commons.latka.http.Proxy;
   import org.apache.commons.jelly.XMLOutput;
   
   /**
  @@ -72,6 +73,14 @@
    */
   public class SessionTag extends LatkaTag {
       
  +    /** default host for requests */
  +    private String _host;
  +    /** default port for requests */
  +    private String _port;
  +    /** Proxy details for requests */
  +    private Proxy _proxy = new Proxy();
  +    /** whether the default is for secure comms */
  +    private boolean _secure;
       /** http client used to store state and execute requests */
       private HttpMultiClient _httpClient;
       
  @@ -88,12 +97,8 @@
        * @throws Exception when any error occurs
        */
       public void doTag(XMLOutput xmlOutput) throws Exception {
  -        String proxyHost = (String) getContext().getVariable("http.proxyHost");
  -        if (proxyHost != null) {
  -            String proxyPort = (String) getContext().
  -                getVariable("http.proxyPort");
  -            _httpClient = new HttpMultiClient(proxyHost, 
  -                Integer.valueOf(proxyPort).intValue());
  +        if (isProxyAvailable()) {
  +            _httpClient = new HttpMultiClient(getProxyHost(), getProxyPort());
           } else {
               _httpClient = new HttpMultiClient();
           }
  @@ -118,5 +123,118 @@
       public void setHttpClient(HttpMultiClient httpClient) {
           _httpClient = httpClient;
       }
  +    /**
  +     * Tests whether the {@link #getProxy() proxy} is ready for use
  +     *
  +     * @return true if the {@link #getProxy() proxy} is configured for use
  +     */
  +    public boolean isProxyAvailable() {
  +        return getProxy() != null && getProxy().getHost() != null 
  +            && getProxy().getPort() != Proxy.PORT_UNSPECIFIED;
  +    }
  +    
  +    /**
  +     * Helper method for proxy host property
  +     *
  +     * @return the {@link #getProxy() proxy's} host property
  +     */
  +    public String getProxyHost() {
  +        return getProxy().getHost();
  +    }
  +    
  +    /**
  +     * Helper method for proxy <code>host</code> property
  +     *
  +     * @param host the {@link #getProxy() proxy's} host property
  +     */
  +    public void setProxyHost(String host) {
  +        getProxy().setHost(host);
  +    }
  +    
  +    /**
  +     * Helper method for proxy <code>port</code> property
  +     *
  +     * @return the {@link #getProxy() proxy's} port property
  +     */
  +    public int getProxyPort() {
  +        return getProxy().getPort();
  +    }
  +    
  +    /**
  +     * Helper method for proxy <code>port</code> property
  +     *
  +     * @param port the {@link #getProxy() proxy's} port property
  +     */
  +    public void setProxyPort(int port) {
  +        getProxy().setPort(port);
  +    }
  +    
  +    /**
  +     * Getter for property host.
  +     *
  +     * @return Value of property host.
  +     */
  +    public String getHost() {
  +        return _host;
  +    }
  +    
  +    /**
  +     * Setter for property host.
  +     *
  +     * @param host New value of property host.
  +     */
  +    public void setHost(String host) {
  +        _host = host;
  +    }
  +    
  +    /** Getter for property port.
  +     * @return Value of property port.
  +     */
  +    public String getPort() {
  +        return _port;
  +    }
  +    
  +    /** Setter for property port.
  +     * @param port New value of property port.
  +     */
  +    public void setPort(String port) {
  +        _port = port;
  +    }
  +    
  +    /**
  +     * Getter for property proxy.
  +     *
  +     * @return Value of property proxy.
  +     */
  +    public Proxy getProxy() {
  +        return _proxy;
  +    }
       
  +    /**
  +     * Setter for property proxy.
  +     *
  +     * @param proxy New value of property proxy.
  +     */
  +    public void setProxy(Proxy proxy) {
  +        _proxy = proxy;
  +    }
  +    
  +    /**
  +     * Getter for property secure.
  +     *
  +     * @return Value of property secure.
  +     */
  +    public boolean isSecure() {
  +        return _secure;
  +    }
  +    
  +    /**
  +     * Setter for property secure.
  +     *
  +     * @param secure New value of property secure.
  +     */
  +    public void setSecure(boolean secure) {
  +        _secure = secure;
  +    }
  +
   }
  
  
  
  1.12      +9 -9      jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/HttpTag.java
  
  Index: HttpTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/HttpTag.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HttpTag.java	7 Jul 2002 14:25:40 -0000	1.11
  +++ HttpTag.java	8 Jul 2002 01:44:43 -0000	1.12
  @@ -117,12 +117,12 @@
               return getUri();
           } else {
               // build it from path, host and optionally port
  -            SuiteTag suiteTag = (SuiteTag) findAncestorWithClass(
  -                SuiteTag.class);
  -            String host = suiteTag.getHost();
  -            String port = suiteTag.getPort();
  +            SessionTag session = (SessionTag) findAncestorWithClass(
  +                SessionTag.class);
  +            String host = session.getHost();
  +            String port = session.getPort();
               // short term hack, need to add port and security in
  -            return host + getPath();
  +            return "http://" + host + getPath();
           }
       }
       
  
  
  
  1.8       +6 -142    jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SuiteTag.java
  
  Index: SuiteTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SuiteTag.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SuiteTag.java	6 Jul 2002 10:34:46 -0000	1.7
  +++ SuiteTag.java	8 Jul 2002 01:44:43 -0000	1.8
  @@ -65,27 +65,14 @@
   import org.apache.commons.latka.http.Proxy;
   
   /**
  - * A tag representing a Latka Suite
  - * - attributes: host, port, proxyHost, proxyPort, proxyUser, proxyPassword, 
  - *      label, id
  - * - holds sessions, requests and messages, proxyCredentials?
  - * - what does it do? Execute's the children? Sets them up somehow? 
  - *      Creates credentials and proxy if needed?
  + * A tag representing a Latka Suite.
  + * <p>holds sessions, requests and messages</p>
    *
    * @author dion
    * @version $Id$
    */
   public class SuiteTag extends LatkaTag {
       
  -    /** default host for requests */
  -    private String _host;
  -    /** default port for requests */
  -    private String _port;
  -    /** Proxy details for requests */
  -    private Proxy _proxy = new Proxy();
  -    /** whether the default is for secure comms */
  -    private boolean _secure;
  -    
       /**
        * Creates a new instance of SuiteTag
        */
  @@ -100,130 +87,7 @@
        * @throws Exception when an error occurs
        */
       public void doTag(XMLOutput xmlOutput) throws Exception {
  -        if (isProxyAvailable()) {
  -            getContext().setVariable("http.proxyHost", getProxyHost());
  -            getContext().setVariable("http.proxyPort", 
  -                String.valueOf(getProxyPort()));
  -        }
           invokeBody(xmlOutput);
  -    }
  -    
  -    //--------------------------------------------------------------------------
  -    // Property accessors/mutators
  -    //--------------------------------------------------------------------------
  -  
  -    /**
  -     * Tests whether the {@link #getProxy() proxy} is ready for use
  -     *
  -     * @return true if the {@link #getProxy() proxy} is configured for use
  -     */
  -    public boolean isProxyAvailable() {
  -        return getProxy() != null && getProxy().getHost() != null 
  -            && getProxy().getPort() != Proxy.PORT_UNSPECIFIED;
  -    }
  -    
  -    /**
  -     * Helper method for proxy host property
  -     *
  -     * @return the {@link #getProxy() proxy's} host property
  -     */
  -    public String getProxyHost() {
  -        return getProxy().getHost();
  -    }
  -    
  -    /**
  -     * Helper method for proxy <code>host</code> property
  -     *
  -     * @param host the {@link #getProxy() proxy's} host property
  -     */
  -    public void setProxyHost(String host) {
  -        getProxy().setHost(host);
  -    }
  -    
  -    /**
  -     * Helper method for proxy <code>port</code> property
  -     *
  -     * @return the {@link #getProxy() proxy's} port property
  -     */
  -    public int getProxyPort() {
  -        return getProxy().getPort();
  -    }
  -    
  -    /**
  -     * Helper method for proxy <code>port</code> property
  -     *
  -     * @param port the {@link #getProxy() proxy's} port property
  -     */
  -    public void setProxyPort(int port) {
  -        getProxy().setPort(port);
  -    }
  -    
  -    /**
  -     * Getter for property host.
  -     *
  -     * @return Value of property host.
  -     */
  -    public String getHost() {
  -        return _host;
  -    }
  -    
  -    /**
  -     * Setter for property host.
  -     *
  -     * @param host New value of property host.
  -     */
  -    public void setHost(String host) {
  -        _host = host;
  -    }
  -    
  -    /** Getter for property port.
  -     * @return Value of property port.
  -     */
  -    public String getPort() {
  -        return _port;
  -    }
  -    
  -    /** Setter for property port.
  -     * @param port New value of property port.
  -     */
  -    public void setPort(String port) {
  -        _port = port;
  -    }
  -    
  -    /**
  -     * Getter for property proxy.
  -     *
  -     * @return Value of property proxy.
  -     */
  -    public Proxy getProxy() {
  -        return _proxy;
  -    }
  -    
  -    /**
  -     * Setter for property proxy.
  -     *
  -     * @param proxy New value of property proxy.
  -     */
  -    public void setProxy(Proxy proxy) {
  -        _proxy = proxy;
  -    }
  -    
  -    /**
  -     * Getter for property secure.
  -     *
  -     * @return Value of property secure.
  -     */
  -    public boolean isSecure() {
  -        return _secure;
  -    }
  -    
  -    /**
  -     * Setter for property secure.
  -     *
  -     * @param secure New value of property secure.
  -     */
  -    public void setSecure(boolean secure) {
  -        _secure = secure;
       }
       
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message