KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > connector > WebDAVConnectionSpec


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/connector/src/java/org/apache/webdav/connector/WebDAVConnectionSpec.java,v 1.3 2004/07/15 12:37:36 ozeigermann Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/15 12:37:36 $
5  *
6  * ====================================================================
7  *
8  * Copyright 2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.webdav.connector;
25
26 import javax.resource.cci.ConnectionSpec JavaDoc;
27 import javax.resource.spi.ConnectionRequestInfo JavaDoc;
28
29 import org.apache.commons.httpclient.HttpURL;
30 import org.apache.commons.httpclient.HttpsURL;
31 import org.apache.commons.httpclient.URIException;
32
33 /**
34  * Specifies where the {@link WebDAVConnection} shall go to.
35  *
36  * @version $Revision: 1.3 $
37  *
38  */

39 public class WebDAVConnectionSpec implements ConnectionSpec JavaDoc, ConnectionRequestInfo JavaDoc {
40     
41     /** The http URL on the client connection. */
42     protected HttpURL httpURL;
43     protected int timeout;
44     
45     /**
46      * Creates a specification where the {@link WebDAVConnection} shall go to.
47      *
48      * @param httpURL complete url of the Slide (WebDAV) server including user and password
49      * @param timeout timeout of the externally controlled transaction
50      */

51     public WebDAVConnectionSpec(HttpURL httpURL, int timeout) {
52         this.httpURL = httpURL;
53         this.timeout = timeout;
54     
55     }
56
57     /**
58      * Creates a specification where the {@link WebDAVConnection} shall go to.
59      *
60      * @param url url string of the Slide (WebDAV) server
61      * @param userName user name for login to the Slide (WebDAV) server
62      * @param password password for login to the Slide (WebDAV) server
63      * @param timeout timeout of the externally controlled transaction
64      * @throws URIException if the given uri is not a valid one
65      */

66     public WebDAVConnectionSpec(String JavaDoc url, String JavaDoc userName, String JavaDoc password, int timeout) throws URIException {
67         this.httpURL = url.startsWith("https") ? new HttpsURL(url) : new HttpURL(url);
68         this.httpURL.setUserinfo(userName, password);
69         this.timeout = timeout;
70     }
71
72     protected HttpURL getHttpURL() {
73         return httpURL;
74     }
75
76     protected int getTimeout() {
77         return timeout;
78     }
79 }
80
Popular Tags