notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2726 - development/main/transit/core/handler/src/main/net/dpml/transit/builder
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2726 - development/main/transit/core/handler/src/main/net/dpml/transit/builder
- Date: Sun, 05 Jun 2005 17:28:18 -0400
Author: mcconnell AT dpml.net
Date: Sun Jun 5 17:28:18 2005
New Revision: 2726
Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyStorageHome.java
- copied, changed from r2717,
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyHelper.java
Removed:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyHelper.java
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
Log:
Put in place active storage management for the proxy sub-system.
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java
Sun Jun 5 17:28:18 2005
@@ -63,6 +63,8 @@
private boolean m_factoryPolicy = true;
private boolean m_purgePolicy = false;
+ private ProxyStorageHome m_proxyHome;
+
//
------------------------------------------------------------------------
// ModificationListener
//
------------------------------------------------------------------------
@@ -137,6 +139,7 @@
Logger logger = getLogger();
Preferences prefs = getPreferences();
URL authority = getAuthority();
+ Date creation = new Date();
if( m_purgePolicy )
{
@@ -179,8 +182,11 @@
// create the sub-systems
//
- Date creation = new Date();
- ProxyManager proxy = createProxyManager( creation );
+ m_proxyHome = createProxyHome( creation );
+ ProxyManager proxy = m_proxyHome.create();
+
+
+ //ProxyManager proxy = createProxyManager( creation );
LayoutRegistryManager layout = createLayoutRegistryManager( creation
);
CacheManager cache = createCacheManager( creation, layout );
ContentRegistryManager content = createContentRegistryManager(
creation );
@@ -205,18 +211,19 @@
}
}
- private ProxyManager createProxyManager( Date creation ) throws
BuilderException
+ private ProxyStorageHome createProxyHome( Date creation ) throws
BuilderException
{
try
{
+ boolean policy = getStoragePolicy();
Logger logger = getLogger().getChildLogger( "proxy" );
Preferences prefs = getPreferences().node( "proxy" );
- return ProxyHelper.createProxyManager( logger, creation, prefs );
+ return new ProxyStorageHome( prefs, logger, creation, policy );
}
catch( Throwable e )
{
final String error =
- "An error occured during construction of the proxy manager.";
+ "An error occured during construction of the proxy storage
home.";
throw new BuilderException( error, e );
}
}
@@ -312,6 +319,11 @@
return m_authority;
}
+ private boolean getStoragePolicy()
+ {
+ return m_savePolicy;
+ }
+
private static final Logger DEFAULT_LOGGER = new LoggingAdapter();
private static final Preferences DEFAULT_PREFS =
Preferences.userNodeForPackage( Transit.class );
}
Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyStorageHome.java
(from r2717,
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyHelper.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyStorageHome.java
Sun Jun 5 17:28:18 2005
@@ -24,33 +24,57 @@
import java.util.Date;
import net.dpml.transit.model.Logger;
-
import net.dpml.transit.management.ProxyManager;
-
+import net.dpml.transit.management.ModificationListener;
+import net.dpml.transit.management.ModificationEvent;
import net.dpml.transit.manager.DefaultProxyManager;
/**
* The LayoutHelper class is responsible for the setup of initial factory
* default preference settings.
*/
-class ProxyHelper extends PreferencesHelper
+class ProxyStorageHome extends AbstractStorageHome
{
+ private ModificationListener m_listener;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ ProxyStorageHome( Preferences prefs, Logger logger, Date creation,
boolean policy )
+ {
+ super( prefs, logger, creation, policy );
+ if( policy )
+ {
+ m_listener = new StorageListener();
+ }
+ }
+
//
------------------------------------------------------------------------
// internalization
//
------------------------------------------------------------------------
- public static ProxyManager createProxyManager( Logger logger, Date
creation, Preferences prefs )
- throws BuilderException, BackingStoreException
+ public ProxyManager create()
+ throws BuilderException
{
- URL host = getURL( prefs, "host" );
- String[] excludes = getExcludes( prefs );
- PasswordAuthentication auth = getAuthentication( prefs );
- return new DefaultProxyManager( logger, creation, host, auth,
excludes );
+ Preferences prefs = getPreferences();
+ Logger logger = getLogger();
+ Date creation = getCreationDate();
+ URL host = getURL( "host" );
+ String[] excludes = getExcludes();
+ PasswordAuthentication auth = getAuthentication();
+ DefaultProxyManager manager = new DefaultProxyManager( logger,
creation, host, auth, excludes );
+ if( null != m_listener )
+ {
+ manager.addModificationListener( m_listener );
+ }
+ return manager;
}
- private static PasswordAuthentication getAuthentication( Preferences
prefs )
+ private PasswordAuthentication getAuthentication()
throws BuilderException
{
+ Preferences prefs = getPreferences();
byte[] bytes = prefs.getByteArray( "authentication", new byte[0] );
if( bytes.length == 0 )
{
@@ -62,30 +86,42 @@
}
}
- private static String[] getExcludes( Preferences prefs ) throws
BackingStoreException
+ private String[] getExcludes() throws BuilderException
{
- Preferences excludes = prefs.node( "excludes" );
- return excludes.keys();
+ try
+ {
+ Preferences prefs = getPreferences();
+ Preferences excludes = prefs.node( "excludes" );
+ return excludes.keys();
+ }
+ catch( BackingStoreException e )
+ {
+ final String error =
+ "Cannot resolve excludes due to preferences backing store
error.";
+ throw new BuilderException( error, e );
+ }
}
//
------------------------------------------------------------------------
// externalization
//
------------------------------------------------------------------------
- public void setProxyManager( ProxyManager model, Preferences prefs )
+ public void setProxyManager( ProxyManager manager )
throws BuilderException
{
- URL url = model.getHost();
- PasswordAuthentication auth = model.getAuthentication();
+ Preferences prefs = getPreferences();
+ URL url = manager.getHost();
+ PasswordAuthentication auth = manager.getAuthentication();
synchronized( prefs )
{
- setProxyHost( prefs, url );
- setProxyAuthentication( prefs, auth );
+ setProxyHost( url );
+ setProxyAuthentication( auth );
}
}
- public void setProxyHost( Preferences prefs, URL host )
+ public void setProxyHost( URL host )
{
+ Preferences prefs = getPreferences();
if( null == host )
{
prefs.remove( "host" );
@@ -94,15 +130,16 @@
}
else
{
- prefs.put( "host", host.toExternalForm() );
+ setURL( "host", host );
prefs.put( "scheme", "" );
prefs.put( "prompt", "" );
}
}
- private static void setProxyAuthentication( Preferences prefs,
PasswordAuthentication auth )
+ private void setProxyAuthentication( PasswordAuthentication auth )
throws BuilderException
{
+ Preferences prefs = getPreferences();
if( null == auth )
{
prefs.putByteArray( "authentication", new byte[0] );
@@ -113,5 +150,25 @@
prefs.putByteArray( "authentication", bytes );
}
}
+
+ private class StorageListener implements ModificationListener
+ {
+ public void modified( ModificationEvent event )
+ {
+ ProxyManager manager = (ProxyManager) event.getManager();
+ try
+ {
+ Date date = new Date();
+ setProxyManager( manager );
+ manager.setCreationDate( date );
+ }
+ catch( Throwable e )
+ {
+ // TODO: propergate the error up to the HCI
+ manager.getLogger().error( "storage failure", e );
+ }
+ }
+ }
}
+
- svn commit: r2726 - development/main/transit/core/handler/src/main/net/dpml/transit/builder, mcconnell, 06/05/2005
Archive powered by MHonArc 2.6.24.