Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2688 - in development/main: . depot/prefs/src/main/net/dpml/depot/prefs transit/core/handler/src/main/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: r2688 - in development/main: . depot/prefs/src/main/net/dpml/depot/prefs transit/core/handler/src/main/net/dpml/transit/manager
  • Date: Wed, 01 Jun 2005 19:08:20 -0400

Author: mcconnell AT dpml.net
Date: Wed Jun 1 19:08:18 2005
New Revision: 2688

Modified:
development/main/build.bat

development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
Log:
Work-in-progress on host availability.

Modified: development/main/build.bat
==============================================================================
--- development/main/build.bat (original)
+++ development/main/build.bat Wed Jun 1 19:08:18 2005
@@ -41,6 +41,8 @@
if ERRORLEVEL 1 goto fail
CALL :metro
if ERRORLEVEL 1 goto fail
+CALL :test
+if ERRORLEVEL 1 goto fail
GOTO :EOF

:fail

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
Wed Jun 1 19:08:18 2005
@@ -556,7 +556,7 @@
String baseValue = m_base.getText();
URL base = resolveBaseURL( baseValue );
boolean trusted = m_trusted.isSelected();
- boolean value = m_enabled.isSelected();
+ boolean enabled = m_enabled.isSelected();
LayoutModel layout = (LayoutModel) m_strategy.getSelectedItem();
m_manager.update( base, null, enabled, trusted, layout );
m_parent.hide();

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java
Wed Jun 1 19:08:18 2005
@@ -24,11 +24,14 @@
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.EventObject;
import java.util.EventListener;
+import java.util.Set;
+import java.util.TreeSet;
import java.util.prefs.Preferences;
import java.util.prefs.PreferenceChangeEvent;
import java.util.prefs.PreferenceChangeListener;
@@ -75,6 +78,8 @@
private final LayoutRegistryManager m_layout;
private final List m_list = new LinkedList();

+ private final Set m_available = Collections.synchronizedSortedSet( new
TreeSet() );
+
private File m_cache;

//
------------------------------------------------------------------------
@@ -92,7 +97,7 @@
//

File cache = resolveCacheDirectory( prefs );
- setCacheDirectory( cache );
+ updateCacheDirectory( cache );

//
// construct the hosts
@@ -129,8 +134,34 @@
//
------------------------------------------------------------------------

/**
- * Return an array of host managers currently assigned to the cache.
+ * Update the preferences cache location attribute with the value of
+ * the supplied file. If the file argument is null the cache location
+ * will be set to "cache" otherwise the string form of the file will
+ * be assigned.
+ *
+ * @param file the cache directory
+ */
+ public void setCacheDirectory( File file )
+ {
+ Preferences prefs = getPreferences();
+ if( null == file )
+ {
+ prefs.put( "location", "cache" );
+ }
+ else
+ {
+ String path = file.toString();
+ prefs.put( "location", path );
+ }
+ }
+
+ /**
+ * Return an array of host managers currently assigned to the cache. This
+ * operations returns all hosts (including non-operation and non-enabled
+ * hosts).
+ *
* @return the host manager array
+ * @see #getAvailableHosts
*/
public HostManager[] getHostManagers()
{
@@ -188,26 +219,6 @@
}

/**
- * Set the local cache directory.
- * @param file the cache directory
- */
- public synchronized void setCacheDirectory( File file )
- {
- if( null == file )
- {
- throw new NullPointerException( "file" );
- }
- File cache = file;
- if( false == cache.isAbsolute() )
- {
- File anchor = getAnchorDirectory();
- cache = new File( anchor, file.toString() );
- cache.mkdirs();
- }
- m_cache = cache;
- }
-
- /**
* Dispose of the manager.
*/
public void dispose()
@@ -272,19 +283,10 @@
*/
public HostModel[] getAvailableHosts()
{
- ArrayList list = new ArrayList();
- HostModel[] hosts = (HostModel[]) m_list.toArray( new HostModel[0] );
- for( int i=0; i<hosts.length; i++ )
+ synchronized( m_available )
{
- HostModel host = hosts[i];
- if( host.getAvailable() && host.getEnabled() )
- {
- list.add( host );
- }
+ return (HostModel[]) m_available.toArray( new HostModel[0] );
}
- HostModel[] selection = (HostModel[]) list.toArray( new HostModel[0]
);
- Arrays.sort( selection );
- return selection;
}

/**
@@ -328,7 +330,7 @@
if( "location".equals( key ) )
{
File cache = resolveCacheDirectory( prefs );
- setCacheDirectory( cache );
+ updateCacheDirectory( cache );
}
}

@@ -385,6 +387,8 @@
*/
public void enabledStateChanged( HostEnabledEvent event )
{
+ HostModel host = event.getHostModel();
+ updateAvailableHostsList( host );
}

/**
@@ -417,19 +421,44 @@
*/
public void availabilityChanged( HostAvailabilityEvent event )
{
- System.out.println(
- "# HOST AVAILABILITY CHANGE "
- + event.getHostModel().getID()
- + ", "
- + event.getAvailability() );
+ HostModel host = event.getHostModel();
+ updateAvailableHostsList( host );
}
-
}

//
------------------------------------------------------------------------
// internal
//
------------------------------------------------------------------------

+ /**
+ * Update the value the local cache directory.
+ *
+ * @param file the cache directory
+ */
+ private synchronized void updateCacheDirectory( File file )
+ {
+ if( null == file )
+ {
+ throw new NullPointerException( "file" );
+ }
+ File cache = file;
+ if( false == cache.isAbsolute() )
+ {
+ File anchor = getAnchorDirectory();
+ cache = new File( anchor, file.toString() );
+ cache.mkdirs();
+ }
+ if( null == m_cache )
+ {
+ getLogger().debug( "setting cache: " + cache );
+ }
+ else
+ {
+ getLogger().debug( "updating cache: " + cache );
+ }
+ m_cache = cache;
+ }
+
private void addHostModel( Preferences prefs, boolean notify ) throws
UnknownHostException, IOException
{
Logger logger = getLogger();
@@ -448,6 +477,7 @@
}
m_list.add( model );
model.addPluginListener( this );
+ updateAvailableHostsList( model );
model.addHostListener( m_availabilityListener );
if( notify )
{
@@ -468,6 +498,10 @@
m_list.remove( model );
model.removePluginListener( this );
model.removeHostListener( m_availabilityListener );
+ synchronized( m_available )
+ {
+ m_available.remove( model );
+ }
HostRemovedEvent event = new HostRemovedEvent( this, model );
super.enqueueEvent( event );
}
@@ -488,6 +522,29 @@
return null;
}

+ private void updateAvailableHostsList( HostModel host )
+ {
+ synchronized( m_available )
+ {
+ boolean available = host.getAvailable();
+ boolean enabled = host.getEnabled();
+ if( available && enabled )
+ {
+ m_available.remove( host );
+ m_available.add( host );
+ getLogger().debug( "added available host: " + host.getID() );
+ }
+ else
+ {
+ boolean removed = m_available.remove( host );
+ if( removed )
+ {
+ getLogger().debug( "removed available host: " +
host.getID() );
+ }
+ }
+ }
+ }
+
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java
Wed Jun 1 19:08:18 2005
@@ -466,19 +466,10 @@
catch( UnknownHostException uhe )
{
setError( uhe );
- final String error =
- "Unable to propergate change event due to an
unresolved host."
- + "\nPreferences Node: " + prefs
- + "\nHost path: " + prefs.get( "base", null );
- getLogger().error( error, uhe );
}
catch( IOException ioe )
{
setError( ioe );
- final String error =
- "Unable to propergate change event due to an
unexpected IO error."
- + "\nPreferences Node: " + prefs;
- getLogger().error( error, ioe );
}
}
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
Wed Jun 1 19:08:18 2005
@@ -165,6 +165,7 @@
*/
public void dispose()
{
+ getLogger().debug( "initiating disposal" );
try
{
getPreferences().removePreferenceChangeListener( this );



  • svn commit: r2688 - in development/main: . depot/prefs/src/main/net/dpml/depot/prefs transit/core/handler/src/main/net/dpml/transit/manager, mcconnell, 06/01/2005

Archive powered by MHonArc 2.6.24.

Top of Page