Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2719 - development/main/transit/core/handler/src/main/net/dpml/transit/cache

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: r2719 - development/main/transit/core/handler/src/main/net/dpml/transit/cache
  • Date: Sun, 05 Jun 2005 15:16:08 -0400

Author: mcconnell AT dpml.net
Date: Sun Jun 5 15:16:08 2005
New Revision: 2719

Modified:

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

development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultResourceHost.java
Log:
Add disposal semantics to the default cache handler and host implementation.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultCacheHandler.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultCacheHandler.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultCacheHandler.java
Sun Jun 5 15:16:08 2005
@@ -45,6 +45,7 @@

import net.dpml.lang.NullArgumentException;

+import net.dpml.transit.Handler;
import net.dpml.transit.Transit;
import net.dpml.transit.TransitException;
import net.dpml.transit.artifact.Artifact;
@@ -69,7 +70,7 @@
* cache configuration, and another listener for changes to subsidiary node
changes
* reflecting the addition, modification and removal of hosts.
*/
-public class DefaultCacheHandler implements CacheHandler, CacheListener
+public class DefaultCacheHandler implements CacheHandler, CacheListener,
Handler
{
//
------------------------------------------------------------------------
// state
@@ -165,6 +166,35 @@
}

//
------------------------------------------------------------------------
+ // Handler
+ //
------------------------------------------------------------------------
+
+ /**
+ * Dispose of the manager. During disposal a manager is required to
+ * release all references such as listeners and internal resources
+ * in preparation for garbage collection.
+ */
+ public void dispose()
+ {
+ m_model.removeCacheListener( this );
+ synchronized( m_resourceHosts )
+ {
+
+ ResourceHost[] hosts = (ResourceHost[])
m_resourceHosts.values().toArray( new ResourceHost[0] );
+ for( int i=0; i<hosts.length; i++ )
+ {
+ ResourceHost host = hosts[i];
+ if( host instanceof Handler )
+ {
+ Handler handler = (Handler) host;
+ handler.dispose();
+ }
+ }
+ m_resourceHosts.clear();
+ }
+ }
+
+ //
------------------------------------------------------------------------
// impl
//
------------------------------------------------------------------------

@@ -567,11 +597,20 @@
*/
public void hostRemoved( HostNodeEvent event )
{
- HostModel host = event.getHostModel();
- String id = host.getID();
synchronized( m_resourceHosts )
{
- m_resourceHosts.remove( id );
+ HostModel model = event.getHostModel();
+ String id = model.getID();
+ ResourceHost host = (ResourceHost) m_resourceHosts.get( id );
+ if( null != host )
+ {
+ if( host instanceof Handler )
+ {
+ Handler handler = (Handler) host;
+ handler.dispose();
+ }
+ m_resourceHosts.remove( id );
+ }
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultResourceHost.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultResourceHost.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultResourceHost.java
Sun Jun 5 15:16:08 2005
@@ -63,6 +63,7 @@
import net.dpml.transit.network.TransitAuthenticator;
import net.dpml.transit.network.TransitAuthenticatorImpl;

+import net.dpml.transit.Handler;
import net.dpml.transit.model.HostModel;
import net.dpml.transit.model.HostListener;
import net.dpml.transit.model.HostNameEvent;
@@ -80,7 +81,7 @@
* realm/domain authentication. It may be introduced in the future.
* </p>
*/
-public class DefaultResourceHost implements ResourceHost, HostListener
+public class DefaultResourceHost implements ResourceHost, HostListener,
Handler
{
//
------------------------------------------------------------------------
// state
@@ -132,6 +133,20 @@
}

//
------------------------------------------------------------------------
+ // Handler
+ //
------------------------------------------------------------------------
+
+ /**
+ * Dispose of the manager. During disposal a manager is required to
+ * release all references such as listeners and internal resources
+ * in preparation for garbage collection.
+ */
+ public void dispose()
+ {
+ m_model.removeHostListener( this );
+ }
+
+ //
------------------------------------------------------------------------
// HostListener
//
------------------------------------------------------------------------




  • svn commit: r2719 - development/main/transit/core/handler/src/main/net/dpml/transit/cache, mcconnell, 06/05/2005

Archive powered by MHonArc 2.6.24.

Top of Page