You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by je...@apache.org on 2001/05/02 10:11:29 UTC

cvs commit: jakarta-slide/src/util/org/apache/util GenericURI.java

jericho     01/05/02 01:11:28

  Modified:    src/webdav/client/src/org/apache/webdav/lib
                        WebdavSession.java
               src/util/org/apache/util GenericURI.java
  Log:
  - Add synchronized to clientInfo for WebdavSession.
    clientInfo is a field to be used mutually by methods.
  - Remove synchronized keywords from GenericURI
    Because this class doesn't have any mutual fields any more...
  
  Revision  Changes    Path
  1.3       +49 -39    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java
  
  Index: WebdavSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebdavSession.java	2001/05/01 21:28:17	1.2
  +++ WebdavSession.java	2001/05/02 08:11:25	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v 1.2 2001/05/01 21:28:17 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/05/01 21:28:17 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v 1.3 2001/05/02 08:11:25 jericho Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/05/02 08:11:25 $
    *
    * ====================================================================
    *
  @@ -127,20 +127,22 @@
       public HttpClient getSessionInstance(HttpURL httpURL)
           throws IOException {
   
  -        String authority = httpURL.getAuthority();
  -        if (!clientInfo.contains(authority)) {
  -            clientInfo.addElement(authority);
  -        }
  +        synchronized (clientInfo) {
  +            String authority = httpURL.getAuthority();
  +            if (!clientInfo.contains(authority)) {
  +                clientInfo.addElement(authority);
  +            }
           
  -        HttpClient client = new HttpClient(httpURL.toURL());
  -        String userName = httpURL.getUserName();
  -        if (userName != null && userName.length() > 0) {
  -            String password = httpURL.getPassword();
  -            client.setCredentials(new Credentials(userName, password));
  -        }
  -        //client.getProgressUtil().addProgressListener(this);
  +            HttpClient client = new HttpClient(httpURL.toURL());
  +            String userName = httpURL.getUserName();
  +            if (userName != null && userName.length() > 0) {
  +                String password = httpURL.getPassword();
  +                client.setCredentials(new Credentials(userName, password));
  +            }
  +            //client.getProgressUtil().addProgressListener(this);
   
  -        return client;
  +            return client;
  +        }
       }
   
   
  @@ -153,10 +155,11 @@
        */
       public boolean isSession(HttpURL httpURL)
           throws MalformedURLException {
  -
  -        String authority = httpURL.getAuthority();
   
  -        return isSession(authority);
  +        synchronized (clientInfo) {
  +            String authority = httpURL.getAuthority();
  +            return isSession(authority);
  +        }
       }
   
   
  @@ -168,7 +171,9 @@
        * @exception MalformedURLException
        */
       public boolean isSession(String authority) {
  -        return (clientInfo.contains(authority)) ? true : false;
  +        synchronized (clientInfo) {
  +            return (clientInfo.contains(authority)) ? true : false;
  +        }
       }
       
       
  @@ -180,18 +185,19 @@
        * @return Authorities to have the given string.
        */
       public Enumeration findSessions(String partOfAuthority) {
  -
  -        Vector sessions = new Vector();
   
  -        Enumeration authorities = clientInfo.elements();
  -        while (authorities.hasMoreElements()) {
  -            String authority = (String) authorities.nextElement();
  -            if (authority.indexOf(partOfAuthority) >= 0) {
  -                sessions.addElement(authority);
  +        synchronized (clientInfo) {
  +            Vector sessions = new Vector();
  +            Enumeration authorities = clientInfo.elements();
  +            while (authorities.hasMoreElements()) {
  +                String authority = (String) authorities.nextElement();
  +                if (authority.indexOf(partOfAuthority) >= 0) {
  +                    sessions.addElement(authority);
  +                }
               }
  +            
  +            return sessions.elements();
           }
  -
  -        return sessions.elements();
       }
   
   
  @@ -201,7 +207,9 @@
        * @return Authorities of all session.
        */
       public Enumeration getSessions() {
  -        return clientInfo.elements();
  +        synchronized (clientInfo) {
  +            return clientInfo.elements();
  +        }
       }
   
   
  @@ -214,17 +222,19 @@
       public void closeSession(HttpClient client)
           throws IOException {
   
  -        HttpURL httpURL =
  -            new HttpURL(client.getUserName(), client.getPassword(), 
  -                        client.getHost(), client.getPort());
  -        String authority = httpURL.getAuthority();
  -        if (isSession(authority)) {
  -            clientInfo.removeElement(authority);
  -            // Remove the progress listener.
  -            //webdavClient.getProgressUtil().addProgressListener(this);
  +        synchronized (clientInfo) {
  +            HttpURL httpURL =
  +                new HttpURL(client.getUserName(), client.getPassword(), 
  +                            client.getHost(), client.getPort());
  +            String authority = httpURL.getAuthority();
  +            if (isSession(authority)) {
  +                clientInfo.removeElement(authority);
  +                // Remove the progress listener.
  +                //webdavClient.getProgressUtil().addProgressListener(this);
  +            }
  +            
  +            client.endSession();
           }
  -
  -        client.endSession();
       }
   
   
  
  
  
  1.2       +17 -17    jakarta-slide/src/util/org/apache/util/GenericURI.java
  
  Index: GenericURI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GenericURI.java	2001/04/30 16:46:21	1.1
  +++ GenericURI.java	2001/05/02 08:11:27	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v 1.1 2001/04/30 16:46:21 jericho Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/04/30 16:46:21 $
  + * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v 1.2 2001/05/02 08:11:27 jericho Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/05/02 08:11:27 $
    *
    * ====================================================================
    *
  @@ -409,7 +409,7 @@
        * @return The escaped scheme of the given URI.
        * @exception MalformedURLException no scheme.
        */
  -    public static synchronized String getEscapedScheme(String escapedURI,
  +    public static String getEscapedScheme(String escapedURI,
                                                          String defaultScheme)
           throws MalformedURLException {
   
  @@ -473,7 +473,7 @@
        * @return The escaped authority part of the given URI.
        * @exception MalformedURLException
        */
  -    public static synchronized String getEscapedAuthority(String escapedURI)
  +    public static String getEscapedAuthority(String escapedURI)
           throws MalformedURLException {
   
           int at = escapedURI.indexOf("://");
  @@ -535,7 +535,7 @@
        * @return The userifno of the given URI.
        * @exception MalformedURLException
        */
  -    public static synchronized String getEscapedUserInfo(String escapedURI)
  +    public static String getEscapedUserInfo(String escapedURI)
           throws MalformedURLException {
   
           String authority = getEscapedAuthority(escapedURI);
  @@ -585,7 +585,7 @@
        * @return The username of URI
        * @exception MalformedURLException
        */
  -    public static synchronized String getUserName(String escapedURI)
  +    public static String getUserName(String escapedURI)
           throws MalformedURLException {
   
           try {
  @@ -621,7 +621,7 @@
        * @return The password of URI
        * @exception MalformedURLException
        */
  -    public static synchronized String getPassword(String escapedURI)
  +    public static String getPassword(String escapedURI)
           throws MalformedURLException {
   
           try {
  @@ -684,7 +684,7 @@
        * @return The hostport
        * @exception MalformedURLException
        */
  -    public static synchronized String getEscapedHostPort(String escapedURI)
  +    public static String getEscapedHostPort(String escapedURI)
           throws MalformedURLException {
   
           String authority = getEscapedAuthority(escapedURI);
  @@ -741,7 +741,7 @@
        * @return The escaped hostname string
        * @exception MalformedURLException
        */
  -    public static synchronized String getEscapedHost(String escapedURI)
  +    public static String getEscapedHost(String escapedURI)
           throws MalformedURLException {
   
           String hostPort = getEscapedHostPort(escapedURI);
  @@ -786,7 +786,7 @@
        * @return The port number
        * @exception MalformedURLException
        */
  -    public static synchronized int getPort(String escapedURI, int defaultPort)
  +    public static int getPort(String escapedURI, int defaultPort)
           throws MalformedURLException {
   
           String hostPort = getEscapedHostPort(escapedURI);
  @@ -851,7 +851,7 @@
        * @param escapedURI The escaped URI string.
        * @return The escaped net_path and query.
        */
  -    public static synchronized String getEscapedNetPathQuery
  +    public static String getEscapedNetPathQuery
           (String escapedURI) {
   
           // consider of net_path
  @@ -912,7 +912,7 @@
        * @param escapedURI The escaped URI string.
        * @return The escaped abs_path or rel_path, and query.
        */
  -    public static synchronized String getEscapedPathQuery(String escapedURI) {
  +    public static String getEscapedPathQuery(String escapedURI) {
   
           // consider of net_path
           int at = escapedURI.indexOf("//");
  @@ -985,7 +985,7 @@
        * @param escapedURI The specified escaped URI string.
        * @return The escaped path.
        */
  -    public static synchronized String getEscapedPath(String escapedURI) {
  +    public static String getEscapedPath(String escapedURI) {
   
           // consider of net_path
           int at = escapedURI.indexOf("//");
  @@ -1022,7 +1022,7 @@
        * @param escapedPath The escaped path string.
        * @return The parent path of the given already-normalized path.
        */
  -    public static synchronized String getParent(String escapedPath) {
  +    public static String getParent(String escapedPath) {
   
           String pathname = getPath(escapedPath);
   
  @@ -1060,7 +1060,7 @@
        * @return The collection name, if the path is a collection,
        *         The resource name, if the path is a resource.
        */
  -    public static synchronized String getName(String escapedPath) {
  +    public static String getName(String escapedPath) {
   
           // Return a string starting with the '/' charcater.
           String name = getPath(escapedPath);
  @@ -1128,7 +1128,7 @@
        * @return The escaped query string.
        * @exception MalformedURLException
        */
  -    public static synchronized String getEscapedQuery(String escapedURI)
  +    public static String getEscapedQuery(String escapedURI)
           throws MalformedURLException {
   
           int at = escapedURI.indexOf("//");
  @@ -1203,7 +1203,7 @@
        * @return The escaped fragment string.
        * @exception MalformedURLException
        */
  -    public static synchronized String getEscapedFragment(String escapedURI)
  +    public static String getEscapedFragment(String escapedURI)
           throws MalformedURLException {
   
           int at = escapedURI.indexOf("//");