Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2714 - in development/main: depot/prefs/src/main/net/dpml/depot/prefs metro/composition/content/src/main/net/dpml/composition/content transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/builder transit/core/handler/src/main/net/dpml/transit/management transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/test transit/core/tools/src/main/net/dpml/transit/tools

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: r2714 - in development/main: depot/prefs/src/main/net/dpml/depot/prefs metro/composition/content/src/main/net/dpml/composition/content transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/builder transit/core/handler/src/main/net/dpml/transit/management transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/test transit/core/tools/src/main/net/dpml/transit/tools
  • Date: Sun, 05 Jun 2005 14:21:33 -0400

Author: mcconnell AT dpml.net
Date: Sun Jun 5 14:21:31 2005
New Revision: 2714

Added:

development/main/transit/core/handler/src/main/net/dpml/transit/management/Manager.java

development/main/transit/core/handler/src/main/net/dpml/transit/management/ModificationEvent.java

development/main/transit/core/handler/src/main/net/dpml/transit/management/ModificationListener.java
Modified:

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

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

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

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

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

development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryManagerPanel.java
development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java

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

development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java

development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/CacheHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentRegistryHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/HostHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutRegistryHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesStorageHome.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitHome.java

development/main/transit/core/handler/src/main/net/dpml/transit/management/PluginManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/management/ProxyManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/management/TransitManager.java

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

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

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

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

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

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

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

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

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

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

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

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

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

development/main/transit/core/handler/src/test/net/dpml/transit/test/LinkTestCase.java

development/main/transit/core/handler/src/test/net/dpml/transit/test/OfflineTestCase.java

development/main/transit/core/handler/src/test/net/dpml/transit/test/OnlineTestCase.java

development/main/transit/core/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
Log:
Add facilities that separate storage management from model management
(enabling model manipulation for both confifuration and runtime scenarios).

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheManagerPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheManagerPanel.java
Sun Jun 5 14:21:31 2005
@@ -48,7 +48,6 @@
import javax.swing.table.TableColumnModel;

import net.dpml.transit.Transit;
-import net.dpml.transit.builder.TransitHome;
import net.dpml.transit.util.ExceptionHelper;
import net.dpml.transit.management.CacheManager;
import net.dpml.transit.management.HostManager;
@@ -75,7 +74,6 @@
//--------------------------------------------------------------

private final Window m_parent;
- private final TransitHome m_home;

private final ClassicTable m_table;
private final EditAction m_editAction;
@@ -92,11 +90,11 @@
// constructor
//--------------------------------------------------------------

- public CacheManagerPanel( Window parent, TransitHome home, CacheManager
manager, LayoutRegistryManager layouts )
+ public CacheManagerPanel(
+ Window parent, CacheManager manager, LayoutRegistryManager layouts )
{
Transit.getInstance();

- m_home = home;
m_parent = parent;
m_manager = manager;
m_layouts = layouts;
@@ -157,14 +155,22 @@
if( "selection".equals( event.getPropertyName() ) )
{
m_selection = (String) event.getNewValue();
- try
+ if( null != m_selection )
{
- HostManager model = m_manager.getHostManager( m_selection );
- m_edit.setEnabled( true );
- m_delete.setEnabled( false == model.isBootstrap() );

- getRootPane().setDefaultButton( m_edit );
+ try
+ {
+ HostManager model = m_manager.getHostManager(
m_selection );
+ m_edit.setEnabled( true );
+ m_delete.setEnabled( false == model.isBootstrap() );

+ getRootPane().setDefaultButton( m_edit );
+ }
+ catch( UnknownKeyException e )
+ {
+ m_edit.setEnabled( false );
+ m_delete.setEnabled( false );
+ }
}
- catch( UnknownKeyException e )
+ else
{
m_edit.setEnabled( false );
m_delete.setEnabled( false );

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryManagerPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryManagerPanel.java
Sun Jun 5 14:21:31 2005
@@ -55,7 +55,6 @@
import net.dpml.transit.management.ContentManager;
import net.dpml.transit.model.UnknownKeyException;
import net.dpml.transit.model.DuplicateKeyException;
-import net.dpml.transit.builder.TransitHome;

/**
* Runnable plugin that handles DPML environment setup.
@@ -69,7 +68,6 @@
//--------------------------------------------------------------

private final Window m_parent;
- private final TransitHome m_home;

private ClassicTable m_table;
private EditAction m_editAction;
@@ -84,11 +82,10 @@
// constructor
//--------------------------------------------------------------

- public ContentRegistryManagerPanel( Window parent, TransitHome home,
ContentRegistryManager manager )
+ public ContentRegistryManagerPanel( Window parent,
ContentRegistryManager manager )
{
super();

- m_home = home;
m_manager = manager;
m_parent = parent;


Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesFrame.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesFrame.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesFrame.java
Sun Jun 5 14:21:31 2005
@@ -41,7 +41,6 @@
import net.dpml.transit.Transit;
import net.dpml.transit.model.TransitModel;
import net.dpml.transit.management.TransitManager;
-import net.dpml.transit.builder.TransitHome;

/**
* Dialog that presents the default preferences for DPML applications
including
@@ -75,7 +74,7 @@
*/
private static final int ZERO = 0;

- public DepotPreferencesFrame( TransitHome home ) throws Exception
+ public DepotPreferencesFrame( TransitManager manager ) throws Exception
{
super();

@@ -85,7 +84,7 @@
setTitle( "DPML Depot" );
Dimension size = new Dimension( DEFAULT_DIALOG_WIDTH,
DEFAULT_DIALOG_HEIGHT );
setSize( size );
- DepotPreferencesPanel panel = new DepotPreferencesPanel( this, home
);
+ DepotPreferencesPanel panel = new DepotPreferencesPanel( this,
manager );
setContentPane( panel );
getRootPane().setDefaultButton( panel.getDefaultButton() );
addWindowListener(

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
Sun Jun 5 14:21:31 2005
@@ -46,7 +46,6 @@
import net.dpml.transit.management.CacheManager;
import net.dpml.transit.management.ContentRegistryManager;
import net.dpml.transit.management.ProxyManager;
-import net.dpml.transit.builder.TransitHome;

/**
* Panel that presents the default preferences for DPML applications
including
@@ -77,7 +76,6 @@

private ButtonPanel m_buttons;

- private TransitHome m_home;
private TransitManager m_manager;
private LayoutRegistryManagerPanel m_layoutPanel;
private CacheManagerPanel m_cachePanel;
@@ -86,15 +84,12 @@

private final Window m_window;

- public DepotPreferencesPanel( Window window, final TransitHome home )
throws Exception
+ public DepotPreferencesPanel( Window window, final TransitManager
manager ) throws Exception
{
super( new BorderLayout() );

- m_home = home;
m_window = window;
- m_manager = home.createTransitManager();
-
- Transit.getInstance( m_manager );
+ m_manager = manager;

JLabel label =
IconHelper.createImageIconJLabel(
@@ -116,8 +111,8 @@
{
final CacheManager cache = m_manager.getCacheManager();
final LayoutRegistryManager layouts =
m_manager.getLayoutRegistryManager();
- m_layoutPanel = new LayoutRegistryManagerPanel( m_window,
home, layouts );
- m_cachePanel = new CacheManagerPanel( m_window, home, cache,
layouts );
+ m_layoutPanel = new LayoutRegistryManagerPanel( m_window,
layouts );
+ m_cachePanel = new CacheManagerPanel( m_window, cache,
layouts );
tabbedPane.addTab( "Cache", m_cachePanel );
tabbedPane.addTab( "Layout", m_layoutPanel );
tabbedPane.revalidate();
@@ -130,7 +125,7 @@
public void run()
{
final ContentRegistryManager content =
m_manager.getContentRegistryManager();
- m_registryPanel = new ContentRegistryManagerPanel( m_window,
home, content );
+ m_registryPanel = new ContentRegistryManagerPanel( m_window,
content );
tabbedPane.addTab( "Content", m_registryPanel );
}
}
@@ -141,7 +136,7 @@
public void run()
{
final ProxyManager proxy = m_manager.getProxyManager();
- m_proxyPanel = new ProxyManagerPanel( m_window, home, proxy );
+ m_proxyPanel = new ProxyManagerPanel( m_window, proxy );
tabbedPane.addTab( "Proxy", m_proxyPanel );
}
}

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutComboBoxModel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutComboBoxModel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutComboBoxModel.java
Sun Jun 5 14:21:31 2005
@@ -72,7 +72,7 @@
public void dispose()
{
m_manager.removeLayoutRegistryListener( this );
- m_host.addHostListener( this );
+ m_host.removeHostListener( this );
}


//--------------------------------------------------------------------------

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryManagerPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryManagerPanel.java
Sun Jun 5 14:21:31 2005
@@ -56,7 +56,6 @@
import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.DuplicateKeyException;
import net.dpml.transit.model.UnknownKeyException;
-import net.dpml.transit.builder.TransitHome;

/**
* Runnable plugin that handles DPML environment setup.
@@ -70,7 +69,6 @@
//--------------------------------------------------------------

private final Window m_parent;
- private final TransitHome m_home;

private ClassicTable m_table;
private EditAction m_editAction;
@@ -85,11 +83,10 @@
// constructor
//--------------------------------------------------------------

- public LayoutRegistryManagerPanel( Window parent, TransitHome home,
LayoutRegistryManager manager )
+ public LayoutRegistryManagerPanel( Window parent, LayoutRegistryManager
manager )
{
super();

- m_home = home;
m_manager = manager;
m_parent = parent;


Modified: development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java
==============================================================================
--- development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java
(original)
+++ development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java
Sun Jun 5 14:21:31 2005
@@ -46,37 +46,9 @@
final Logger logger = new LoggingAdapter();

//
- // check if a prefs reset has been requested
- //
-
- for( int i=0; i < args.length; i++ )
- {
- String arg = args[i];
- if( arg.equals( "-reset" ) )
- {
- try
- {
- Preferences usr = Preferences.userNodeForPackage(
Transit.class );
- logger.info( "resetting preferences: " + usr );
- usr.removeNode();
- usr.flush();
- Preferences sys = Preferences.systemNodeForPackage(
Transit.class );
- logger.info( "resetting preferences: " + sys );
- sys.removeNode();
- sys.flush();
- }
- catch( Throwable e )
- {
- logger.error( "preference reset failed", e );
- }
- }
- }
-
- //
// Setup transit protocol handler
//

- System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
SwingUtilities.invokeLater(
new Runnable() {
public void run()
@@ -97,8 +69,12 @@
Preferences prefs = Preferences.userNodeForPackage( Transit.class );
try
{
- TransitHome home = new PreferencesStorageHome( logger, prefs );
- new DepotPreferencesFrame( home );
+ TransitHome home = new PreferencesStorageHome();
+ home.setLogger( logger );
+ home.setPersistOnModification( true );
+ TransitManager manager = home.create();
+ Transit.getInstance( manager );
+ new DepotPreferencesFrame( manager );
}
catch( Exception e )
{

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyManagerPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyManagerPanel.java
Sun Jun 5 14:21:31 2005
@@ -50,7 +50,6 @@
import javax.swing.table.TableColumnModel;

import net.dpml.transit.Transit;
-import net.dpml.transit.builder.TransitHome;
import net.dpml.transit.model.ProxyModel;
import net.dpml.transit.model.ProxyListener;
import net.dpml.transit.management.ProxyManager;
@@ -74,7 +73,6 @@
//--------------------------------------------------------------

private final Window m_parent;
- private final TransitHome m_home;

private ProxyManager m_manager;
private AddAction m_add;
@@ -90,11 +88,10 @@
// constructor
//--------------------------------------------------------------

- public ProxyManagerPanel( Window parent, TransitHome home, ProxyManager
manager )
+ public ProxyManagerPanel( Window parent, ProxyManager manager )
{
super();

- m_home = home;
m_parent = parent;
m_manager = manager;


Modified:
development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java
==============================================================================
---
development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java
(original)
+++
development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java
Sun Jun 5 14:21:31 2005
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.ContentHandler;
+import java.util.Date;

import net.dpml.transit.TransitException;
import net.dpml.transit.model.Logger;
@@ -75,9 +76,10 @@
{
try
{
+ Date creation = new Date();
Logger logger = manager.getLogger().getChildLogger( PART );
URI uri = new URI( PART_HANDLER_PLUGIN_PATH );
- ContentManager m = new DefaultContentManager( logger, uri,
PART, TITLE );
+ ContentManager m = new DefaultContentManager( logger,
creation, uri, PART, TITLE );
manager.addContentManager( m );
}
catch( Throwable e )

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
Sun Jun 5 14:21:31 2005
@@ -155,7 +155,7 @@
try
{
TransitHome home = new PreferencesStorageHome();
- TransitModel model = home.createTransitManager();
+ TransitModel model = home.create();
return getInstance( model );
}
catch( TransitException e )

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/CacheHelper.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/CacheHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/CacheHelper.java
Sun Jun 5 14:21:31 2005
@@ -21,6 +21,7 @@
import java.net.URI;
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;

@@ -44,7 +45,7 @@
class CacheHelper extends HostHelper
{
public static CacheManager createCacheManager(
- LayoutRegistryModel registry, Logger logger, Preferences prefs )
+ LayoutRegistryModel registry, Logger logger, Date creation,
Preferences prefs )
throws BackingStoreException, UnknownKeyException,
DuplicateKeyException, BuilderException
{
File cache = getCacheDirectory( prefs );
@@ -55,12 +56,12 @@
{
String name = names[i];
Preferences p = hostsNode.node( name );
- HostManager manager = createHostManager( registry, logger, p );
+ HostManager manager = createHostManager( registry, logger,
creation, p );
list.add( manager );
}
HostManager[] managers = (HostManager[]) list.toArray( new
HostManager[0] );
URI uri = getURI( prefs, "uri" );
- return new DefaultCacheManager( logger, uri, registry, cache,
managers );
+ return new DefaultCacheManager( logger, creation, uri, registry,
cache, managers );
}

/**

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentHelper.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentHelper.java
Sun Jun 5 14:21:31 2005
@@ -18,6 +18,7 @@

import java.net.URI;
import java.net.MalformedURLException;
+import java.util.Date;
import java.util.prefs.Preferences;

import net.dpml.transit.model.Logger;
@@ -32,13 +33,13 @@
*/
class ContentHelper extends PreferencesHelper
{
- public static ContentManager createContentManager( Logger logger,
Preferences prefs )
+ public static ContentManager createContentManager( Logger logger, Date
creation, Preferences prefs )
throws BuilderException
{
String type = prefs.name();
String title = prefs.get( "title", type );
URI uri = getURI( prefs, "uri" );
- return new DefaultContentManager( logger, uri, type, title );
+ return new DefaultContentManager( logger, creation, uri, type, title
);
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentRegistryHelper.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentRegistryHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentRegistryHelper.java
Sun Jun 5 14:21:31 2005
@@ -19,6 +19,7 @@
import java.net.URI;
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;

@@ -36,7 +37,8 @@
*/
class ContentRegistryHelper extends ContentHelper
{
- public static ContentRegistryManager createContentRegistryManager(
Logger logger, Preferences prefs )
+ public static ContentRegistryManager createContentRegistryManager(
+ Logger logger, Date creation, Preferences prefs )
throws BackingStoreException, BuilderException, DuplicateKeyException
{
ArrayList list = new ArrayList();
@@ -45,12 +47,12 @@
{
String name = names[i];
Preferences p = prefs.node( name );
- ContentManager manager = createContentManager( logger, p );
+ ContentManager manager = createContentManager( logger, creation,
p );
list.add( manager );
}
ContentManager[] managers = (ContentManager[]) list.toArray( new
ContentManager[0] );
URI uri = getURI( prefs, "uri" );
- return new DefaultContentRegistryManager( logger, uri, managers );
+ return new DefaultContentRegistryManager( logger, creation, uri,
managers );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/HostHelper.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/HostHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/HostHelper.java
Sun Jun 5 14:21:31 2005
@@ -19,6 +19,7 @@
import java.net.URI;
import java.net.URL;
import java.net.MalformedURLException;
+import java.util.Date;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;
import java.net.PasswordAuthentication;
@@ -43,7 +44,7 @@
class HostHelper extends PreferencesHelper
{
public static HostManager createHostManager(
- LayoutRegistryModel registry, Logger logger, Preferences prefs )
+ LayoutRegistryModel registry, Logger logger, Date creation,
Preferences prefs )
throws BuilderException, UnknownKeyException
{
String id = prefs.name();
@@ -61,9 +62,8 @@
String prompt = prefs.get( "prompt", "" );
if( bootstrap )
{
-
return new DefaultHostManager(
- logger, id, new Local(
"net.dpml.transit.host.DefaultResoureHost", bootstrap ),
+ logger, creation, id, new Local(
"net.dpml.transit.host.DefaultResoureHost", bootstrap ),
base, index, name, trusted, enabled, priority,
layout, auth, scheme, prompt );
}
@@ -71,7 +71,7 @@
{
URI uri = getURI( prefs, "uri" );
return new DefaultHostManager(
- logger, id, new Plugin( uri ), base, index, name, trusted,
enabled, priority,
+ logger, creation, id, new Plugin( uri ), base, index, name,
trusted, enabled, priority,
layout, auth, scheme, prompt );
}
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutHelper.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutHelper.java
Sun Jun 5 14:21:31 2005
@@ -18,6 +18,7 @@

import java.net.URL;
import java.net.URI;
+import java.util.Date;
import java.util.prefs.Preferences;

import net.dpml.transit.model.Logger;
@@ -34,7 +35,7 @@
*/
class LayoutHelper extends PreferencesHelper
{
- public static LayoutManager createLayoutManager( Logger logger,
Preferences prefs )
+ public static LayoutManager createLayoutManager( Logger logger, Date
creation, Preferences prefs )
throws BuilderException
{
String id = prefs.name();
@@ -43,7 +44,7 @@
if( null != uri )
{
Plugin plugin = new Plugin( uri );
- return new DefaultLayoutManager( logger, id, plugin, title );
+ return new DefaultLayoutManager( logger, creation, id, plugin,
title );
}
else
{
@@ -51,12 +52,12 @@
if( null != classname )
{
Local local = new Local( classname, false );
- return new DefaultLayoutManager( logger, id, local, title );
+ return new DefaultLayoutManager( logger, creation, id,
local, title );
}
else
{
Local local = new Local(
"net.dpml.transit.layout.ClassicLayout", false );
- return new DefaultLayoutManager( logger, id, local, title );
+ return new DefaultLayoutManager( logger, creation, id,
local, title );
}
}
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutRegistryHelper.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutRegistryHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutRegistryHelper.java
Sun Jun 5 14:21:31 2005
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;
+import java.util.Date;

import net.dpml.transit.model.Logger;
import net.dpml.transit.model.DuplicateKeyException;
@@ -37,7 +38,8 @@
*/
class LayoutRegistryHelper extends LayoutHelper
{
- public static LayoutRegistryManager createLayoutRegistryManager( Logger
logger, Preferences prefs )
+ public static LayoutRegistryManager createLayoutRegistryManager(
+ Logger logger, Date creation, Preferences prefs )
throws BuilderException, BackingStoreException, DuplicateKeyException
{
ArrayList list = new ArrayList();
@@ -46,11 +48,11 @@
{
String name = names[i];
Preferences p = prefs.node( name );
- LayoutManager layout = createLayoutManager( logger, p );
+ LayoutManager layout = createLayoutManager( logger, creation, p
);
list.add( layout );
}
LayoutManager[] managers = (LayoutManager[]) list.toArray( new
LayoutManager[0] );
URI uri = getURI( prefs, "uri" );
- return new DefaultLayoutRegistryManager( logger, uri, managers );
+ return new DefaultLayoutRegistryManager( logger, creation, uri,
managers );
}
}

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 14:21:31 2005
@@ -18,6 +18,7 @@

import java.net.URL;
import java.net.MalformedURLException;
+import java.util.Date;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;

@@ -32,6 +33,8 @@
import net.dpml.transit.management.ProxyManager;
import net.dpml.transit.management.RepositoryManager;
import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.management.ModificationListener;
+import net.dpml.transit.management.ModificationEvent;

import net.dpml.transit.manager.DefaultTransitManager;

@@ -40,7 +43,7 @@
* The LayoutRegistryHelper class provides support for the crreating of a
* ContentRegistryManager based on a supplied preferences node.
*/
-public class PreferencesStorageHome implements TransitHome
+public class PreferencesStorageHome implements TransitHome,
ModificationListener
{
//
------------------------------------------------------------------------
// static
@@ -54,59 +57,107 @@
//
------------------------------------------------------------------------

private Logger m_logger;
- private final Preferences m_prefs;
- private final URL m_authority;
+ private Preferences m_prefs;
+ private URL m_authority;
+ private boolean m_savePolicy = false;
+ private boolean m_factoryPolicy = true;
+ private boolean m_purgePolicy = false;

//
------------------------------------------------------------------------
- // constructor
+ // ModificationListener
//
------------------------------------------------------------------------

- public PreferencesStorageHome()
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
{
- this( new LoggingAdapter() );
+ System.out.println( "# mod: " +
event.getManager().getClass().getName() );
}

- public PreferencesStorageHome( Logger logger )
- {
- this( logger, DEFAULT_PREFS_NODE );
- }
+ //
------------------------------------------------------------------------
+ // TransitHome
+ //
------------------------------------------------------------------------

- public PreferencesStorageHome( Preferences prefs )
+ public void setLogger( Logger logger )
{
- this( new LoggingAdapter(), prefs, null );
+ if( null == m_logger )
+ {
+ m_logger = logger;
+ }
+ else
+ {
+ throw new IllegalStateException( "logger already set" );
+ }
}

- public PreferencesStorageHome( Logger logger, Preferences prefs )
+ public void setPreferences( Preferences prefs )
{
- this( logger, prefs, null );
+ if( null == m_prefs )
+ {
+ m_prefs = prefs;
+ }
+ else
+ {
+ throw new IllegalStateException( "preferences already set" );
+ }
}

- public PreferencesStorageHome( Logger logger, Preferences prefs, URL
authority )
+ public void setAuthority( URL authority )
{
- if( null == logger )
+ if( null == m_authority )
{
- throw new NullPointerException( "logger" );
+ m_authority = authority;
}
- if( null == prefs )
+ else
{
- throw new NullPointerException( "prefs" );
+ throw new IllegalStateException( "authority already set" );
}
- m_logger = logger;
- m_prefs = prefs;
- m_authority = authority;
}

- //
------------------------------------------------------------------------
- // TransitHome
- //
------------------------------------------------------------------------
+ public void setPersistOnModification( boolean policy )
+ {
+ m_savePolicy = policy;
+ }

- public TransitManager createTransitManager()
+ public void useFactoryInitialization( boolean policy )
+ {
+ m_factoryPolicy = policy;
+ }
+
+ public void clearBeforeInitialization( boolean policy )
+ {
+ m_purgePolicy = policy;
+ }
+
+ public TransitManager create()
throws BuilderException
{
Logger logger = getLogger();
Preferences prefs = getPreferences();
URL authority = getAuthority();

+ if( m_purgePolicy )
+ {
+ try
+ {
+ String[] names = prefs.childrenNames();
+ for( int i=0; i<names.length; i++ )
+ {
+ Preferences child = prefs.node( names[i] );
+ child.removeNode();
+ }
+ prefs.clear();
+ }
+ catch( BackingStoreException e )
+ {
+ final String error =
+ "Internal error while attempting to purge preferences.";
+ throw new BuilderException( error, e );
+ }
+ }
+
//
// check for virgin prefs
//
@@ -115,7 +166,7 @@
{
TransitPreferences.setupPreferences( prefs, authority );
}
- else
+ else if( m_factoryPolicy )
{
long install = prefs.getLong( "installation", -1 );
if( install < 0 )
@@ -128,16 +179,23 @@
// create the sub-systems
//

- ProxyManager proxy = createProxyManager();
- LayoutRegistryManager layout = createLayoutRegistryManager();
- CacheManager cache = createCacheManager( layout );
- ContentRegistryManager content = createContentRegistryManager();
- RepositoryManager repository = createRepositoryManager();
+ Date creation = new Date();
+ ProxyManager proxy = createProxyManager( creation );
+ LayoutRegistryManager layout = createLayoutRegistryManager( creation
);
+ CacheManager cache = createCacheManager( creation, layout );
+ ContentRegistryManager content = createContentRegistryManager(
creation );
+ RepositoryManager repository = createRepositoryManager( creation );
+
+ ModificationListener store = null;
+ if( m_savePolicy )
+ {
+ store = this;
+ }

try
{
return new DefaultTransitManager(
- logger, layout, cache, content, repository, proxy );
+ this, logger, creation, layout, cache, content, repository,
proxy );
}
catch( Throwable e )
{
@@ -147,18 +205,13 @@
}
}

- public void saveTransitManager( TransitManager manager ) throws
BuilderException
- {
- throw new UnsupportedOperationException( "saveTransitManager/1" );
- }
-
- private ProxyManager createProxyManager() throws BuilderException
+ private ProxyManager createProxyManager( Date creation ) throws
BuilderException
{
try
{
Logger logger = getLogger().getChildLogger( "proxy" );
Preferences prefs = getPreferences().node( "proxy" );
- return ProxyHelper.createProxyManager( logger, prefs );
+ return ProxyHelper.createProxyManager( logger, creation, prefs );
}
catch( Throwable e )
{
@@ -168,13 +221,13 @@
}
}

- private LayoutRegistryManager createLayoutRegistryManager() throws
BuilderException
+ private LayoutRegistryManager createLayoutRegistryManager( Date creation
) throws BuilderException
{
try
{
Logger logger = getLogger().getChildLogger( "layout" );
Preferences prefs = getPreferences().node( "layout" );
- return LayoutRegistryHelper.createLayoutRegistryManager( logger,
prefs );
+ return LayoutRegistryHelper.createLayoutRegistryManager( logger,
creation, prefs );
}
catch( Throwable e )
{
@@ -184,13 +237,14 @@
}
}

- private CacheManager createCacheManager( LayoutRegistryManager registry
) throws BuilderException
+ private CacheManager createCacheManager(
+ Date creation, LayoutRegistryManager registry ) throws BuilderException
{
try
{
Logger logger = getLogger().getChildLogger( "cache" );
Preferences prefs = getPreferences().node( "cache" );
- return CacheHelper.createCacheManager( registry, logger, prefs );
+ return CacheHelper.createCacheManager( registry, logger,
creation, prefs );
}
catch( Throwable e )
{
@@ -200,13 +254,13 @@
}
}

- private ContentRegistryManager createContentRegistryManager() throws
BuilderException
+ private ContentRegistryManager createContentRegistryManager( Date
creation ) throws BuilderException
{
try
{
Logger logger = getLogger().getChildLogger( "content" );
Preferences prefs = getPreferences().node( "content" );
- return ContentRegistryHelper.createContentRegistryManager(
logger, prefs );
+ return ContentRegistryHelper.createContentRegistryManager(
logger, creation, prefs );
}
catch( Throwable e )
{
@@ -216,13 +270,13 @@
}
}

- private RepositoryManager createRepositoryManager() throws
BuilderException
+ private RepositoryManager createRepositoryManager( Date creation )
throws BuilderException
{
try
{
Logger logger = getLogger().getChildLogger( "repository" );
Preferences prefs = getPreferences().node( "repository" );
- return RepositoryHelper.createRepositoryManager( logger, prefs );
+ return RepositoryHelper.createRepositoryManager( logger,
creation, prefs );
}
catch( Throwable e )
{
@@ -234,11 +288,22 @@

private Preferences getPreferences()
{
- return m_prefs;
+ if( null == m_prefs )
+ {
+ return DEFAULT_PREFS;
+ }
+ else
+ {
+ return m_prefs;
+ }
}

private Logger getLogger()
{
+ if( null == m_logger )
+ {
+ return DEFAULT_LOGGER;
+ }
return m_logger;
}

@@ -247,6 +312,8 @@
return m_authority;
}

+ private static final Logger DEFAULT_LOGGER = new LoggingAdapter();
+ private static final Preferences DEFAULT_PREFS =
Preferences.userNodeForPackage( Transit.class );
}



Modified:
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/ProxyHelper.java
Sun Jun 5 14:21:31 2005
@@ -21,6 +21,7 @@
import java.net.PasswordAuthentication;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;
+import java.util.Date;

import net.dpml.transit.model.Logger;

@@ -38,13 +39,13 @@
// internalization
//
------------------------------------------------------------------------

- public static ProxyManager createProxyManager( Logger logger,
Preferences prefs )
+ public static ProxyManager createProxyManager( Logger logger, Date
creation, Preferences prefs )
throws BuilderException, BackingStoreException
{
URL host = getURL( prefs, "host" );
String[] excludes = getExcludes( prefs );
PasswordAuthentication auth = getAuthentication( prefs );
- return new DefaultProxyManager( logger, host, auth, excludes );
+ return new DefaultProxyManager( logger, creation, host, auth,
excludes );
}

private static PasswordAuthentication getAuthentication( Preferences
prefs )

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryHelper.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryHelper.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryHelper.java
Sun Jun 5 14:21:31 2005
@@ -18,6 +18,7 @@

import java.net.URI;
import java.net.MalformedURLException;
+import java.util.Date;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;

@@ -33,11 +34,11 @@
*/
class RepositoryHelper extends PreferencesHelper
{
- public static RepositoryManager createRepositoryManager( Logger logger,
Preferences prefs )
+ public static RepositoryManager createRepositoryManager( Logger logger,
Date creation, Preferences prefs )
throws BuilderException
{
URI uri = getURI( prefs, "uri" );
- return new DefaultRepositoryManager( logger, uri );
+ return new DefaultRepositoryManager( logger, creation, uri );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitHome.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitHome.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitHome.java
Sun Jun 5 14:21:31 2005
@@ -18,7 +18,11 @@

package net.dpml.transit.builder;

+import java.net.URL;
+import java.util.prefs.Preferences;
+
import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.model.Logger;

/**
* The Home defines the persistent storage home for transit management
configurations.
@@ -27,7 +31,18 @@
*/
public interface TransitHome
{
- TransitManager createTransitManager() throws BuilderException;
+ void setLogger( Logger logger );
+
+ void setPreferences( Preferences prefs );
+
+ void setAuthority( URL authority );
+
+ void setPersistOnModification( boolean policy );
+
+ void useFactoryInitialization( boolean policy );
+
+ void clearBeforeInitialization( boolean policy );
+
+ TransitManager create() throws BuilderException;

- void saveTransitManager( TransitManager manager ) throws
BuilderException;
}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/Manager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/Manager.java
Sun Jun 5 14:21:31 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.transit.management;
+
+import java.util.Date;
+
+/**
+ * The ProxyManager is an interface implemented by proxy managers.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface Manager
+{
+ Date getCreationDate();
+
+ Date getModificationDate();
+
+ void setCreationDate( Date date );
+
+ boolean isModified();
+
+ void addModificationListener( ModificationListener listener );
+
+ void removeModificationListener( ModificationListener listener );
+}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/ModificationEvent.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/ModificationEvent.java
Sun Jun 5 14:21:31 2005
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.transit.management;
+
+import java.util.Date;
+import java.util.EventObject;
+
+/**
+ * An event signalling a model modification.
+ */
+public class ModificationEvent extends EventObject
+{
+ private final Date m_date;
+ private final Manager m_manager;
+
+ public ModificationEvent( Manager manager, ModificationEvent source )
+ {
+ super( manager );
+ m_manager = source.getManager();
+ m_date = source.getModificationDate();
+ }
+
+ public ModificationEvent( Manager source, Date date )
+ {
+ super( source );
+ m_date = date;
+ m_manager = source;
+ }
+
+ public Manager getManager()
+ {
+ return m_manager;
+ }
+
+ public Date getModificationDate()
+ {
+ return m_date;
+ }
+}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/ModificationListener.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/ModificationListener.java
Sun Jun 5 14:21:31 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2005 Stephen McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.transit.management;
+
+import java.util.EventListener;
+
+/**
+ * A ProxyListener maintains information about the configuration of
+ * tranist proxy settings.
+ */
+public interface ModificationListener extends EventListener
+{
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ void modified( ModificationEvent event );
+
+}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/management/PluginManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/management/PluginManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/PluginManager.java
Sun Jun 5 14:21:31 2005
@@ -27,7 +27,7 @@
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
-public interface PluginManager extends PluginModel
+public interface PluginManager extends Manager, PluginModel
{
/**
* Set the plugin uri value.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/management/ProxyManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/management/ProxyManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/ProxyManager.java
Sun Jun 5 14:21:31 2005
@@ -28,7 +28,7 @@
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
-public interface ProxyManager extends ProxyModel
+public interface ProxyManager extends Manager, ProxyModel
{
void update( URL host, PasswordAuthentication auth, String[] excludes );


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/management/TransitManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/management/TransitManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/TransitManager.java
Sun Jun 5 14:21:31 2005
@@ -27,7 +27,7 @@
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
-public interface TransitManager extends TransitModel
+public interface TransitManager extends Manager, TransitModel
{
//
------------------------------------------------------------------------
// TransitMananger

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultCacheManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultCacheManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultCacheManager.java
Sun Jun 5 14:21:31 2005
@@ -25,6 +25,7 @@
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
@@ -63,6 +64,8 @@
import net.dpml.transit.management.ModelReferenceException;
import net.dpml.transit.management.CacheManager;
import net.dpml.transit.management.HostManager;
+import net.dpml.transit.management.ModificationListener;
+import net.dpml.transit.management.ModificationEvent;

import net.dpml.transit.util.PropertyResolver;

@@ -73,7 +76,7 @@
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id: StandardTransitDirector.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
*/
-public class DefaultCacheManager extends DefaultPluginManager implements
CacheManager
+public class DefaultCacheManager extends DefaultPluginManager implements
CacheManager, ModificationListener
{
//
------------------------------------------------------------------------
// state
@@ -90,10 +93,10 @@
//
------------------------------------------------------------------------

public DefaultCacheManager(
- Logger logger, URI uri, LayoutRegistryModel registry, File cache,
HostManager[] managers )
+ Logger logger, Date creation, URI uri, LayoutRegistryModel registry,
File cache, HostManager[] managers )
throws DuplicateKeyException
{
- super( logger, uri );
+ super( logger, creation, uri );
if( null == cache )
{
throw new NullPointerException( "cache" );
@@ -104,16 +107,29 @@
}

m_registry = registry;
-
- setCacheDirectory( cache );
+ setCacheDirectory( cache, false );
for( int i=0; i<managers.length; i++ )
{
HostManager manager = managers[i];
- addHostManager( manager );
+ addHostManager( manager, false );
}
}

//
------------------------------------------------------------------------
+ // ModificationListener (listen to modification to hosts)
+ //
------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
+ {
+ ModificationEvent e = new ModificationEvent( this, event );
+ enqueueEvent( e );
+ }
+
+ //
------------------------------------------------------------------------
// CacheManager
//
------------------------------------------------------------------------

@@ -124,6 +140,16 @@
*/
public void setCacheDirectory( final File file )
{
+ setCacheDirectory( file, true );
+ }
+
+ /**
+ * Update the value the local cache directory.
+ *
+ * @param file the cache directory
+ */
+ public void setCacheDirectory( final File file, boolean notify )
+ {
synchronized( m_lock )
{
if( null == file )
@@ -146,8 +172,12 @@
getLogger().debug( "updating cache: " + cache );
}
m_cache = cache;
- CacheDirectoryChangeEvent event = new CacheDirectoryChangeEvent(
this, m_cache );
- enqueueEvent( event );
+ if( notify )
+ {
+ setModified();
+ CacheDirectoryChangeEvent event = new
CacheDirectoryChangeEvent( this, m_cache );
+ enqueueEvent( event );
+ }
}
}

@@ -189,6 +219,7 @@
LayoutModel layout = m_registry.getLayoutModel( "classic" );
HostManager manager =
new DefaultHostManager( logger, id, layout );
+ addHostManager( manager );
}
catch( UnknownKeyException e )
{
@@ -198,19 +229,29 @@

public void addHostManager( HostManager manager ) throws
DuplicateKeyException
{
+ addHostManager( manager, true );
+ }
+
+ public void addHostManager( HostManager manager, boolean notify ) throws
DuplicateKeyException
+ {
synchronized( m_lock )
{
String id = manager.getID();
try
{
- HostManager m = getHostManager( id );
- throw new DuplicateKeyException( id );
+ HostManager m = getHostManager( id );
+ throw new DuplicateKeyException( id );
}
catch( UnknownKeyException e )
{
- m_list.add( manager );
- HostAddedEvent event = new HostAddedEvent( this, manager );
- enqueueEvent( event );
+ m_list.add( manager );
+ manager.addModificationListener( this );
+ if( notify )
+ {
+ HostAddedEvent event = new HostAddedEvent( this, manager
);
+ enqueueEvent( event );
+ setModified();
+ }
}
}
}
@@ -220,11 +261,13 @@
synchronized( m_lock )
{
Object[] listeners = manager.getListeners();
- if( listeners.length == 0 )
+ if( listeners.length == 1 )
{
- m_list.remove( manager );
- HostRemovedEvent event = new HostRemovedEvent( this,
manager );
- super.enqueueEvent( event );
+ m_list.remove( manager );
+ manager.removeModificationListener( this );
+ HostRemovedEvent event = new HostRemovedEvent( this, manager
);
+ super.enqueueEvent( event );
+ setModified();
}
else
{
@@ -279,11 +322,7 @@

public void processEvent( EventObject event )
{
- if( event instanceof PluginChangeEvent )
- {
- super.processPluginChangeEvent( (PluginChangeEvent) event );
- }
- else if( event instanceof HostNodeEvent )
+ if( event instanceof HostNodeEvent )
{
processHostEvent( (HostNodeEvent) event );
}
@@ -293,10 +332,7 @@
}
else
{
- final String error =
- "Event type not regognized."
- + "\nEvent Class: " + event.getClass();
- throw new IllegalArgumentException( error );
+ super.processEvent( event );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentManager.java
Sun Jun 5 14:21:31 2005
@@ -21,6 +21,7 @@
import java.net.URI;
import java.util.EventObject;
import java.util.EventListener;
+import java.util.Date;

import net.dpml.transit.model.ContentModel;
import net.dpml.transit.model.PluginModel;
@@ -53,12 +54,12 @@

public DefaultContentManager( Logger logger, String type )
{
- this( logger, null, type, type );
+ this( logger, new Date(), null, type, type );
}

- public DefaultContentManager( Logger logger, URI uri, String type,
String title )
+ public DefaultContentManager( Logger logger, Date creation, URI uri,
String type, String title )
{
- super( logger, uri );
+ super( logger, creation, uri );
m_type = type;
m_title = title;
}
@@ -114,6 +115,7 @@
m_title = title;
ContentEvent event = new ContentEvent( this );
super.enqueueEvent( event );
+ setModified();
}
}

@@ -123,20 +125,13 @@

public void processEvent( EventObject event )
{
- if( event instanceof PluginChangeEvent )
- {
- super.processPluginChangeEvent( (PluginChangeEvent) event );
- }
- else if( event instanceof ContentEvent )
+ if( event instanceof ContentEvent )
{
processContentEvent( (ContentEvent) event );
}
else
{
- final String error =
- "Event type not regognized."
- + "\nEvent Class: " + event.getClass();
- throw new IllegalArgumentException( error );
+ super.processEvent( event );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentRegistryManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentRegistryManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentRegistryManager.java
Sun Jun 5 14:21:31 2005
@@ -20,6 +20,7 @@

import java.net.URI;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
@@ -40,6 +41,8 @@
import net.dpml.transit.management.ModelReferenceException;
import net.dpml.transit.management.ContentRegistryManager;
import net.dpml.transit.management.ContentManager;
+import net.dpml.transit.management.ModificationListener;
+import net.dpml.transit.management.ModificationEvent;

/**
* Default implementation of a content handler registry manager that
maitains
@@ -48,7 +51,8 @@
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id: StandardTransitDirector.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
*/
-public class DefaultContentRegistryManager extends DefaultPluginManager
implements ContentRegistryManager
+public class DefaultContentRegistryManager extends DefaultPluginManager
+ implements ContentRegistryManager, ModificationListener
{
//
------------------------------------------------------------------------
// state
@@ -61,17 +65,31 @@
//
------------------------------------------------------------------------

public DefaultContentRegistryManager(
- Logger logger, URI uri, ContentManager[] managers ) throws
DuplicateKeyException
+ Logger logger, Date creation, URI uri, ContentManager[] managers )
throws DuplicateKeyException
{
- super( logger, uri );
+ super( logger, creation, uri );
for( int i=0; i<managers.length; i++ )
{
ContentManager manager = managers[i];
- addContentManager( manager );
+ addContentManager( manager, false );
}
}

//
------------------------------------------------------------------------
+ // ModificationListener (listen to modification to hosts)
+ //
------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
+ {
+ ModificationEvent e = new ModificationEvent( this, event );
+ enqueueEvent( e );
+ }
+
+ //
------------------------------------------------------------------------
// ContentRegistryManager
//
------------------------------------------------------------------------

@@ -113,19 +131,29 @@

public void addContentManager( ContentManager manager ) throws
DuplicateKeyException
{
+ addContentManager( manager, true );
+ }
+
+ private void addContentManager( ContentManager manager, boolean notify )
throws DuplicateKeyException
+ {
synchronized( m_lock )
{
String id = manager.getContentType();
try
{
- ContentManager m = getContentManager( id );
- throw new DuplicateKeyException( id );
+ ContentManager m = getContentManager( id );
+ throw new DuplicateKeyException( id );
}
catch( UnknownKeyException e )
{
- m_list.add( manager );
- ContentAddedEvent event = new ContentAddedEvent ( this,
manager );
- enqueueEvent( event );
+ m_list.add( manager );
+ manager.addModificationListener( this );
+ if( notify )
+ {
+ ContentAddedEvent event = new ContentAddedEvent ( this,
manager );
+ enqueueEvent( event );
+ setModified();
+ }
}
}
}
@@ -135,11 +163,13 @@
synchronized( m_lock )
{
Object[] listeners = manager.getListeners();
- if( listeners.length == 0 )
+ if( listeners.length == 1 )
{
- m_list.remove( manager );
- ContentRemovedEvent event = new ContentRemovedEvent( this,
manager );
- super.enqueueEvent( event );
+ m_list.remove( manager );
+ manager.removeModificationListener( this );
+ ContentRemovedEvent event = new ContentRemovedEvent( this,
manager );
+ super.enqueueEvent( event );
+ setModified();
}
else
{
@@ -190,20 +220,13 @@

public void processEvent( EventObject event )
{
- if( event instanceof PluginChangeEvent )
- {
- super.processPluginChangeEvent( (PluginChangeEvent) event );
- }
- else if( event instanceof ContentRegistryEvent )
+ if( event instanceof ContentRegistryEvent )
{
processContentRegistryEvent( (ContentRegistryEvent) event );
}
else
{
- final String error =
- "Event type not regognized."
- + "\nEvent Class: " + event.getClass();
- throw new IllegalArgumentException( error );
+ super.processEvent( event );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultHostManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultHostManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultHostManager.java
Sun Jun 5 14:21:31 2005
@@ -85,17 +85,17 @@
Logger logger, String id, LayoutModel layout )
{
this(
- logger, id,
+ logger, new Date(), id,
new Local( "", false ),
getDefaultHostURL(), null, id, false, false, 900, layout, null,
"", "" );
}

public DefaultHostManager(
- Logger logger, String id, Strategy strategy, URL base, URL index,
String name, boolean trusted,
- boolean enabled, int priority, LayoutModel layout,
PasswordAuthentication auth,
- String scheme, String prompt )
+ Logger logger, Date creation, String id, Strategy strategy, URL base,
URL index,
+ String name, boolean trusted, boolean enabled, int priority,
LayoutModel layout,
+ PasswordAuthentication auth, String scheme, String prompt )
{
- super( logger, null );
+ super( logger, creation, null );

m_id = id;
m_name = name;
@@ -111,7 +111,7 @@
if( strategy instanceof Plugin )
{
Plugin plugin = (Plugin) strategy;
- setPluginURI( plugin.getURI() );
+ setPluginURI( plugin.getURI(), false );
m_bootstrap = false;
}
else
@@ -139,7 +139,7 @@
m_authentication = auth;

m_identifier = getRequestIdentifier( base, scheme, prompt );
-
+ setModified();
HostChangeEvent e =
new HostChangeEvent(
this, base, index, m_identifier, auth, enabled, trusted );

@@ -152,6 +152,7 @@
synchronized( m_lock )
{
m_name = name;
+ setModified();
HostNameEvent e = new HostNameEvent( this, m_name );
enqueueEvent( e );
}
@@ -162,6 +163,7 @@
synchronized( m_lock )
{
m_priority = priority;
+ setModified();
HostPriorityEvent e = new HostPriorityEvent( this, m_priority );
enqueueEvent( e );
}
@@ -188,7 +190,9 @@
}
}

+System.out.println( "# setting host layout" );
m_layout = layout;
+ setModified();
HostLayoutEvent e = new HostLayoutEvent( this, m_layout );
enqueueEvent( e );
}
@@ -373,11 +377,7 @@

protected void processEvent( EventObject event )
{
- if( event instanceof PluginChangeEvent )
- {
- super.processPluginChangeEvent( (PluginChangeEvent) event );
- }
- else if( event instanceof HostChangeEvent )
+ if( event instanceof HostChangeEvent )
{
processHostChangeEvent( (HostChangeEvent) event );
}
@@ -395,10 +395,7 @@
}
else
{
- final String error =
- "Event type not regognized."
- + "\nEvent Class: " + event.getClass();
- throw new IllegalArgumentException( error );
+ super.processEvent( event );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutManager.java
Sun Jun 5 14:21:31 2005
@@ -21,6 +21,7 @@
import java.net.URI;
import java.util.EventObject;
import java.util.EventListener;
+import java.util.Date;

import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.PluginModel;
@@ -60,13 +61,13 @@
public DefaultLayoutManager(
final Logger logger, final String id )
{
- this( logger, id, new Local(
"net.dpml.transit.layout.ClassicLayout", false ), id );
+ this( logger, new Date(), id, new Local(
"net.dpml.transit.layout.ClassicLayout", false ), id );
}

public DefaultLayoutManager(
- final Logger logger, final String id, Strategy strategy, final String
title )
+ final Logger logger, Date creation, final String id, Strategy
strategy, final String title )
{
- super( logger, null );
+ super( logger, creation, null );

m_id = id;
m_title = title;
@@ -96,6 +97,7 @@
m_title = title;
LayoutEvent event = new LayoutEvent( this );
super.enqueueEvent( event );
+ setModified();
}
}

@@ -178,20 +180,13 @@

public void processEvent( EventObject event )
{
- if( event instanceof PluginChangeEvent )
- {
- super.processPluginChangeEvent( (PluginChangeEvent) event );
- }
- else if( event instanceof LayoutEvent )
+ if( event instanceof LayoutEvent )
{
processLayoutEvent( (LayoutEvent) event );
}
else
{
- final String error =
- "Event type not regognized."
- + "\nEvent Class: " + event.getClass();
- throw new IllegalArgumentException( error );
+ super.processEvent( event );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutRegistryManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutRegistryManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutRegistryManager.java
Sun Jun 5 14:21:31 2005
@@ -19,6 +19,7 @@
package net.dpml.transit.manager;

import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
@@ -44,6 +45,8 @@
import net.dpml.transit.management.LayoutManager;
import net.dpml.transit.management.LayoutRegistryManager;
import net.dpml.transit.management.ModelReferenceException;
+import net.dpml.transit.management.ModificationListener;
+import net.dpml.transit.management.ModificationEvent;

/**
* Default implementation of a layout subsystem that maitains
@@ -53,7 +56,7 @@
* @version $Id: StandardTransitDirector.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
*/
public class DefaultLayoutRegistryManager extends DefaultPluginManager
- implements LayoutRegistryManager
+ implements LayoutRegistryManager, ModificationListener
{
//
------------------------------------------------------------------------
// state
@@ -65,18 +68,33 @@
// constructor
//
------------------------------------------------------------------------

- public DefaultLayoutRegistryManager( Logger logger, URI uri,
LayoutManager[] managers )
+ public DefaultLayoutRegistryManager(
+ Logger logger, Date creation, URI uri, LayoutManager[] managers )
throws DuplicateKeyException
{
- super( logger, uri );
+ super( logger, creation, uri );
for( int i=0; i<managers.length; i++ )
{
LayoutManager manager = managers[i];
- addLayoutManager( manager );
+ addLayoutManager( manager, false );
}
}

//
------------------------------------------------------------------------
+ // ModificationListener (listen to modification to hosts)
+ //
------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
+ {
+ ModificationEvent e = new ModificationEvent( this, event );
+ enqueueEvent( e );
+ }
+
+ //
------------------------------------------------------------------------
// LayoutRegistryModel
//
------------------------------------------------------------------------

@@ -125,19 +143,29 @@

public void addLayoutManager( LayoutManager manager ) throws
DuplicateKeyException
{
+ addLayoutManager( manager, true );
+ }
+
+ private void addLayoutManager( LayoutManager manager, boolean notify )
throws DuplicateKeyException
+ {
synchronized( m_lock )
{
String id = manager.getID();
try
{
- LayoutManager m = getLayoutManager( id );
- throw new DuplicateKeyException( id );
+ LayoutManager m = getLayoutManager( id );
+ throw new DuplicateKeyException( id );
}
catch( UnknownKeyException e )
{
- m_list.add( manager );
- LayoutAddedEvent event = new LayoutAddedEvent( this,
manager );
- enqueueEvent( event );
+ m_list.add( manager );
+ manager.addModificationListener( this );
+ if( notify )
+ {
+ LayoutAddedEvent event = new LayoutAddedEvent( this,
manager );
+ enqueueEvent( event );
+ setModified();
+ }
}
}
}
@@ -180,15 +208,17 @@
synchronized( m_lock )
{
Object[] listeners = manager.getListeners();
- if( listeners.length == 0 )
+ if( listeners.length == 1 )
{
- m_list.remove( manager );
- LayoutRemovedEvent event = new LayoutRemovedEvent( this,
manager );
- enqueueEvent( event );
+ m_list.remove( manager );
+ manager.removeModificationListener( this );
+ LayoutRemovedEvent event = new LayoutRemovedEvent( this,
manager );
+ enqueueEvent( event );
+ setModified();
}
else
{
- throw new ModelReferenceException( manager, listeners );
+ throw new ModelReferenceException( manager, listeners );
}
}
}
@@ -199,20 +229,13 @@

public void processEvent( EventObject event )
{
- if( event instanceof PluginChangeEvent )
- {
- super.processPluginChangeEvent( (PluginChangeEvent) event );
- }
- else if( event instanceof LayoutRegistryEvent )
+ if( event instanceof LayoutRegistryEvent )
{
processLayoutRegistryEvent( (LayoutRegistryEvent) event );
}
else
{
- final String error =
- "Event type not regognized."
- + "\nEvent Class: " + event.getClass();
- throw new IllegalArgumentException( error );
+ super.processEvent( event );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultManager.java
Sun Jun 5 14:21:31 2005
@@ -19,6 +19,7 @@
package net.dpml.transit.manager;

import java.net.URI;
+import java.util.Date;
import java.util.EventObject;
import java.util.EventListener;
import java.util.List;
@@ -29,13 +30,15 @@
import net.dpml.transit.util.ExceptionHelper;
import net.dpml.transit.model.Logger;
import net.dpml.transit.model.Model;
-
+import net.dpml.transit.management.Manager;
+import net.dpml.transit.management.ModificationEvent;
+import net.dpml.transit.management.ModificationListener;

/**
* A abstract base class that established an event queue and handles event
dispatch
* operations for listeners declared in a class extending this base class.
*/
-public abstract class DefaultManager implements Model
+public abstract class DefaultManager implements Manager, Model
{
//
------------------------------------------------------------------------
// state
@@ -53,11 +56,21 @@
*/
protected final Object m_lock = new Object();

+ /**
+ * Last modification date.
+ */
+ protected Date m_creation = new Date();
+
+ /**
+ * Last modification date.
+ */
+ protected Date m_modification;
+
//
------------------------------------------------------------------------
// constructor
//
------------------------------------------------------------------------

- public DefaultManager( Logger logger )
+ public DefaultManager( Logger logger, Date creation )
throws NullPointerException
{
if( null == logger )
@@ -65,6 +78,7 @@
throw new NullPointerException( "logger" );
}
m_logger = logger;
+ m_creation = creation;
}

//
------------------------------------------------------------------------
@@ -77,25 +91,110 @@
}

//
------------------------------------------------------------------------
+ // Manager
+ //
------------------------------------------------------------------------
+
+ public Date getCreationDate()
+ {
+ synchronized( m_lock )
+ {
+ return m_creation;
+ }
+ }
+
+ public void setCreationDate( Date date )
+ {
+ synchronized( m_lock )
+ {
+ m_creation = date;
+ }
+ }
+
+ public Date getModificationDate()
+ {
+ synchronized( m_lock )
+ {
+ if( null == m_modification )
+ {
+ return m_creation;
+ }
+ else
+ {
+ return m_modification;
+ }
+ }
+ }
+
+ public boolean isModified()
+ {
+ synchronized( m_lock )
+ {
+ long modification = getModificationDate().getTime();
+ long creation = getCreationDate().getTime();
+ return modification > creation;
+ }
+ }
+
+ public void addModificationListener( ModificationListener listener )
+ {
+ addListener( listener );
+ }
+
+ public void removeModificationListener( ModificationListener listener )
+ {
+ removeListener( listener );
+ }
+
+ //
------------------------------------------------------------------------
// DefaultManager
//
------------------------------------------------------------------------

+ protected void setModified()
+ {
+ m_modification = new Date();
+ ModificationEvent e = new ModificationEvent( this, m_modification );
+ enqueueEvent( e );
+ }
+
+ protected void processEvent( EventObject eventObject )
+ {
+ if( eventObject instanceof ModificationEvent )
+ {
+ ModificationEvent event = (ModificationEvent) eventObject;
+ EventListener[] listeners = listeners();
+ for( int i=0; i<listeners.length; i++ )
+ {
+ EventListener listener = listeners[i];
+ if( listener instanceof ModificationListener )
+ {
+ ModificationListener pl = (ModificationListener)
listener;
+ try
+ {
+ pl.modified( event );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Modification listener notification error.";
+ getLogger().error( error, e );
+ }
+ }
+ }
+ }
+ else
+ {
+ final String error =
+ "Event class not recognized: " +
eventObject.getClass().getName();
+ throw new IllegalArgumentException( error );
+ }
+ }
+
public Object[] getListeners()
{
return listeners();
}

/**
- * Abstract operation to be implemented by classes extending this base
class.
- * An implementation is reposible for the posting of the event to
associated
- * listeners. Event posting will be executed under a separate thread to
the
- * thread that initiated the event post.
- *
- * @param event the event to process
- */
- protected abstract void processEvent( EventObject event );
-
- /**
* Add a listener to the set of listeners handled by this producer.
* @param listener the event listener
*/
@@ -109,7 +208,8 @@
{
m_listeners.put( listener, null );
}
- startEventDispatchThread();
+ Logger logger = getLogger();
+ startEventDispatchThread( logger );
}

/**
@@ -145,6 +245,18 @@
*/
private static class EventDispatchThread extends Thread
{
+ private Logger m_logger;
+
+ EventDispatchThread( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
public void run()
{
while( true )
@@ -192,14 +304,14 @@
"Unexpected error while processing event."
+ "\nEvent: " + event
+ "\nSource: " + this;
- String msg = ExceptionHelper.packException( error,
e, true );
- System.err.println( msg );
+ getLogger().error( error );
}
}
else
{
final String error =
- "Event source is not an instance of " +
DefaultManager.class.getName();
+ "Event source is not an instance of "
+ + DefaultManager.class.getName();
throw new IllegalStateException( error );
}
}
@@ -213,11 +325,11 @@
* is called. The event dispatch thread will be started only
* if someone registers a listener.
*/
- private static synchronized void startEventDispatchThread()
+ private static synchronized void startEventDispatchThread( Logger logger
)
{
if( EVENT_DISPATCH_THREAD == null )
{
- EVENT_DISPATCH_THREAD = new EventDispatchThread();
+ EVENT_DISPATCH_THREAD = new EventDispatchThread( logger );
EVENT_DISPATCH_THREAD.setDaemon( true );
EVENT_DISPATCH_THREAD.start();
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultPluginManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultPluginManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultPluginManager.java
Sun Jun 5 14:21:31 2005
@@ -19,6 +19,8 @@
package net.dpml.transit.manager;

import java.net.URI;
+import java.util.Date;
+import java.util.EventObject;
import java.util.EventListener;
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.PreferenceChangeEvent;
@@ -53,9 +55,9 @@
// constructor
//
------------------------------------------------------------------------

- public DefaultPluginManager( Logger logger, URI uri )
+ public DefaultPluginManager( Logger logger, Date creation, URI uri )
{
- super( logger );
+ super( logger, creation );
m_uri = uri;
}

@@ -69,11 +71,24 @@
*/
public void setPluginURI( URI uri )
{
+ setPluginURI( uri, true );
+ }
+
+ /**
+ * Set the plugin uri value.
+ * @return the plugin uri
+ */
+ protected void setPluginURI( URI uri, boolean notify )
+ {
synchronized( m_lock )
{
m_uri = uri;
- PluginChangeEvent e = new PluginChangeEvent( this, m_uri );
- super.enqueueEvent( e );
+ if( notify )
+ {
+ PluginChangeEvent e = new PluginChangeEvent( this, m_uri );
+ super.enqueueEvent( e );
+ setModified();
+ }
}
}

@@ -115,6 +130,19 @@
// internals
//
------------------------------------------------------------------------

+ protected void processEvent( EventObject eventObject )
+ {
+ if( eventObject instanceof PluginChangeEvent )
+ {
+ PluginChangeEvent event = (PluginChangeEvent) eventObject;
+ processPluginChangeEvent( event );
+ }
+ else
+ {
+ super.processEvent( eventObject );
+ }
+ }
+
protected void processPluginChangeEvent( PluginChangeEvent event )
{
EventListener[] listeners = super.listeners();

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultProxyManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultProxyManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultProxyManager.java
Sun Jun 5 14:21:31 2005
@@ -20,10 +20,7 @@

import java.io.File;
import java.io.IOException;
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.BackingStoreException;
+import java.util.Date;
import java.util.EventObject;
import java.util.EventListener;
import java.net.PasswordAuthentication;
@@ -61,10 +58,10 @@
//
------------------------------------------------------------------------

public DefaultProxyManager(
- Logger logger, URL host, PasswordAuthentication auth, String[]
excludes )
+ Logger logger, Date creation, URL host, PasswordAuthentication auth,
String[] excludes )
throws NullPointerException
{
- super( logger );
+ super( logger, creation );
m_host = host;
m_authentication = auth;
m_excludes = excludes;
@@ -85,6 +82,7 @@
ProxyEvent event =
new ProxyEvent( this, request, m_authentication, m_excludes );
super.enqueueEvent( event );
+ setModified();
}
}

@@ -97,6 +95,7 @@
ProxyEvent event =
new ProxyEvent( this, request, m_authentication, m_excludes );
super.enqueueEvent( event );
+ setModified();
}
}

@@ -109,6 +108,7 @@
ProxyEvent event =
new ProxyEvent( this, request, m_authentication, m_excludes );
super.enqueueEvent( event );
+ setModified();
}
}

@@ -121,6 +121,7 @@
ProxyEvent event =
new ProxyEvent( this, request, m_authentication, m_excludes );
super.enqueueEvent( event );
+ setModified();
}
}

@@ -188,6 +189,19 @@

protected void processEvent( EventObject eventObject )
{
+ if( eventObject instanceof ProxyEvent )
+ {
+ ProxyEvent event = (ProxyEvent) eventObject;
+ processProxyEvent( event );
+ }
+ else
+ {
+ super.processEvent( eventObject );
+ }
+ }
+
+ private void processProxyEvent( ProxyEvent event )
+ {
EventListener[] listeners = super.listeners();
for( int i=0; i<listeners.length; i++ )
{
@@ -195,19 +209,15 @@
if( listener instanceof ProxyListener )
{
ProxyListener pl = (ProxyListener) listener;
- if( eventObject instanceof ProxyEvent )
+ try
+ {
+ pl.proxyChanged( event );
+ }
+ catch( Throwable e )
{
- ProxyEvent event = (ProxyEvent) eventObject;
- try
- {
- pl.proxyChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "Proxy listener notification error.";
- getLogger().error( error, e );
- }
+ final String error =
+ "Proxy listener notification error.";
+ getLogger().error( error, e );
}
}
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultRepositoryManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultRepositoryManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultRepositoryManager.java
Sun Jun 5 14:21:31 2005
@@ -20,6 +20,7 @@

import java.net.URI;
import java.util.EventObject;
+import java.util.Date;

import net.dpml.transit.management.RepositoryManager;
import net.dpml.transit.model.PluginChangeEvent;
@@ -32,24 +33,9 @@
*/
public class DefaultRepositoryManager extends DefaultPluginManager
implements RepositoryManager
{
- public DefaultRepositoryManager( Logger logger, URI uri )
+ public DefaultRepositoryManager( Logger logger, Date creation, URI uri )
{
- super( logger, uri );
- }
-
- public void processEvent( EventObject event )
- {
- if( event instanceof PluginChangeEvent )
- {
- super.processPluginChangeEvent( (PluginChangeEvent) event );
- }
- else
- {
- final String error =
- "Event type not regignized."
- + "\nEvent Class: " + event.getClass();
- throw new IllegalArgumentException( error );
- }
+ super( logger, creation, uri );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultTransitManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultTransitManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultTransitManager.java
Sun Jun 5 14:21:31 2005
@@ -18,6 +18,7 @@

package net.dpml.transit.manager;

+import java.util.Date;
import java.util.EventObject;

import net.dpml.transit.model.Logger;
@@ -34,6 +35,8 @@
import net.dpml.transit.management.RepositoryManager;
import net.dpml.transit.management.ProxyManager;
import net.dpml.transit.management.LayoutRegistryManager;
+import net.dpml.transit.management.ModificationListener;
+import net.dpml.transit.management.ModificationEvent;

/**
* The DefaultTransitManager class maintains an active configuration of the
@@ -41,7 +44,7 @@
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
-public class DefaultTransitManager extends DefaultManager implements
TransitManager
+public class DefaultTransitManager extends DefaultManager implements
TransitManager, ModificationListener
{
//
------------------------------------------------------------------------
// state
@@ -52,16 +55,18 @@
private final RepositoryManager m_repository;
private final ProxyManager m_proxy;
private final LayoutRegistryManager m_layout;
+ private final ModificationListener m_listener;

//
------------------------------------------------------------------------
// constructor
//
------------------------------------------------------------------------

public DefaultTransitManager(
- Logger logger, LayoutRegistryManager layout, CacheManager cache,
+ ModificationListener listener,
+ Logger logger, Date creation, LayoutRegistryManager layout,
CacheManager cache,
ContentRegistryManager content, RepositoryManager repository,
ProxyManager proxy )
{
- super( logger );
+ super( logger, creation );

if( null == layout )
{
@@ -89,6 +94,32 @@
m_registry = content;
m_repository = repository;
m_proxy = proxy;
+ m_listener = listener;
+
+ m_layout.addModificationListener( this );
+ m_cache.addModificationListener( this );
+ m_registry.addModificationListener( this );
+ m_repository.addModificationListener( this );
+ m_proxy.addModificationListener( this );
+
+ if( m_listener != null )
+ {
+ addModificationListener( m_listener );
+ }
+ }
+
+ //
------------------------------------------------------------------------
+ // ModificationListener (listen to modification to hosts)
+ //
------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of a change to the manager modification date.
+ * @param event the modification event
+ */
+ public void modified( ModificationEvent event )
+ {
+ ModificationEvent e = new ModificationEvent( this, event );
+ enqueueEvent( e );
}

//
------------------------------------------------------------------------
@@ -197,9 +228,5 @@
{
return getLayoutRegistryManager();
}
-
- public void processEvent( EventObject event )
- {
- }
}


Modified:
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
==============================================================================
---
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
(original)
+++
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
Sun Jun 5 14:21:31 2005
@@ -54,8 +54,10 @@
System.setProperty( "dpml.data", path );
Preferences prefs =
Preferences.userNodeForPackage( Transit.class ).node( "test"
).node( "proxy-manager-test" );
- TransitHome home = new PreferencesStorageHome( prefs );
- m_manager = home.createTransitManager();
+ TransitHome home = new PreferencesStorageHome();
+ home.setPreferences( prefs );
+ home.clearBeforeInitialization( true );
+ m_manager = home.create();
}

public void testProxyAuthentication() throws Exception
@@ -67,7 +69,7 @@
new PasswordAuthentication( username, password.toCharArray() );
URL host = new URL( "http://localhost"; );
String[] excludes = new String[]{ "http://abc";, "http://xyz"; };
- ProxyManager manager = new DefaultProxyManager( logger, host, auth,
excludes );
+ ProxyManager manager = new DefaultProxyManager( logger, new Date(),
host, auth, excludes );
assertEquals( "host", host, manager.getHost() );
assertEquals( "auth", auth, manager.getAuthentication() );
assertEquals( "logger", logger, manager.getLogger() );

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
Sun Jun 5 14:21:31 2005
@@ -47,8 +47,10 @@
m_data = new File( path );
System.setProperty( "dpml.data", path );
Preferences prefs = Preferences.userNodeForPackage( Transit.class
).node( "test" );
- TransitHome home = new PreferencesStorageHome( prefs );
- m_manager = home.createTransitManager();
+ TransitHome home = new PreferencesStorageHome();
+ home.setPreferences( prefs );
+ home.clearBeforeInitialization( true );
+ m_manager = home.create();
}

public void testCacheDirectory() throws Exception

Modified:
development/main/transit/core/handler/src/test/net/dpml/transit/test/LinkTestCase.java
==============================================================================
---
development/main/transit/core/handler/src/test/net/dpml/transit/test/LinkTestCase.java
(original)
+++
development/main/transit/core/handler/src/test/net/dpml/transit/test/LinkTestCase.java
Sun Jun 5 14:21:31 2005
@@ -61,8 +61,11 @@
Logger logger = Logger.getLogger( "test" );
//logger.setLevel( Level.parse( "FINE" ) );
LoggingAdapter adapter = new LoggingAdapter( logger );
- TransitHome home = new PreferencesStorageHome( adapter, prefs,
authority );
- TransitManager manager = home.createTransitManager();
+ TransitHome home = new PreferencesStorageHome();
+ home.setPreferences( prefs );
+ home.clearBeforeInitialization( true );
+ home.setAuthority( authority );
+ TransitManager manager = home.create();
TRANSIT = Transit.getInstance( manager );
}
}

Modified:
development/main/transit/core/handler/src/test/net/dpml/transit/test/OfflineTestCase.java
==============================================================================
---
development/main/transit/core/handler/src/test/net/dpml/transit/test/OfflineTestCase.java
(original)
+++
development/main/transit/core/handler/src/test/net/dpml/transit/test/OfflineTestCase.java
Sun Jun 5 14:21:31 2005
@@ -64,8 +64,12 @@
Logger logger = Logger.getLogger( "test" );
//logger.setLevel( Level.parse( "FINE" ) );
LoggingAdapter adapter = new LoggingAdapter( logger );
- TransitHome home = new PreferencesStorageHome( adapter, prefs,
authority );
- TransitManager manager = home.createTransitManager();
+ TransitHome home = new PreferencesStorageHome();
+ home.setPreferences( prefs );
+ home.clearBeforeInitialization( true );
+ home.setAuthority( authority );
+ home.setLogger( adapter );
+ TransitManager manager = home.create();
TRANSIT = Transit.getInstance( manager );
}
}

Modified:
development/main/transit/core/handler/src/test/net/dpml/transit/test/OnlineTestCase.java
==============================================================================
---
development/main/transit/core/handler/src/test/net/dpml/transit/test/OnlineTestCase.java
(original)
+++
development/main/transit/core/handler/src/test/net/dpml/transit/test/OnlineTestCase.java
Sun Jun 5 14:21:31 2005
@@ -52,8 +52,10 @@
{
Preferences prefs =
Preferences.userNodeForPackage( Transit.class
).node("test").node( "online-test" );
- TransitHome home = new PreferencesStorageHome( prefs );
- TransitManager manager = home.createTransitManager();
+ TransitHome home = new PreferencesStorageHome();
+ home.setPreferences( prefs );
+ home.clearBeforeInitialization( true );
+ TransitManager manager = home.create();
TRANSIT = Transit.getInstance( manager );
}
}

Modified:
development/main/transit/core/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
==============================================================================
---
development/main/transit/core/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
(original)
+++
development/main/transit/core/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
Sun Jun 5 14:21:31 2005
@@ -55,8 +55,9 @@
try
{
Logger logger = new AntAdapter( this );
- TransitHome home = new PreferencesStorageHome( logger );
- TransitManager manager = home.createTransitManager();
+ TransitHome home = new PreferencesStorageHome();
+ home.setLogger( logger );
+ TransitManager manager = home.create();
Transit.getInstance( manager );
}
catch( TransitAlreadyInitializedException e )



  • svn commit: r2714 - in development/main: depot/prefs/src/main/net/dpml/depot/prefs metro/composition/content/src/main/net/dpml/composition/content transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/builder transit/core/handler/src/main/net/dpml/transit/management transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/test transit/core/tools/src/main/net/dpml/transit/tools, mcconnell, 06/05/2005

Archive powered by MHonArc 2.6.24.

Top of Page