Changeset 801

Show
Ignore:
Timestamp:
06/29/07 11:21:33 (2 years ago)
Author:
yuanying
Message:

architecture is changed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/build.properties

    r778 r801  
    1 source.. = src/,\ 
    2            json-src/ 
     1source.. = src/ 
    32output.. = bin/ 
    43bin.includes = META-INF/,\ 
     
    98               META-INF/,\ 
    109               build.properties,\ 
    11                json-src/,\ 
    12                lib/,\ 
    13                lib-http/,\ 
    14                lib-json/,\ 
    1510               src/ 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/Connection.java

    r778 r801  
    4343     * @return 
    4444     */ 
    45     Response put(String url, Map<String, String> queryParams, RequestEntity body) throws ConnectionException; 
     45    Response put(String url, Map<String, String> queryParams, Representation body) throws ConnectionException; 
    4646     
    4747    /** 
     
    5252     * @return 
    5353     */ 
    54     Response post(String url, Map<String, String> queryParams, RequestEntity body) throws ConnectionException; 
     54    Response post(String url, Map<String, String> queryParams, Representation body) throws ConnectionException; 
    5555} 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/HttpClientConnection.java

    r778 r801  
    182182     */ 
    183183    public Response post(String url, Map<String, String> queryParams, 
    184             RequestEntity body) throws ConnectionException { 
     184            Representation body) throws ConnectionException { 
    185185        try { 
    186186            PostMethod method = new PostMethod(url); 
     
    199199     */ 
    200200    public Response put(String url, Map<String, String> queryParams, 
    201             RequestEntity body) throws ConnectionException { 
     201            Representation body) throws ConnectionException { 
    202202        try { 
    203203            PutMethod method = new PutMethod(url); 
     
    218218     * @throws IOException 
    219219     */ 
    220     private Response doEntityEnclosingMethod(RequestEntity body, 
     220    private Response doEntityEnclosingMethod(Representation body, 
    221221            Map<String, String> queryParams, EntityEnclosingMethod method) 
    222222            throws HttpException, IOException { 
     
    305305    private class RequestEntityWrapper implements 
    306306            org.apache.commons.httpclient.methods.RequestEntity { 
    307         private final RequestEntity requestEntity; 
    308  
    309         public RequestEntityWrapper(RequestEntity requestEntity) { 
     307        private final Representation requestEntity; 
     308 
     309        public RequestEntityWrapper(Representation requestEntity) { 
    310310            this.requestEntity = requestEntity; 
    311311        } 
     
    316316 
    317317        public String getContentType() { 
    318             return requestEntity.getContentType(); 
     318            return requestEntity.getMediaType(); 
    319319        } 
    320320 
     
    324324 
    325325        public void writeRequest(OutputStream out) throws IOException { 
    326             requestEntity.writeRequest(out); 
     326            requestEntity.write(out); 
    327327        } 
    328328    } 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/Representation.java

    r689 r801  
    1212 
    1313import java.io.IOException; 
     14import java.io.InputStream; 
    1415import java.io.OutputStream; 
    1516 
     
    1920 * 
    2021 */ 
    21 public interface RequestEntity
     22public interface Representation
    2223    /** 
    2324     *  
     
    2930     * @return 
    3031     */ 
    31     String getContentType(); 
     32    String getMediaType(); 
    3233    /** 
    3334     *  
     
    3940     * @param out 
    4041     */ 
    41     void writeRequest(OutputStream out) throws IOException; 
     42    void write(OutputStream out) throws IOException; 
     43     
     44    /** 
     45     *  
     46     * @return 
     47     * @throws IOException 
     48     */ 
     49    InputStream read() throws IOException; 
    4250} 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/StringRepresentation.java

    r689 r801  
    1111package org.jalcedo.client.rest.connect; 
    1212 
     13import java.io.IOException; 
     14import java.io.InputStream; 
     15import java.io.OutputStream; 
    1316import java.io.UnsupportedEncodingException; 
    1417 
     
    1821 * 
    1922 */ 
    20 public class StringRequestEntity extends org.apache.commons.httpclient.methods.StringRequestEntity 
    21     implements RequestEntity
     23public class StringRepresentation extends org.apache.commons.httpclient.methods.StringRequestEntity 
     24    implements Representation
    2225 
    23     public StringRequestEntity(String content, String contentType, 
     26    public StringRepresentation(String content, String contentType, 
    2427            String charset) throws UnsupportedEncodingException { 
    2528        super(content, contentType, charset); 
    2629    } 
     30 
     31    public String getMediaType() { 
     32        return this.getContentType(); 
     33    } 
     34    public void write(OutputStream out) throws IOException { 
     35        this.writeRequest(out); 
     36    } 
     37     
     38    public InputStream read() throws IOException { 
     39        // FIXME 
     40        throw new UnsupportedOperationException(); 
     41    } 
    2742} 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/WWWFormUrlEncodedRepresentation.java

    r730 r801  
    1212 
    1313import java.io.IOException; 
     14import java.io.InputStream; 
    1415import java.io.OutputStream; 
    1516import java.io.UnsupportedEncodingException; 
     
    2122 * 
    2223 */ 
    23 public class FormRequestEntity implements RequestEntity
     24public class WWWFormUrlEncodedRepresentation implements Representation
    2425     
    2526    private StringBuilder data = new StringBuilder(); 
    2627    private String charset; 
    2728     
    28     private StringRequestEntity wrapper = null; 
     29    private StringRepresentation wrapper = null; 
    2930     
    30     public FormRequestEntity() { 
     31    public WWWFormUrlEncodedRepresentation() { 
    3132        this("utf-8"); 
    3233    } 
    3334     
    34     public FormRequestEntity(String charset) { 
     35    public WWWFormUrlEncodedRepresentation(String charset) { 
    3536        this.charset = charset; 
    3637    } 
     
    4647    } 
    4748     
    48     protected RequestEntity getWrapper() { 
     49    protected Representation getWrapper() { 
    4950        if (this.wrapper == null) { 
    5051            try { 
    51                 this.wrapper = new StringRequestEntity(this.data.toString(), "application/x-www-form-urlencoded", this.charset); 
     52                this.wrapper = new StringRepresentation(this.data.toString(), "application/x-www-form-urlencoded", this.charset); 
    5253            } catch (UnsupportedEncodingException e) { 
    5354                throw new IllegalStateException(e); 
     
    5859 
    5960    public long getContentLength() { 
    60         RequestEntity wrapper = this.getWrapper(); 
     61        Representation wrapper = this.getWrapper(); 
    6162        return wrapper.getContentLength(); 
    6263    } 
    6364 
    64     public String getContentType() { 
    65         RequestEntity wrapper = this.getWrapper(); 
    66         return wrapper.getContentType(); 
     65    public String getMediaType() { 
     66        Representation wrapper = this.getWrapper(); 
     67        return wrapper.getMediaType(); 
    6768    } 
    6869 
    6970    public boolean isRepeatable() { 
    70         RequestEntity wrapper = this.getWrapper(); 
     71        Representation wrapper = this.getWrapper(); 
    7172        return wrapper.isRepeatable(); 
    7273    } 
    7374 
    74     public void writeRequest(OutputStream out) throws IOException { 
    75         RequestEntity wrapper = this.getWrapper(); 
    76         wrapper.writeRequest(out); 
     75    public void write(OutputStream out) throws IOException { 
     76        Representation wrapper = this.getWrapper(); 
     77        wrapper.write(out); 
    7778    } 
    7879 
     80    public InputStream read() throws IOException { 
     81        // TODO Auto-generated method stub 
     82        return null; 
     83    } 
    7984}