Return-Path: Delivered-To: apmail-jakarta-jetspeed-dev-archive@jakarta.apache.org Received: (qmail 64296 invoked by uid 500); 29 May 2001 09:30:01 -0000 Mailing-List: contact jetspeed-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: jetspeed-dev@jakarta.apache.org Delivered-To: mailing list jetspeed-dev@jakarta.apache.org Received: (qmail 64274 invoked by uid 500); 29 May 2001 09:29:58 -0000 Delivered-To: apmail-jakarta-jetspeed-cvs@apache.org Date: 29 May 2001 09:29:57 -0000 Message-ID: <20010529092957.64268.qmail@apache.org> From: sgala@apache.org To: jakarta-jetspeed-cvs@apache.org Subject: cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager JetspeedURLManagerService.java URLInfo.java sgala 01/05/29 02:29:57 Modified: src/java/org/apache/jetspeed/services/urlmanager JetspeedURLManagerService.java URLInfo.java Log: Changes to documentation, and also to ensure that the url string in entries is interned, as it is used to synchronize access later Revision Changes Path 1.11 +18 -10 jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager/JetspeedURLManagerService.java Index: JetspeedURLManagerService.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager/JetspeedURLManagerService.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JetspeedURLManagerService.java 2001/04/03 00:26:35 1.10 +++ JetspeedURLManagerService.java 2001/05/29 09:29:54 1.11 @@ -75,7 +75,7 @@ * @see URLManagerService * @author Rapha�l Luta * @author Santiago Gala - * @version $Id: JetspeedURLManagerService.java,v 1.10 2001/04/03 00:26:35 raphael Exp $ + * @version $Id: JetspeedURLManagerService.java,v 1.11 2001/05/29 09:29:54 sgala Exp $ */ public class JetspeedURLManagerService extends TurbineBaseService @@ -150,6 +150,7 @@ proxies.put( hashKey, hashValue ); } } + path = config.getServletContext().getRealPath( JetspeedResources .getString( "services."+URLManagerService.SERVICE_NAME+".url" ) ); @@ -236,7 +237,8 @@ public void register( URLInfo info ) { if ( info != null) { synchronized (urls) { - urls.put( info.getURL(), info ); + if( getInfo( info.getURL() ) == null ) + urls.put( info.getURL().intern(), info ); } } } @@ -249,7 +251,7 @@ public void unregister( String url ) { if ( url != null ) { synchronized (urls) { - urls.remove( url ); + urls.remove( url.intern() ); } } } @@ -266,7 +268,7 @@ if ( url != null ) { synchronized(urls) { - info = (URLInfo)urls.get( url ); + info = (URLInfo)urls.get( url.intern() ); } } @@ -306,7 +308,7 @@ * the given status. * * @param status the status to be retrieved. May be - * {@link URLManagerService.SERVICE_ANY} to indicate any status + * {@link URLManagerService#STATUS_ANY} to indicate any status * @return a List of URL strings known to this repository with this status */ public List list( int status ) { @@ -342,15 +344,20 @@ int count = 1; String url = null; - while ( ( url=config.getString("entry."+count+".url") ) != null ) { + while ( ( url = ( config + .getString("entry."+count+".url") ) ) != null ) { + //Intern the url to ensure we can use "==" to compare + //and synchronize on it + url = url.intern(); int status = config.getInteger("entry."+count+".status", URLManagerService.STATUS_OK ); - store.put( url, new URLInfo( url, status ) ); + if( store.get( url ) == null ) + store.put( url, new URLInfo( url, status ) ); count++; } Log.note( "URLManager loaded " + count + " urls" ); - } catch ( IOException e ) { + } catch ( Exception e ) { Log.error( "Could not restore URLManager state", e ); return; } finally { @@ -419,8 +426,9 @@ } /** - * Escape values when saving. - * Appends a String to a StringBuffer, escaping commas. + *

Escape values when saving. + * Appends a String to a StringBuffer, escaping commas.

+ *

We assume that commas are unescaped.

* @param sink a StringBuffer to write output * @param element a value to be written */ 1.4 +9 -3 jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager/URLInfo.java Index: URLInfo.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/urlmanager/URLInfo.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- URLInfo.java 2001/03/07 06:49:36 1.3 +++ URLInfo.java 2001/05/29 09:29:55 1.4 @@ -55,10 +55,16 @@ package org.apache.jetspeed.services.urlmanager; /** - *

This is a simple URL information record which can be used

+ *

This is a simple URL information record which can be used + * to track URL resources status in a persistent way.

* + *

The url String used to initialize it MUST be interned, + * to ensure that if two such urls are "equal()", they will be + * also "=="

+ * + * * @author Rapha�l Luta - * @version $Id: URLInfo.java,v 1.3 2001/03/07 06:49:36 taylor Exp $ + * @version $Id: URLInfo.java,v 1.4 2001/05/29 09:29:55 sgala Exp $ */ public class URLInfo implements java.io.Serializable { @@ -94,7 +100,7 @@ * the status of the url */ URLInfo( String url, int status, String message ) { - this.url = url; + this.url = url.intern(); this.status = status; this.message = message; } --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org