Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2966 - in development/main/transit/core/handler/src: main/net/dpml/transit/model main/net/dpml/transit/runtime main/net/dpml/transit/store main/net/dpml/transit/unit test/net/dpml/transit/manager

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2966 - in development/main/transit/core/handler/src: main/net/dpml/transit/model main/net/dpml/transit/runtime main/net/dpml/transit/store main/net/dpml/transit/unit test/net/dpml/transit/manager
  • Date: Mon, 04 Jul 2005 18:39:52 -0400

Author: mcconnell AT dpml.net
Date: Mon Jul 4 18:39:52 2005
New Revision: 2966

Added:

development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheDirectoryChangeEvent.java
- copied, changed from r2960,
development/main/transit/core/handler/src/main/net/dpml/transit/model/FileChangeEvent.java
Removed:

development/main/transit/core/handler/src/main/net/dpml/transit/model/FileChangeEvent.java
Modified:

development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheListener.java

development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheModel.java

development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultCacheModel.java

development/main/transit/core/handler/src/main/net/dpml/transit/runtime/DefaultCacheHandler.java

development/main/transit/core/handler/src/main/net/dpml/transit/store/CacheStorage.java

development/main/transit/core/handler/src/main/net/dpml/transit/unit/CacheStorageUnit.java

development/main/transit/core/handler/src/test/net/dpml/transit/manager/TransitManagerTestCase.java
Log:
Replace the references to the cache directory with references to symbolic
paths.

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheDirectoryChangeEvent.java
(from r2960,
development/main/transit/core/handler/src/main/net/dpml/transit/model/FileChangeEvent.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/FileChangeEvent.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheDirectoryChangeEvent.java
Mon Jul 4 18:39:52 2005
@@ -24,18 +24,23 @@
/**
* Event signalling a change to the Tranist cache directory.
*/
-public abstract class FileChangeEvent extends EventObject
+public class CacheDirectoryChangeEvent extends EventObject
{
- private final File m_file;
+ private final String m_path;

- public FileChangeEvent( Object source, File file )
+ public CacheDirectoryChangeEvent( CacheModel source, String path )
{
super( source );
- m_file = file;
+ m_path = path;
+ }
+
+ public CacheModel getCacheModel()
+ {
+ return (CacheModel) getSource();
}

- public File getFile()
+ public String getCachePath()
{
- return m_file;
+ return m_path;
}
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheListener.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheListener.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheListener.java
Mon Jul 4 18:39:52 2005
@@ -31,7 +31,7 @@
* Notify the listener of a change to the cache directory.
* @param event the cache directory change event
*/
- void cacheDirectoryChanged( FileChangeEvent event ) throws
RemoteException;
+ void cacheDirectoryChanged( CacheDirectoryChangeEvent event ) throws
RemoteException;

/**
* Notify the listener of the addition of a new host.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheModel.java
Mon Jul 4 18:39:52 2005
@@ -34,17 +34,23 @@
static final String CACHE_LAYOUT_KEY = "dpml.transit.cache.layout";

/**
+ * Return the directory path to be used by the cache handler.
+ * @return the cache directory path.
+ */
+ String getCacheDirectoryPath() throws RemoteException;
+
+ /**
* Return the directory to be used by the cache handler as the cache
directory.
* @return the cache directory.
*/
File getCacheDirectory() throws RemoteException;

/**
- * Update the value the local cache directory.
+ * Update the value the local cache directory path.
*
* @param file the cache directory
*/
- void setCacheDirectory( final File file ) throws RemoteException;
+ void setCacheDirectoryPath( final String path ) throws RemoteException;

/**
* Return the array of hosts configured for the cache.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultCacheModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultCacheModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultCacheModel.java
Mon Jul 4 18:39:52 2005
@@ -94,8 +94,8 @@
m_layout = registry.getLayoutModel( key );
m_layout.addDisposalListener( this );

- File cache = home.getCacheDirectory();
- setCacheDirectory( cache, false );
+ String path = home.getCacheDirectoryPath();
+ setCacheDirectoryPath( path, false );

HostStorage[] hosts = home.getInitialHosts();
m_sortedHosts = sortHosts();
@@ -147,9 +147,9 @@
*
* @param file the cache directory
*/
- public void setCacheDirectory( final File file ) throws RemoteException
+ public void setCacheDirectoryPath( final String path ) throws
RemoteException
{
- setCacheDirectory( file, true );
+ setCacheDirectoryPath( path, true );
}

/**
@@ -157,19 +157,20 @@
*
* @param file the cache directory
*/
- public void setCacheDirectory( final File file, boolean notify ) throws
RemoteException
+ public void setCacheDirectoryPath( final String path, boolean notify )
throws RemoteException
{
synchronized( m_lock )
{
- if( null == file )
+ if( null == path )
{
- throw new NullPointerException( "file" );
+ throw new NullPointerException( "path" );
}
- File cache = file;
+ String resolved = PropertyResolver.resolve( path );
+ File cache = new File( resolved );
if( false == cache.isAbsolute() )
{
File anchor = getAnchorDirectory();
- cache = new File( anchor, file.toString() );
+ cache = new File( anchor, resolved );
cache.mkdirs();
}
if( null == m_cache )
@@ -181,10 +182,10 @@
getLogger().debug( "updating cache: " + cache );
}
m_cache = cache;
- m_home.setCacheDirectory( cache );
+ m_home.setCacheDirectoryPath( path );
if( notify )
{
- CacheDirectoryChangeEvent event = new
CacheDirectoryChangeEvent( this, m_cache );
+ CacheDirectoryChangeEvent event = new
CacheDirectoryChangeEvent( this, path );
enqueueEvent( event );
}
}
@@ -282,6 +283,15 @@
}

/**
+ * Return the cache directory path.
+ * @return the cache path.
+ */
+ public String getCacheDirectoryPath() throws RemoteException
+ {
+ return m_home.getCacheDirectoryPath();
+ }
+
+ /**
* Return the directory to be used by the cache handler as the cache
directory.
* @return the cache directory.
*/
@@ -437,13 +447,5 @@
super( source, host );
}
}
-
- class CacheDirectoryChangeEvent extends FileChangeEvent
- {
- public CacheDirectoryChangeEvent( Object source, File file )
- {
- super( source, file );
- }
- }
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/runtime/DefaultCacheHandler.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/runtime/DefaultCacheHandler.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/runtime/DefaultCacheHandler.java
Mon Jul 4 18:39:52 2005
@@ -49,7 +49,7 @@
import net.dpml.transit.model.CacheModel;
import net.dpml.transit.model.CacheListener;
import net.dpml.transit.model.Logger;
-import net.dpml.transit.model.FileChangeEvent;
+import net.dpml.transit.model.CacheDirectoryChangeEvent;
import net.dpml.transit.model.HostModel;
import net.dpml.transit.model.CacheEvent;
import net.dpml.transit.model.LayoutModel;
@@ -187,9 +187,9 @@
* Notify the listener of a change to the cache directory.
* @param event the cache directory change event
*/
- public void cacheDirectoryChanged( FileChangeEvent event ) throws
RemoteException
+ public void cacheDirectoryChanged( CacheDirectoryChangeEvent event )
throws RemoteException
{
- File cache = event.getFile();
+ File cache = m_model.getCacheDirectory();
synchronized( this )
{
setLocalCacheDirectory( cache );

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/store/CacheStorage.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/store/CacheStorage.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/store/CacheStorage.java
Mon Jul 4 18:39:52 2005
@@ -28,12 +28,12 @@
public interface CacheStorage extends CodeBaseStorage
{
/**
- * Return the cache directory.
- * @return the cache directory
+ * Return the cache directory path.
+ * @return the cache directory path
*/
- File getCacheDirectory();
+ String getCacheDirectoryPath();

- void setCacheDirectory( File cache );
+ void setCacheDirectoryPath( String path );

String getLayoutModelKey();


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/unit/CacheStorageUnit.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/unit/CacheStorageUnit.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/unit/CacheStorageUnit.java
Mon Jul 4 18:39:52 2005
@@ -60,16 +60,15 @@
*
* @param file the cache directory
*/
- public void setCacheDirectory( File file )
+ public void setCacheDirectoryPath( String path )
{
Preferences prefs = getPreferences();
- if( null == file )
+ if( null == path )
{
setValue( "location", null );
}
else
{
- String path = file.toString();
setValue( "location", path );
}
}
@@ -131,12 +130,10 @@
* @param prefs the cache preferences
* @return the cache directory
*/
- public File getCacheDirectory()
+ public String getCacheDirectoryPath()
{
Preferences prefs = getPreferences();
- String path = prefs.get( "location", "cache" );
- String cache = PropertyResolver.resolve( System.getProperties(),
path );
- return new File( cache );
+ return prefs.get( "location", "${dpml.data}/cache" );
}

private Preferences getHostsNodePreferences()

Modified:
development/main/transit/core/handler/src/test/net/dpml/transit/manager/TransitManagerTestCase.java
==============================================================================
---
development/main/transit/core/handler/src/test/net/dpml/transit/manager/TransitManagerTestCase.java
(original)
+++
development/main/transit/core/handler/src/test/net/dpml/transit/manager/TransitManagerTestCase.java
Mon Jul 4 18:39:52 2005
@@ -52,10 +52,9 @@

public void testCacheDirectory() throws Exception
{
- File dir = new File( m_data, "cache" ).getAbsoluteFile();
- m_model.getCacheModel().setCacheDirectory( dir );
- File cache = m_model.getCacheModel().getCacheDirectory();
- assertEquals( "cache", dir, cache );
+ m_model.getCacheModel().setCacheDirectoryPath( "my-cache" );
+ String cache = m_model.getCacheModel().getCacheDirectoryPath();
+ assertEquals( "cache", "my-cache", cache );
}
}




  • svn commit: r2966 - in development/main/transit/core/handler/src: main/net/dpml/transit/model main/net/dpml/transit/runtime main/net/dpml/transit/store main/net/dpml/transit/unit test/net/dpml/transit/manager, mcconnell, 07/04/2005

Archive powered by MHonArc 2.6.24.

Top of Page