Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2703 - in development/main: . depot depot/console/src/main/net/dpml/depot/lang depot/prefs/src/main/net/dpml/depot/prefs depot/station depot/test depot/test/src depot/test/src/main depot/test/src/main/net depot/test/src/main/net/dpml depot/test/src/main/net/dpml/depot depot/test/src/main/net/dpml/depot/test metro/composition/content/src/main/net/dpml/composition/content test/plugins/layout/src/main/net/dpml/test/layout test/unit/plus/src/test/net/dpml/test/acme/plus 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/cache transit/core/handler/src/main/net/dpml/transit/content transit/core/handler/src/main/net/dpml/transit/host transit/core/handler/src/main/net/dpml/transit/management transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/main/net/dpml/transit/model 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: r2703 - in development/main: . depot depot/console/src/main/net/dpml/depot/lang depot/prefs/src/main/net/dpml/depot/prefs depot/station depot/test depot/test/src depot/test/src/main depot/test/src/main/net depot/test/src/main/net/dpml depot/test/src/main/net/dpml/depot depot/test/src/main/net/dpml/depot/test metro/composition/content/src/main/net/dpml/composition/content test/plugins/layout/src/main/net/dpml/test/layout test/unit/plus/src/test/net/dpml/test/acme/plus 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/cache transit/core/handler/src/main/net/dpml/transit/content transit/core/handler/src/main/net/dpml/transit/host transit/core/handler/src/main/net/dpml/transit/management transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/main/net/dpml/transit/model 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 00:41:27 -0400

Author: mcconnell AT dpml.net
Date: Sun Jun 5 00:41:19 2005
New Revision: 2703

Added:

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryManagerPanel.java
- copied, changed from r2687,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryManagerPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryTableModel.java
- copied, changed from r2687,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryTableModel.java
development/main/depot/test/ (props changed)
development/main/depot/test/build.xml
development/main/depot/test/src/
development/main/depot/test/src/main/
development/main/depot/test/src/main/net/
development/main/depot/test/src/main/net/dpml/
development/main/depot/test/src/main/net/dpml/depot/
development/main/depot/test/src/main/net/dpml/depot/test/

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

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

development/main/transit/core/handler/src/main/net/dpml/transit/builder/BuilderException.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/CredentialsHelper.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/PreferencesHelper.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/TransitHelper.java

development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitPreferences.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/TransitPreferences.java

development/main/transit/core/handler/src/main/net/dpml/transit/host/DefaultResourceHost.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/host/ClassicResourceHost.java

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

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

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

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

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

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

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

development/main/transit/core/handler/src/main/net/dpml/transit/management/ModelReferenceException.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/RepositoryManager.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
- copied, changed from r2693,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentManager.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/ContentManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentRegistryManager.java
- copied, changed from r2690,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RegistryManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultHostManager.java
- copied, changed from r2688,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutManager.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/LayoutManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutRegistryManager.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/LayoutRegistryManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultManager.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/EventProducer.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultPluginManager.java
- copied, changed from r2688,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultProxyManager.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/ProxyManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultRepositoryManager.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RepositoryManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultTransitManager.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/TransitManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryEvent.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryEvent.java

development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryListener.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryListener.java

development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryModel.java
- copied, changed from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryModel.java

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

development/main/transit/core/handler/src/main/net/dpml/transit/model/UnknownKeyException.java
Removed:

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

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

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

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

development/main/transit/core/handler/src/main/net/dpml/transit/host/ClassicResourceHost.java

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryModel.java
Modified:
development/main/ (props changed)
development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
development/main/depot/index.xml

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

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

development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheTableModel.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/HostManagerPanel.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/LayoutRegistryTableModel.java
development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java

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

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

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

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyManagerPanel.java
development/main/depot/station/build.xml

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

development/main/test/plugins/layout/src/main/net/dpml/test/layout/DemoLayoutControlPanel.java

development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java

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

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

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

development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentRegistry.java

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

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

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

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

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

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

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

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

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

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

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

development/main/transit/core/handler/src/main/net/dpml/transit/model/TransitModel.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/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
Log:
Breakout management functions from model implementation (note - currently
implementation does not provide persistent storage of transit configuration
changes).

Modified:
development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
==============================================================================
--- development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
(original)
+++ development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
Sun Jun 5 00:41:19 2005
@@ -22,6 +22,10 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
+import java.net.URI;
+import java.rmi.Remote;
+import java.rmi.registry.Registry;
+import java.rmi.registry.LocateRegistry;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -30,6 +34,7 @@
import java.util.prefs.Preferences;

import net.dpml.transit.Transit;
+import net.dpml.transit.repository.Repository;

/**
* CLI hander for the depot package.
@@ -83,14 +88,60 @@
return;
}

- if( false == profile.nodeExists( "classpath" ) )
+ //
+ // check for a plugin attribute and if not declare, check for a
+ // classpath node
+ //
+
+ String pluginUri = profile.get( "plugin", null );
+ if( null != pluginUri )
{
- final String error =
- "Requested profile '" + profile + "' does not declare a
classpath node.";
- System.err.println( error );
- return;
+ //
+ // load the plugin using the system classloader as the base
+ //
+
+ try
+ {
+ URI uri = new URI( pluginUri );
+ Repository loader = Transit.getInstance().getRepository();
+ ClassLoader system = ClassLoader.getSystemClassLoader();
+ Object object = loader.getPlugin( system, uri, new Object[]{
args } );
+ logger.info( "loaded plugin: " + uri );
+ Thread thread = null;
+ if( profile.nodeExists( "jndi" ) )
+ {
+ //
+ // register the plugin with JNDI
+ //
+
+ Preferences jndi = profile.node( "jndi" );
+ int port = jndi.getInt( "port", 1099 );
+ String name = jndi.get( "name", profile.name() );
+ Registry reg = LocateRegistry.createRegistry( port );
+ reg.bind( name, (Remote) object );
+ logger.info( "service bound to rmi://localhost:" + port
+ "/" + name );
+ }
+ else if( object instanceof Runnable )
+ {
+ //
+ // run the plugin
+ //
+
+ logger.info( "starting " + object.getClass().getName() );
+ thread = new Thread( (Runnable) object );
+ thread.start();
+ }
+ setShutdownHook( thread );
+ }
+ catch( Throwable e )
+ {
+ String message = e.getMessage();
+ Throwable cause = e.getCause();
+ logger.log( Level.SEVERE, message, cause );
+ return;
+ }
}
- else
+ else if( profile.nodeExists( "classpath" ) )
{
Preferences classpath = profile.node( "classpath" );
ClassLoader system = ClassLoader.getSystemClassLoader();
@@ -168,6 +219,13 @@
System.err.println( error );
}
}
+ else
+ {
+ final String error =
+ "Requested profile '" + profile + "' does not declare a
classpath node or plugin attribute.";
+ System.err.println( error );
+ return;
+ }
}

private static void clearPreferences( Logger logger, Class c )

Modified: development/main/depot/index.xml
==============================================================================
--- development/main/depot/index.xml (original)
+++ development/main/depot/index.xml Sun Jun 5 00:41:19 2005
@@ -55,6 +55,7 @@
<name>dpml-depot-station</name>
<types>
<type>jar</type>
+ <type>plugin</type>
</types>
</info>
<dependencies>
@@ -63,4 +64,18 @@
</dependencies>
</project>

+ <project basedir="test">
+ <info>
+ <group>dpml/depot</group>
+ <name>dpml-depot-test</name>
+ <types>
+ <type>jar</type>
+ <type>plugin</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-depot-station"/>
+ </dependencies>
+ </project>
+
</index>

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheDirectoryPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheDirectoryPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheDirectoryPanel.java
Sun Jun 5 00:41:19 2005
@@ -37,7 +37,7 @@

import net.dpml.depot.lang.DPML;
import net.dpml.transit.Transit;
-import net.dpml.transit.manager.CacheManager;
+import net.dpml.transit.management.CacheManager;
import net.dpml.transit.model.CacheListener;
import net.dpml.transit.model.FileChangeEvent;
import net.dpml.transit.model.HostNodeEvent;

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 00:41:19 2005
@@ -49,10 +49,11 @@

import net.dpml.transit.Transit;
import net.dpml.transit.util.ExceptionHelper;
-import net.dpml.transit.manager.CacheManager;
-import net.dpml.transit.manager.HostManager;
-import net.dpml.transit.manager.LayoutRegistryManager;
+import net.dpml.transit.management.CacheManager;
+import net.dpml.transit.management.HostManager;
+import net.dpml.transit.management.LayoutRegistryManager;
import net.dpml.transit.model.HostModel;
+import net.dpml.transit.model.UnknownKeyException;
import net.dpml.transit.cache.CacheHandler;

/**
@@ -153,14 +154,14 @@
if( "selection".equals( event.getPropertyName() ) )
{
m_selection = (String) event.getNewValue();
- HostManager model = m_manager.getHostManager( m_selection );
- if( null != model )
+ try
{
+ HostManager model = m_manager.getHostManager( m_selection );
m_edit.setEnabled( true );
m_delete.setEnabled( false == model.isBootstrap() );

getRootPane().setDefaultButton( m_edit );
}
- else
+ catch( UnknownKeyException e )
{
m_edit.setEnabled( false );
m_delete.setEnabled( false );
@@ -297,9 +298,22 @@
public void actionPerformed( ActionEvent event )
{
String name = JOptionPane.showInputDialog( m_parent, "Host
name:" );
- if( null != name )
+ if( null == name )
{
- m_manager.addHostModel( name );
+ return;
+ }
+ try
+ {
+ m_manager.addHostManager( name );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to add a new host."
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
}
}
}
@@ -360,7 +374,8 @@

try
{
- m_manager.removeHostModel( m_selection );
+ HostManager host = m_manager.getHostManager( m_selection );
+ m_manager.removeHostManager( host );
}
catch( Throwable e )
{

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheTableModel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheTableModel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheTableModel.java
Sun Jun 5 00:41:19 2005
@@ -26,7 +26,7 @@
import net.dpml.transit.model.HostModel;
import net.dpml.transit.model.HostNodeEvent;
import net.dpml.transit.model.CacheListener;
-import net.dpml.transit.manager.CacheManager;
+import net.dpml.transit.management.CacheManager;

/**
* Table model that maps table rows to child nodes of a supplied preferences
node.
@@ -62,7 +62,7 @@
*/
private static final Icon FEATURE_ICON =
IconHelper.createImageIcon(
- RegistryTableModel.class.getClassLoader(), ICON_PATH, "Features" );
+ CacheTableModel.class.getClassLoader(), ICON_PATH, "Features" );

private final CacheManager m_manager;


Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryManagerPanel.java
(from r2687,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryManagerPanel.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryManagerPanel.java
Sun Jun 5 00:41:19 2005
@@ -51,15 +51,17 @@
import net.dpml.transit.Transit;
import net.dpml.transit.util.ExceptionHelper;
import net.dpml.transit.content.ContentRegistry;
-import net.dpml.transit.manager.RegistryManager;
-import net.dpml.transit.manager.ContentManager;
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.ContentManager;
+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;

/**
* Runnable plugin that handles DPML environment setup.
*
* @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
*/
-class RegistryManagerPanel extends ClassicPanel implements
PropertyChangeListener
+class ContentRegistryManagerPanel extends ClassicPanel implements
PropertyChangeListener
{
//--------------------------------------------------------------
// state
@@ -72,14 +74,14 @@
private JButton m_delete;
private String m_selection;

- private RegistryManager m_manager;
- private RegistryTableModel m_tableModel;
+ private ContentRegistryManager m_manager;
+ private ContentRegistryTableModel m_tableModel;

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

- public RegistryManagerPanel( Window parent, RegistryManager manager )
+ public ContentRegistryManagerPanel( Window parent,
ContentRegistryManager manager )
{
super();

@@ -99,7 +101,7 @@
panel.setBorder( new CompoundBorder( tb, border5 ) );

TableColumnModel columns = createContentHandlerColumnModel();
- m_tableModel = new RegistryTableModel( manager );
+ m_tableModel = new ContentRegistryTableModel( manager );

m_table = new ClassicTable( m_tableModel, columns );
m_table.addPropertyChangeListener( this );
@@ -250,9 +252,18 @@
{
return;
}
- else
+ try
+ {
+ m_manager.addContentManager( type );
+ }
+ catch( DuplicateKeyException e )
{
- m_manager.newContentModel( type );
+ final String error =
+ "Unexpected error while attempting to add a content type."
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
}
}
}
@@ -316,7 +327,8 @@
}
try
{
- m_manager.removeContentModel( m_selection );
+ ContentManager m = m_manager.getContentManager( m_selection
);
+ m_manager.removeContentManager( m );
}
catch( Throwable e )
{
@@ -324,8 +336,8 @@
"Unexpected error while attempting to delete a content
handler plugin preferences node."
+ "\nCODEBASE: "
+
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
- String message = ExceptionHelper.packException( error, e,
true );
- System.out.println( message );
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
}
}
}

Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryTableModel.java
(from r2687,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryTableModel.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryTableModel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentRegistryTableModel.java
Sun Jun 5 00:41:19 2005
@@ -20,14 +20,14 @@
import javax.swing.table.AbstractTableModel;

import net.dpml.transit.Transit;
-import net.dpml.transit.model.RegistryEvent;
-import net.dpml.transit.model.RegistryListener;
-import net.dpml.transit.manager.RegistryManager;
+import net.dpml.transit.model.ContentRegistryEvent;
+import net.dpml.transit.model.ContentRegistryListener;
+import net.dpml.transit.management.ContentRegistryManager;

/**
* Table model that maps table rows to child nodes of a supplied preferences
node.
*/
-public class RegistryTableModel extends AbstractTableModel implements
RegistryListener
+public class ContentRegistryTableModel extends AbstractTableModel implements
ContentRegistryListener
{

//--------------------------------------------------------------------------
// static
@@ -58,9 +58,9 @@
*/
private static final Icon FEATURE_ICON =
IconHelper.createImageIcon(
- RegistryTableModel.class.getClassLoader(), ICON_PATH, "Features" );
+ ContentRegistryTableModel.class.getClassLoader(), ICON_PATH,
"Features" );

- private final RegistryManager m_manager;
+ private final ContentRegistryManager m_manager;


//--------------------------------------------------------------------------
// constructor
@@ -72,7 +72,7 @@
*
* @param manager the registry configuration manager
*/
- public RegistryTableModel( RegistryManager manager )
+ public ContentRegistryTableModel( ContentRegistryManager manager )
{
super();
m_manager = manager;
@@ -96,14 +96,14 @@
}


//--------------------------------------------------------------------------
- // RegistryListener
+ // ContentRegistryListener

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

/**
* Notify all listeners of the addition of a content model.
* @param event the registry event
*/
- public void contentAdded( RegistryEvent event )
+ public void contentAdded( ContentRegistryEvent event )
{
fireTableStructureChanged();
}
@@ -112,7 +112,7 @@
* Notify all listeners of the removal of a content model.
* @param event the registry event
*/
- public void contentRemoved( RegistryEvent event )
+ public void contentRemoved( ContentRegistryEvent event )
{
fireTableStructureChanged();
}

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 00:41:19 2005
@@ -40,7 +40,7 @@

import net.dpml.transit.Transit;
import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.manager.TransitManager;
+import net.dpml.transit.management.TransitManager;

/**
* Dialog that presents the default preferences for DPML applications
including

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 00:41:19 2005
@@ -41,11 +41,11 @@

import net.dpml.transit.Transit;
import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.manager.TransitManager;
-import net.dpml.transit.manager.LayoutRegistryManager;
-import net.dpml.transit.manager.CacheManager;
-import net.dpml.transit.manager.RegistryManager;
-import net.dpml.transit.manager.ProxyManager;
+import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.management.LayoutRegistryManager;
+import net.dpml.transit.management.CacheManager;
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.ProxyManager;

/**
* Panel that presents the default preferences for DPML applications
including
@@ -79,7 +79,7 @@
private TransitManager m_manager;
private LayoutRegistryManagerPanel m_layoutPanel;
private CacheManagerPanel m_cachePanel;
- private RegistryManagerPanel m_registryPanel;
+ private ContentRegistryManagerPanel m_registryPanel;
private ProxyManagerPanel m_proxyPanel;

private final Window m_window;
@@ -124,8 +124,8 @@
new Runnable() {
public void run()
{
- final RegistryManager content = manager.getRegistryManager();
- m_registryPanel = new RegistryManagerPanel( m_window, content
);
+ final ContentRegistryManager content =
manager.getContentRegistryManager();
+ m_registryPanel = new ContentRegistryManagerPanel( m_window,
content );
tabbedPane.addTab( "Content", m_registryPanel );
}
}

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
Sun Jun 5 00:41:19 2005
@@ -51,16 +51,14 @@
import javax.swing.event.ListDataListener;
import javax.swing.event.ListDataEvent;

-import net.dpml.transit.manager.HostManager;
-import net.dpml.transit.manager.LayoutRegistryManager;
+import net.dpml.transit.management.HostManager;
+import net.dpml.transit.management.LayoutRegistryManager;
import net.dpml.transit.model.HostListener;
import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.HostChangeEvent;
import net.dpml.transit.model.HostLayoutEvent;
-import net.dpml.transit.model.HostEnabledEvent;
-import net.dpml.transit.model.HostTrustedEvent;
import net.dpml.transit.model.HostPriorityEvent;
-import net.dpml.transit.model.HostAvailabilityEvent;
+import net.dpml.transit.model.HostNameEvent;

/**
* A interactive panel that presents the preferences for a single host.
@@ -92,6 +90,7 @@
private JButton m_revert;
private LayoutComboBoxModel m_strategy;
private CredentialsAction m_credentials;
+ private PasswordAuthentication m_auth;

private PropertyChangeSupport m_propertyChangeSupport;

@@ -106,6 +105,7 @@
m_parent = parent;
m_manager = manager;
m_layouts = layouts;
+ m_auth = manager.getAuthentication();

m_manager.addHostListener( this );
m_propertyChangeSupport = new PropertyChangeSupport( this );
@@ -235,7 +235,6 @@
m_enabled = new JCheckBox( new EnableAction( "Enabled" ) );
m_enabled.setBackground( Color.white );
m_enabled.setSelected( m_manager.getEnabled() );
- m_enabled.setEnabled( m_manager.getAvailable() );

JPanel enabledPanel = new JPanel();
enabledPanel.setLayout( new BorderLayout() );
@@ -306,22 +305,6 @@
}

/**
- * Notify a consumer of a change to the enabled state.
- * @param event the host event
- */
- public void enabledStateChanged( HostEnabledEvent event )
- {
- }
-
- /**
- * Notify a consumer of a change to the trusted state.
- * @param event the host event
- */
- public void trustedStateChanged( HostTrustedEvent event )
- {
- }
-
- /**
* Notify a consumer of a change to the host priority.
* @param event the host event
*/
@@ -341,7 +324,7 @@
* Notify a consumer of a change to the availability status.
* @param event the host event
*/
- public void availabilityChanged( HostAvailabilityEvent event )
+ public void nameChanged( HostNameEvent event )
{
}

@@ -398,7 +381,6 @@
}
catch( Throwable e )
{
- m_enabled.setEnabled( m_manager.getAvailable() );
m_enabled.setSelected( m_manager.getEnabled() );
}
}
@@ -558,7 +540,7 @@
boolean trusted = m_trusted.isSelected();
boolean enabled = m_enabled.isSelected();
LayoutModel layout = (LayoutModel) m_strategy.getSelectedItem();
- m_manager.update( base, null, enabled, trusted, layout );
+ m_manager.update( base, null, enabled, trusted, layout, m_auth,
"", "" );
m_parent.hide();
dispose();
}
@@ -578,9 +560,8 @@
final String title = "Credentials: " +
m_manager.getHostName();
final Dimension size = new Dimension( 300, 280 );
ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
- PasswordAuthentication auth = m_manager.getAuthentication();
ClassicCredentialsPanel panel =
- new ClassicCredentialsPanel( dialog, auth, this );
+ new ClassicCredentialsPanel( dialog, m_auth, this );
dialog.getBody().add( panel );
dialog.setLocationRelativeTo( (Component) event.getSource()
);
dialog.setResizable( false );
@@ -603,20 +584,7 @@
*/
public void passwordAuthenticationChanged(
PasswordAuthenticationEvent event )
{
- PasswordAuthentication auth = event.getPasswordAuthentication();
- try
- {
- m_manager.setAuthentication( auth );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while attempting to update host sign-on
credentials. "
- + "\nCODEBASE: "
- +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
- Logger logger = Logger.getLogger( "depot.prefs" );
- logger.log( Level.SEVERE, error, e );
- }
+ m_auth = event.getPasswordAuthentication();
}
}


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 00:41:19 2005
@@ -21,15 +21,13 @@
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;

-import net.dpml.transit.manager.HostManager;
-import net.dpml.transit.manager.LayoutRegistryManager;
+import net.dpml.transit.management.HostManager;
+import net.dpml.transit.management.LayoutRegistryManager;
import net.dpml.transit.model.HostListener;
import net.dpml.transit.model.HostChangeEvent;
-import net.dpml.transit.model.HostEnabledEvent;
-import net.dpml.transit.model.HostTrustedEvent;
import net.dpml.transit.model.HostPriorityEvent;
import net.dpml.transit.model.HostLayoutEvent;
-import net.dpml.transit.model.HostAvailabilityEvent;
+import net.dpml.transit.model.HostNameEvent;
import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.LayoutRegistryListener;
import net.dpml.transit.model.LayoutRegistryEvent;
@@ -114,26 +112,18 @@
}

/**
- * Notify a consumer of a change to the enabled state.
+ * Notify a consumer of a change to the host priority.
* @param event the host event
*/
- public void enabledStateChanged( HostEnabledEvent event )
+ public void priorityChanged( HostPriorityEvent event )
{
}

/**
- * Notify a consumer of a change to the trusted state.
+ * Notify a consumer of a change to the host name.
* @param event the host event
*/
- public void trustedStateChanged( HostTrustedEvent event )
- {
- }
-
- /**
- * Notify a consumer of a change to the host priority.
- * @param event the host event
- */
- public void priorityChanged( HostPriorityEvent event )
+ public void nameChanged( HostNameEvent event )
{
}

@@ -149,14 +139,5 @@
setSelectedItem( layout );
}
}
-
-
- /**
- * Notify a consumer of a change to the availability status.
- * @param event the host event
- */
- public void availabilityChanged( HostAvailabilityEvent event )
- {
- }
}


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 00:41:19 2005
@@ -51,9 +51,11 @@
import net.dpml.transit.util.ExceptionHelper;
import net.dpml.transit.layout.LayoutRegistry;
import net.dpml.transit.layout.Layout;
-import net.dpml.transit.manager.LayoutRegistryManager;
-import net.dpml.transit.manager.LayoutManager;
+import net.dpml.transit.management.LayoutRegistryManager;
+import net.dpml.transit.management.LayoutManager;
import net.dpml.transit.model.LayoutModel;
+import net.dpml.transit.model.DuplicateKeyException;
+import net.dpml.transit.model.UnknownKeyException;

/**
* Runnable plugin that handles DPML environment setup.
@@ -146,15 +148,23 @@
if( "selection".equals( event.getPropertyName() ) )
{
m_selection = (String) event.getNewValue();
- LayoutModel resolver = m_manager.getLayoutModel( m_selection );
- if( null != resolver )
+ if( null != m_selection )
{
- m_edit.setEnabled( true );
- if( null == resolver.getClassname() )
+ try
{
- m_delete.setEnabled( true );
+ LayoutModel resolver = m_manager.getLayoutModel(
m_selection );
+ m_edit.setEnabled( true );
+ if( false == resolver.isBootstrap() )
+ {
+ m_delete.setEnabled( true );
+ }
+ getRootPane().setDefaultButton( m_edit );
+ }
+ catch( UnknownKeyException e )
+ {
+ m_edit.setEnabled( false );
+ m_delete.setEnabled( false );
}
- getRootPane().setDefaultButton( m_edit );
}
else
{
@@ -255,9 +265,18 @@
{
return;
}
- else
+ try
+ {
+ m_manager.addLayoutManager( id );
+ }
+ catch( DuplicateKeyException e )
{
- m_manager.newLayoutModel( id );
+ final String error =
+ "Unexpected error while attempting to add a new layout
model."
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
}
}
}
@@ -321,12 +340,13 @@
}
try
{
- m_manager.removeLayoutModel( m_selection );
+ LayoutManager layout = m_manager.getLayoutManager(
m_selection );
+ m_manager.removeLayoutManager( layout );
}
catch( Throwable e )
{
final String error =
- "Unexpected error while attempting to delete a layout
plugin reference."
+ "Unexpected error while attempting to delete a layout
model."
+ "\nCODEBASE: "
+
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
String message = ExceptionHelper.packException( error, e,
true );

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryTableModel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryTableModel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryTableModel.java
Sun Jun 5 00:41:19 2005
@@ -22,7 +22,7 @@
import net.dpml.transit.Transit;
import net.dpml.transit.model.LayoutRegistryEvent;
import net.dpml.transit.model.LayoutRegistryListener;
-import net.dpml.transit.manager.LayoutRegistryManager;
+import net.dpml.transit.management.LayoutRegistryManager;

/**
* Table model that maps table rows to child nodes of a supplied preferences
node.

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 00:41:19 2005
@@ -26,7 +26,8 @@

import net.dpml.transit.Transit;
import net.dpml.transit.adapter.LoggingAdapter;
-import net.dpml.transit.manager.TransitManager;
+import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.builder.TransitHelper;
import net.dpml.transit.model.Logger;

/**
@@ -95,7 +96,7 @@
Preferences prefs = Preferences.userNodeForPackage( Transit.class );
try
{
- TransitManager manager = new TransitManager( logger, prefs );
+ TransitManager manager = TransitHelper.createTransitManager(
logger, prefs );
Transit.getInstance( manager );
new DepotPreferencesFrame( manager );
}

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PluginManagerPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PluginManagerPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PluginManagerPanel.java
Sun Jun 5 00:41:19 2005
@@ -53,7 +53,7 @@
import net.dpml.transit.TransitException;
import net.dpml.transit.repository.Plugin;
import net.dpml.transit.repository.Repository;
-import net.dpml.transit.manager.PluginManager;
+import net.dpml.transit.management.PluginManager;
import net.dpml.transit.model.PluginListener;
import net.dpml.transit.model.PluginChangeEvent;

@@ -62,7 +62,8 @@
*
* @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
*/
-class PluginManagerPanel extends ClassicPanel implements PluginListener,
PropertyChangeListener, DocumentListener
+class PluginManagerPanel extends ClassicPanel
+ implements PluginListener, PropertyChangeListener, DocumentListener
{
//--------------------------------------------------------------
// state

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludesTableModel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludesTableModel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludesTableModel.java
Sun Jun 5 00:41:19 2005
@@ -22,8 +22,7 @@
import net.dpml.transit.Transit;
import net.dpml.transit.model.ProxyListener;
import net.dpml.transit.model.ProxyModel;
-import net.dpml.transit.model.ProxyChangeEvent;
-import net.dpml.transit.model.ProxyExcludesEvent;
+import net.dpml.transit.model.ProxyEvent;

/**
* Table model that presents the set of excluded hosts.
@@ -60,16 +59,7 @@
* Notify a listener of the change to Transit proxy settings.
* @param event the proxy change event
*/
- public void proxySettingsChanged( ProxyChangeEvent event )
- {
- // not our problem
- }
-
- /**
- * Notify a listener of the change to the set of excluded hosts.
- * @param event the proxy excludes change event
- */
- public void proxyExcludesChanged( ProxyExcludesEvent event )
+ public void proxyChanged( ProxyEvent event )
{
fireTableStructureChanged();
}

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyFeaturesPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyFeaturesPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyFeaturesPanel.java
Sun Jun 5 00:41:19 2005
@@ -53,7 +53,7 @@
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

-import net.dpml.transit.manager.ProxyManager;
+import net.dpml.transit.management.ProxyManager;

/**
* Control panel for editing the cache preferences.
@@ -75,6 +75,7 @@
private String m_host;
private CredentialsAction m_credentials;
private JButton m_close;
+ private PasswordAuthentication m_auth;

//--------------------------------------------------------------
// constructor
@@ -91,6 +92,7 @@
m_manager = manager;

m_host = getProxyHost();
+ m_auth = m_manager.getAuthentication();
m_propertyChangeSupport = new PropertyChangeSupport( this );
m_ok = new JButton( new OKAction( "OK" ) );
m_revert = new JButton( new RevertAction( "Undo" ) );
@@ -265,15 +267,23 @@
{
if( "".equals( text ) )
{
- m_manager.setProxyHost( null );
+ String[] excludes = m_manager.getExcludes();
+ m_manager.update( null, m_auth, excludes );
}
else
{
- m_manager.setProxyHost( text );
+ try
+ {
+ URL url = new URL( text );
+ String[] excludes = m_manager.getExcludes();
+ m_manager.update( url, m_auth, excludes );
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
}
}
- m_ok.setEnabled( false );
- m_revert.setEnabled( false );
m_parent.hide();
}
}
@@ -292,9 +302,8 @@
final String title = "Proxy Credentials";
final Dimension size = new Dimension( 300, 280 );
ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
- PasswordAuthentication auth =
m_manager.getProxyAuthentication();
ClassicCredentialsPanel panel =
- new ClassicCredentialsPanel( dialog, auth, this );
+ new ClassicCredentialsPanel( dialog, m_auth, this );
dialog.getBody().add( panel );
dialog.setLocationRelativeTo( (Component) event.getSource()
);
dialog.setResizable( false );
@@ -317,33 +326,21 @@
*/
public void passwordAuthenticationChanged(
PasswordAuthenticationEvent event )
{
- PasswordAuthentication auth = event.getPasswordAuthentication();
- try
- {
- m_manager.setProxyAuthentication( auth );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while attempting to update proxy sign-on
credentials. "
- + "\nCODEBASE: "
- +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
- Logger logger = Logger.getLogger( "depot.prefs" );
- logger.log( Level.SEVERE, error, e );
- }
+ m_auth = event.getPasswordAuthentication();
+ m_manager.setAuthentication( m_auth );
}
}

private String getProxyHost()
{
- String host = m_manager.getProxyHost();
+ URL host = m_manager.getHost();
if( null == host )
{
return "";
}
else
{
- return host;
+ return host.toString();
}
}


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 00:41:19 2005
@@ -32,6 +32,7 @@
import java.net.ContentHandler;
import java.util.logging.Logger;
import java.util.logging.Level;
+import java.util.ArrayList;

import javax.swing.AbstractAction;
import javax.swing.BoxLayout;
@@ -49,9 +50,10 @@
import javax.swing.table.TableColumnModel;

import net.dpml.transit.Transit;
-import net.dpml.transit.util.ExceptionHelper;
import net.dpml.transit.model.ProxyModel;
-import net.dpml.transit.manager.ProxyManager;
+import net.dpml.transit.model.ProxyListener;
+import net.dpml.transit.management.ProxyManager;
+import net.dpml.transit.util.ExceptionHelper;

/**
* Runnable plugin that handles DPML environment setup.
@@ -164,6 +166,73 @@
}
}

+
+ //--------------------------------------------------------------
+ // impl
+ //--------------------------------------------------------------
+
+ private void removeExclude( String exclude )
+ {
+ if( null == exclude )
+ {
+ return;
+ }
+ ArrayList list = new ArrayList();
+ String[] excludes = m_manager.getExcludes();
+ for( int i=0; i<excludes.length; i++ )
+ {
+ String s = excludes[i];
+ if( false == exclude.equals( s ) )
+ {
+ list.add( s );
+ }
+ }
+ String[] values = (String[]) list.toArray( new String[0] );
+ m_manager.setExcludes( values );
+ }
+
+ private void changeExclude( String exclude, String value )
+ {
+ if( null == exclude )
+ {
+ return;
+ }
+ if( null == value )
+ {
+ return;
+ }
+ ArrayList list = new ArrayList();
+ String[] excludes = m_manager.getExcludes();
+ for( int i=0; i<excludes.length; i++ )
+ {
+ String s = excludes[i];
+ if( exclude.equals( s ) )
+ {
+ list.add( value );
+ }
+ else
+ {
+ list.add( s );
+ }
+ }
+ String[] values = (String[]) list.toArray( new String[0] );
+ m_manager.setExcludes( values );
+ }
+
+ private void addExclude( String exclude )
+ {
+ ArrayList list = new ArrayList();
+ String[] excludes = m_manager.getExcludes();
+ for( int i=0; i<excludes.length; i++ )
+ {
+ String s = excludes[i];
+ list.add( s );
+ }
+ list.add( exclude );
+ String[] values = (String[]) list.toArray( new String[0] );
+ m_manager.setExcludes( values );
+ }
+
//--------------------------------------------------------------
// internals
//--------------------------------------------------------------
@@ -180,7 +249,7 @@
{
if( m_selection != null )
{
- m_manager.removeExclude( m_selection );
+ removeExclude( m_selection );
}
}
}
@@ -207,7 +276,7 @@
}
else
{
- m_manager.changeExclude( m_selection, name );
+ changeExclude( m_selection, name );
}
}
}
@@ -229,7 +298,7 @@
}
else
{
- m_manager.addExclude( name );
+ addExclude( name );
}
}
}

Modified: development/main/depot/station/build.xml
==============================================================================
--- development/main/depot/station/build.xml (original)
+++ development/main/depot/station/build.xml Sun Jun 5 00:41:19 2005
@@ -7,24 +7,12 @@
<transit:import uri="artifact:template:dpml/magic/standard"/>

<target name="build" depends="standard.build">
- <rmic base="${basedir}/target/classes" includes="**/DepotStation.class"/>
+ <rmic base="${basedir}/target/classes"
includes="**/DepotStation.class"/>
+ <rmic base="${basedir}/target/classes"
includes="**/ClientListener.class"/>
</target>

- <target name="install" depends="standard.install">
- <echo>
-#----------------------------------------------------------------------------------
-# Updating DPML DATA ${dpml.data}/lib
-#----------------------------------------------------------------------------------
- </echo>
- <property name="lib" location="${dpml.data}/lib"/>
- <mkdir dir="${lib}"/>
- <copy toDir="${lib}" preservelastmodified="true" overwrite="true">
- <fileset dir="${basedir}/target/deliverables/jars">
- <include name="${project.filename}"/>
- <include name="${project.filename}.md5"/>
- <include name="${project.filename}.asc"/>
- </fileset>
- </copy>
+ <target name="package" depends="standard.package">
+ <x:export class="net.dpml.depot.station.DepotStation"/>
</target>

</project>

Added: development/main/depot/test/build.xml
==============================================================================
--- (empty file)
+++ development/main/depot/test/build.xml Sun Jun 5 00:41:19 2005
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-depot-test" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <!--
+ <target name="build" depends="standard.build">
+ <x:path id="rmic.classpath"/>
+ <rmic base="${basedir}/target/classes" classpathref="rmic.classpath"
includes="**/ClientListener.class"/>
+ </target>
+ -->
+
+ <target name="package" depends="standard.package">
+ <x:export class="net.dpml.depot.test.Client"/>
+ </target>
+
+</project>

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 00:41:19 2005
@@ -21,14 +21,16 @@
import java.io.IOException;
import java.net.URI;
import java.net.ContentHandler;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;

import net.dpml.transit.TransitException;
import net.dpml.transit.model.Logger;
-import net.dpml.transit.model.RegistryModel;
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.ContentManager;
import net.dpml.transit.model.ContentModel;
+import net.dpml.transit.model.DuplicateKeyException;
+import net.dpml.transit.model.UnknownKeyException;
import net.dpml.transit.content.DefaultContentRegistry;
+import net.dpml.transit.manager.DefaultContentManager;

/**
* A registry of descriptions of plugable content handlers. This
implementation
@@ -41,7 +43,7 @@
//
------------------------------------------------------------------------

private final Logger m_logger;
- private final RegistryModel m_model;
+ private final ContentRegistryManager m_manager;

//
------------------------------------------------------------------------
// constructor
@@ -54,54 +56,49 @@
*
* @param model the registry model
*/
- public CompositionContentHandlerRegistry( RegistryModel model ) throws
BackingStoreException
+ public CompositionContentHandlerRegistry( ContentRegistryManager manager
) throws Exception
{
- super( model );
- m_logger = model.getLogger();
- m_model = model;
- }
+ super( manager );
+ m_logger = manager.getLogger();
+ m_manager = manager;

- //
------------------------------------------------------------------------
- // ContentHandlerRegistry
- //
------------------------------------------------------------------------
+ try
+ {
+ ContentManager m = manager.getContentManager( PART );

- public ContentHandler getContentHandler( final String type ) throws
IOException
- {
- synchronized( m_model )
+ // TODO:
+ // part handler already registered - but as soon as we have
+ // links in place we need to validate that the assigned handler
is
+ // up-to-date and potentially update it if required
+ }
+ catch( UnknownKeyException uke )
{
- ContentHandler handler = super.getContentHandler( type );
- if( null != handler )
+ try
{
- return handler;
+ Logger logger = manager.getLogger().getChildLogger( PART );
+ URI uri = new URI( PART_HANDLER_PLUGIN_PATH );
+ ContentManager m = new DefaultContentManager( logger, uri,
PART, TITLE );
+ manager.addContentManager( m );
}
- else if( "part".equals( type ) )
+ catch( Throwable e )
{
- try
- {
- URI uri = new URI( PART_HANDLER_PLUGIN_PATH );
- String title = "Part Content Handler";
- ContentModel model = m_model.addContentModel( PART,
title, uri );
- return getContentHandler( model );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while attempting to establish part
handler."
- + "\nPlugin URI: " + PART_HANDLER_PLUGIN_PATH
- + "\nContent Type: " + type;
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
- }
- }
- else
- {
- return null;
+ final String error =
+ "Unexpected error while attempting to establish part
handler."
+ + "\nPlugin URI: " + PART_HANDLER_PLUGIN_PATH
+ + "\nContent Type: " + PART;
+ IOException ioe = new IOException( error );
+ ioe.initCause( e );
+ throw ioe;
}
}
}

+ //
------------------------------------------------------------------------
+ // static (util)
+ //
------------------------------------------------------------------------
+
private static final String PART = "part";
+ private static final String TITLE = "Part Content Handler";

private static final String PART_HANDLER_PLUGIN_PATH =
"@COMPOSITION-CONTENT-PART-HANDLER-PLUGIN-URI@";
}

Modified:
development/main/test/plugins/layout/src/main/net/dpml/test/layout/DemoLayoutControlPanel.java
==============================================================================
---
development/main/test/plugins/layout/src/main/net/dpml/test/layout/DemoLayoutControlPanel.java
(original)
+++
development/main/test/plugins/layout/src/main/net/dpml/test/layout/DemoLayoutControlPanel.java
Sun Jun 5 00:41:19 2005
@@ -42,7 +42,7 @@
import javax.swing.ImageIcon;
import javax.swing.JTextField;

-import net.dpml.transit.manager.LayoutManager;
+import net.dpml.transit.management.LayoutManager;

import net.dpml.depot.prefs.IconHelper;


Modified:
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
==============================================================================
---
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
(original)
+++
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
Sun Jun 5 00:41:19 2005
@@ -19,6 +19,7 @@

package net.dpml.test.acme.plus;

+import java.net.URI;
import java.net.URL;

import junit.framework.TestCase;
@@ -29,6 +30,10 @@

import net.dpml.test.acme.Dimension;

+import net.dpml.transit.Transit;
+import net.dpml.transit.builder.TransitHelper;
+import net.dpml.transit.management.TransitManager;
+
/**
* Test URL content handling.
*
@@ -109,11 +114,23 @@
private final static String PLUS_TEST_PART = "@PLUS-TEST-PART@";
private final static String CONTENT_MANAGER_PLUGIN =
"@CONTENT-MANAGER-PLUGIN@";

+ private static TransitManager MANAGER = null;
+ private static Transit TRANSIT = null;
+
static
{
System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
System.setProperty( "java.util.logging.config.class",
"net.dpml.depot.logging.ConfigurationHandler" );
- System.setProperty( "dpml.transit.preferences.enabled", "true" );
- System.setProperty( "dpml.transit.content.plugin",
CONTENT_MANAGER_PLUGIN );
+ try
+ {
+ URI uri = new URI( CONTENT_MANAGER_PLUGIN );
+ TransitManager MANAGER = TransitHelper.createTransitManager();
+ MANAGER.getContentRegistryManager().setPluginURI( uri );
+ TRANSIT = Transit.getInstance( MANAGER );
+ }
+ catch( Throwable e )
+ {
+ e.printStackTrace();
+ }
}
}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/Handler.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/Handler.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+/**
+ * A handler is an interface implemented by a disposable Transit sub-system.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface Handler
+{
+ /**
+ * Dispose of the manager. During disposal a manager is required to
+ * release all references such as listeners and internal resources
+ * in preparation for garbage collection.
+ */
+ void dispose();
+}
+

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/SecuredTransitContext.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/SecuredTransitContext.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/SecuredTransitContext.java
Sun Jun 5 00:41:19 2005
@@ -31,14 +31,16 @@
import net.dpml.transit.layout.DefaultLayoutRegistry;
import net.dpml.transit.layout.ClassicLayout;
import net.dpml.transit.model.Logger;
-import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.model.RegistryModel;
import net.dpml.transit.model.CacheModel;
+import net.dpml.transit.model.TransitModel;
+import net.dpml.transit.model.ContentRegistryModel;
import net.dpml.transit.model.LayoutRegistryModel;
+import net.dpml.transit.model.PluginListener;
+import net.dpml.transit.model.PluginChangeEvent;
+import net.dpml.transit.model.PluginModel;
import net.dpml.transit.model.ProxyModel;
import net.dpml.transit.model.ProxyListener;
-import net.dpml.transit.model.ProxyChangeEvent;
-import net.dpml.transit.model.ProxyExcludesEvent;
+import net.dpml.transit.model.ProxyEvent;
import net.dpml.transit.network.DelegatingAuthenticator;
import net.dpml.transit.network.RequestIdentifier;
import net.dpml.transit.network.TransitAuthenticator;
@@ -175,6 +177,11 @@
*/
private Repository m_repository;

+ /**
+ * The transit plugin listener.
+ */
+ private PluginListener m_listener;
+
//------------------------------------------------------------------
// constructors
//------------------------------------------------------------------
@@ -200,13 +207,14 @@
ClassicLayout resolver = new ClassicLayout();
CacheModel cacheModel = model.getCacheModel();
DefaultCacheHandler cache = new DefaultCacheHandler( cacheModel,
resolver );
- RegistryModel registryModel = model.getRegistryModel();
+ ContentRegistryModel registryModel = model.getContentRegistryModel();
ContentRegistry registry = new DefaultContentRegistry( registryModel
);

m_cacheHandler = cache;
m_registry = registry;
m_layout = layout;
m_logger = model.getLogger();
+ m_listener = new TransitListener();

ProxyModel proxy = m_model.getProxyModel();
synchronized( proxy )
@@ -268,26 +276,27 @@
protected synchronized void setupProxy()
{
ProxyModel model = m_model.getProxyModel();
- if( model.isProxyEnabled() )
+ URL proxy = model.getHost();
+ if( null != proxy )
{
- PasswordAuthentication auth = model.getProxyAuthentication();
+ PasswordAuthentication auth = model.getAuthentication();
if( null != auth )
{
TransitAuthenticator ta = new TransitAuthenticatorImpl( auth
);
- RequestIdentifier id = model.getProxyRequestIdentifier();
+ RequestIdentifier id = model.getRequestIdentifier();
DelegatingAuthenticator da =
DelegatingAuthenticator.getInstance();
da.addTransitAuthenticator( ta, id );
}

- String proxy = model.getProxyHost();
- int port = model.getProxyPort();
+ int port = proxy.getPort();
Properties system = System.getProperties();
system.put( "http.proxyHost", proxy );
system.put( "http.proxyPort", "" + port );
- String excludes = model.getProxyExcludes();
- if( null != excludes )
+ String[] excludes = model.getExcludes();
+ String path = toExcludesPath( excludes );
+ if( null != path )
{
- system.put( "http.nonProxyHosts", excludes );
+ system.put( "http.nonProxyHosts", path );
}
}
}
@@ -318,29 +327,33 @@
*/
private void initializeCache() throws TransitException
{
- CacheModel model = m_model.getCacheModel();
- URI uri = model.getPluginURI();
- if( null == uri )
- {
- ((DefaultCacheHandler)m_cacheHandler).initialize();
- }
- else
+ synchronized( m_listener )
{
- m_logger.debug( "loading custom cache handler" );
- try
+ CacheModel model = m_model.getCacheModel();
+ model.addPluginListener( m_listener );
+ URI uri = model.getPluginURI();
+ if( null == uri )
{
- Object[] args = new Object[]{ model };
- ClassLoader classloader = Transit.class.getClassLoader();
- CacheHandler handler = (CacheHandler)
getRepository().getPlugin( classloader, uri, args );
- m_cacheHandler = handler;
+ ((DefaultCacheHandler)m_cacheHandler).initialize();
}
- catch( Throwable e )
+ else
{
- final String error =
- "Bypassing custom cache hander assignment due to internal
error.";
- m_logger.error( error, e );
+ m_logger.debug( "loading custom cache handler" );
+ try
+ {
+ Object[] args = new Object[]{ model };
+ ClassLoader classloader = Transit.class.getClassLoader();
+ CacheHandler handler = (CacheHandler)
getRepository().getPlugin( classloader, uri, args );
+ m_cacheHandler = handler;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Bypassing custom cache hander assignment due to
internal error.";
+ m_logger.error( error, e );
+ }
}
- }
+ }
}

/**
@@ -350,23 +363,77 @@
*/
private void initializeRegistry() throws TransitException
{
- RegistryModel model = m_model.getRegistryModel();
- URI uri = model.getPluginURI();
- if( null != uri )
+ synchronized( m_listener )
+ {
+ ContentRegistryModel model = m_model.getContentRegistryModel();
+ model.addPluginListener( m_listener );
+ URI uri = model.getPluginURI();
+ if( null != uri )
+ {
+ setContentRegistry( model );
+ }
+ }
+ }
+
+ /**
+ * ContentRegistry initialization.
+ *
+ * @exception TransitException if an initialization error occurs
+ */
+ private void setContentRegistry( ContentRegistryModel model )
+ {
+ synchronized( m_registry )
+ {
+ URI uri = model.getPluginURI();
+ if( null != uri )
+ {
+ m_logger.info( "loading custom content handler registry" );
+ try
+ {
+ Object[] args = new Object[]{ model };
+ ClassLoader classloader = Transit.class.getClassLoader();
+ ContentRegistry registry =
+ (ContentRegistry) getRepository().getPlugin(
classloader, uri, args );
+ handleDisposal( m_registry );
+ m_registry = registry;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Bypassing custom content hander registry assignment
due to internal error.";
+ m_logger.error( error, e );
+ }
+ }
+ else
+ {
+ try
+ {
+ m_logger.info( "loading standard content handler
registry" );
+ handleDisposal( m_registry );
+ m_registry = new DefaultContentRegistry( model );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Critical error occured while attempting to establish
default content management subsystem.";
+ throw new TransitError( error, e );
+ }
+ }
+ }
+ }
+
+ private void handleDisposal( Object object )
+ {
+ if( object instanceof Handler )
{
- m_logger.debug( "loading custom content handler registry" );
+ Handler handler = (Handler) object;
try
{
- Object[] args = new Object[]{ model };
- ClassLoader classloader = Transit.class.getClassLoader();
- ContentRegistry registry = (ContentRegistry)
getRepository().getPlugin( classloader, uri, args );
- m_registry = registry;
+ handler.dispose();
}
catch( Throwable e )
{
- final String error =
- "Bypassing custom content hander registry assignment due
to internal error.";
- m_logger.error( error, e );
+ // interesting but ignorable for now
}
}
}
@@ -377,31 +444,90 @@
* Notify a listener of the change to Transit proxy settings.
* @param event the proxy change event
*/
- public void proxySettingsChanged( ProxyChangeEvent event )
+ public void proxyChanged( ProxyEvent event )
{
setupProxy();
}
+ }

+ /**
+ * Internal listener that listens to changes to plugable sub-systems
+ * and is responsible for swapping facilities on the fly.
+ *
+ * @param manager the transit manager
+ */
+ private class TransitListener implements PluginListener
+ {
/**
- * Notify a listener of the change to the set of excluded hosts.
- * @param event the proxy excludes change event
+ * Notification of the change to a plugin uri assigned to a
sub-system.
+ * @param event a plugin change event
*/
- public void proxyExcludesChanged( ProxyExcludesEvent event )
+ public void pluginChanged( PluginChangeEvent event )
{
- String excludes = event.getProxyModel().getProxyExcludes();
- if( null != excludes )
+ PluginModel model = event.getPluginModel();
+ URI uri = event.getPluginURI();
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "Initiating sub-system change."
+ + "\nSub-System: " + model
+ + "\nURI: " + uri;
+ getLogger().debug( message );
+ }
+
+ //
+ // Currently the only switchable sub-system is the content
management
+ // system (which is where Metro gets connected). This needs to
be extended to
+ // include the cache system, the layout registry and the
indexing system.
+ //
+
+ if( m_model.getContentRegistryModel().equals( model ) )
{
- Properties system = System.getProperties();
- system.put( "http.nonProxyHosts", excludes );
+ ContentRegistryModel m = m_model.getContentRegistryModel();
+ setContentRegistry( m );
}
}
}

+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
//------------------------------------------------------------------
// static (utils)
//------------------------------------------------------------------

/**
+ * Resolve the list of host names to be assigned as non-proxied hosts. If
proxy
+ * excludes are defined the string returned contains the host name
(wilcards allowed)
+ * separated by the "|" character. If no proxy excludes are defined the
value returned
+ * shall be null. The implementation reads the set of attribute names
associated
+ * with a preferences node named "excludes". Each attribute name is
appended to
+ * a single string where names are separated by the "|" character.
+ *
+ * @param prefs the 'proxy' prefs node containing a child node named
'excludes'
+ * @return a string containing a sequence of excluded hosts (possibly
null)
+ */
+ private static String toExcludesPath( String[] names )
+ {
+ String spec = null;
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ if( null == spec )
+ {
+ spec = name;
+ }
+ else
+ {
+ spec = spec + "|" + name;
+ }
+ }
+ return spec;
+ }
+
+ /**
* The namespace string for transit related properties.
*/
static public final String DOMAIN = "dpml.transit";

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 00:41:19 2005
@@ -44,8 +44,10 @@

import net.dpml.transit.model.Logger;
import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.manager.TransitManager;
+import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.manager.DefaultTransitManager;
import net.dpml.transit.adapter.LoggingAdapter;
+import net.dpml.transit.builder.TransitHelper;

/**
* The Transit class manages the establishment of a singleton transit
instance
@@ -152,8 +154,7 @@
try
{
Logger logger = new LoggingAdapter();
- Preferences prefs = Preferences.userNodeForPackage(
Transit.class );
- TransitModel model = new TransitManager( logger, prefs
);
+ TransitModel model =
TransitHelper.createTransitManager( logger );
return getInstance( model );
}
catch( TransitException e )

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/TransitError.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/TransitError.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * 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;
+
+/**
+ * Critical Transit system error.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: TransitException.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
+ */
+public class TransitError extends Error
+{
+ /**
+ * Construct a new <code>TransitError</code> instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public TransitError( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>TransitError</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param cause the root cause of the exception
+ */
+ public TransitError( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/BuilderException.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/BuilderException.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,52 @@
+/*
+ * 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.builder;
+
+import net.dpml.transit.model.ModelException;
+
+/**
+ * Exception raised when an attempt is made to associate a plugin based model
+ * with a bootstrap model.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class BuilderException extends ModelException
+{
+ /**
+ * Construct a new <code>BuilderException</code> instance.
+ *
+ * @param message the detailed error message
+ */
+ public BuilderException( String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>BuilderException</code> instance.
+ *
+ * @param message the detailed error message
+ * @param cause the causal exception
+ */
+ public BuilderException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/CacheHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/CacheHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,99 @@
+/*
+ * 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.builder;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.model.LayoutRegistryModel;
+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;
+
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.CacheManager;
+import net.dpml.transit.management.HostManager;
+
+import net.dpml.transit.manager.DefaultCacheManager;
+
+import net.dpml.transit.util.PropertyResolver;
+
+/**
+ * The LayoutRegistryHelper class provides support for the crreating of a
+ * ContentRegistryManager based on a supplied preferences node.
+ */
+public class CacheHelper extends HostHelper
+{
+ public static CacheManager createCacheManager(
+ LayoutRegistryModel registry, Logger logger, Preferences prefs )
+ throws BackingStoreException, UnknownKeyException,
DuplicateKeyException, BuilderException
+ {
+ File cache = getCacheDirectory( prefs );
+ Preferences hostsNode = prefs.node( "hosts" );
+ ArrayList list = new ArrayList();
+ String[] names = hostsNode.childrenNames();
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ Preferences p = hostsNode.node( name );
+ HostManager manager = createHostManager( registry, logger, 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 );
+ }
+
+ /**
+ * Resolve the cache directory using preferences.
+ * @param prefs the cache preferences
+ * @return the cache directory
+ */
+ private static File getCacheDirectory( Preferences prefs )
+ {
+ String path = prefs.get( "location", "cache" );
+ String cache = PropertyResolver.resolve( System.getProperties(),
path );
+ return new File( cache );
+ }
+
+ /**
+ * Update the preferences cache location attribute with the value of
+ * the supplied file. If the file argument is null the cache location
+ * will be set to "cache" otherwise the string form of the file will
+ * be assigned
+ *
+ * @param file the cache directory
+ */
+ public static void setCacheDirectory( Preferences prefs, File file )
+ {
+ if( null == file )
+ {
+ prefs.remove( "location" );
+ }
+ else
+ {
+ String path = file.toString();
+ prefs.put( "location", path );
+ }
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,44 @@
+/*
+ * 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.builder;
+
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.prefs.Preferences;
+
+import net.dpml.transit.model.Logger;
+
+import net.dpml.transit.management.ContentManager;
+
+import net.dpml.transit.manager.DefaultContentManager;
+
+/**
+ * The LayoutHelper class is responsible for the setup of initial factory
+ * default preference settings.
+ */
+public class ContentHelper extends PreferencesHelper
+{
+ public static ContentManager createContentManager( Logger logger,
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 );
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentRegistryHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ContentRegistryHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,56 @@
+/*
+ * 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.builder;
+
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.model.DuplicateKeyException;
+
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.ContentManager;
+
+import net.dpml.transit.manager.DefaultContentRegistryManager;
+
+/**
+ * The LayoutRegistryHelper class provides support for the crreating of a
+ * ContentRegistryManager based on a supplied preferences node.
+ */
+public class ContentRegistryHelper extends ContentHelper
+{
+ public static ContentRegistryManager createContentRegistryManager(
Logger logger, Preferences prefs )
+ throws BackingStoreException, BuilderException, DuplicateKeyException
+ {
+ ArrayList list = new ArrayList();
+ String[] names = prefs.childrenNames();
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ Preferences p = prefs.node( name );
+ ContentManager manager = createContentManager( logger, p );
+ list.add( manager );
+ }
+ ContentManager[] managers = (ContentManager[]) list.toArray( new
ContentManager[0] );
+ URI uri = getURI( prefs, "uri" );
+ return new DefaultContentRegistryManager( logger, uri, managers );
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/CredentialsHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/CredentialsHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 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.builder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.net.PasswordAuthentication;
+
+import net.dpml.transit.TransitException;
+
+
+/**
+ * Helper class used to convert credentials to and from byte arrays.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+class CredentialsHelper
+{
+ private CredentialsHelper()
+ {
+ // static utility class
+ }
+
+ public static byte[] exportCredentials( PasswordAuthentication auth )
throws BuilderException
+ {
+ CrendentialsHolder holder = new CrendentialsHolder( auth );
+ return toByteArray( holder );
+ }
+
+ public static PasswordAuthentication importCredentials( byte[] bytes )
throws BuilderException
+ {
+ try
+ {
+ ByteArrayInputStream input = new ByteArrayInputStream( bytes );
+ ObjectInputStream stream = new ObjectInputStream( input );
+ CrendentialsHolder holder = (CrendentialsHolder)
stream.readObject();
+ return holder.getPasswordAuthentication();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Error while attempting to load credentials input stream.";
+ throw new BuilderException( error, e );
+ }
+ }
+
+ public static byte[] toByteArray( Serializable object ) throws
BuilderException
+ {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ObjectOutputStream output = null;
+ try
+ {
+ output = new ObjectOutputStream( stream );
+ output.writeObject( object );
+ return stream.toByteArray();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Error while attempting to write object to a byte array."
+ + "\nclass: " + object.getClass().getName()
+ + "\nreason: " + e.toString();
+ throw new BuilderException( error, e );
+ }
+ finally
+ {
+ closeStream( output );
+ }
+ }
+
+ private static void closeStream( OutputStream out )
+ {
+ if( null != out )
+ {
+ try
+ {
+ out.close();
+ }
+ catch( IOException ioe )
+ {
+ boolean ignoreMe = true;
+ }
+ }
+ }
+
+ private static class CrendentialsHolder implements Serializable
+ {
+ static final long serialVersionUID = 1L;
+
+ private final String m_username;
+ private final char[] m_password;
+
+ CrendentialsHolder( PasswordAuthentication auth )
+ {
+ m_username = auth.getUserName();
+ m_password = auth.getPassword();
+ }
+
+ public PasswordAuthentication getPasswordAuthentication()
+ {
+ return new PasswordAuthentication( m_username, m_password );
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( false == ( other instanceof CrendentialsHolder ) )
+ {
+ return false;
+ }
+ CrendentialsHolder holder = (CrendentialsHolder) other;
+ if( false == equals( m_username, holder.m_username ) )
+ {
+ return false;
+ }
+ if( false == equals( m_password , holder.m_password ) )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int hash = m_username.hashCode();
+ hash ^= new String( m_password ).hashCode();
+ return hash;
+ }
+
+ private boolean equals( String s1, String s2 )
+ {
+ if( null == s1 )
+ {
+ return null == s2;
+ }
+ else
+ {
+ return s1.equals( s2 );
+ }
+ }
+
+ private boolean equals( char[] s1, char[] s2 )
+ {
+ if( null == s1 )
+ {
+ return null == s2;
+ }
+ else if( null == s2 )
+ {
+ return null == s1;
+ }
+ else if( s1.length != s2.length )
+ {
+ return false;
+ }
+ else
+ {
+ for( int i=0; i<s1.length; i++ )
+ {
+ char c = s1[i];
+ if( c != s2[i] )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ }
+}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/HostHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/HostHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,236 @@
+/*
+ * 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.builder;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+import java.net.PasswordAuthentication;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.model.LayoutModel;
+import net.dpml.transit.model.LayoutRegistryModel;
+import net.dpml.transit.model.UnknownKeyException;
+
+import net.dpml.transit.management.HostManager;
+import net.dpml.transit.management.HostManager;
+
+import net.dpml.transit.manager.DefaultManager.Local;
+import net.dpml.transit.manager.DefaultManager.Plugin;
+import net.dpml.transit.manager.DefaultHostManager;
+
+
+/**
+ * The LayoutHelper class is responsible for the setup of initial factory
+ * default preference settings.
+ */
+public class HostHelper extends PreferencesHelper
+{
+ public static HostManager createHostManager(
+ LayoutRegistryModel registry, Logger logger, Preferences prefs )
+ throws BuilderException, UnknownKeyException
+ {
+ String id = prefs.name();
+ boolean bootstrap = prefs.getBoolean( "bootstrap", false );
+ String name = prefs.get( "name", id );
+ boolean trusted = prefs.getBoolean( "trusted", false );
+ boolean enabled = prefs.getBoolean( "enabled", false );
+ int priority = prefs.getInt( "priority", 600 );
+ String layoutKey = prefs.get( "layout", "classic" );
+ LayoutModel layout = registry.getLayoutModel( layoutKey );
+ PasswordAuthentication auth = getPasswordAuthentication( prefs );
+ URL base = getBase( prefs );
+ URL index = getIndex( base, prefs );
+ String scheme = prefs.get( "scheme", "" );
+ String prompt = prefs.get( "prompt", "" );
+ if( bootstrap )
+ {
+
+ return new DefaultHostManager(
+ logger, id, new Local(
"net.dpml.transit.host.DefaultResoureHost", bootstrap ),
+ base, index, name, trusted, enabled, priority,
+ layout, auth, scheme, prompt );
+ }
+ else
+ {
+ URI uri = getURI( prefs, "uri" );
+ return new DefaultHostManager(
+ logger, id, new Plugin( uri ), base, index, name, trusted,
enabled, priority,
+ layout, auth, scheme, prompt );
+ }
+ }
+
+ private static URL getBase( Preferences prefs )
+ throws BuilderException
+ {
+ String baseSpec = prefs.get( "base", null );
+ if( null == baseSpec )
+ {
+ final String error =
+ "Undefined host base url"
+ + "\nHost ID: " + prefs.name();
+ throw new BuilderException( error );
+ }
+
+ //
+ // make sure the base path ends with a "/" otherwise relative url
references
+ // will not be correct
+ //
+
+ if( false == baseSpec.endsWith( "/" ) )
+ {
+ baseSpec = baseSpec + "/";
+ }
+
+ try
+ {
+ return new URL( baseSpec );
+ }
+ catch( MalformedURLException e )
+ {
+ final String error =
+ "Invalid host base url"
+ + "\nHost ID: " + prefs.name()
+ + "\nHost Path: " + baseSpec;
+ throw new BuilderException( error, e );
+ }
+ }
+
+ private static PasswordAuthentication getPasswordAuthentication(
Preferences prefs )
+ {
+ String username = prefs.get( "username", "" );
+ String password = prefs.get( "password", "" );
+ return new PasswordAuthentication( username, password.toCharArray()
);
+ }
+
+ private static URL getIndex( URL base, Preferences prefs ) throws
BuilderException
+ {
+ if( null == base )
+ {
+ throw new NullPointerException( "base" );
+ }
+ String indexSpec = prefs.get( "index", null );
+ if( null == indexSpec )
+ {
+ return null;
+ }
+
+ try
+ {
+ return new URL( indexSpec );
+ }
+ catch( MalformedURLException e )
+ {
+ final String error =
+ "Invalid index url"
+ + "\nHost ID: " + prefs.name()
+ + "\nIndex Path: " + indexSpec;
+ throw new BuilderException( error, e );
+ }
+ }
+
+ public static void putHostManager( Preferences prefs, HostManager
manager )
+ throws BuilderException
+ {
+ synchronized( prefs )
+ {
+ URL base = manager.getBaseURL();
+ URL index = manager.getIndexURL();
+ boolean trusted = manager.getTrusted();
+ boolean enabled = manager.getEnabled();
+ LayoutModel layout = manager.getLayoutModel();
+ PasswordAuthentication auth = manager.getAuthentication();
+
+ putBaseURL( prefs, base );
+ putIndexURL( prefs, index );
+ putTrusted( prefs, trusted );
+ putEnabled( prefs, enabled );
+ putLayoutModel( prefs, layout );
+ putAuthentication( prefs, auth );
+ }
+ }
+
+ private static void putBaseURL( Preferences prefs, URL base )
+ {
+ if( null == base )
+ {
+ prefs.remove( "base" );
+ }
+ else
+ {
+ prefs.put( "base", base.toExternalForm() );
+ }
+ }
+
+ private static void putIndexURL( Preferences prefs, URL index )
+ {
+ if( null == index )
+ {
+ prefs.remove( "index" );
+ }
+ else
+ {
+ prefs.put( "index", index.toExternalForm() );
+ }
+ }
+
+
+ private static void putTrusted( Preferences prefs, boolean trusted )
+ {
+ prefs.putBoolean( "trusted", trusted );
+ }
+
+ private static void putEnabled( Preferences prefs, boolean enabled )
+ {
+ prefs.putBoolean( "enabled", enabled );
+ }
+
+ private static void putLayoutModel( Preferences prefs, LayoutModel
layout )
+ {
+ if( null == layout )
+ {
+ prefs.remove( "layout" );
+ }
+ else
+ {
+ String id = layout.getID();
+ prefs.put( "layout", id );
+ }
+ }
+
+ /**
+ * Set the host authentication.
+ * @param auth the password authentication to use for host sign-on
+ */
+ public static void putAuthentication( Preferences prefs,
PasswordAuthentication auth )
+ throws BuilderException
+ {
+ if( null == auth )
+ {
+ prefs.putByteArray( "authentication", new byte[0] );
+ }
+ else
+ {
+ byte[] bytes = CredentialsHelper.exportCredentials( auth );
+ prefs.putByteArray( "authentication", bytes );
+ }
+ }
+
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,64 @@
+/*
+ * 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.builder;
+
+import java.net.URL;
+import java.net.URI;
+import java.util.prefs.Preferences;
+
+import net.dpml.transit.model.Logger;
+
+import net.dpml.transit.management.LayoutManager;
+
+import net.dpml.transit.manager.DefaultManager.Plugin;
+import net.dpml.transit.manager.DefaultManager.Local;
+import net.dpml.transit.manager.DefaultLayoutManager;
+
+/**
+ * The LayoutHelper class is responsible for the setup of initial factory
+ * default preference settings.
+ */
+public class LayoutHelper extends PreferencesHelper
+{
+ public static LayoutManager createLayoutManager( Logger logger,
Preferences prefs )
+ throws BuilderException
+ {
+ String id = prefs.name();
+ String title = prefs.get( "title", id );
+ URI uri = getURI( prefs, "uri" );
+ if( null != uri )
+ {
+ Plugin plugin = new Plugin( uri );
+ return new DefaultLayoutManager( logger, id, plugin, title );
+ }
+ else
+ {
+ String classname = prefs.get( "classname", null );
+ if( null != classname )
+ {
+ Local local = new Local( classname, false );
+ return new DefaultLayoutManager( logger, id, local, title );
+ }
+ else
+ {
+ Local local = new Local(
"net.dpml.transit.layout.ClassicLayout", false );
+ return new DefaultLayoutManager( logger, id, local, title );
+ }
+ }
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutRegistryHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/LayoutRegistryHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,56 @@
+/*
+ * 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.builder;
+
+import java.net.URL;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.model.DuplicateKeyException;
+
+import net.dpml.transit.manager.DefaultLayoutRegistryManager;
+
+import net.dpml.transit.management.LayoutRegistryManager;
+import net.dpml.transit.management.LayoutManager;
+
+/**
+ * The LayoutHelper class is responsible for the setup of initial factory
+ * default preference settings.
+ */
+public class LayoutRegistryHelper extends LayoutHelper
+{
+ public static LayoutRegistryManager createLayoutRegistryManager( Logger
logger, Preferences prefs )
+ throws BuilderException, BackingStoreException, DuplicateKeyException
+ {
+ ArrayList list = new ArrayList();
+ String[] names = prefs.childrenNames();
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ Preferences p = prefs.node( name );
+ LayoutManager layout = createLayoutManager( logger, p );
+ list.add( layout );
+ }
+ LayoutManager[] managers = (LayoutManager[]) list.toArray( new
LayoutManager[0] );
+ URI uri = getURI( prefs, "uri" );
+ return new DefaultLayoutRegistryManager( logger, uri, managers );
+ }
+}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/PreferencesHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,102 @@
+/*
+ * 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.builder;
+
+import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+/**
+ * Utility class that provides support for the creation of URI and URL
+ * values from preference attributes.
+ */
+public class PreferencesHelper
+{
+ public static URI getURI( Preferences prefs, String key ) throws
BuilderException
+ {
+ String path = prefs.get( key, null );
+ try
+ {
+ if( null == path )
+ {
+ return null;
+ }
+ else
+ {
+ return new URI( path );
+ }
+ }
+ catch( URISyntaxException e )
+ {
+ final String error =
+ "Invalid URI attribute value."
+ + "\nPreferences: " + prefs
+ + "\nAttribute: " + key
+ + "\nValue: " + path;
+ throw new BuilderException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to construct a uri."
+ + "\nPreferences: " + prefs
+ + "\nAttribute: " + key
+ + "\nValue: " + path;
+ throw new BuilderException( error, e );
+ }
+ }
+
+ public static URL getURL( Preferences prefs, String key ) throws
BuilderException
+ {
+ String path = prefs.get( key, null );
+ try
+ {
+ if( null == path )
+ {
+ return null;
+ }
+ else
+ {
+ return new URL( path );
+ }
+ }
+ catch( MalformedURLException e )
+ {
+ final String error =
+ "Invalid URL attribute value."
+ + "\nPreferences: " + prefs
+ + "\nAttribute: " + key
+ + "\nValue: " + path;
+ throw new BuilderException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to construct url."
+ + "\nPreferences: " + prefs
+ + "\nAttribute: " + key
+ + "\nValue: " + path;
+ throw new BuilderException( error, e );
+ }
+ }
+
+
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/ProxyHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,116 @@
+/*
+ * 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.builder;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.PasswordAuthentication;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import net.dpml.transit.model.Logger;
+
+import net.dpml.transit.management.ProxyManager;
+
+import net.dpml.transit.manager.DefaultProxyManager;
+
+/**
+ * The LayoutHelper class is responsible for the setup of initial factory
+ * default preference settings.
+ */
+public class ProxyHelper extends PreferencesHelper
+{
+ //
------------------------------------------------------------------------
+ // internalization
+ //
------------------------------------------------------------------------
+
+ public static ProxyManager createProxyManager( Logger logger,
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 );
+ }
+
+ private static PasswordAuthentication getAuthentication( Preferences
prefs )
+ throws BuilderException
+ {
+ byte[] bytes = prefs.getByteArray( "authentication", new byte[0] );
+ if( bytes.length == 0 )
+ {
+ return null;
+ }
+ else
+ {
+ return CredentialsHelper.importCredentials( bytes );
+ }
+ }
+
+ private static String[] getExcludes( Preferences prefs ) throws
BackingStoreException
+ {
+ Preferences excludes = prefs.node( "excludes" );
+ return excludes.keys();
+ }
+
+ //
------------------------------------------------------------------------
+ // externalization
+ //
------------------------------------------------------------------------
+
+ public void setProxyManager( ProxyManager model, Preferences prefs )
+ throws BuilderException
+ {
+ URL url = model.getHost();
+ PasswordAuthentication auth = model.getAuthentication();
+ synchronized( prefs )
+ {
+ setProxyHost( prefs, url );
+ setProxyAuthentication( prefs, auth );
+ }
+ }
+
+ public void setProxyHost( Preferences prefs, URL host )
+ {
+ if( null == host )
+ {
+ prefs.remove( "host" );
+ prefs.remove( "scheme" );
+ prefs.remove( "prompt" );
+ }
+ else
+ {
+ prefs.put( "host", host.toExternalForm() );
+ prefs.put( "scheme", "" );
+ prefs.put( "prompt", "" );
+ }
+ }
+
+ private static void setProxyAuthentication( Preferences prefs,
PasswordAuthentication auth )
+ throws BuilderException
+ {
+ if( null == auth )
+ {
+ prefs.putByteArray( "authentication", new byte[0] );
+ }
+ else
+ {
+ byte[] bytes = CredentialsHelper.exportCredentials( auth );
+ prefs.putByteArray( "authentication", bytes );
+ }
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/RepositoryHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,43 @@
+/*
+ * 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.builder;
+
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import net.dpml.transit.model.Logger;
+
+import net.dpml.transit.management.RepositoryManager;
+
+import net.dpml.transit.manager.DefaultRepositoryManager;
+
+/**
+ * The LayoutHelper class is responsible for the setup of initial factory
+ * default preference settings.
+ */
+public class RepositoryHelper extends PreferencesHelper
+{
+ public static RepositoryManager createRepositoryManager( Logger logger,
Preferences prefs )
+ throws BuilderException
+ {
+ URI uri = getURI( prefs, "uri" );
+ return new DefaultRepositoryManager( logger, uri );
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitHelper.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitHelper.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,139 @@
+/*
+ * 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.builder;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import net.dpml.transit.Transit;
+
+import net.dpml.transit.model.Logger;
+
+import net.dpml.transit.adapter.LoggingAdapter;
+import net.dpml.transit.management.CacheManager;
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.LayoutRegistryManager;
+import net.dpml.transit.management.ProxyManager;
+import net.dpml.transit.management.RepositoryManager;
+import net.dpml.transit.management.TransitManager;
+
+import net.dpml.transit.manager.DefaultTransitManager;
+
+
+/**
+ * The LayoutRegistryHelper class provides support for the crreating of a
+ * ContentRegistryManager based on a supplied preferences node.
+ */
+public class TransitHelper
+{
+ public static TransitManager createTransitManager()
+ throws BuilderException
+ {
+ Logger logger = new LoggingAdapter();
+ return createTransitManager( logger );
+ }
+
+ public static TransitManager createTransitManager( Logger logger )
+ throws BuilderException
+ {
+ Preferences prefs = Preferences.userNodeForPackage( Transit.class );
+ return createTransitManager( logger, prefs, null );
+ }
+
+ public static TransitManager createTransitManager( Preferences prefs )
+ throws BuilderException
+ {
+ Logger logger = new LoggingAdapter();
+ return createTransitManager( logger, prefs );
+ }
+
+ public static TransitManager createTransitManager( Logger logger,
Preferences prefs )
+ throws BuilderException
+ {
+ return createTransitManager( logger, prefs, null );
+ }
+
+ public static TransitManager createTransitManager( Logger logger,
Preferences prefs, URL authority )
+ throws BuilderException
+ {
+ if( null == prefs )
+ {
+ throw new NullPointerException( "prefs" );
+ }
+ if( null == logger )
+ {
+ throw new NullPointerException( "logger" );
+ }
+
+ //
+ // check for virgin prefs
+ //
+
+ if( null != authority )
+ {
+ TransitPreferences.setupPreferences( prefs, authority );
+ }
+ else
+ {
+ long install = prefs.getLong( "installation", -1 );
+ if( install < 0 )
+ {
+ TransitPreferences.setupFactoryPreferences( prefs );
+ }
+ }
+
+ //
+ // create the subsystem
+ //
+
+ try
+ {
+ ProxyManager proxy =
+ ProxyHelper.createProxyManager(
+ logger.getChildLogger( "proxy" ), prefs.node( "proxy" ) );
+
+ LayoutRegistryManager layout =
+ LayoutRegistryHelper.createLayoutRegistryManager(
+ logger.getChildLogger( "layout" ), prefs.node( "layout" ) );
+
+ CacheManager cache =
+ CacheHelper.createCacheManager(
+ layout, logger.getChildLogger( "cache" ), prefs.node(
"cache" ) );
+
+ ContentRegistryManager content =
+ ContentRegistryHelper.createContentRegistryManager(
+ logger.getChildLogger( "content" ), prefs.node( "content" )
);
+
+ RepositoryManager repository =
+ RepositoryHelper.createRepositoryManager(
+ logger.getChildLogger( "repository" ), prefs.node(
"repository" ) );
+
+ return new DefaultTransitManager(
+ logger, layout, cache, content, repository, proxy );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "An error occured during construction of the transit manager.";
+ throw new BuilderException( error, e );
+ }
+ }
+}
+
+

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitPreferences.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/TransitPreferences.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/TransitPreferences.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/builder/TransitPreferences.java
Sun Jun 5 00:41:19 2005
@@ -14,7 +14,7 @@
* limitations under the License.
*/

-package net.dpml.transit.manager;
+package net.dpml.transit.builder;

import java.io.File;
import java.io.IOException;
@@ -50,6 +50,8 @@
import net.dpml.transit.layout.EclipseLayout;
import net.dpml.transit.util.Util;

+import net.dpml.transit.model.CacheModel;
+
/**
* The TransitInstaller class is responsible for the setup of initial factory
* default preference settings.
@@ -73,10 +75,6 @@
public static final String HOST_TRUSTED_KEY =
"dpml.transit.host.trusted";
public static final String HOST_BOOTSTRAP_KEY =
"dpml.transit.host.bootstrap";

- public static final String CACHE_LOCATION_KEY =
"dpml.transit.cache.location";
- public static final String CACHE_CLASS_KEY = "dpml.transit.cache.class";
- public static final String CACHE_LAYOUT_KEY =
"dpml.transit.cache.layout";
-
/**
* Default priority string.
*/
@@ -85,9 +83,9 @@
/**
* Setup the default factory preferences for the Transit system.
* @param root the preferences node to use for the population of transit
preferences
- * @exception TransitException if a error occcurs during preferences
initialization
+ * @exception BuilderException if a error occcurs during preferences
initialization
*/
- public static void setupFactoryPreferences( Preferences root ) throws
TransitException
+ public static void setupFactoryPreferences( Preferences root ) throws
BuilderException
{
ClassLoader classloader = Transit.class.getClassLoader();
URL cacheUrl = classloader.getResource(
"transit/authority/cache.properties" );
@@ -101,17 +99,11 @@
setupHostsPreferences( hosts );
root.putLong( "installation", new Date().getTime() );
}
- catch( BackingStoreException e )
- {
- final String error =
- "Unable to establish default transit preferences due to a
backing store error.";
- throw new TransitException( error, e );
- }
catch( Exception e )
{
final String error =
"Unable to resolve default transit preferences due to an
unexpected error.";
- throw new TransitException( error, e );
+ throw new BuilderException( error, e );
}
}

@@ -120,9 +112,9 @@
* the authority attribute.
*
* @param root the preferences node to use for the population of transit
preferences
- * @exception TransitException if a error occcurs during preferences
initialization
+ * @exception BuilderException if a error occcurs during preferences
initialization
*/
- public static void setupPreferences( Preferences root, URL authority )
throws TransitException
+ public static void setupPreferences( Preferences root, URL authority )
throws BuilderException
{
String protocol = authority.getProtocol();
Preferences cachePrefs = root.node( "cache" );
@@ -200,17 +192,11 @@
}
}
}
- catch( BackingStoreException e )
- {
- final String error =
- "Unable to resolve transit preferences due to a backing store
error.";
- throw new TransitException( error, e );
- }
catch( Exception e )
{
final String error =
"Unable to resolve transit preferences due to an unexpected
error.";
- throw new TransitException( error, e );
+ throw new BuilderException( error, e );
}
}

@@ -229,33 +215,43 @@
}

private static void setupCachePreferences( URL resource, Preferences
prefs )
- throws IOException, BackingStoreException
+ throws BuilderException
{
- Properties properties = Util.readProps( resource );
- setupCachePreferences( properties, prefs );
+ try
+ {
+ Properties properties = Util.readProps( resource );
+ setupCachePreferences( properties, prefs );
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "IO exception while attempting to read cache properties."
+ + "\nProperties URL: " + resource;
+ throw new BuilderException( error, ioe );
+ }
}

private static void setupCachePreferences( Properties properties,
Preferences prefs )
- throws IOException, BackingStoreException
+ throws BuilderException
{
- String location = properties.getProperty( CACHE_LOCATION_KEY );
+ String location = properties.getProperty(
CacheModel.CACHE_LOCATION_KEY );
if( null != location )
{
prefs.put( "location", location );
}
- String classname = properties.getProperty( CACHE_CLASS_KEY );
+ String classname = properties.getProperty(
CacheModel.CACHE_CLASS_KEY );
if( null != classname )
{
prefs.put( "classname", classname );
}
- String resolver = properties.getProperty( CACHE_LAYOUT_KEY );
+ String resolver = properties.getProperty(
CacheModel.CACHE_LAYOUT_KEY );
if( null != resolver )
{
prefs.put( "layout", resolver );
}
}

- private static void setupHostsPreferences( Preferences prefs ) throws
IOException, BackingStoreException
+ private static void setupHostsPreferences( Preferences prefs ) throws
BuilderException
{
setupNamedHost( prefs, "local", "transit/authority/hosts/local.host"
);
setupNamedHost( prefs, "repository.dpml.net",
"transit/authority/hosts/repository.dpml.net.host" );
@@ -263,32 +259,53 @@
setupNamedHost( prefs, "www.ibiblio.org",
"transit/authority/hosts/www.ibiblio.org.host" );
}

- private static void setupNamedHost( Preferences prefs, String name,
String resource ) throws IOException
+ private static void setupNamedHost( Preferences prefs, String name,
String resource ) throws BuilderException
{
URL url = Transit.class.getClassLoader().getResource( resource );
- Preferences host = prefs.node( name );
- Properties properties = Util.readProps( url );
- setupHost( properties, host );
+ try
+ {
+ Preferences host = prefs.node( name );
+ Properties properties = Util.readProps( url );
+ setupHost( properties, host );
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "IO exception while attempting to read named host properties."
+ + "\nHost: " + name
+ + "\nURL: " + url;
+ throw new BuilderException( error, ioe );
+ }
}

- private static void setupHost( Preferences prefs, URL hostDef ) throws
IOException, TransitException
+ private static void setupHost( Preferences prefs, URL hostDef ) throws
BuilderException
{
- Properties properties = Util.readProps( hostDef );
- String id = properties.getProperty( HOST_ID_KEY );
- if( null == id )
+ try
{
- final String error =
- "Remote host description does not declare '"
- + HOST_ID_KEY
- + "' property."
- + "\nHost descriptor URL: " + hostDef;
- throw new TransitException( error );
+ Properties properties = Util.readProps( hostDef );
+ String id = properties.getProperty( HOST_ID_KEY );
+ if( null == id )
+ {
+ final String error =
+ "Remote host description does not declare '"
+ + HOST_ID_KEY
+ + "' property."
+ + "\nHost descriptor URL: " + hostDef;
+ throw new BuilderException( error );
+ }
+ Preferences host = prefs.node( id );
+ setupHost( properties, host );
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "IO exception while attempting to read host properties."
+ + "\nURL: " + hostDef ;
+ throw new BuilderException( error, ioe );
}
- Preferences host = prefs.node( id );
- setupHost( properties, host );
}

- private static void setupHost( Properties properties, Preferences prefs
) throws TransitException
+ private static void setupHost( Properties properties, Preferences prefs
) throws BuilderException
{
if( null == properties )
{
@@ -308,7 +325,7 @@
final String error =
"Invalid host defintion (no base url declaration)."
+ "\nHost ID: " + prefs.name();
- throw new IllegalArgumentException( error );
+ throw new BuilderException( error );
}
String index = Util.getProperty( properties, HOST_INDEX_KEY,
null );
String priorityText = Util.getProperty( properties,
HOST_PRIORITY_KEY, DEFAULT_PRIORITY_STRING );
@@ -350,11 +367,11 @@
"Unexpected error occured while attempting to construct a
default host preferences."
+ "\nHost Name: " + name
+ "\nProperties: " + properties;
- throw new TransitException( error, e );
+ throw new BuilderException( error, e );
}
}

- private static File convertToFile( URL url ) throws IOException
+ private static File convertToFile( URL url ) throws BuilderException
{
String protocol = url.getProtocol();
if( "file".equals( protocol ) )
@@ -367,7 +384,7 @@
{
final String error =
"Don't know how to convert the '" + protocol + "' protocol to
a file.";
- throw new IOException( error );
+ throw new BuilderException( error );
}
}

@@ -392,9 +409,9 @@
* Return the url of a file.
* @param file the file to convert
* @return the equivalent url
- * @exception TransitException if a error occurs in file to url conversion
+ * @exception BuilderException if a error occurs in file to url conversion
*/
- private static URL fileToURL( File file ) throws TransitException
+ private static URL fileToURL( File file ) throws BuilderException
{
try
{
@@ -410,11 +427,11 @@
+ ") raised a malformed url exception with the message '"
+ mue.getMessage()
+ "'.";
- throw new TransitException( error );
+ throw new BuilderException( error );
}
}

- private static URL resolveAuthority( Preferences prefs ) throws
TransitException
+ private static URL resolveAuthority( Preferences prefs ) throws
BuilderException
{
String authority = prefs.get( "authority", null );
if( null == authority )
@@ -422,7 +439,7 @@
final String error =
"Authority attribute is undefined."
+ "\nPreferences: " + prefs;
- throw new TransitException( error );
+ throw new BuilderException( error );
}
try
{
@@ -440,7 +457,7 @@
final String error =
"Unable to resolve the Transit authority url."
+ "\nPreferences: " + prefs;
- throw new TransitException( error, e );
+ throw new BuilderException( error, e );
}
}
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultCacheHandler.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultCacheHandler.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/cache/DefaultCacheHandler.java
Sun Jun 5 00:41:19 2005
@@ -51,7 +51,7 @@
import net.dpml.transit.artifact.ArtifactAlreadyExistsException;
import net.dpml.transit.artifact.ArtifactNotFoundException;
import net.dpml.transit.host.ResourceHost;
-import net.dpml.transit.host.ClassicResourceHost;
+import net.dpml.transit.host.DefaultResourceHost;
import net.dpml.transit.layout.Layout;
import net.dpml.transit.model.CacheModel;
import net.dpml.transit.model.CacheListener;
@@ -130,7 +130,7 @@
// with host loading for plugin based resource hosts.
//

- HostModel[] hosts = model.getAvailableHosts();
+ HostModel[] hosts = model.getHostModels();
if( m_logger.isDebugEnabled() )
{
m_logger.debug( "cache configuration host count: " +
hosts.length );
@@ -148,7 +148,7 @@
+ "\nBase URL: " + host.getBaseURL();
m_logger.debug( message );
}
- ResourceHost handler = createClassicResourceHost( host );
+ ResourceHost handler = createDefaultResourceHost( host );
m_resourceHosts.put( id, handler );
}
}
@@ -182,7 +182,7 @@
{
m_model.addCacheListener( this );

- HostModel[] hosts = m_model.getAvailableHosts();
+ HostModel[] hosts = m_model.getHostModels();
for( int i=0; i<hosts.length; i++ )
{
HostModel host = hosts[i];
@@ -586,30 +586,17 @@
{
synchronized( m_resourceHosts )
{
- if( model.getAvailable() )
+ String id = model.getID();
+ if( null == m_resourceHosts.get( id ) )
{
- String id = model.getID();
- if( null == m_resourceHosts.get( id ) )
- {
- ResourceHost host = createResourceHost( model );
- m_resourceHosts.put( id, host );
- }
- else
- {
- final String error =
- "Illegal attempt to override existing host handler: "
+ id;
- throw new TransitException( error );
- }
+ ResourceHost host = createResourceHost( model );
+ m_resourceHosts.put( id, host );
}
else
{
- System.out.println( "# HOST UNAVAILABLE: " + model.getID() );
-
- // TODO:
- // its a host in construction so we need to track this and
add it
- // if and when it becomes available - or alternatively - we
drop
- // local host references and just consult the model with a
local cache
- // a weakly referenced host instances
+ final String error =
+ "Illegal attempt to override existing host handler: " + id;
+ throw new TransitException( error );
}
}
}
@@ -620,7 +607,7 @@
URI uri = model.getPluginURI();
if( null == uri )
{
- return createClassicResourceHost( model );
+ return createDefaultResourceHost( model );
}
else
{
@@ -675,7 +662,7 @@
}
}

- private ResourceHost createClassicResourceHost( HostModel model ) throws
TransitException
+ private ResourceHost createDefaultResourceHost( HostModel model ) throws
TransitException
{
if( m_logger.isDebugEnabled() )
{
@@ -687,7 +674,7 @@
}
try
{
- return new ClassicResourceHost( model, m_resolver );
+ return new DefaultResourceHost( model, m_resolver );
}
catch( Throwable e )
{

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentRegistry.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentRegistry.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentRegistry.java
Sun Jun 5 00:41:19 2005
@@ -31,20 +31,22 @@
import java.util.prefs.NodeChangeEvent;
import java.util.prefs.BackingStoreException;

+import net.dpml.transit.Handler;
import net.dpml.transit.Transit;
import net.dpml.transit.TransitException;
import net.dpml.transit.repository.Repository;
-import net.dpml.transit.model.RegistryModel;
-import net.dpml.transit.model.RegistryListener;
-import net.dpml.transit.model.RegistryEvent;
+import net.dpml.transit.model.ContentRegistryModel;
+import net.dpml.transit.model.ContentRegistryListener;
+import net.dpml.transit.model.ContentRegistryEvent;
import net.dpml.transit.model.ContentModel;
+import net.dpml.transit.model.UnknownKeyException;
import net.dpml.transit.model.Logger;

/**
* A registry of descriptions of plugable content handlers. This
implementation
* maps user defined preferences to instance of ContentHandlerDescriptor.
*/
-public class DefaultContentRegistry implements ContentRegistry,
RegistryListener
+public class DefaultContentRegistry implements Handler, ContentRegistry,
ContentRegistryListener
{
//
------------------------------------------------------------------------
// state
@@ -58,7 +60,7 @@

private final Map m_handlers = new Hashtable();

- private final RegistryModel m_model;
+ private final ContentRegistryModel m_model;

//
------------------------------------------------------------------------
// constructor
@@ -69,7 +71,7 @@
* artifact types, and values that correspond to the description of a
* content type handler plugins.
*/
- public DefaultContentRegistry( RegistryModel model )
+ public DefaultContentRegistry( ContentRegistryModel model )
{
m_model = model;
m_logger = model.getLogger();
@@ -77,19 +79,40 @@
}

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

public ContentHandler getContentHandler( final String type ) throws
IOException
{
- ContentModel model = m_model.getContentModel( type );
- if( null == model )
+ try
{
- return null;
+ ContentModel model = m_model.getContentModel( type );
+ if( null != model.getPluginURI() )
+ {
+ return getContentHandler( model );
+ }
+ else
+ {
+ return null;
+ }
}
- else
+ catch( UnknownKeyException e )
{
- return getContentHandler( model );
+ return null;
}
}

@@ -101,22 +124,25 @@
* Notify all listeners of the addition of a content model.
* @param event the registry event
*/
- public void contentAdded( RegistryEvent event )
+ public void contentAdded( ContentRegistryEvent event )
{
synchronized( m_handlers )
{
ContentModel model = event.getContentModel();
- try
+ if( null != model.getPluginURI() )
{
- getContentHandler( model ); // setup cached reference
- }
- catch( Exception e )
- {
- final String error =
- "Internal error while attempting to add a content
handler."
- + "\nContent Type: " + model.getContentType()
- + "\nPlugin URI: " + model.getPluginURI();
- m_logger.warn( error, e );
+ try
+ {
+ getContentHandler( model ); // setup cached reference
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Internal error while attempting to add a content
handler."
+ + "\nContent Type: " + model.getContentType()
+ + "\nPlugin URI: " + model.getPluginURI();
+ m_logger.error( error, e );
+ }
}
}
}
@@ -125,7 +151,7 @@
* Notify all listeners of the removal of a content model.
* @param event the registry event
*/
- public void contentRemoved( RegistryEvent event )
+ public void contentRemoved( ContentRegistryEvent event )
{
synchronized( m_handlers )
{
@@ -140,7 +166,7 @@
"Internal error while attempting to remove a content
handler."
+ "\nContent Type: " + model.getContentType()
+ "\nPlugin URI: " + model.getPluginURI();
- m_logger.warn( error, e );
+ m_logger.error( error, e );
}
}
}
@@ -168,6 +194,7 @@
protected Class loadContentHandlerClass( ContentModel model ) throws
IOException
{
URI uri = model.getPluginURI();
+
Class clazz = (Class) m_plugins.get( uri );
if( null != clazz )
{

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/host/DefaultResourceHost.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/host/ClassicResourceHost.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/host/ClassicResourceHost.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/host/DefaultResourceHost.java
Sun Jun 5 00:41:19 2005
@@ -65,11 +65,9 @@

import net.dpml.transit.model.HostModel;
import net.dpml.transit.model.HostListener;
+import net.dpml.transit.model.HostNameEvent;
import net.dpml.transit.model.HostChangeEvent;
-import net.dpml.transit.model.HostEnabledEvent;
-import net.dpml.transit.model.HostTrustedEvent;
import net.dpml.transit.model.HostPriorityEvent;
-import net.dpml.transit.model.HostAvailabilityEvent;
import net.dpml.transit.model.HostLayoutEvent;
import net.dpml.transit.model.Logger;

@@ -82,7 +80,7 @@
* realm/domain authentication. It may be introduced in the future.
* </p>
*/
-public class ClassicResourceHost implements ResourceHost, HostListener
+public class DefaultResourceHost implements ResourceHost, HostListener
{
//
------------------------------------------------------------------------
// state
@@ -91,14 +89,14 @@
/**
* Known groups.
*/
- private HashSet m_knownGroups = new HashSet();
+ private HashSet m_knownGroups = new HashSet();

/**
* locks.
* The key is the Artifact one wants to lock against, and the value is an
* anonymously lock object.
*/
- private HashMap m_locks = new HashMap();
+ private HashMap m_locks = new HashMap();

/**
* Connections.
@@ -120,7 +118,7 @@
* @param layout the host layout strategy
* @exception UnknownHostException if the supplied base url references
an unknown host
*/
- public ClassicResourceHost( HostModel model, Layout layout )
+ public DefaultResourceHost( HostModel model, Layout layout )
throws UnknownHostException, IOException
{
m_model = model;
@@ -162,15 +160,7 @@
* Notify a consumer of a change to the enabled state.
* @param event the host event
*/
- public void enabledStateChanged( HostEnabledEvent event )
- {
- }
-
- /**
- * Notify a consumer of a change to the trusted state.
- * @param event the host event
- */
- public void trustedStateChanged( HostTrustedEvent event )
+ public void nameChanged( HostNameEvent event )
{
}

@@ -190,14 +180,6 @@
{
}

- /**
- * Notify a consumer of a change to the available status.
- * @param event the availability change event
- */
- public void availabilityChanged( HostAvailabilityEvent event )
- {
- }
-
//
------------------------------------------------------------------------
// ResourceHost
//
------------------------------------------------------------------------

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/BootstrapException.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/BootstrapException.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,42 @@
+/*
+ * 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 net.dpml.transit.model.Model;
+import net.dpml.transit.model.ModelException;
+
+/**
+ * Exception raised when an attempt is made to associate a plugin based model
+ * with a bootstrap model.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class BootstrapException extends ModelException
+{
+ /**
+ * Construct a new <code>ModelReferenceException</code> instance.
+ *
+ * @param message the detailed error message
+ */
+ public BootstrapException( String message )
+ {
+ super( message );
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/CacheManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/CacheManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,57 @@
+/*
+ * 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.io.File;
+
+import net.dpml.transit.model.CacheModel;
+
+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;
+
+/**
+ * Contract implemented by cache managers.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface CacheManager extends PluginManager, CacheModel
+{
+ /**
+ * Update the value the local cache directory.
+ *
+ * @param file the cache directory
+ */
+ void setCacheDirectory( final File file );
+
+ /**
+ * Return an array of host managers assigned to the cache.
+ *
+ * @return the host manager array
+ */
+ HostManager[] getHostManagers();
+
+ HostManager getHostManager( String type ) throws UnknownKeyException;
+
+ void addHostManager( String id ) throws DuplicateKeyException;
+
+ void addHostManager( HostManager manager ) throws DuplicateKeyException;
+
+ void removeHostManager( HostManager manager ) throws
ModelReferenceException;
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/ContentManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/ContentManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,33 @@
+/*
+ * 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 net.dpml.transit.model.ContentModel;
+
+/**
+ * Contract implemented by objects providing content management.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface ContentManager extends PluginManager, ContentModel
+{
+ void setTitle( String title );
+
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/ContentRegistryManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/ContentRegistryManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,47 @@
+/*
+ * 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 net.dpml.transit.model.DuplicateKeyException;
+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.ContentRegistryModel;
+
+/**
+ * Contract implemented by objects providing content registry management
support.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface ContentRegistryManager extends PluginManager,
ContentRegistryModel
+{
+ /**
+ * Return an array of content managers currently assigned to the registry.
+ * @return the content manager array
+ */
+ ContentManager[] getContentManagers();
+
+ ContentManager getContentManager( String type ) throws
UnknownKeyException;
+
+ void addContentManager( String type ) throws DuplicateKeyException;
+
+ void addContentManager( ContentManager manager ) throws
DuplicateKeyException;
+
+ void removeContentManager( ContentManager manager ) throws
ModelReferenceException;
+}
+
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/HostManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/HostManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,62 @@
+/*
+ * 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.net.URL;
+import java.net.PasswordAuthentication;
+
+import net.dpml.transit.model.HostModel;
+import net.dpml.transit.model.LayoutModel;
+
+/**
+ * Contract implemented by a host manager.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: HostManager.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
+ */
+public interface HostManager extends PluginManager, HostModel
+{
+ /**
+ * HTTP port number.
+ */
+ static final int HTTP_PORT = 80;
+
+ /**
+ * FTP port number.
+ */
+ static final int FTP_PORT = 21;
+
+ /**
+ * HTTPS port number.
+ */
+ static final int HTTPS_PORT = 443;
+
+
+ public void update(
+ URL base, URL index, boolean enabled, boolean trusted, LayoutModel
layout,
+ PasswordAuthentication auth, String scheme, String prompt );
+
+ void setName( String name );
+
+ void setPriority( int priority );
+
+ void setLayoutModel( LayoutModel layout ) throws BootstrapException;
+
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/LayoutManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/LayoutManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,31 @@
+/*
+ * 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 net.dpml.transit.model.LayoutModel;
+
+/**
+ * Contract implemented by layout managers.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface LayoutManager extends PluginManager, LayoutModel
+{
+ void setTitle( String title );
+}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/LayoutRegistryManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/LayoutRegistryManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,48 @@
+/*
+ * 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 net.dpml.transit.model.LayoutRegistryModel;
+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;
+
+/**
+ * Default implementation of a layout subsystem that maitains
+ * information about the set of registred location resolver configurations.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface LayoutRegistryManager extends PluginManager,
LayoutRegistryModel
+{
+ /**
+ * Return an array of layout managers currently assigned to the registry.
+ * @return the layout manager array
+ */
+ LayoutManager[] getLayoutManagers();
+
+ public LayoutManager getLayoutManager( String id ) throws
UnknownKeyException;
+
+ void addLayoutManager( String id ) throws DuplicateKeyException;
+
+ void addLayoutManager( LayoutManager manager ) throws
DuplicateKeyException;
+
+ void removeLayoutManager( LayoutManager manager ) throws
ModelReferenceException;
+}
+
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/ModelReferenceException.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/ModelReferenceException.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,75 @@
+/*
+ * 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 net.dpml.transit.model.Model;
+import net.dpml.transit.model.ModelException;
+
+/**
+ * Exception raised when an attempt is made to remove a model
+ * that is referenced by another model.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class ModelReferenceException extends ModelException
+{
+ private Model m_target;
+ private final Object[] m_consumers;
+
+ /**
+ * Construct a new <code>ModelReferenceException</code> instance.
+ *
+ * @param model the target model
+ * @param consumer the consumer model
+ */
+ public ModelReferenceException( final Model target, final Object[]
consumers )
+ {
+ super( buildMessage( target, consumers ) );
+
+ m_target = target;
+ m_consumers = consumers;
+ }
+
+ public Model getModel()
+ {
+ return m_target;
+ }
+
+ public Object[] getConsumers()
+ {
+ return m_consumers;
+ }
+
+ private static String buildMessage( final Model target, final Object[]
consumers )
+ {
+ int n = consumers.length;
+ final String error =
+ "Cannot remove a model due to "
+ + n
+ + " active consumers.";
+ StringBuffer buffer = new StringBuffer( error );
+ for( int i=0; i<consumers.length; i++ )
+ {
+ Object consumer = consumers[i];
+ buffer.append( "\nReference: " + consumer );
+ }
+ return buffer.toString();
+ }
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/PluginManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/PluginManager.java
Sun Jun 5 00:41:19 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.net.URI;
+
+import net.dpml.transit.model.PluginModel;
+
+/**
+ * Contract implementated by managers of plugable sub-systems.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface PluginManager extends PluginModel
+{
+ /**
+ * Set the plugin uri value.
+ * @param the plugin uri
+ */
+ void setPluginURI( URI uri );
+
+ Object[] getListeners();
+
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/ProxyManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/ProxyManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.net.URL;
+import java.net.PasswordAuthentication;
+
+import net.dpml.transit.model.ProxyModel;
+
+/**
+ * The ProxyManager is an interface implemented by proxy managers.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface ProxyManager extends ProxyModel
+{
+ void update( URL host, PasswordAuthentication auth, String[] excludes );
+
+ void setHost( URL host );
+
+ void setExcludes( String[] excludes );
+
+ void setAuthentication( PasswordAuthentication auth );
+}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/RepositoryManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/RepositoryManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,31 @@
+/*
+ * 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 net.dpml.transit.model.RepositoryModel;
+
+/**
+ * The repository manager contract.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface RepositoryManager extends PluginManager, RepositoryModel
+{
+}
+

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/management/TransitManager.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/management/TransitManager.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,70 @@
+/*
+ * 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 net.dpml.transit.model.Logger;
+import net.dpml.transit.model.TransitModel;
+
+/**
+ * The DefaultTransitManager class maintains an active configuration of the
+ * Transit system.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface TransitManager extends TransitModel
+{
+ //
------------------------------------------------------------------------
+ // TransitMananger
+ //
------------------------------------------------------------------------
+
+ /**
+ * Return the proxy manager.
+ * @return the proxy configuration manager.
+ */
+ ProxyManager getProxyManager();
+
+ /**
+ * Return the cache manager.
+ * @return the cache manager
+ */
+ CacheManager getCacheManager();
+
+ /**
+ * Return the content registry manager.
+ *
+ * @return the content manager
+ */
+ ContentRegistryManager getContentRegistryManager();
+
+ /**
+ * Return the repository manager.
+ *
+ * @return the repository director
+ */
+ RepositoryManager getRepositoryManager();
+
+ /**
+ * Return the layout registry manager.
+ *
+ * @return the layout manager
+ */
+ LayoutRegistryManager getLayoutRegistryManager();
+
+}
+

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultCacheManager.java
(from r2693,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultCacheManager.java
Sun Jun 5 00:41:19 2005
@@ -42,6 +42,7 @@
import net.dpml.transit.Transit;

import net.dpml.transit.model.CacheModel;
+import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.HostModel;
import net.dpml.transit.model.PluginChangeEvent;
import net.dpml.transit.model.PluginListener;
@@ -49,14 +50,19 @@
import net.dpml.transit.model.FileChangeEvent;
import net.dpml.transit.model.HostNodeEvent;
import net.dpml.transit.model.HostChangeEvent;
-import net.dpml.transit.model.HostEnabledEvent;
-import net.dpml.transit.model.HostTrustedEvent;
import net.dpml.transit.model.HostPriorityEvent;
import net.dpml.transit.model.HostLayoutEvent;
-import net.dpml.transit.model.HostAvailabilityEvent;
+import net.dpml.transit.model.HostNameEvent;
import net.dpml.transit.model.HostListener;
import net.dpml.transit.model.ModelException;
import net.dpml.transit.model.Logger;
+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;
+
+import net.dpml.transit.model.LayoutRegistryModel;
+import net.dpml.transit.management.ModelReferenceException;
+import net.dpml.transit.management.CacheManager;
+import net.dpml.transit.management.HostManager;

import net.dpml.transit.util.PropertyResolver;

@@ -67,66 +73,44 @@
* @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 CacheManager extends PluginManager
- implements CacheModel, NodeChangeListener , PluginListener
+public class DefaultCacheManager extends DefaultPluginManager implements
CacheManager
{
//
------------------------------------------------------------------------
// state
//
------------------------------------------------------------------------

- private final AvailabilityListener m_availabilityListener = new
AvailabilityListener();
- private final LayoutRegistryManager m_layout;
- private final List m_list = new LinkedList();
-
- private final Set m_available = Collections.synchronizedSortedSet( new
TreeSet() );
+ private final Set m_list = Collections.synchronizedSortedSet( new
TreeSet() );

private File m_cache;

+ private LayoutRegistryModel m_registry;
+
//
------------------------------------------------------------------------
// constructor
//
------------------------------------------------------------------------

- public CacheManager( Logger logger, Preferences prefs,
LayoutRegistryManager layout ) throws ModelException
+ public DefaultCacheManager(
+ Logger logger, URI uri, LayoutRegistryModel registry, File cache,
HostManager[] managers )
+ throws DuplicateKeyException
{
- super( logger, prefs );
-
- m_layout = layout;
-
- //
- // setup the cache
- //
-
- File cache = resolveCacheDirectory( prefs );
- updateCacheDirectory( cache );
-
- //
- // construct the hosts
- //
-
- Preferences hostsNode = getHostsRoot();
- hostsNode.addNodeChangeListener( this );
- try
+ super( logger, uri );
+ if( null == cache )
{
- String[] names = hostsNode.childrenNames();
- for( int i=0; i<names.length; i++ )
- {
- String name = names[i];
- Preferences p = hostsNode.node( name );
- addHostModel( p, false );
- }
+ throw new NullPointerException( "cache" );
}
- catch( Exception e )
+ if( null == registry )
{
- final String error =
- "Unexpected exception while resolving host preferences."
- + "\nPreferences: " + prefs;
- throw new ModelException( error, e );
+ throw new NullPointerException( "registry" );
}
- }

- private Preferences getHostsRoot()
- {
- return getPreferences().node( "hosts" );
+ m_registry = registry;
+
+ setCacheDirectory( cache );
+ for( int i=0; i<managers.length; i++ )
+ {
+ HostManager manager = managers[i];
+ addHostManager( manager );
+ }
}

//
------------------------------------------------------------------------
@@ -134,123 +118,117 @@
//
------------------------------------------------------------------------

/**
- * Update the preferences cache location attribute with the value of
- * the supplied file. If the file argument is null the cache location
- * will be set to "cache" otherwise the string form of the file will
- * be assigned.
+ * Update the value the local cache directory.
*
* @param file the cache directory
*/
- public void setCacheDirectory( File file )
+ public void setCacheDirectory( final File file )
{
- Preferences prefs = getPreferences();
- if( null == file )
- {
- prefs.put( "location", "cache" );
- }
- else
+ synchronized( m_lock )
{
- String path = file.toString();
- prefs.put( "location", path );
+ if( null == file )
+ {
+ throw new NullPointerException( "file" );
+ }
+ File cache = file;
+ if( false == cache.isAbsolute() )
+ {
+ File anchor = getAnchorDirectory();
+ cache = new File( anchor, file.toString() );
+ cache.mkdirs();
+ }
+ if( null == m_cache )
+ {
+ getLogger().debug( "setting cache: " + cache );
+ }
+ else
+ {
+ getLogger().debug( "updating cache: " + cache );
+ }
+ m_cache = cache;
+ CacheDirectoryChangeEvent event = new CacheDirectoryChangeEvent(
this, m_cache );
+ enqueueEvent( event );
}
}

/**
- * Return an array of host managers currently assigned to the cache. This
- * operations returns all hosts (including non-operation and non-enabled
- * hosts).
- *
+ * Return an array of host managers assigned to the cache.
+ *
* @return the host manager array
- * @see #getAvailableHosts
*/
public HostManager[] getHostManagers()
{
- return (HostManager[]) m_list.toArray( new HostManager[0] );
- }
-
- public void addHostModel( String id )
- {
- if( null != id )
+ synchronized( m_lock )
{
- getHostsRoot().node( id );
+ return (HostManager[]) m_list.toArray( new HostManager[0] );
}
}

- public HostManager getHostManager( String id )
+ public HostManager getHostManager( String id ) throws UnknownKeyException
{
- if( null == id )
+ synchronized( m_lock )
{
- return null;
- }
- HostManager[] managers = getHostManagers();
- for( int i=0; i<managers.length; i++ )
- {
- HostManager manager = managers[i];
- if( id.equals( manager.getID() ) )
+ HostManager[] managers = getHostManagers();
+ for( int i=0; i<managers.length; i++ )
{
- return manager;
+ HostManager manager = managers[i];
+ if( id.equals( manager.getID() ) )
+ {
+ return manager;
+ }
}
+ throw new UnknownKeyException( id );
}
- return null;
}

- public void removeHostModel( String id ) throws ModelException
+ public void addHostManager( String id ) throws DuplicateKeyException
{
- if( null == id )
- {
- return;
- }
try
{
- if( getHostsRoot().nodeExists( id ) )
- {
- Preferences prefs = getHostsRoot().node( id );
- prefs.removeNode();
- }
+ Logger logger = getLogger();
+ LayoutModel layout = m_registry.getLayoutModel( "classic" );
+ HostManager manager =
+ new DefaultHostManager( logger, id, layout );
}
- catch( BackingStoreException e )
+ catch( UnknownKeyException e )
{
- final String error =
- "Preferences backing store access error during host model
removal."
- + "\nPreferences: " + getPreferences()
- + "\nHost ID: " + id;
- throw new ModelException( error );
+ // will not happen
}
}

- /**
- * Dispose of the manager.
- */
- public void dispose()
+ public void addHostManager( HostManager manager ) throws
DuplicateKeyException
{
- super.dispose();
- try
- {
- getHostsRoot().removeNodeChangeListener( this );
- }
- catch( Throwable e )
- {
- // ignore
- }
- HostModel[] models = getHostModels();
- for( int i=0; i<models.length; i++ )
+ synchronized( m_lock )
{
- HostModel model = models[i];
+ String id = manager.getID();
try
{
- model.removePluginListener( this );
+ HostManager m = getHostManager( id );
+ throw new DuplicateKeyException( id );
}
- catch( Throwable e )
+ catch( UnknownKeyException e )
{
- // ignore
+ m_list.add( manager );
+ HostAddedEvent event = new HostAddedEvent( this, manager );
+ enqueueEvent( event );
}
- try
+ }
+ }
+
+ public void removeHostManager( HostManager manager ) throws
ModelReferenceException
+ {
+ synchronized( m_lock )
+ {
+ Object[] listeners = manager.getListeners();
+ if( listeners.length == 0 )
{
- model.removeHostListener( m_availabilityListener );
+ m_list.remove( manager );
+ HostRemovedEvent event = new HostRemovedEvent( this,
manager );
+ super.enqueueEvent( event );
}
- catch( Throwable e )
+ else
{
- // ignore
+ throw new ModelReferenceException( manager, listeners );
}
}
}
@@ -274,19 +252,7 @@
*/
public HostModel[] getHostModels()
{
- return (HostModel[]) m_list.toArray( new HostModel[0] );
- }
-
- /**
- * Return an array of available and enabled hosts is priority order.
- * @return the available host model array
- */
- public HostModel[] getAvailableHosts()
- {
- synchronized( m_available )
- {
- return (HostModel[]) m_available.toArray( new HostModel[0] );
- }
+ return getHostManagers();
}

/**
@@ -308,245 +274,9 @@
}

//
------------------------------------------------------------------------
- // PluginListener (listens to changes to plugin uris)
- //
------------------------------------------------------------------------
-
- public void pluginChanged( PluginChangeEvent event )
- {
- getLogger().info( "plugin changed: " + event.getPluginURI() );
- }
-
- //
------------------------------------------------------------------------
- // PreferencesChangeListener (listens to cache prefs)
- //
------------------------------------------------------------------------
-
- public void preferenceChange( PreferenceChangeEvent event )
- {
- super.preferenceChange( event );
-
- String key = event.getKey();
- String value = event.getNewValue();
- Preferences prefs = event.getNode();
- if( "location".equals( key ) )
- {
- File cache = resolveCacheDirectory( prefs );
- updateCacheDirectory( cache );
- }
- }
-
- //
------------------------------------------------------------------------
- // NodeChangeListener (listens to host prefs node addition and removal)
- //
------------------------------------------------------------------------
-
- /**
- * Handle the addition of a host following a preferences node change to
the
- * relative node hosts.
- *
- * @param event the node addition event
- */
- public void childAdded( NodeChangeEvent event )
- {
- Preferences prefs = event.getChild();
- getLogger().info( "adding host: " + prefs.name() );
- try
- {
- addHostModel( prefs, true );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to add host."
- + "\nPreferences Node: " + event.getChild()
- + "\nHost path: " + event.getChild().get( "base", null );
- getLogger().error( error, e );
- }
- }
-
- public void childRemoved( NodeChangeEvent event )
- {
- Preferences prefs = event.getChild();
- getLogger().info( "removing host: " + prefs.name() );
- removeHostModel( prefs );
- }
-
- //
------------------------------------------------------------------------
- // HostListener
- //
------------------------------------------------------------------------
-
- private class AvailabilityListener implements HostListener
- {
- /**
- * Notify a consumer of an aggregated set of changes.
- * @param event the host change event
- */
- public void hostChanged( HostChangeEvent event )
- {
- }
-
- /**
- * Notify a consumer of a change to the enabled state.
- * @param event the host event
- */
- public void enabledStateChanged( HostEnabledEvent event )
- {
- HostModel host = event.getHostModel();
- updateAvailableHostsList( host );
- }
-
- /**
- * Notify a consumer of a change to the trusted state.
- * @param event the host event
- */
- public void trustedStateChanged( HostTrustedEvent event )
- {
- }
-
- /**
- * Notify a consumer of a change to the host priority.
- * @param event the host event
- */
- public void priorityChanged( HostPriorityEvent event )
- {
- }
-
- /**
- * Notify a consumer of a change to the host resolver.
- * @param event the host resolver change event
- */
- public void layoutChanged( HostLayoutEvent event )
- {
- }
-
- /**
- * Notify a consumer of a change to availability status of a host.
- * @param event the host availability event
- */
- public void availabilityChanged( HostAvailabilityEvent event )
- {
- HostModel host = event.getHostModel();
- updateAvailableHostsList( host );
- }
- }
-
- //
------------------------------------------------------------------------
// internal
//
------------------------------------------------------------------------

- /**
- * Update the value the local cache directory.
- *
- * @param file the cache directory
- */
- private synchronized void updateCacheDirectory( File file )
- {
- if( null == file )
- {
- throw new NullPointerException( "file" );
- }
- File cache = file;
- if( false == cache.isAbsolute() )
- {
- File anchor = getAnchorDirectory();
- cache = new File( anchor, file.toString() );
- cache.mkdirs();
- }
- if( null == m_cache )
- {
- getLogger().debug( "setting cache: " + cache );
- }
- else
- {
- getLogger().debug( "updating cache: " + cache );
- }
- m_cache = cache;
- }
-
- private void addHostModel( Preferences prefs, boolean notify ) throws
UnknownHostException, IOException
- {
- Logger logger = getLogger();
- HostModel model = new HostManager( logger, prefs, m_layout );
- String id = model.getID();
- int priority = model.getPriority();
- synchronized( m_list )
- {
- HostModel h = findHostModel( id );
- if( null != h )
- {
- final String error =
- "Host already registered."
- + "\nHost ID: " + id;
- throw new IllegalArgumentException( error );
- }
- m_list.add( model );
- model.addPluginListener( this );
- updateAvailableHostsList( model );
- model.addHostListener( m_availabilityListener );
- if( notify )
- {
- HostAddedEvent event = new HostAddedEvent( this, model,
priority );
- super.enqueueEvent( event );
- }
- }
- }
-
- private void removeHostModel( Preferences prefs )
- {
- synchronized( m_list )
- {
- String id = prefs.name();
- HostModel model = findHostModel( id );
- if( null != model )
- {
- m_list.remove( model );
- model.removePluginListener( this );
- model.removeHostListener( m_availabilityListener );
- synchronized( m_available )
- {
- m_available.remove( model );
- }
- HostRemovedEvent event = new HostRemovedEvent( this, model );
- super.enqueueEvent( event );
- }
- }
- }
-
- private HostModel findHostModel( String id )
- {
- HostModel[] models = getHostModels();
- for( int i=0; i<models.length; i++ )
- {
- HostModel model = models[i];
- if( id.equals( model.getID() ) )
- {
- return model;
- }
- }
- return null;
- }
-
- private void updateAvailableHostsList( HostModel host )
- {
- synchronized( m_available )
- {
- boolean available = host.getAvailable();
- boolean enabled = host.getEnabled();
- if( available && enabled )
- {
- m_available.remove( host );
- m_available.add( host );
- getLogger().debug( "added available host: " + host.getID() );
- }
- else
- {
- boolean removed = m_available.remove( host );
- if( removed )
- {
- getLogger().debug( "removed available host: " +
host.getID() );
- }
- }
- }
- }
-
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )
@@ -632,19 +362,6 @@
}
}

- /**
- * Resolve the cache directory using preferences.
- * @param prefs the cache preferences
- * @return the cache directory
- */
- private File resolveCacheDirectory( Preferences prefs )
- {
- String path = prefs.get( "location", "cache" );
- String location = System.getProperty(
TransitPreferences.CACHE_LOCATION_KEY, path );
- String cache = PropertyResolver.resolve( System.getProperties(),
location );
- return new File( cache );
- }
-
private File getAnchorDirectory()
{
return Transit.DPML_DATA;
@@ -654,15 +371,10 @@
{
private int m_priority;

- public HostAddedEvent( CacheModel source, HostModel host, int
priority )
+ public HostAddedEvent( CacheModel source, HostModel host )
{
super( source, host );
}
-
- public int getPriority()
- {
- return m_priority;
- }
}

static class HostRemovedEvent extends HostNodeEvent
@@ -673,20 +385,6 @@
}
}

- static class CachePluginChangeEvent extends PluginChangeEvent
- {
- /**
- * Creation of a new CachePluginChangeEvent.
- *
- * @param source the object initiating the event
- * @param plugin the plugin uri
- */
- public CachePluginChangeEvent( CacheModel source, URI plugin )
- {
- super( source, plugin );
- }
- }
-
class CacheDirectoryChangeEvent extends FileChangeEvent
{
public CacheDirectoryChangeEvent( Object source, File file )

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentManager.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/ContentManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/ContentManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentManager.java
Sun Jun 5 00:41:19 2005
@@ -18,11 +18,9 @@

package net.dpml.transit.manager;

+import java.net.URI;
import java.util.EventObject;
import java.util.EventListener;
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;

import net.dpml.transit.model.ContentModel;
import net.dpml.transit.model.PluginModel;
@@ -31,31 +29,38 @@
import net.dpml.transit.model.ContentListener;
import net.dpml.transit.model.Logger;

+import net.dpml.transit.management.ContentManager;
+
/**
* Default implementation of a content manager that maintains an active
* configuration model of a pluggable content handler.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id: HostManager.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
*/
-public class ContentManager extends PluginManager implements ContentModel
+public class DefaultContentManager extends DefaultPluginManager implements
ContentManager
{
//----------------------------------------------------------------------
// state
//----------------------------------------------------------------------

private final String m_type;
+
private String m_title;

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

- public ContentManager( Logger logger, Preferences prefs )
+ public DefaultContentManager( Logger logger, String type )
+ {
+ this( logger, null, type, type );
+ }
+
+ public DefaultContentManager( Logger logger, URI uri, String type,
String title )
{
- super( logger, prefs );
- m_type = prefs.name();
- m_title = prefs.get( "title", m_type );
+ super( logger, uri );
+ m_type = type;
+ m_title = title;
}

//----------------------------------------------------------------------
@@ -75,7 +80,7 @@
* Returns the human readable name of the content type handler.
* @return the content type human readable name
*/
- public String getContentHandlerTitle()
+ public String getTitle()
{
return m_title;
}
@@ -99,33 +104,16 @@
}

//
------------------------------------------------------------------------
- // PreferencesChangeListener
+ // ContentManager
//
------------------------------------------------------------------------

- /**
- * Listen to changes in the preferences object that defines this
descriptor
- * and reflect the changes in the state of the descriptor class.
- *
- * @param event the preference change event
- */
- public void preferenceChange( PreferenceChangeEvent event )
+ public void setTitle( String title )
{
- super.preferenceChange( event );
-
- String key = event.getKey();
- String value = event.getNewValue();
- Preferences prefs = event.getNode();
- if( "title".equals( key ) )
- {
- setTitle( value );
- }
- else if( false == "uri".equals( key ) )
+ synchronized( m_lock )
{
- final String warning =
- "A content handler plugin preference node change event
references an unrecognized key."
- + "\nPreference Node: " + prefs
- + "\nKey: " + key;
- getLogger().warn( warning );
+ m_title = title;
+ ContentEvent event = new ContentEvent( this );
+ super.enqueueEvent( event );
}
}

@@ -133,13 +121,6 @@
// internal
//
------------------------------------------------------------------------

- private void setTitle( String title )
- {
- m_title = title;
- ContentEvent event = new ContentEvent( this );
- super.enqueueEvent( event );
- }
-
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentRegistryManager.java
(from r2690,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RegistryManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RegistryManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultContentRegistryManager.java
Sun Jun 5 00:41:19 2005
@@ -18,26 +18,28 @@

package net.dpml.transit.manager;

+import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.EventObject;
import java.util.EventListener;
-import java.util.prefs.Preferences;
-import java.util.prefs.NodeChangeEvent;
-import java.util.prefs.NodeChangeListener;
-import java.util.prefs.BackingStoreException;
-import java.net.URI;

-import net.dpml.transit.model.RegistryModel;
import net.dpml.transit.model.ContentModel;
+import net.dpml.transit.model.ContentRegistryListener;
+import net.dpml.transit.model.ContentRegistryEvent;
+import net.dpml.transit.model.ContentRegistryModel;
import net.dpml.transit.model.PluginChangeEvent;
-import net.dpml.transit.model.RegistryListener;
-import net.dpml.transit.model.RegistryEvent;
import net.dpml.transit.model.PluginListener;
import net.dpml.transit.model.ModelException;
import net.dpml.transit.model.Logger;
+import net.dpml.transit.model.DuplicateKeyException;
+import net.dpml.transit.model.UnknownKeyException;
+
+import net.dpml.transit.management.ModelReferenceException;
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.ContentManager;

/**
* Default implementation of a content handler registry manager that
maitains
@@ -46,8 +48,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 RegistryManager extends PluginManager
- implements RegistryModel, NodeChangeListener, PluginListener
+public class DefaultContentRegistryManager extends DefaultPluginManager
implements ContentRegistryManager
{
//
------------------------------------------------------------------------
// state
@@ -59,223 +60,99 @@
// constructor
//
------------------------------------------------------------------------

- public RegistryManager( Logger logger, Preferences prefs ) throws
ModelException
+ public DefaultContentRegistryManager(
+ Logger logger, URI uri, ContentManager[] managers ) throws
DuplicateKeyException
{
- super( logger, prefs );
-
- //
- // construct the content handler configurations
- //
-
- try
- {
- String[] names = prefs.childrenNames();
- for( int i=0; i<names.length; i++ )
- {
- String name = names[i];
- Preferences p = prefs.node( name );
- addContentManager( p, false );
- }
- }
- catch( ModelException e )
- {
- throw e;
- }
- catch( Exception e )
+ super( logger, uri );
+ for( int i=0; i<managers.length; i++ )
{
- final String error =
- "Unexpected exception while reading content preferences."
- + "\nPreferences: " + prefs;
- throw new ModelException( error, e );
+ ContentManager manager = managers[i];
+ addContentManager( manager );
}
-
- //
- // add a listener to the preferences
- //
-
- prefs.addNodeChangeListener( this );
}

//
------------------------------------------------------------------------
- // RegistryManager
+ // ContentRegistryManager
//
------------------------------------------------------------------------

/**
- * Return the plugin uri.
- * @return the plugin uri
- */
- public URI getPluginURI()
- {
- String spec = System.getProperty( "dpml.transit.content.plugin" );
- if( null != spec )
- {
- try
- {
- return new URI( spec );
- }
- catch( Throwable e )
- {
- final String error =
- "Cannot resolve registry plugin uri from system property."
- + "\nProperty name: dpml.transit.content.plugin"
- + "\nProperty Value: " + spec;
- throw new IllegalStateException( error );
- }
- }
- else
- {
- return super.getPluginURI();
- }
- }
-
- /**
* Return an array of content managers currently assigned to the registry.
* @return the content manager array
*/
public ContentManager[] getContentManagers()
{
- return (ContentManager[]) m_list.toArray( new ContentManager[0] );
- }
-
- public ContentManager getContentManager( String type )
- {
- ContentManager[] managers = getContentManagers();
- for( int i=0; i<managers.length; i++ )
+ synchronized( m_lock )
{
- ContentManager manager = managers[i];
- if( type.equals( manager.getContentType() ) )
- {
- return manager;
- }
+ return (ContentManager[]) m_list.toArray( new ContentManager[0]
);
}
+ }

- //
- // check for a system property that defines the plugin uri
- //
-
- String spec = "dpml.transit.content.plugin." + type;
- String value = System.getProperty( spec );
- if( null != value )
+ public ContentManager getContentManager( String type ) throws
UnknownKeyException
+ {
+ synchronized( m_lock )
{
- try
- {
- URI uri = new URI( value );
- return addContentManager( type, type, uri );
- }
- catch( Throwable e )
+ ContentManager[] managers = getContentManagers();
+ for( int i=0; i<managers.length; i++ )
{
- final String error =
- "Cannot construct content handler for system property
specification."
- + "\nContent Type ID: " + type
- + "\nSystem Defined URI: " + value;
- IllegalArgumentException exception =
- new IllegalArgumentException( error );
- exception.initCause( e );
- throw exception;
+ ContentManager manager = managers[i];
+ if( type.equals( manager.getContentType() ) )
+ {
+ return manager;
+ }
}
+ throw new UnknownKeyException( type );
}
-
- return null;
}

- /**
- * Register a new content manager.
- *
- * @return the content manager
- */
- public ContentManager addContentManager( String type, String title, URI
uri ) throws ModelException
+ public void addContentManager( String type ) throws DuplicateKeyException
{
- if( null == type )
- {
- throw new NullPointerException( "type" );
- }
- if( null == title )
- {
- throw new NullPointerException( "title" );
- }
- if( null == uri )
- {
- throw new NullPointerException( "uri" );
- }
-
- Preferences prefs = getPreferences().node( type );
- prefs.put( "title", title );
- prefs.put( "uri", uri.toString() );
- return addContentManager( prefs, true );
+ Logger logger = getLogger();
+ ContentManager manager = new DefaultContentManager( logger, type );
+ addContentManager( manager );
}

- public void removeContentModel( String type ) throws ModelException
+ public void addContentManager( ContentManager manager ) throws
DuplicateKeyException
{
- try
+ synchronized( m_lock )
{
- if( getPreferences().nodeExists( type ) )
+ String id = manager.getContentType();
+ try
{
- Preferences prefs = getPreferences().node( type );
- prefs.removeNode();
+ ContentManager m = getContentManager( id );
+ throw new DuplicateKeyException( id );
+ }
+ catch( UnknownKeyException e )
+ {
+ m_list.add( manager );
+ ContentAddedEvent event = new ContentAddedEvent ( this,
manager );
+ enqueueEvent( event );
}
- }
- catch( BackingStoreException e )
- {
- final String error =
- "Preferences backing store access error during content model
removal."
- + "\nPreferences: " + getPreferences()
- + "\nContent Type: " + type;
- throw new ModelException( error );
}
}

- /**
- * Dispose of the manager.
- */
- public void dispose()
+ public void removeContentManager( ContentManager manager ) throws
ModelReferenceException
{
- super.dispose();
- try
+ synchronized( m_lock )
{
- getPreferences().removeNodeChangeListener( this );
- }
- catch( Throwable e )
- {
- // ignore
- }
- ContentModel[] models = getContentModels();
- for( int i=0; i<models.length; i++ )
- {
- ContentModel model = models[i];
- try
+ Object[] listeners = manager.getListeners();
+ if( listeners.length == 0 )
{
- model.removePluginListener( this );
+ m_list.remove( manager );
+ ContentRemovedEvent event = new ContentRemovedEvent( this,
manager );
+ super.enqueueEvent( event );
}
- catch( Throwable e )
+ else
{
- // ignore
+ throw new ModelReferenceException( manager, listeners );
}
}
}

- public void newContentModel( String type )
- {
- getPreferences().node( type );
- }
-
//
------------------------------------------------------------------------
- // RegistryModel
+ // ContentRegistryModel
//
------------------------------------------------------------------------

- /**
- * Register a new content model.
- *
- * @param type the content type identifier
- * @param title the title of the content model
- * @param plugin the content plugin uri
- * @return the content model
- */
- public ContentModel addContentModel( String type, String title, URI
plugin ) throws ModelException
- {
- return addContentManager( type, title, plugin );
- }
-
- public ContentModel getContentModel( String type )
+ public ContentModel getContentModel( String type ) throws
UnknownKeyException
{
return getContentManager( type );
}
@@ -293,7 +170,7 @@
* Add a regstry change listener.
* @param listener the registry change listener to add
*/
- public void addRegistryListener( RegistryListener listener )
+ public void addRegistryListener( ContentRegistryListener listener )
{
super.addListener( listener );
}
@@ -302,118 +179,24 @@
* Remove a regstry change listener.
* @param listener the registry change listener to remove
*/
- public void removeRegistryListener( RegistryListener listener )
+ public void removeRegistryListener( ContentRegistryListener listener )
{
super.removeListener( listener );
}

//
------------------------------------------------------------------------
- // PluginListener (listens to changes to plugin uris)
- //
------------------------------------------------------------------------
-
- public void pluginChanged( PluginChangeEvent event )
- {
- getLogger().info( "plugin changed: " + event.getPluginURI() );
- }
-
- //
------------------------------------------------------------------------
- // NodeChangeListener (listens to content prefs node addition and
removal)
- //
------------------------------------------------------------------------
-
- /**
- * Handle the addition of a content handler configuration following a
- * preferences node change.
- *
- * @param event the node addition event
- */
- public void childAdded( NodeChangeEvent event )
- {
- Preferences prefs = event.getChild();
- try
- {
- addContentManager( prefs, true );
- }
- catch( ModelException e )
- {
- String message = e.getMessage();
- Throwable cause = e.getCause();
- getLogger().error( message, cause );
- }
- }
-
- public void childRemoved( NodeChangeEvent event )
- {
- Preferences prefs = event.getChild();
- removeContentModel( prefs );
- }
-
- //
------------------------------------------------------------------------
// internal
//
------------------------------------------------------------------------

- private ContentManager addContentManager( Preferences prefs, boolean
notify ) throws ModelException
- {
- Logger logger = getLogger();
- ContentManager model = new ContentManager( logger, prefs );
- String type = model.getContentType();
- synchronized( m_list )
- {
- ContentManager m = getContentManager( type );
- if( null != m )
- {
- URI uri = m.getPluginURI();
- if( false == uri.equals( model.getPluginURI() ) )
- {
- final String error =
- "Content type handler already registered."
- + "\nContent Type: " + type
- + "\nPlugin URI: " + uri;
- throw new ModelException( error );
- }
- else
- {
- return m;
- }
- }
- else
- {
- m_list.add( model );
- model.addPluginListener( this );
- if( notify )
- {
- ContentAddedEvent event = new ContentAddedEvent( this,
model );
- super.enqueueEvent( event );
- }
- return model;
- }
- }
- }
-
- private void removeContentModel( Preferences prefs )
- {
- synchronized( m_list )
- {
- String type = prefs.name();
- ContentModel model = getContentModel( type );
- if( null != model )
- {
- m_list.remove( model );
- model.removePluginListener( this );
- ContentRemovedEvent event = new ContentRemovedEvent( this,
model );
- super.enqueueEvent( event );
- }
- }
- }
-
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )
{
super.processPluginChangeEvent( (PluginChangeEvent) event );
}
- else if( event instanceof RegistryEvent )
+ else if( event instanceof ContentRegistryEvent )
{
- processRegistryEvent( (RegistryEvent) event );
+ processContentRegistryEvent( (ContentRegistryEvent) event );
}
else
{
@@ -424,15 +207,15 @@
}
}

- private void processRegistryEvent( RegistryEvent event )
+ private void processContentRegistryEvent( ContentRegistryEvent event )
{
EventListener[] listeners = super.listeners();
for( int i=0; i<listeners.length; i++ )
{
EventListener listener = listeners[i];
- if( listener instanceof RegistryListener )
+ if( listener instanceof ContentRegistryListener )
{
- RegistryListener rl = (RegistryListener) listener;
+ ContentRegistryListener rl = (ContentRegistryListener)
listener;
if( event instanceof ContentAddedEvent )
{
try
@@ -442,7 +225,7 @@
catch( Throwable e )
{
final String error =
- "RegistryListener content addition notification
error.";
+ "ContentRegistryListener content addition
notification error.";
getLogger().error( error, e );
}
}
@@ -455,7 +238,7 @@
catch( Throwable e )
{
final String error =
- "RegistryListener content removed notification
error.";
+ "ContentRegistryListener content removed
notification error.";
getLogger().error( error, e );
}
}
@@ -463,34 +246,21 @@
}
}

- static class ContentAddedEvent extends RegistryEvent
+ static class ContentAddedEvent extends ContentRegistryEvent
{
- public ContentAddedEvent( RegistryModel source, ContentModel handler
)
+ public ContentAddedEvent( ContentRegistryModel source, ContentModel
handler )
{
super( source, handler );
}
}

- static class ContentRemovedEvent extends RegistryEvent
+ static class ContentRemovedEvent extends ContentRegistryEvent
{
- public ContentRemovedEvent( RegistryModel source, ContentModel
handler )
+ public ContentRemovedEvent( ContentRegistryModel source,
ContentModel handler )
{
super( source, handler );
}
}
-
- static class RegistryPluginChangeEvent extends PluginChangeEvent
- {
- /**
- * Creation of a new RegistryPluginChangeEvent.
- *
- * @param source the object initiating the event
- * @param plugin the plugin uri
- */
- public RegistryPluginChangeEvent( RegistryModel source, URI plugin )
- {
- super( source, plugin );
- }
- }
}

+

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultHostManager.java
(from r2688,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultHostManager.java
Sun Jun 5 00:41:19 2005
@@ -29,12 +29,9 @@
import java.net.URL;
import java.net.UnknownHostException;
import java.net.PasswordAuthentication;
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;

-import net.dpml.transit.model.HostAvailabilityEvent;
-import net.dpml.transit.model.HostEnabledEvent;
+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;
import net.dpml.transit.model.HostChangeEvent;
import net.dpml.transit.model.HostEvent;
import net.dpml.transit.model.HostLayoutEvent;
@@ -42,14 +39,15 @@
import net.dpml.transit.model.HostModel;
import net.dpml.transit.model.HostNameEvent;
import net.dpml.transit.model.HostPriorityEvent;
-import net.dpml.transit.model.HostTrustedEvent;
import net.dpml.transit.model.LayoutModel;
-import net.dpml.transit.model.LayoutRegistryModel;
import net.dpml.transit.model.Logger;
import net.dpml.transit.model.ModelException;
import net.dpml.transit.model.PluginModel;
import net.dpml.transit.model.PluginChangeEvent;

+import net.dpml.transit.management.HostManager;
+import net.dpml.transit.management.BootstrapException;
+
import net.dpml.transit.network.RequestIdentifier;


@@ -61,12 +59,10 @@
* and consildated under the HostModel implementation.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id: HostManager.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
*/
-public class HostManager extends PluginManager implements HostModel
+public class DefaultHostManager extends DefaultPluginManager implements
HostManager
{
private final String m_id;
- private final LayoutRegistryModel m_layoutRegistry;

private String m_name;
private URL m_base;
@@ -85,65 +81,43 @@
// constructor
//
------------------------------------------------------------------------

- public HostManager( Logger logger, Preferences prefs,
LayoutRegistryModel registry )
- throws UnknownHostException, IOException
+ public DefaultHostManager(
+ Logger logger, String id, LayoutModel layout )
{
- super( logger, prefs );
-
- m_layoutRegistry = registry;
- m_bootstrap = prefs.getBoolean( "bootstrap", false );
- m_id = prefs.name();
-
- m_name = prefs.get( "name", m_id );
- m_trusted = prefs.getBoolean( "trusted", m_trusted );
- m_enabled = prefs.getBoolean( "enabled", m_enabled );
- m_priority = prefs.getInt( "priority", m_priority );
- String layout = prefs.get( "layout", "classic" );
- m_layout = resolveLayoutModel( layout );
-
- try
- {
- m_base = resolveBase( prefs );
- m_index = resolveIndex( m_base, prefs );
- m_identifier = resolveRequestIdentifier( m_base, prefs );
- m_authentication = resolvePasswordAuthentication( prefs );
- }
- catch( Throwable e )
- {
- setError( e );
- }
- }
+ this(
+ logger, 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 )
+ {
+ super( logger, null );
+
+ m_id = id;
+ m_name = name;
+ m_trusted = trusted;
+ m_enabled = enabled;
+ m_priority = priority;
+ m_layout = layout;
+ m_base = base;
+ m_index = index;
+ m_authentication = auth;

- private void setError( Throwable e )
- {
- if( null == m_error )
+ m_identifier = getRequestIdentifier( base, scheme, prompt );
+ if( strategy instanceof Plugin )
{
- if( null != e )
- {
- // raise a non-available event
- m_error = e;
- HostAvailabilityEvent event = new HostAvailabilityEvent(
this, false );
- enqueueEvent( event );
- }
- else
- {
- // nothing changes
- }
+ Plugin plugin = (Plugin) strategy;
+ setPluginURI( plugin.getURI() );
+ m_bootstrap = false;
}
else
{
- if( null == e )
- {
- // raise a available event
- m_error = null;
- HostAvailabilityEvent event = new HostAvailabilityEvent(
this, true );
- enqueueEvent( event );
- }
- else
- {
- // update the error state
- m_error = e;
- }
+ Local local = (Local) strategy;
+ m_bootstrap = local.isBootstrap();
}
}

@@ -151,59 +125,73 @@
// HostManager
//----------------------------------------------------------------------

- public synchronized void update( URL base, URL index, boolean enabled,
boolean trusted, LayoutModel layout )
+ public void update(
+ URL base, URL index, boolean enabled, boolean trusted, LayoutModel
layout,
+ PasswordAuthentication auth, String scheme, String prompt )
{
- storeBaseURL( base );
- storeTrusted( trusted );
- storeLayoutModel( layout );
- storeEnabled( enabled );
- storeModified();
- }
-
- private void storeBaseURL( URL base )
- {
- Preferences prefs = getPreferences();
- if( null == base )
+ synchronized( m_lock )
{
- prefs.remove( "base" );
- }
- else
- {
- prefs.put( "base", base.toExternalForm() );
- }
- }
+ m_base = base;
+ m_index = index;
+ m_enabled = enabled;
+ m_trusted = trusted;
+ m_layout = layout;
+ m_authentication = auth;

- private void storeTrusted( boolean trusted )
- {
- Preferences prefs = getPreferences();
- prefs.putBoolean( "trusted", trusted );
- }
+ m_identifier = getRequestIdentifier( base, scheme, prompt );

- private void storeEnabled( boolean enabled )
- {
- Preferences prefs = getPreferences();
- prefs.putBoolean( "enabled", enabled );
+ HostChangeEvent e =
+ new HostChangeEvent(
+ this, base, index, m_identifier, auth, enabled, trusted );

+ enqueueEvent( e );
+ }
}

- private void storeLayoutModel( LayoutModel layout )
+ public void setName( String name )
{
- Preferences prefs = getPreferences();
- if( null == layout )
+ synchronized( m_lock )
{
- prefs.put( "layout", "classic" );
+ m_name = name;
+ HostNameEvent e = new HostNameEvent( this, m_name );
+ enqueueEvent( e );
}
- else
+ }
+
+ public void setPriority( int priority )
+ {
+ synchronized( m_lock )
{
- String id = layout.getID();
- prefs.put( "layout", id );
+ m_priority = priority;
+ HostPriorityEvent e = new HostPriorityEvent( this, m_priority );
+ enqueueEvent( e );
}
}

- private void storeModified()
+ /**
+ * If this is a bootstrap host then resolver ids must map to
+ * a resolver model that is based on a classname as opposed to
+ * plugin (because bootstrap hosts are repository indepedent)
+ */
+ public void setLayoutModel( LayoutModel layout ) throws
BootstrapException
{
- Preferences prefs = getPreferences();
- long timestamp = new Date().getTime();
- prefs.putLong( "modified", timestamp );
+ synchronized( m_lock )
+ {
+ if( isBootstrap() )
+ {
+ if( null != layout.getPluginURI() )
+ {
+ final String error =
+ "Illegal attempt to assign a plugin based layout to a
bootstrap host."
+ + "\nHost ID: " + getID()
+ + "\nLayout ID: " + layout.getID();
+ throw new BootstrapException( error );
+ }
+ }
+
+ m_layout = layout;
+ HostLayoutEvent e = new HostLayoutEvent( this, m_layout );
+ enqueueEvent( e );
+ }
}

//----------------------------------------------------------------------
@@ -258,16 +246,10 @@
*/
public int getPriority()
{
- return m_priority;
- }
-
- /**
- * Return the available status.
- * @return TRUE if available
- */
- public boolean getAvailable()
- {
- return ( null == m_error );
+ synchronized( m_lock )
+ {
+ return m_priority;
+ }
}

/**
@@ -276,7 +258,10 @@
*/
public String getHostName()
{
- return m_name;
+ synchronized( m_lock )
+ {
+ return m_name;
+ }
}

/**
@@ -285,7 +270,10 @@
*/
public URL getBaseURL()
{
- return m_base;
+ synchronized( m_lock )
+ {
+ return m_base;
+ }
}

/**
@@ -294,7 +282,10 @@
*/
public URL getIndexURL()
{
- return m_index;
+ synchronized( m_lock )
+ {
+ return m_index;
+ }
}

/**
@@ -303,7 +294,10 @@
*/
public boolean getEnabled()
{
- return m_enabled;
+ synchronized( m_lock )
+ {
+ return m_enabled;
+ }
}

/**
@@ -312,7 +306,10 @@
*/
public boolean getTrusted()
{
- return m_trusted;
+ synchronized( m_lock )
+ {
+ return m_trusted;
+ }
}

/**
@@ -321,7 +318,10 @@
*/
public PasswordAuthentication getAuthentication()
{
- return m_authentication;
+ synchronized( m_lock )
+ {
+ return m_authentication;
+ }
}

/**
@@ -330,7 +330,10 @@
*/
public RequestIdentifier getRequestIdentifier()
{
- return m_identifier;
+ synchronized( m_lock )
+ {
+ return m_identifier;
+ }
}

/**
@@ -339,7 +342,10 @@
*/
public LayoutModel getLayoutModel()
{
- return m_layout;
+ synchronized( m_lock )
+ {
+ return m_layout;
+ }
}

/**
@@ -360,259 +366,10 @@
super.removeListener( listener );
}

- //
------------------------------------------------------------------------
- // PreferenceChangeListener
- //
------------------------------------------------------------------------
-
- public void preferenceChange( PreferenceChangeEvent event )
- {
- String key = event.getKey();
- if( "enabled".equals( key ) )
- {
- boolean flag = event.getNode().getBoolean( "enabled", m_enabled
);
- if( m_enabled != flag )
- {
- m_enabled = flag;
- HostEnabledEvent e = new HostEnabledEvent( this, m_enabled );
- enqueueEvent( e );
- }
- }
- else if( "trusted".equals( key ) )
- {
- boolean flag = event.getNode().getBoolean( "trusted", m_trusted
);
- if( m_trusted != flag )
- {
- m_trusted = flag;
- HostTrustedEvent e = new HostTrustedEvent( this, m_trusted );
- enqueueEvent( e );
- }
- }
- else if( "priority".equals( key ) )
- {
- int priority = event.getNode().getInt( "priority", m_priority );
- if( m_priority != priority )
- {
- m_priority = priority;
- HostPriorityEvent e = new HostPriorityEvent( this,
m_priority );
- enqueueEvent( e );
- }
- }
- else if( "name".equals( key ) )
- {
- String name = event.getNode().get( "name", m_name );
- if( m_name != name )
- {
- m_name = name;
- HostNameEvent e = new HostNameEvent( this, m_name );
- enqueueEvent( e );
- }
- }
- else if( "layout".equals( key ) )
- {
- String id = event.getNewValue();
- try
- {
- m_layout = resolveLayoutModel( id );
- HostLayoutEvent e = new HostLayoutEvent( this, m_layout );
- enqueueEvent( e );
- }
- catch( ModelException e )
- {
- setError( e );
- final String error =
- "Host layout not set due to an unexpected error.";
- getLogger().error( error, e );
- return;
- }
- }
- else if( "modified".equals( key ) )
- {
- // This is a trigger marking modification to any of the
- // attributes "base", "index", "username", "password", "prompt"
- // or "scheme".
- //
- // If the value of the modified attribute is greater than zero
- // this signals that the preceeding attributes are in a state
- // ready for propergation into the model. If propergation
- // raises an error the modified attribute will be reset.
- //
-
-
- // If the value of the modified attribute is greater than zero
this
- // signals a valid set of information that we can use in a host
change
- // event. we notify a host controller of the change via
- // a single HostChangeEvent
-
- synchronized( this )
- {
- Preferences prefs = event.getNode();
- try
- {
- URL base = resolveBase( prefs );
- URL index = resolveIndex( base, prefs );
- RequestIdentifier identifier = resolveRequestIdentifier(
base, prefs );
- PasswordAuthentication authentication =
resolvePasswordAuthentication( prefs );
-
- m_base = base;
- m_index = index;
- m_identifier = identifier;
- m_authentication = authentication;
-
- HostChangeEvent e =
- new HostChangeEvent( this, base, index, identifier,
authentication );
- enqueueEvent( e );
- setError( null );
- }
- catch( UnknownHostException uhe )
- {
- setError( uhe );
- }
- catch( IOException ioe )
- {
- setError( ioe );
- }
- }
- }
- }
-
//----------------------------------------------------------------------
// internal
//----------------------------------------------------------------------

- /**
- * Set the host authentication.
- * @param auth the password authentication to use for host sign-on
- */
- public void setAuthentication( PasswordAuthentication auth ) throws
IOException
- {
- m_authentication = auth;
- Preferences prefs = getPreferences();
- if( null == auth )
- {
- prefs.putByteArray( "authentication", new byte[0] );
- }
- else
- {
- byte[] bytes = CredentialsHelper.exportCredentials(
m_authentication );
- prefs.putByteArray( "authentication", bytes );
- }
- }
-
- public LayoutModel resolveLayoutModel( String id ) throws ModelException
- {
- if( ( null != m_layout ) && m_layout.getID().equals( id ) )
- {
- return m_layout;
- }
- else
- {
- LayoutModel layout = m_layoutRegistry.getLayoutModel( id );
- if( null == layout )
- {
- final String error =
- "Unknown layout identifier: " + id
- + "\nHost ID: " + getID();
- throw new ModelException( error );
- }
-
- //
- // if this is a bootstrap host then resolver ids must map to
- // a resolver model that is based on a classname as opposed to
- // plugin (because bootstrap hosts are repository indepedent)
- //
-
- if( isBootstrap() )
- {
- if( null != layout.getPluginURI() )
- {
- final String error =
- "Illegal attempt to assign a plugin based layout to a
bootstrap host."
- + "\nHost ID: " + getID()
- + "\nLayout ID: " + id;
- throw new ModelException( error );
- }
- }
-
- return layout;
- }
- }
-
- private RequestIdentifier resolveRequestIdentifier( URL base,
Preferences prefs )
- {
- if( null == base )
- {
- throw new NullPointerException( "base" );
- }
- String scheme = prefs.get( "scheme", "" );
- String prompt = prefs.get( "prompt", "" );
- String protocol = base.getProtocol();
- String host = base.getHost();
- int port = base.getPort();
- if( port == 0 )
- {
- if( protocol.equals( "http" ) )
- {
- port = HTTP_PORT;
- }
- else if( protocol.equals( "ftp" ) )
- {
- port = FTP_PORT;
- }
- else if( protocol.equals( "https" ) )
- {
- port = HTTPS_PORT;
- }
- }
- return new RequestIdentifier( host, port, protocol, scheme, prompt );
- }
-
- private PasswordAuthentication resolvePasswordAuthentication(
Preferences prefs )
- {
- String username = prefs.get( "username", "" );
- String password = prefs.get( "password", "" );
- return new PasswordAuthentication( username, password.toCharArray()
);
- }
-
- private URL resolveBase( Preferences prefs ) throws
UnknownHostException, IOException
- {
- String baseSpec = prefs.get( "base", null );
- if( null == baseSpec )
- {
- final String error =
- "Undefined host base url"
- + "\nHost ID: " + prefs.name();
- throw new ModelException( error );
- }
-
- //
- // make sure the base path ends with a "/" otherwise relative url
references
- // will not be correct
- //
-
- if( false == baseSpec.endsWith( "/" ) )
- {
- baseSpec = baseSpec + "/";
- }
-
- return new URL( baseSpec );
- }
-
- private URL resolveIndex( URL base, Preferences prefs ) throws
IOException
- {
- if( null == base )
- {
- throw new NullPointerException( "base" );
- }
- String indexSpec = prefs.get( "index", null );
- if( null != indexSpec )
- {
- return new URL( base, indexSpec );
- }
- else
- {
- return null;
- }
- }

protected void processEvent( EventObject event )
{
@@ -620,10 +377,6 @@
{
super.processPluginChangeEvent( (PluginChangeEvent) event );
}
- else if( event instanceof HostAvailabilityEvent )
- {
- processHostAvailabilityEvent( (HostAvailabilityEvent) event );
- }
else if( event instanceof HostChangeEvent )
{
processHostChangeEvent( (HostChangeEvent) event );
@@ -632,18 +385,14 @@
{
processHostLayoutEvent( (HostLayoutEvent) event );
}
- else if( event instanceof HostEnabledEvent )
- {
- processHostEnabledEvent( (HostEnabledEvent) event );
- }
- else if( event instanceof HostTrustedEvent )
- {
- processHostTrustedEvent( (HostTrustedEvent) event );
- }
else if( event instanceof HostPriorityEvent )
{
processHostPriorityEvent( (HostPriorityEvent) event );
}
+ else if( event instanceof HostNameEvent )
+ {
+ processHostNameEvent( (HostNameEvent) event );
+ }
else
{
final String error =
@@ -653,45 +402,7 @@
}
}

- private void processHostEnabledEvent( HostEnabledEvent event )
- {
- HostListener[] listeners = getHostListeners();
- for( int i=0; i<listeners.length; i++ )
- {
- HostListener listener = listeners[i];
- try
- {
- listener.enabledStateChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "HostListener enabled status change notification error.";
- getLogger().warn( error, e );
- }
- }
- }
-
- private void processHostAvailabilityEvent( HostAvailabilityEvent event )
- {
- HostListener[] listeners = getHostListeners();
- for( int i=0; i<listeners.length; i++ )
- {
- HostListener listener = listeners[i];
- try
- {
- listener.availabilityChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "HostListener availability change notification error.";
- getLogger().warn( error, e );
- }
- }
- }
-
- private void processHostTrustedEvent( HostTrustedEvent event )
+ private void processHostLayoutEvent( HostLayoutEvent event )
{
HostListener[] listeners = getHostListeners();
for( int i=0; i<listeners.length; i++ )
@@ -699,18 +410,18 @@
HostListener listener = listeners[i];
try
{
- listener.trustedStateChanged( event );
+ listener.layoutChanged( event );
}
catch( Throwable e )
{
final String error =
- "HostListener trusted status change notification error.";
+ "HostListener resolver change notification error.";
getLogger().warn( error, e );
}
}
}

- private void processHostLayoutEvent( HostLayoutEvent event )
+ private void processHostPriorityEvent( HostPriorityEvent event )
{
HostListener[] listeners = getHostListeners();
for( int i=0; i<listeners.length; i++ )
@@ -718,18 +429,18 @@
HostListener listener = listeners[i];
try
{
- listener.layoutChanged( event );
+ listener.priorityChanged( event );
}
catch( Throwable e )
{
final String error =
- "HostListener resolver change notification error.";
+ "HostListener priority change notification error.";
getLogger().warn( error, e );
}
}
}

- private void processHostPriorityEvent( HostPriorityEvent event )
+ private void processHostNameEvent( HostNameEvent event )
{
HostListener[] listeners = getHostListeners();
for( int i=0; i<listeners.length; i++ )
@@ -737,12 +448,12 @@
HostListener listener = listeners[i];
try
{
- listener.priorityChanged( event );
+ listener.nameChanged( event );
}
catch( Throwable e )
{
final String error =
- "HostListener priority change notification error.";
+ "HostListener name change notification error.";
getLogger().warn( error, e );
}
}
@@ -787,55 +498,52 @@
// static (utils)
//
------------------------------------------------------------------------

- static class HostHostEnabledEvent extends HostEvent
+ private static RequestIdentifier getRequestIdentifier( URL base, String
scheme, String prompt )
{
- private boolean m_enabled;
-
- /**
- * Creation of a new HostHostEnabledEvent.
- *
- * @param source the object initiating the event
- * @param plugin the plugin uri
- */
- public HostHostEnabledEvent( HostModel source, boolean enabled )
+ if( null == base )
{
- super( source );
- m_enabled = enabled;
+ throw new NullPointerException( "base" );
}
-
- public boolean isEnabled()
+ if( null == scheme )
{
- return m_enabled;
+ throw new NullPointerException( "scheme" );
}
+ if( null == prompt )
+ {
+ throw new NullPointerException( "prompt" );
+ }
+ String protocol = base.getProtocol();
+ String host = base.getHost();
+ int port = base.getPort();
+ if( port == 0 )
+ {
+ if( protocol.equals( "http" ) )
+ {
+ port = HTTP_PORT;
+ }
+ else if( protocol.equals( "ftp" ) )
+ {
+ port = FTP_PORT;
+ }
+ else if( protocol.equals( "https" ) )
+ {
+ port = HTTPS_PORT;
+ }
+ }
+ return new RequestIdentifier( host, port, protocol, scheme, prompt );
}

- static class HostPluginChangeEvent extends PluginChangeEvent
+ private static URL getDefaultHostURL()
{
- /**
- * Creation of a new HostPluginChangeEvent.
- *
- * @param source the object initiating the event
- * @param plugin the plugin uri
- */
- public HostPluginChangeEvent( HostModel source, URI plugin )
+ try
+ {
+ return new URL( "http://localhost"; );
+ }
+ catch( Exception e )
{
- super( source, plugin );
+ return null;
}
}

- /**
- * HTTP port number.
- */
- private static final int HTTP_PORT = 80;
-
- /**
- * FTP port number.
- */
- private static final int FTP_PORT = 21;
-
- /**
- * HTTPS port number.
- */
- private static final int HTTPS_PORT = 443;
}


Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutManager.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/LayoutManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/LayoutManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutManager.java
Sun Jun 5 00:41:19 2005
@@ -18,11 +18,9 @@

package net.dpml.transit.manager;

+import java.net.URI;
import java.util.EventObject;
import java.util.EventListener;
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;

import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.PluginModel;
@@ -31,6 +29,11 @@
import net.dpml.transit.model.LayoutListener;
import net.dpml.transit.model.Logger;

+import net.dpml.transit.management.LayoutManager;
+import net.dpml.transit.manager.DefaultManager.Strategy;
+import net.dpml.transit.manager.DefaultManager.Plugin;
+import net.dpml.transit.manager.DefaultManager.Local;
+
/**
* Default implementation of a content manager that maintains an active
* configuration model of a pluggable content handler.
@@ -38,27 +41,62 @@
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id: HostManager.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
*/
-public class LayoutManager extends PluginManager implements LayoutModel
+public class DefaultLayoutManager extends DefaultPluginManager implements
LayoutManager
{
//----------------------------------------------------------------------
// state
//----------------------------------------------------------------------

private final String m_id;
+ private final String m_classname;
+ private final boolean m_bootstrap;
+
private String m_title;
- private String m_classname;

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

- public LayoutManager( Logger logger, Preferences prefs )
+ public DefaultLayoutManager(
+ final Logger logger, final String id )
{
- super( logger, prefs );
+ this( logger, id, new Local(
"net.dpml.transit.layout.ClassicLayout", false ), id );
+ }

- m_id = prefs.name();
- m_title = prefs.get( "title", m_id );
- m_classname = prefs.get( "classname", null );
+ public DefaultLayoutManager(
+ final Logger logger, final String id, Strategy strategy, final String
title )
+ {
+ super( logger, null );
+
+ m_id = id;
+ m_title = title;
+ if( strategy instanceof Plugin )
+ {
+ Plugin plugin = (Plugin) strategy;
+ setPluginURI( plugin.getURI() );
+ m_classname = null;
+ m_bootstrap = false;
+ }
+ else
+ {
+ Local local = (Local) strategy;
+ m_classname = local.getClassname();
+ m_bootstrap = local.isBootstrap();
+ }
+ }
+
+ //----------------------------------------------------------------------
+ // LayoutManager
+ //----------------------------------------------------------------------
+
+ public void setTitle( String title )
+ {
+ synchronized( m_lock )
+ {
+ m_title = title;
+ LayoutEvent event = new LayoutEvent( this );
+ super.enqueueEvent( event );
+ }
}

//----------------------------------------------------------------------
@@ -75,6 +113,16 @@
}

/**
+ * Return true if this is a bootstrap resolver.
+ *
+ * @return the bootstrap status of the resolver.
+ */
+ public boolean isBootstrap()
+ {
+ return m_bootstrap;
+ }
+
+ /**
* Return a possibly null classname. If the classname is not null the
* manager represents a bootstrap resolver.
*
@@ -91,7 +139,10 @@
*/
public String getTitle()
{
- return m_title;
+ synchronized( m_lock )
+ {
+ return m_title;
+ }
}

/**
@@ -113,48 +164,6 @@
}

//
------------------------------------------------------------------------
- // PreferencesChangeListener
- //
------------------------------------------------------------------------
-
- /**
- * Listen to changes in the preferences object that defines this
descriptor
- * and reflect the changes in the state of the descriptor class.
- *
- * @param event the preference change event
- */
- public void preferenceChange( PreferenceChangeEvent event )
- {
- if( null == m_classname )
- {
- super.preferenceChange( event );
- }
-
- String key = event.getKey();
- String value = event.getNewValue();
- Preferences prefs = event.getNode();
- if( "title".equals( key ) )
- {
- setTitle( value );
- }
- else if( "classname".equals( key ) )
- {
- setClassname( value );
- }
- else if( "uri".equals( key ) )
- {
- // already handled
- }
- else
- {
- final String warning =
- "A layout plugin preference node change event contains an
unrecognized key."
- + "\nPreference Node: " + prefs
- + "\nKey: " + key;
- getLogger().warn( warning );
- }
- }
-
- //
------------------------------------------------------------------------
// Object
//
------------------------------------------------------------------------

@@ -167,20 +176,6 @@
// internal
//
------------------------------------------------------------------------

- private void setTitle( String title )
- {
- m_title = title;
- LayoutEvent event = new LayoutEvent( this );
- super.enqueueEvent( event );
- }
-
- private void setClassname( String classname )
- {
- m_classname = classname;
- LayoutEvent event = new LayoutEvent( this );
- super.enqueueEvent( event );
- }
-
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutRegistryManager.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/LayoutRegistryManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/LayoutRegistryManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultLayoutRegistryManager.java
Sun Jun 5 00:41:19 2005
@@ -30,6 +30,8 @@
import java.util.prefs.BackingStoreException;
import java.net.URI;

+import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;
import net.dpml.transit.model.LayoutRegistryModel;
import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.PluginChangeEvent;
@@ -39,6 +41,10 @@
import net.dpml.transit.model.ModelException;
import net.dpml.transit.model.Logger;

+import net.dpml.transit.management.LayoutManager;
+import net.dpml.transit.management.LayoutRegistryManager;
+import net.dpml.transit.management.ModelReferenceException;
+
/**
* Default implementation of a layout subsystem that maitains
* information about the set of registred location resolver configurations.
@@ -46,8 +52,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 LayoutRegistryManager extends PluginManager
- implements LayoutRegistryModel, NodeChangeListener, PluginListener
+public class DefaultLayoutRegistryManager extends DefaultPluginManager
+ implements LayoutRegistryManager
{
//
------------------------------------------------------------------------
// state
@@ -59,207 +65,24 @@
// constructor
//
------------------------------------------------------------------------

- public LayoutRegistryManager( Logger logger, Preferences prefs ) throws
ModelException
+ public DefaultLayoutRegistryManager( Logger logger, URI uri,
LayoutManager[] managers )
+ throws DuplicateKeyException
{
- super( logger, prefs );
-
- //
- // construct the location resolver configurations
- //
-
- try
- {
- String[] names = prefs.childrenNames();
- for( int i=0; i<names.length; i++ )
- {
- String name = names[i];
- Preferences p = prefs.node( name );
- addLayoutModel( p, false );
- }
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected exception while reading resolver preferences."
- + "\nPreferences: " + prefs;
- throw new ModelException( error, e );
- }
-
- //
- // add a listener to the preferences
- //
-
- prefs.addNodeChangeListener( this );
- }
-
- //
------------------------------------------------------------------------
- // LayoutRegistryManager
- //
------------------------------------------------------------------------
-
- /**
- * Return an array of content managers currently assigned to the registry.
- * @return the content manager array
- */
- public LayoutManager[] getLayoutManagers()
- {
- return (LayoutManager[]) m_list.toArray( new LayoutManager[0] );
- }
-
- public LayoutManager getLayoutManager( String id )
- {
- if( null == id )
- {
- return null;
- }
- LayoutManager[] managers = getLayoutManagers();
+ super( logger, uri );
for( int i=0; i<managers.length; i++ )
{
LayoutManager manager = managers[i];
- if( id.equals( manager.getID() ) )
- {
- return manager;
- }
+ addLayoutManager( manager );
}
- return null;
}

- public void removeLayoutModel( String id ) throws ModelException
- {
- if( null == id )
- {
- return;
- }
- try
- {
- if( getPreferences().nodeExists( id ) )
- {
- LayoutManager manager = getLayoutManager( id );
- Object[] listeners = manager.listeners();
- ArrayList consumers = new ArrayList();
- for( int i=0; i<listeners.length; i++ )
- {
- Object listener = listeners[i];
- if( listener != this )
- {
- consumers.add( listener );
- }
- }
- int n = consumers.size();
- if( n == 0 )
- {
- Preferences prefs = getPreferences().node( id );
- prefs.removeNode();
- }
- else
- {
- // we have one or more consumer references
-
- final String message =
- "Cannot remove a layout due to "
- + n
- + " active consumers.";
- StringBuffer buffer = new StringBuffer( message );
- Object[] objects = consumers.toArray();
- for( int i=0; i<objects.length; i++ )
- {
- buffer.append( "\nReference: " + objects[i] );
- }
- String error = buffer.toString();
- throw new ModelException( error );
- }
- }
- }
- catch( BackingStoreException e )
- {
- final String error =
- "Preferences backing store access error during resolver model
removal."
- + "\nPreferences: " + getPreferences()
- + "\nResolver ID: " + id;
- throw new ModelException( error );
- }
- }
-
- /**
- * Dispose of the manager.
- */
- public void dispose()
- {
- super.dispose();
- try
- {
- getPreferences().removeNodeChangeListener( this );
- }
- catch( Throwable e )
- {
- // ignore
- }
- LayoutModel[] models = getLayoutModels();
- for( int i=0; i<models.length; i++ )
- {
- LayoutModel model = models[i];
- try
- {
- model.removePluginListener( this );
- }
- catch( Throwable e )
- {
- // ignore
- }
- }
- }
-
- public void newLayoutModel( String id )
- {
- getPreferences().node( id );
- }
-
-
//
------------------------------------------------------------------------
- // LayoutRegistryManager
+ // LayoutRegistryModel
//
------------------------------------------------------------------------

- /**
- * Register a new content model.
- *
- * @return the content model
- */
- public LayoutModel addLayoutModel( String id, String title, URI uri )
- {
- if( null == id )
- {
- throw new NullPointerException( "id" );
- }
- if( null == title )
- {
- throw new NullPointerException( "title" );
- }
- if( null == uri )
- {
- throw new NullPointerException( "uri" );
- }
-
- Preferences prefs = getPreferences().node( id );
- prefs.put( "title", title );
- prefs.put( "uri", uri.toString() );
- return addLayoutModel( prefs, true );
- }
-
- public LayoutModel getLayoutModel( String id )
+ public LayoutModel getLayoutModel( String id ) throws UnknownKeyException
{
- if( null == id )
- {
- return null;
- }
- LayoutModel[] models = getLayoutModels();
- for( int i=0; i<models.length; i++ )
- {
- LayoutModel model = models[i];
- if( id.equals( model.getID() ) )
- {
- return model;
- }
- }
- return null;
+ return getLayoutManager( id );
}

/**
@@ -268,7 +91,7 @@
*/
public LayoutModel[] getLayoutModels()
{
- return (LayoutModel[]) m_list.toArray( new LayoutModel[0] );
+ return getLayoutManagers();
}

/**
@@ -290,82 +113,90 @@
}

//
------------------------------------------------------------------------
- // PluginListener (listens to changes to plugin uris)
+ // LayoutRegistryManager
//
------------------------------------------------------------------------

- public void pluginChanged( PluginChangeEvent event )
+ public void addLayoutManager( String id ) throws DuplicateKeyException
{
- getLogger().info( "plugin changed: " + event.getPluginURI() );
+ Logger logger = getLogger();
+ DefaultLayoutManager m = new DefaultLayoutManager( logger, id );
+ addLayoutManager( m );
}

- //
------------------------------------------------------------------------
- // NodeChangeListener (listens to content prefs node addition and
removal)
- //
------------------------------------------------------------------------
+ public void addLayoutManager( LayoutManager manager ) throws
DuplicateKeyException
+ {
+ synchronized( m_lock )
+ {
+ String id = manager.getID();
+ try
+ {
+ LayoutManager m = getLayoutManager( id );
+ throw new DuplicateKeyException( id );
+ }
+ catch( UnknownKeyException e )
+ {
+ m_list.add( manager );
+ LayoutAddedEvent event = new LayoutAddedEvent( this,
manager );
+ enqueueEvent( event );
+ }
+ }
+ }

/**
- * Handle the addition of a content handler configuration following a
- * preferences node change.
- *
- * @param event the node addition event
+ * Return an array of content managers currently assigned to the registry.
+ * @return the content manager array
*/
- public void childAdded( NodeChangeEvent event )
+ public LayoutManager[] getLayoutManagers()
{
- Preferences prefs = event.getChild();
- addLayoutModel( prefs, true );
+ synchronized( m_lock )
+ {
+ return (LayoutManager[]) m_list.toArray( new LayoutManager[0] );
+ }
}

- public void childRemoved( NodeChangeEvent event )
+ public LayoutManager getLayoutManager( String id ) throws
UnknownKeyException
{
- Preferences prefs = event.getChild();
- synchronized( m_list )
+ synchronized( m_lock )
{
- String id = prefs.name();
- LayoutManager manager = getLayoutManager( id );
- if( null != manager )
+ if( null == id )
+ {
+ throw new NullPointerException( "id" );
+ }
+ LayoutManager[] managers = getLayoutManagers();
+ for( int i=0; i<managers.length; i++ )
{
- m_list.remove( manager );
- manager.removePluginListener( this );
- manager.dispose();
- LayoutRemovedEvent e = new LayoutRemovedEvent( this, manager
);
- super.enqueueEvent( e );
+ LayoutManager manager = managers[i];
+ if( id.equals( manager.getID() ) )
+ {
+ return manager;
+ }
}
+ throw new UnknownKeyException( id );
}
}

- //
------------------------------------------------------------------------
- // internal
- //
------------------------------------------------------------------------
-
- private LayoutModel addLayoutModel( Preferences prefs, boolean notify )
+ public void removeLayoutManager( LayoutManager manager ) throws
ModelReferenceException
{
- Logger logger = getLogger();
- LayoutModel model = new LayoutManager( logger, prefs );
- String type = model.getID();
- synchronized( m_list )
- {
- Iterator iterator = m_list.iterator();
- while( iterator.hasNext() )
+ synchronized( m_lock )
+ {
+ Object[] listeners = manager.getListeners();
+ if( listeners.length == 0 )
{
- LayoutModel d = (LayoutModel) iterator.next();
- if( type.equals( d.getID() ) )
- {
- final String error =
- "Resolver type already registered."
- + "\nType: " + type;
- throw new IllegalArgumentException( error );
- }
+ m_list.remove( manager );
+ LayoutRemovedEvent event = new LayoutRemovedEvent( this,
manager );
+ enqueueEvent( event );
}
- m_list.add( model );
- model.addPluginListener( this );
- if( notify )
+ else
{
- LayoutAddedEvent event = new LayoutAddedEvent( this, model );
- super.enqueueEvent( event );
+ throw new ModelReferenceException( manager, listeners );
}
- return model;
}
}

+ //
------------------------------------------------------------------------
+ // impl
+ //
------------------------------------------------------------------------
+
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )
@@ -439,20 +270,6 @@
super( source, handler );
}
}
-
- static class LayoutPluginChangeEvent extends PluginChangeEvent
- {
- /**
- * Creation of a new LayoutPluginChangeEvent.
- *
- * @param source the object initiating the event
- * @param plugin the plugin uri
- */
- public LayoutPluginChangeEvent( LayoutRegistryModel source, URI
plugin )
- {
- super( source, plugin );
- }
- }
}



Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultManager.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/EventProducer.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/EventProducer.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultManager.java
Sun Jun 5 00:41:19 2005
@@ -18,6 +18,7 @@

package net.dpml.transit.manager;

+import java.net.URI;
import java.util.EventObject;
import java.util.EventListener;
import java.util.List;
@@ -26,14 +27,25 @@
import java.util.WeakHashMap;

import net.dpml.transit.util.ExceptionHelper;
+import net.dpml.transit.model.Logger;
+import net.dpml.transit.model.Model;


/**
* 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 EventProducer
+public abstract class DefaultManager implements Model
{
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ /**
+ * Internal logging channel.
+ */
+ private final Logger m_logger;
+
private Map m_listeners = new WeakHashMap();

/**
@@ -41,6 +53,38 @@
*/
protected final Object m_lock = new Object();

+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ public DefaultManager( Logger logger )
+ throws NullPointerException
+ {
+ if( null == logger )
+ {
+ throw new NullPointerException( "logger" );
+ }
+ m_logger = logger;
+ }
+
+ //
------------------------------------------------------------------------
+ // Model
+ //
------------------------------------------------------------------------
+
+ public Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ //
------------------------------------------------------------------------
+ // DefaultManager
+ //
------------------------------------------------------------------------
+
+ 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
@@ -135,9 +179,9 @@
}

Object source = event.getSource();
- if( source instanceof EventProducer )
+ if( source instanceof DefaultManager )
{
- EventProducer producer = (EventProducer) source;
+ DefaultManager producer = (DefaultManager) source;
try
{
producer.processEvent( event );
@@ -155,7 +199,7 @@
else
{
final String error =
- "Event source is not an instance of " +
EventProducer.class.getName();
+ "Event source is not an instance of " +
DefaultManager.class.getName();
throw new IllegalStateException( error );
}
}
@@ -226,4 +270,46 @@
}
}
}
+
+ public abstract static class Strategy
+ {
+ }
+
+ public static class Local extends Strategy
+ {
+ private String m_classname;
+ private boolean m_bootstrap;
+
+ public Local( String classname, boolean bootstrap )
+ {
+ m_classname = classname;
+ m_bootstrap = bootstrap;
+ }
+
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ public boolean isBootstrap()
+ {
+ return m_bootstrap;
+ }
+ }
+
+ public static class Plugin extends Strategy
+ {
+ private URI m_uri;
+
+ public Plugin( URI uri )
+ {
+ m_uri = uri;
+ }
+
+ public URI getURI()
+ {
+ return m_uri;
+ }
+ }
+
}

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultPluginManager.java
(from r2688,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultPluginManager.java
Sun Jun 5 00:41:19 2005
@@ -30,6 +30,8 @@
import net.dpml.transit.model.PluginListener;
import net.dpml.transit.model.Logger;

+import net.dpml.transit.management.PluginManager;
+
/**
* An abstract plugin manager is an implementation that monitors
configuration changes
* to a preferences node containg a uri attribute. Modifications to the uri
attribute
@@ -39,38 +41,22 @@
* @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 abstract class PluginManager extends EventProducer implements
PluginModel, PreferenceChangeListener
+public abstract class DefaultPluginManager extends DefaultManager implements
PluginManager
{
- private final Preferences m_preferences;
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------

private URI m_uri;
- private Logger m_logger;
- private boolean m_disposed = false;

- public PluginManager( Logger logger, Preferences prefs )
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ public DefaultPluginManager( Logger logger, URI uri )
{
- if( null == logger )
- {
- throw new NullPointerException( "logger" );
- }
- if( null == prefs )
- {
- throw new NullPointerException( "prefs" );
- }
- m_logger = logger;
- m_preferences = prefs;
- prefs.addPreferenceChangeListener( this );
- try
- {
- m_uri = getPluginURI( prefs );
- }
- catch( IllegalArgumentException e )
- {
- m_uri = null;
- final String message =
- "Setting plugin uri to a null value.";
- m_logger.error( message, e );
- }
+ super( logger );
+ m_uri = uri;
}

//
------------------------------------------------------------------------
@@ -86,22 +72,11 @@
synchronized( m_lock )
{
m_uri = uri;
- if( null != uri )
- {
- m_preferences.put( "uri", uri.toString() );
- }
- else
- {
- m_preferences.remove( "uri" );
- }
+ PluginChangeEvent e = new PluginChangeEvent( this, m_uri );
+ super.enqueueEvent( e );
}
}

- public Logger getLogger()
- {
- return m_logger;
- }
-
//
------------------------------------------------------------------------
// PluginModel
//
------------------------------------------------------------------------
@@ -137,58 +112,9 @@
}

//
------------------------------------------------------------------------
- // PreferencesChangeListener (listens to changes to the uri attribute)
- //
------------------------------------------------------------------------
-
- public void preferenceChange( PreferenceChangeEvent event )
- {
- String key = event.getKey();
- String value = event.getNewValue();
- Preferences prefs = event.getNode();
- if( "uri".equals( key ) )
- {
- synchronized( m_lock )
- {
- m_uri = getPluginURI( prefs );
- PluginChangeEvent e = new PluginChangeEvent( this, m_uri );
- super.enqueueEvent( e );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // disposal
- //
------------------------------------------------------------------------
-
- /**
- * Dispose of the manager.
- */
- public void dispose()
- {
- getLogger().debug( "initiating disposal" );
- try
- {
- getPreferences().removePreferenceChangeListener( this );
- }
- catch( Throwable e )
- {
- // ignore
- }
- finally
- {
- m_disposed = true;
- }
- }
-
- //
------------------------------------------------------------------------
// internals
//
------------------------------------------------------------------------

- protected Preferences getPreferences()
- {
- return m_preferences;
- }
-
protected void processPluginChangeEvent( PluginChangeEvent event )
{
EventListener[] listeners = super.listeners();
@@ -206,40 +132,10 @@
{
final String error =
"PluginListener notification error.";
- m_logger.error( error, e );
+ getLogger().error( error, e );
}
}
}
}
-
- public void finalize()
- {
- dispose();
- }
-
- private static URI getPluginURI( Preferences prefs ) throws
IllegalArgumentException
- {
- String path = prefs.get( "uri", null );
- try
- {
- if( null == path )
- {
- return null;
- }
- else
- {
- return new URI( path );
- }
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to construct a plugin uri."
- + "\nPreferences: " + prefs
- + "\nURI Specification: " + path;
- throw new IllegalArgumentException( error );
- }
- }
-
}


Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultProxyManager.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/ProxyManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/ProxyManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultProxyManager.java
Sun Jun 5 00:41:19 2005
@@ -27,15 +27,16 @@
import java.util.EventObject;
import java.util.EventListener;
import java.net.PasswordAuthentication;
+import java.net.URL;

import net.dpml.transit.model.ProxyModel;
import net.dpml.transit.model.ProxyListener;
import net.dpml.transit.model.ProxyEvent;
-import net.dpml.transit.model.ProxyExcludesEvent;
-import net.dpml.transit.model.ProxyChangeEvent;
import net.dpml.transit.model.ModelException;
import net.dpml.transit.model.Logger;

+import net.dpml.transit.management.ProxyManager;
+
import net.dpml.transit.network.RequestIdentifier;

/**
@@ -45,124 +46,82 @@
* @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 ProxyManager extends EventProducer implements ProxyModel
+public class DefaultProxyManager extends DefaultManager implements
ProxyManager
{
//
------------------------------------------------------------------------
// state
//
------------------------------------------------------------------------

- private final ModificationHandler m_modificationHandler = new
ModificationHandler();
- private final ExcludesHandler m_excludesHandler = new ExcludesHandler();
-
- private final Preferences m_preferences;
- private final Preferences m_excludesPreferences;
- private final Logger m_logger;
-
+ private URL m_host;
private PasswordAuthentication m_authentication;
- private RequestIdentifier m_identifier;
private String[] m_excludes;
- private String m_excludesString;

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

- public ProxyManager( Logger logger, Preferences prefs )
+ public DefaultProxyManager(
+ Logger logger, URL host, PasswordAuthentication auth, String[]
excludes )
throws NullPointerException
{
- if( null == prefs )
- {
- throw new NullPointerException( "prefs" );
- }
- if( null == logger )
- {
- throw new NullPointerException( "logger" );
- }
-
- m_logger = logger;
- m_preferences = prefs;
- m_excludesPreferences = prefs.node( "excludes" );
-
- //
- // setup the proxy settings
- //
-
- m_preferences.addPreferenceChangeListener( m_modificationHandler );
- m_excludesPreferences.addPreferenceChangeListener( m_excludesHandler
);
- setupProxyConfiguration( prefs, false );
+ super( logger );
+ m_host = host;
+ m_authentication = auth;
+ m_excludes = excludes;
}

//
------------------------------------------------------------------------
// ProxyManager
//
------------------------------------------------------------------------

- public Logger getLogger()
+ public void update( URL host, PasswordAuthentication auth, String[]
excludes )
{
- return m_logger;
- }
-
- public void setProxyHost( String host )
- {
- Preferences prefs = getPreferences();
- if( null == host )
+ synchronized( m_lock )
{
- prefs.remove( "host" );
- prefs.remove( "scheme" );
- prefs.remove( "prompt" );
- }
- else
- {
- prefs.put( "host", host );
- prefs.put( "scheme", "" );
- prefs.put( "prompt", "" );
+ m_host = host;
+ m_authentication = auth;
+ m_excludes = excludes;
+ RequestIdentifier request = getRequestIdentifier( m_host );
+ ProxyEvent event =
+ new ProxyEvent( this, request, m_authentication, m_excludes );
+ super.enqueueEvent( event );
}
}

- /**
- * Set the proxy authentication.
- * @param auth the password authentication to use for proxy sign-on
- */
- public void setProxyAuthentication( PasswordAuthentication auth ) throws
IOException
+ public void setHost( URL host )
{
- m_authentication = auth;
- Preferences prefs = getPreferences();
- if( null == auth )
+ synchronized( m_lock )
{
- prefs.putByteArray( "authentication", new byte[0] );
- }
- else
- {
- byte[] bytes = CredentialsHelper.exportCredentials(
m_authentication );
- prefs.putByteArray( "authentication", bytes );
+ m_host = host;
+ RequestIdentifier request = getRequestIdentifier( m_host );
+ ProxyEvent event =
+ new ProxyEvent( this, request, m_authentication, m_excludes );
+ super.enqueueEvent( event );
}
}

- public void addExclude( String key )
- {
- Preferences excludes = getExcludesPreferences();
- excludes.put( key, "" );
- }
-
- public void removeExclude( String key )
- {
- Preferences excludes = getExcludesPreferences();
- excludes.remove( key );
- }
-
- public void changeExclude( String key, String value )
+ public void setExcludes( String[] excludes )
{
- Preferences excludes = getExcludesPreferences();
- excludes.remove( key );
- excludes.put( value, "" );
+ synchronized( m_lock )
+ {
+ m_excludes = excludes;
+ RequestIdentifier request = getRequestIdentifier( m_host );
+ ProxyEvent event =
+ new ProxyEvent( this, request, m_authentication, m_excludes );
+ super.enqueueEvent( event );
+ }
}

- /**
- * Dispose of the manager.
- */
- public void dispose()
+ public void setAuthentication( PasswordAuthentication auth )
{
- getExcludesPreferences().removePreferenceChangeListener(
m_excludesHandler );
- getPreferences().removePreferenceChangeListener(
m_modificationHandler );
+ synchronized( m_lock )
+ {
+ m_authentication = auth;
+ RequestIdentifier request = getRequestIdentifier( m_host );
+ ProxyEvent event =
+ new ProxyEvent( this, request, m_authentication, m_excludes );
+ super.enqueueEvent( event );
+ }
}

//
------------------------------------------------------------------------
@@ -170,40 +129,19 @@
//
------------------------------------------------------------------------

/**
- * Returns TRUE if a proxy configuration is enabled.
- * @return the proxy configuration enabled status
- */
- public boolean isProxyEnabled()
- {
- return ( null != m_preferences.get( "host", null ) );
- }
-
- /**
- * Return the proxy host name. If not defined the implementation returns a
- * zero length string.
- * @return the proxy host name
+ * Return the proxy host name.
+ * @return the proxy host (possibly null)
*/
- public String getProxyHost()
+ public URL getHost()
{
- Preferences prefs = getPreferences();
- return prefs.get( "host", "" );
- }
-
- /**
- * Return the proxy port.
- * @return the proxy port
- */
- public int getProxyPort()
- {
- Preferences prefs = getPreferences();
- return prefs.getInt( "port", 0 );
+ return m_host;
}

/**
* Return the proxy authentication or null if not defined.
* @return the proxy authentication credentials
*/
- public PasswordAuthentication getProxyAuthentication()
+ public PasswordAuthentication getAuthentication()
{
return m_authentication;
}
@@ -212,9 +150,9 @@
* Return the proxy host request identifier.
* @return the request identifier for the proxy host or null if not
defined.
*/
- public RequestIdentifier getProxyRequestIdentifier()
+ public RequestIdentifier getRequestIdentifier()
{
- return m_identifier;
+ return getRequestIdentifier( m_host );
}

/**
@@ -227,15 +165,6 @@
}

/**
- * Return the String identifying the non-proxy hosts.
- * @return the non-proxied hosts value (possibly null)
- */
- public String getProxyExcludes()
- {
- return m_excludesString;
- }
-
- /**
* Add a proxy listener to the model.
* @param listener the listener to add
*/
@@ -257,54 +186,6 @@
// internal
//
------------------------------------------------------------------------

- private void setupProxyConfiguration( Preferences prefs, boolean notify )
- {
- m_excludes = getProxyExcludesFromPrefs();
- try
- {
- m_authentication = resolveProxyPasswordAuthentication( prefs );
- }
- catch( IOException e )
- {
- final String error =
- "Unexpected error while resolving proxy credentials.";
- getLogger().error( error, e );
- m_authentication = null;
- }
-
- if( null != prefs.get( "host", null ) )
- {
- try
- {
- RequestIdentifier identifier = resolveRequestIdentifier(
prefs );
- String excludes = resolveProxyExcludes( m_excludes );
- synchronized( this )
- {
- m_identifier = identifier;
- m_excludesString = excludes;
- }
- }
- catch( Throwable e )
- {
- final String error =
- "Proxy configuration setup error.";
- m_logger.error( error, e );
- }
- }
- else
- {
- m_identifier = null;
- m_excludesString = null;
- }
- if( notify )
- {
- boolean enabled = isProxyEnabled();
- ProxyChangeEvent event =
- new ProxyChangeEvent( this, enabled, m_identifier,
m_authentication, m_excludesString );
- super.enqueueEvent( event );
- }
- }
-
protected void processEvent( EventObject eventObject )
{
EventListener[] listeners = super.listeners();
@@ -314,186 +195,43 @@
if( listener instanceof ProxyListener )
{
ProxyListener pl = (ProxyListener) listener;
- if( eventObject instanceof ProxyChangeEvent )
- {
- ProxyChangeEvent event = (ProxyChangeEvent) eventObject;
- try
- {
- pl.proxySettingsChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "PluginListener notification error.";
- m_logger.error( error, e );
- }
- }
- else if( eventObject instanceof ProxyExcludesEvent )
+ if( eventObject instanceof ProxyEvent )
{
- ProxyExcludesEvent event = (ProxyExcludesEvent)
eventObject;
+ ProxyEvent event = (ProxyEvent) eventObject;
try
{
- pl.proxyExcludesChanged( event );
+ pl.proxyChanged( event );
}
catch( Throwable e )
{
final String error =
- "PluginListener excludes notification error.";
- m_logger.error( error, e );
+ "Proxy listener notification error.";
+ getLogger().error( error, e );
}
}
}
}
}

- public void finalize()
- {
- dispose();
- }
-
- private PasswordAuthentication resolveProxyPasswordAuthentication(
Preferences prefs )
- throws IOException
- {
- byte[] bytes = prefs.getByteArray( "authentication", new byte[0] );
- if( bytes.length == 0 )
- {
- return null;
- }
- else
- {
- return CredentialsHelper.importCredentials( bytes );
- }
- }
-
- /**
- * Resolve the list of host names to be assigned as non-proxied hosts. If
proxy
- * excludes are defined the string returned contains the host name
(wilcards allowed)
- * separated by the "|" character. If no proxy excludes are defined the
value returned
- * shall be null. The implementation reads the set of attribute names
associated
- * with a preferences node named "excludes". Each attribute name is
appended to
- * a single string where names are separated by the "|" character.
- *
- * @param prefs the 'proxy' prefs node containing a child node named
'excludes'
- * @return a string containing a sequence of excluded hosts (possibly
null)
- */
- private String resolveProxyExcludes( String[] names )
- {
- String spec = null;
- for( int i=0; i<names.length; i++ )
- {
- String name = names[i];
- if( null == spec )
- {
- spec = name;
- }
- else
- {
- spec = spec + "|" + name;
- }
- }
- return spec;
- }
-
- private String[] getProxyExcludesFromPrefs()
- {
- Preferences prefs = getExcludesPreferences();
- try
- {
- return prefs.keys();
- }
- catch( BackingStoreException e )
- {
- final String error =
- "Ignoring possible proxy exclude settings due to a
preferences backing store error."
- + "\nPreferences: " + prefs;
- getLogger().error( error, e );
- return new String[0];
- }
- }
+ private static final PasswordAuthentication NULL_AUTHENTICATION =
+ new PasswordAuthentication( "", new char[0] );

- private RequestIdentifier resolveRequestIdentifier( Preferences prefs )
+ private static RequestIdentifier getRequestIdentifier( URL url )
{
- String host = prefs.get( "host", null );
- if( null == host )
+ if( null == url )
{
return null;
}
else
{
- String protocol = prefs.get( "protocol", "http" );
- String scheme = prefs.get( "scheme", null );
- if( scheme == null )
- {
- final String error =
- "Proxy configuration does not declare a scheme."
- + "\nPreferences: " + prefs;
- throw new IllegalArgumentException( error );
- }
- String prompt = prefs.get( "prompt", null );
- if( prompt == null )
- {
- final String error =
- "Proxy configuration does not declare a prompt."
- + "\nPreferences: " + prefs;
- throw new IllegalArgumentException( error );
- }
- int port = prefs.getInt( "port", 0 );
+ String protocol = url.getProtocol();
+ String scheme = "";
+ String prompt = "";
+ int port = url.getPort();
+ String host = url.getHost();
return new RequestIdentifier( host, port, protocol, scheme,
prompt );
}
}

- private Preferences getExcludesPreferences()
- {
- return m_excludesPreferences;
- }
-
- private Preferences getPreferences()
- {
- return m_preferences;
- }
-
- private class ModificationHandler implements PreferenceChangeListener
- {
- public void preferenceChange( PreferenceChangeEvent prefsEvent )
- {
- String key = prefsEvent.getKey();
- String value = prefsEvent.getNewValue();
- Preferences prefs = prefsEvent.getNode();
- if( "modified".equals( key ) )
- {
- setupProxyConfiguration( prefs, true );
- }
- }
- }
-
- private class ExcludesHandler implements PreferenceChangeListener
- {
- public void preferenceChange( PreferenceChangeEvent event )
- {
- String key = event.getKey();
- Preferences prefs = event.getNode();
- try
- {
- String[] keys = prefs.keys();
- setExcludes( keys );
- }
- catch( BackingStoreException e )
- {
- final String error =
- "Proxy excludes access error.";
- m_logger.error( error, e );
- }
- }
- }
-
- private void setExcludes( String[] excludes )
- {
- m_excludes = excludes;
- ProxyExcludesEvent event = new ProxyExcludesEvent( this, m_excludes
);
- enqueueEvent( event );
- }
-
- private static final PasswordAuthentication NULL_AUTHENTICATION =
- new PasswordAuthentication( "", new char[0] );

}

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultRepositoryManager.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RepositoryManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RepositoryManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultRepositoryManager.java
Sun Jun 5 00:41:19 2005
@@ -18,13 +18,10 @@

package net.dpml.transit.manager;

-import java.util.EventObject;
-import java.util.EventListener;
-import java.util.prefs.Preferences;
import java.net.URI;
+import java.util.EventObject;

-import net.dpml.transit.model.RepositoryModel;
-import net.dpml.transit.model.PluginModel;
+import net.dpml.transit.management.RepositoryManager;
import net.dpml.transit.model.PluginChangeEvent;
import net.dpml.transit.model.Logger;

@@ -32,13 +29,12 @@
* Default implementation of a pluggable repository manager.
*
* @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 RepositoryManager extends PluginManager implements
RepositoryModel
+public class DefaultRepositoryManager extends DefaultPluginManager
implements RepositoryManager
{
- public RepositoryManager( Logger logger, Preferences prefs )
+ public DefaultRepositoryManager( Logger logger, URI uri )
{
- super( logger, prefs );
+ super( logger, uri );
}

public void processEvent( EventObject event )
@@ -55,20 +51,5 @@
throw new IllegalArgumentException( error );
}
}
-
- static class RepositoryPluginChangeEvent extends PluginChangeEvent
- {
- /**
- * Creation of a new RepositoryPluginChangeEvent.
- *
- * @param source the object initiating the event
- * @param plugin the plugin uri
- */
- public RepositoryPluginChangeEvent( RepositoryModel source, URI
plugin )
- {
- super( source, plugin );
- }
- }
-
}


Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultTransitManager.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/manager/TransitManager.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/TransitManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/DefaultTransitManager.java
Sun Jun 5 00:41:19 2005
@@ -18,90 +18,77 @@

package net.dpml.transit.manager;

-import java.io.File;
-import java.util.prefs.Preferences;
-import java.net.URL;
+import java.util.EventObject;

+import net.dpml.transit.model.Logger;
import net.dpml.transit.model.TransitModel;
import net.dpml.transit.model.CacheModel;
-import net.dpml.transit.model.RegistryModel;
+import net.dpml.transit.model.ContentRegistryModel;
import net.dpml.transit.model.RepositoryModel;
import net.dpml.transit.model.ProxyModel;
import net.dpml.transit.model.LayoutRegistryModel;
-import net.dpml.transit.model.ModelException;
-import net.dpml.transit.model.Logger;

-import net.dpml.transit.TransitException;
+import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.management.CacheManager;
+import net.dpml.transit.management.ContentRegistryManager;
+import net.dpml.transit.management.RepositoryManager;
+import net.dpml.transit.management.ProxyManager;
+import net.dpml.transit.management.LayoutRegistryManager;

/**
- * The TransitManager class maintains an active configuration of the
- * Transit system based on a supplied preferences node.
+ * The DefaultTransitManager class maintains an active configuration of the
+ * Transit system.
*
* @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 TransitManager implements TransitModel
+public class DefaultTransitManager extends DefaultManager implements
TransitManager
{
//
------------------------------------------------------------------------
// state
//
------------------------------------------------------------------------

private final CacheManager m_cache;
- private final RegistryManager m_registry;
+ private final ContentRegistryManager m_registry;
private final RepositoryManager m_repository;
private final ProxyManager m_proxy;
private final LayoutRegistryManager m_layout;
- private final Logger m_logger;

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

- public TransitManager( Logger logger, Preferences prefs )
- throws NullPointerException, TransitException
+ public DefaultTransitManager(
+ Logger logger, LayoutRegistryManager layout, CacheManager cache,
+ ContentRegistryManager content, RepositoryManager repository,
ProxyManager proxy )
{
- this( logger, prefs, null );
- }
+ super( logger );

- public TransitManager( Logger logger, Preferences prefs, URL authority )
- throws NullPointerException, TransitException
- {
- if( null == prefs )
+ if( null == layout )
{
- throw new NullPointerException( "prefs" );
+ throw new NullPointerException( "layout" );
}
- if( null == logger )
+ if( null == cache )
{
- throw new NullPointerException( "logger" );
+ throw new NullPointerException( "cache" );
}
-
- //
- // check for virgin prefs
- //
-
- if( null != authority )
+ if( null == content )
{
- TransitPreferences.setupPreferences( prefs, authority );
+ throw new NullPointerException( "content" );
}
- else
+ if( null == repository )
{
- long install = prefs.getLong( "installation", -1 );
- if( install < 0 )
- {
- TransitPreferences.setupFactoryPreferences( prefs );
- }
+ throw new NullPointerException( "repository" );
+ }
+ if( null == proxy )
+ {
+ throw new NullPointerException( "proxy" );
}

- //
- // create the subsystem configurations
- //
-
- m_logger = logger;
- m_layout = createLayoutRegistryModel( logger, prefs );
- m_cache = createCacheModel( logger, prefs );
- m_registry = createRegistryModel( logger, prefs );
- m_repository = createRepositoryModel( logger, prefs );
- m_proxy = createProxyModel( logger, prefs );
+ m_layout = layout;
+ m_cache = cache;
+ m_registry = content;
+ m_repository = repository;
+ m_proxy = proxy;
}

//
------------------------------------------------------------------------
@@ -127,19 +114,17 @@
}

/**
- * Return the model maintiaining configuration information about
- * the conent registry.
+ * Return the content registry manager.
*
- * @return the content director
+ * @return the content manager
*/
- public RegistryManager getRegistryManager()
+ public ContentRegistryManager getContentRegistryManager()
{
return m_registry;
}

/**
- * Return the model maintaining configuration information about
- * the repository service.
+ * Return the repository manager.
*
* @return the repository director
*/
@@ -149,8 +134,7 @@
}

/**
- * Return the model maintaining configuration information about
- * the available location resolvers.
+ * Return the layout registry manager.
*
* @return the layout model
*/
@@ -164,14 +148,6 @@
//
------------------------------------------------------------------------

/**
- * Return the assigned logging channel.
- */
- public Logger getLogger()
- {
- return m_logger;
- }
-
- /**
* Return the proxy model.
* @return the proxy configuration model.
*/
@@ -195,9 +171,9 @@
*
* @return the content director
*/
- public RegistryModel getRegistryModel()
+ public ContentRegistryModel getContentRegistryModel()
{
- return getRegistryManager();
+ return getContentRegistryManager();
}

/**
@@ -222,59 +198,8 @@
return getLayoutRegistryManager();
}

- //
------------------------------------------------------------------------
- // AbstractManager
- //
------------------------------------------------------------------------
-
- /**
- * Dispose of the manager.
- */
- public void dispose()
- {
- m_cache.dispose();
- m_registry.dispose();
- m_repository.dispose();
- m_proxy.dispose();
- m_layout.dispose();
- }
-
- //
------------------------------------------------------------------------
- // internal
- //
------------------------------------------------------------------------
-
- private CacheManager createCacheModel( Logger logger, Preferences root )
throws ModelException
- {
- Preferences prefs = root.node( "cache" );
- Logger log = logger.getChildLogger( "cache" );
- return new CacheManager( log, prefs, m_layout );
- }
-
- private RegistryManager createRegistryModel( Logger logger, Preferences
root ) throws ModelException
- {
- Preferences prefs = root.node( "content" );
- Logger log = logger.getChildLogger( "content" );
- return new RegistryManager( log, prefs );
- }
-
- private RepositoryManager createRepositoryModel( Logger logger,
Preferences root )
- {
- Preferences prefs = root.node( "repository" );
- Logger log = logger.getChildLogger( "repository" );
- return new RepositoryManager( log, prefs );
- }
-
- private ProxyManager createProxyModel( Logger logger, Preferences root )
- {
- Preferences prefs = root.node( "proxy" );
- Logger log = logger.getChildLogger( "proxy" );
- return new ProxyManager( log, prefs );
- }
-
- private LayoutRegistryManager createLayoutRegistryModel( Logger logger,
Preferences root ) throws ModelException
+ public void processEvent( EventObject event )
{
- Preferences prefs = root.node( "layout" );
- Logger log = logger.getChildLogger( "layout" );
- return new LayoutRegistryManager( log, prefs );
}
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/CacheModel.java
Sun Jun 5 00:41:19 2005
@@ -28,6 +28,10 @@
*/
public interface CacheModel extends PluginModel
{
+ static final String CACHE_LOCATION_KEY = "dpml.transit.cache.location";
+ static final String CACHE_CLASS_KEY = "dpml.transit.cache.class";
+ static final String CACHE_LAYOUT_KEY = "dpml.transit.cache.layout";
+
/**
* Return the directory to be used by the cache handler as the cache
directory.
* @return the cache directory.
@@ -41,12 +45,6 @@
HostModel[] getHostModels();

/**
- * Return an array of available and enabled hosts is priority order.
- * @return the available host model array
- */
- HostModel[] getAvailableHosts();
-
- /**
* Add a cache listener to the director.
* @param listener the listener to add
*/

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentModel.java
Sun Jun 5 00:41:19 2005
@@ -37,7 +37,7 @@
* Returns the human readable name of the content type handler.
* @return the content type human readable name
*/
- public String getContentHandlerTitle();
+ public String getTitle();

/**
* Add a content listener to the director.

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryEvent.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryEvent.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryEvent.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryEvent.java
Sun Jun 5 00:41:19 2005
@@ -24,10 +24,10 @@
* An event issued by a registry signalling changes tye addition or removal
* of a content model.
*/
-public abstract class RegistryEvent extends EventObject
+public abstract class ContentRegistryEvent extends EventObject
{
private final ContentModel m_content;
- private final RegistryModel m_registry;
+ private final ContentRegistryModel m_registry;

/**
* Creation of a new RegistryEvent signalling the addition
@@ -36,7 +36,7 @@
* @param registry the content registry director
* @param content the content director that was added or removed
*/
- public RegistryEvent( RegistryModel registry, ContentModel content )
+ public ContentRegistryEvent( ContentRegistryModel registry, ContentModel
content )
{
super( registry );
m_content = content;
@@ -47,7 +47,7 @@
* Return the registry director initiating the event.
* @return the registry director
*/
- public RegistryModel getRegistryModel()
+ public ContentRegistryModel getRegistryModel()
{
return m_registry;
}

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryListener.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryListener.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryListener.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryListener.java
Sun Jun 5 00:41:19 2005
@@ -21,22 +21,22 @@
import java.util.EventListener;

/**
- * A RegistryListener maintains information about the configuration of a
Transit
+ * A ContentRegistryListener maintains information about the configuration
of a Transit
* content management system. An implementation of this interface would be
supplied
* a ContentRegistry implementation.
*/
-public interface RegistryListener extends EventListener
+public interface ContentRegistryListener extends EventListener
{
/**
* Notify all listeners of the addition of a content model.
* @param event the registry event
*/
- void contentAdded( RegistryEvent event );
+ void contentAdded( ContentRegistryEvent event );

/**
* Notify all listeners of the removal of a content model.
* @param event the registry event
*/
- void contentRemoved( RegistryEvent event );
+ void contentRemoved( ContentRegistryEvent event );

}

Copied:
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryModel.java
(from r2687,
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryModel.java)
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/RegistryModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/ContentRegistryModel.java
Sun Jun 5 00:41:19 2005
@@ -18,32 +18,20 @@

package net.dpml.transit.model;

-import java.net.URI;
-
/**
* A RegistryModel maintains information about the configuration of the
Transit
* content registry subsystem. Instances of RegistryModel shall be supplied
to
* registry implementations as constructor arguments.
*/
-public interface RegistryModel extends PluginModel
+public interface ContentRegistryModel extends PluginModel
{
/**
- * Register a new content model.
- *
- * @param type the content type identifier
- * @param title the title of the content model
- * @param plugin the content plugin uri
- * @return the content model
- */
- ContentModel addContentModel( String type, String title, URI plugin )
throws ModelException;
-
- /**
* Return a content model matching the supplied type. If the type is
unknown
* an implementation shall return a null value.
*
* @return the content model
*/
- ContentModel getContentModel( String type );
+ ContentModel getContentModel( String type ) throws UnknownKeyException;

/**
* Return an array of content directors currently assigned to the
registry.
@@ -55,12 +43,12 @@
* Add a regstry change listener.
* @param listener the registry change listener to add
*/
- void addRegistryListener( RegistryListener listener );
+ void addRegistryListener( ContentRegistryListener listener );

/**
* Remove a regstry change listener.
* @param listener the registry change listener to remove
*/
- void removeRegistryListener( RegistryListener listener );
+ void removeRegistryListener( ContentRegistryListener listener );

}

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/model/DuplicateKeyException.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/DuplicateKeyException.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.model;
+
+import net.dpml.transit.model.ModelException;
+
+/**
+ * Exception to indicate an error arrising from the use of a duplicate key.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class DuplicateKeyException extends ModelException
+{
+ /**
+ * Construct a new <code>DuplicateKeyException</code> instance.
+ *
+ * @param key the duplicate key
+ */
+ public DuplicateKeyException( final String key )
+ {
+ super( key );
+ }
+}
+

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostChangeEvent.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostChangeEvent.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostChangeEvent.java
Sun Jun 5 00:41:19 2005
@@ -34,16 +34,21 @@
private final URL m_index;
private final RequestIdentifier m_identifier;
private final PasswordAuthentication m_authentication;
+ private final boolean m_enabled;
+ private final boolean m_trusted;

public HostChangeEvent(
HostModel host, URL base, URL index,
- RequestIdentifier identifier, PasswordAuthentication auth )
+ RequestIdentifier identifier, PasswordAuthentication auth,
+ boolean enabled, boolean trusted )
{
super( host );
m_base = base;
m_index = index;
m_identifier = identifier;
m_authentication = auth;
+ m_enabled = enabled;
+ m_trusted = trusted;
}

public URL getBaseURL()

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostListener.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostListener.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostListener.java
Sun Jun 5 00:41:19 2005
@@ -29,22 +29,17 @@
public interface HostListener extends EventListener
{
/**
- * Notify a consumer of an aggregated set of changes.
- * @param event the host change event
- */
- void hostChanged( HostChangeEvent event );
-
- /**
- * Notify a consumer of a change to the enabled state.
- * @param event the host event
+ * Notify a consumer of the change to the host name.
+ * @param event the host name change event
*/
- void enabledStateChanged( HostEnabledEvent event );
+ void nameChanged( HostNameEvent event );

/**
- * Notify a consumer of a change to the trusted state.
- * @param event the host event
+ * Notify a consumer of an aggregated set of changes concerning the
+ * base url, index, request identifier and/or authentication.
+ * @param event the host change event
*/
- void trustedStateChanged( HostTrustedEvent event );
+ void hostChanged( HostChangeEvent event );

/**
* Notify a consumer of a change to the host priority.
@@ -53,16 +48,10 @@
void priorityChanged( HostPriorityEvent event );

/**
- * Notify a consumer of a change to the host resolver.
- * @param event the host resolver change event
+ * Notify a consumer of a change to the host layout.
+ * @param event the host layout change event
*/
void layoutChanged( HostLayoutEvent event );

- /**
- * Notify a consumer of a change to availability status of a host.
- * @param event the host availability event
- */
- void availabilityChanged( HostAvailabilityEvent event );
-
}


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/HostModel.java
Sun Jun 5 00:41:19 2005
@@ -49,14 +49,6 @@
boolean isBootstrap();

/**
- * Return the available status. A host model may declare itself as
unavailable
- * if its data model is incomplete or inconsitent.
- *
- * @return TRUE if available
- */
- public boolean getAvailable();
-
- /**
* Return the name of the resource host. The value returned may be used
to uniquely
* identify the host within the set of managed hosts.
*/

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/LayoutModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/LayoutModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/LayoutModel.java
Sun Jun 5 00:41:19 2005
@@ -33,6 +33,13 @@
String getID();

/**
+ * Return true if this is a bootstrap resolver.
+ *
+ * @return the bootstrap status of the resolver.
+ */
+ boolean isBootstrap();
+
+ /**
* Return a possibly null classname. If the classname is not null the
* manager represents a bootstrap resolver. Bootstrap resolver plugin
* uris shall return a null value.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/LayoutRegistryModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/LayoutRegistryModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/LayoutRegistryModel.java
Sun Jun 5 00:41:19 2005
@@ -38,17 +38,7 @@
*
* @return the layout model
*/
- LayoutModel getLayoutModel( String id );
-
- /**
- * Register a new layout resolver model.
- *
- * @param id the layout identifier
- * @param title the title of the layout resolver model
- * @param plugin the plugin uri
- * @return the layout resolver model
- */
- LayoutModel addLayoutModel( String id, String title, URI plugin );
+ LayoutModel getLayoutModel( String id ) throws UnknownKeyException;

/**
* Add a change listener.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/PluginChangeEvent.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/PluginChangeEvent.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/PluginChangeEvent.java
Sun Jun 5 00:41:19 2005
@@ -28,13 +28,18 @@
{
private final URI m_plugin;

- public PluginChangeEvent( Object source, URI plugin )
+ public PluginChangeEvent( PluginModel source, URI plugin )
{
super( source );

m_plugin = plugin;
}

+ public PluginModel getPluginModel()
+ {
+ return (PluginModel) getSource();
+ }
+
public URI getPluginURI()
{
return m_plugin;

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyEvent.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyEvent.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyEvent.java
Sun Jun 5 00:41:19 2005
@@ -27,15 +27,40 @@
/**
* An event pertaining to the Transit proxy configuration.
*/
-public abstract class ProxyEvent extends EventObject
+public class ProxyEvent extends EventObject
{
- public ProxyEvent( ProxyModel model )
+ private final RequestIdentifier m_identifier;
+ private final PasswordAuthentication m_authentication;
+ private final String[] m_excludes;
+
+ public ProxyEvent(
+ ProxyModel model, RequestIdentifier identifier,
+ PasswordAuthentication auth, String[] excludes )
{
super( model );
+
+ m_identifier = identifier;
+ m_authentication = auth;
+ m_excludes = excludes;
}

public ProxyModel getProxyModel()
{
return (ProxyModel) super.getSource();
}
+
+ public RequestIdentifier getRequestIdentifier()
+ {
+ return m_identifier;
+ }
+
+ public PasswordAuthentication getPasswordAuthentication()
+ {
+ return m_authentication;
+ }
+
+ public String[] getExcludes()
+ {
+ return m_excludes;
+ }
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyListener.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyListener.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyListener.java
Sun Jun 5 00:41:19 2005
@@ -30,12 +30,6 @@
* Notify a listener of the change to Transit proxy settings.
* @param event the proxy change event
*/
- void proxySettingsChanged( ProxyChangeEvent event );
-
- /**
- * Notify a listener of the change to the set of excluded hosts.
- * @param event the proxy excludes change event
- */
- void proxyExcludesChanged( ProxyExcludesEvent event );
+ void proxyChanged( ProxyEvent event );

}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/ProxyModel.java
Sun Jun 5 00:41:19 2005
@@ -18,7 +18,7 @@

package net.dpml.transit.model;

-import java.net.URI;
+import java.net.URL;
import java.net.PasswordAuthentication;

import net.dpml.transit.network.RequestIdentifier;
@@ -30,42 +30,23 @@
public interface ProxyModel extends Model
{
/**
- * Returns TRUE if a proxy configuration is enabled.
- * @return the proxy configuration enabled status
- */
- boolean isProxyEnabled();
-
- /**
- * Return the proxy host name. If not defined an implementation shall
- * returns a zero length string.
+ * Return the proxy host url.
*
- * @return the proxy host name
+ * @return the proxy host (possibly null)
*/
- public String getProxyHost();
-
- /**
- * Return the proxy port or 0 is undefined.
- * @return the proxy port
- */
- public int getProxyPort();
+ public URL getHost();

/**
* Return the proxy authentication or null if not defined.
* @return the proxy authentication credentials
*/
- PasswordAuthentication getProxyAuthentication();
+ PasswordAuthentication getAuthentication();

/**
* Return the proxy host request identifier.
* @return the request identifier for the proxy host or null if not
defined.
*/
- RequestIdentifier getProxyRequestIdentifier();
-
- /**
- * Return the String identifying the non-proxy hosts.
- * @return the non-proxied hosts value (possibly null)
- */
- String getProxyExcludes();
+ RequestIdentifier getRequestIdentifier();

/**
* Return the set of excluded hosts as an array.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/TransitModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/TransitModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/TransitModel.java
Sun Jun 5 00:41:19 2005
@@ -42,7 +42,7 @@
*
* @return the content model
*/
- RegistryModel getRegistryModel();
+ ContentRegistryModel getContentRegistryModel();

/**
* Return the model maintaining configuration information about

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/model/UnknownKeyException.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/UnknownKeyException.java
Sun Jun 5 00:41:19 2005
@@ -0,0 +1,38 @@
+/*
+ * 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.model;
+
+/**
+ * Exception to indicate an error arrising from the use of an unknown key.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class UnknownKeyException extends ModelException
+{
+ /**
+ * Construct a new <code>UnknownKeyException</code> instance.
+ *
+ * @param key the unknown key
+ */
+ public UnknownKeyException( final String key )
+ {
+ super( key );
+ }
+}
+

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 00:41:19 2005
@@ -29,20 +29,18 @@

import net.dpml.transit.Transit;
import net.dpml.transit.adapter.LoggingAdapter;
-import net.dpml.transit.model.RepositoryModel;
-import net.dpml.transit.model.CacheModel;
-import net.dpml.transit.model.RegistryModel;
-import net.dpml.transit.model.ProxyChangeEvent;
-import net.dpml.transit.model.ProxyExcludesEvent;
+import net.dpml.transit.model.ProxyEvent;
import net.dpml.transit.model.ProxyListener;
import net.dpml.transit.model.Logger;

+import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.builder.TransitHelper;
+
/**
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
public class ProxyManagerTestCase extends TestCase
{
- private Preferences m_prefs;
private TransitManager m_manager;
private File m_data;

@@ -51,47 +49,9 @@
String path = "target/test/data";
m_data = new File( path );
System.setProperty( "dpml.data", path );
- Preferences prefs = Preferences.userNodeForPackage( Transit.class );
- m_prefs = prefs.node( "test" );
- m_manager = new TransitManager( new LoggingAdapter(), m_prefs );
- }
-
- public void tearDown() throws Exception
- {
- m_manager.dispose();
- }
-
- public void testDefaultProxySetting() throws Exception
- {
- Preferences prefs = m_prefs.node( "proxy" );
- try
- {
- boolean enabled = m_manager.getProxyModel().isProxyEnabled();
- assertFalse( "proxy-disabled", enabled );
- }
- catch( Throwable e )
- {
- prefs.exportNode( System.out );
- }
- }
-
- public void testProxyEnabled() throws Exception
- {
- Preferences prefs = m_prefs.node( "proxy" );
- TestProxyEnabledListener listener = new TestProxyEnabledListener();
- m_manager.getProxyModel().addProxyListener( listener );
- try
- {
- prefs.put( "host", "http://proxy.dpml.net"; );
- prefs.put( "scheme", "a-scheme" );
- prefs.put( "prompt", "a-prompt" );
- prefs.putLong( "modified", new Date().getTime() );
- prefs.flush();
- }
- finally
- {
- prefs.clear();
- }
+ Preferences prefs =
+ Preferences.userNodeForPackage( Transit.class ).node( "test"
).node( "proxy-manager-test" );
+ m_manager = TransitHelper.createTransitManager( prefs );
}

public void testProxyAuthentication() throws Exception
@@ -100,75 +60,28 @@
String password = "rabbit";
PasswordAuthentication auth =
new PasswordAuthentication( username, password.toCharArray() );
- Preferences prefs = m_prefs.node( "proxy" );
+
TestProxyAuthListener listener = new TestProxyAuthListener( auth );
- m_manager.getProxyModel().addProxyListener( listener );
- try
- {
- prefs.put( "host", "http://proxy.dpml.net"; );
- prefs.put( "scheme", "a-scheme" );
- prefs.put( "prompt", "a-prompt" );
- m_manager.getProxyManager().setProxyAuthentication( auth );
- prefs.putLong( "modified", new Date().getTime() );
- prefs.flush();
- }
- finally
- {
- prefs.clear();
- }
+ m_manager.getProxyManager().addProxyListener( listener );
+ m_manager.getProxyManager().update( null, auth, null );
}

public void testProxyExcludes() throws Exception
{
- Preferences prefs = m_prefs.node( "proxy" );
TestProxyExcludesListener listener = new TestProxyExcludesListener();
- m_manager.getProxyModel().addProxyListener( listener );
-
- Preferences excludes = prefs.node( "excludes" );
- excludes.put( "http://www.osm.net";, "" );
- excludes.put( "http://repository.dpml.net";, "" );
- try
- {
- prefs.put( "host", "http://proxy.dpml.net"; );
- prefs.put( "scheme", "a-scheme" );
- prefs.put( "prompt", "a-prompt" );
- prefs.putLong( "modified", new Date().getTime() );
- prefs.flush();
- }
- finally
- {
- excludes.clear();
- prefs.clear();
- prefs.flush();
- }
- }
-
- public class TestProxyEnabledListener implements ProxyListener
- {
- public void proxySettingsChanged( ProxyChangeEvent event )
- {
- event.getProxyModel().removeProxyListener( this );
- assertTrue( "enabled", event.isProxyEnabled() );
- }
-
- public void proxyExcludesChanged( ProxyExcludesEvent event )
- {
- }
+ m_manager.getProxyManager().addProxyListener( listener );
+ String[] excludes = new String[]{ "http://www.osm.net";,
"http://repository.dpml.net"; };
+ m_manager.getProxyManager().update( null, null, excludes );
}

public class TestProxyExcludesListener implements ProxyListener
{
- public void proxySettingsChanged( ProxyChangeEvent event )
+ public void proxyChanged( ProxyEvent event )
{
event.getProxyModel().removeProxyListener( this );
- String result = event.getProxyExcludes();
+ String[] result = event.getExcludes();
assertNotNull( "excludes-not-null", result );
- String expected =
"http://www.osm.net|http://repository.dpml.net";;
- assertEquals( "excludes-length", expected.length(),
result.length() );
- }
-
- public void proxyExcludesChanged( ProxyExcludesEvent event )
- {
+ assertEquals( "excludes", 2, result.length );
}
}

@@ -180,7 +93,7 @@
m_auth = auth;
}

- public void proxySettingsChanged( ProxyChangeEvent event )
+ public void proxyChanged( ProxyEvent event )
{
event.getProxyModel().removeProxyListener( this );
PasswordAuthentication auth = event.getPasswordAuthentication();
@@ -190,10 +103,6 @@
new String( m_auth.getPassword() ),
new String( auth.getPassword() ) );
}
-
- public void proxyExcludesChanged( ProxyExcludesEvent event )
- {
- }
}

static

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 00:41:19 2005
@@ -28,17 +28,15 @@

import net.dpml.transit.Transit;
import net.dpml.transit.adapter.LoggingAdapter;
-import net.dpml.transit.model.RepositoryModel;
-import net.dpml.transit.model.CacheModel;
-import net.dpml.transit.model.RegistryModel;
import net.dpml.transit.model.Logger;
+import net.dpml.transit.builder.TransitHelper;
+import net.dpml.transit.management.TransitManager;

/**
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
public class TransitManagerTestCase extends TestCase
{
- private Preferences m_prefs;
private TransitManager m_manager;
private File m_data;

@@ -47,23 +45,15 @@
String path = "target/test/data";
m_data = new File( path );
System.setProperty( "dpml.data", path );
- Preferences prefs = Preferences.userNodeForPackage( Transit.class );
- m_prefs = prefs.node( "test" );
- m_manager = new TransitManager( new LoggingAdapter(), m_prefs );
- }
-
- public void tearDown() throws Exception
- {
- synchronized( this )
- {
- m_manager.dispose();
- }
+ Preferences prefs = Preferences.userNodeForPackage( Transit.class
).node( "test" );
+ m_manager = TransitHelper.createTransitManager( prefs );
}

public void testCacheDirectory() throws Exception
{
- File cache = m_manager.getCacheModel().getCacheDirectory();
File dir = new File( m_data, "cache" ).getAbsoluteFile();
+ m_manager.getCacheManager().setCacheDirectory( dir );
+ File cache = m_manager.getCacheModel().getCacheDirectory();
assertEquals( "cache", dir, cache );
}
}

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 00:41:19 2005
@@ -18,14 +18,6 @@

package net.dpml.transit.test;

-import junit.framework.TestCase;
-import net.dpml.transit.artifact.ArtifactNotFoundException;
-import net.dpml.transit.link.Link;
-import net.dpml.transit.util.StreamUtils;
-import net.dpml.transit.manager.TransitManager;
-import net.dpml.transit.adapter.LoggingAdapter;
-import net.dpml.transit.Transit;
-
import java.io.File;
import java.io.InputStream;
import java.net.URI;
@@ -34,6 +26,17 @@
import java.util.logging.Logger;
import java.util.logging.Level;

+import junit.framework.TestCase;
+
+import net.dpml.transit.artifact.ArtifactNotFoundException;
+import net.dpml.transit.link.Link;
+import net.dpml.transit.util.StreamUtils;
+import net.dpml.transit.adapter.LoggingAdapter;
+import net.dpml.transit.Transit;
+
+import net.dpml.transit.builder.TransitHelper;
+import net.dpml.transit.management.TransitManager;
+
/**
*
* @author <a href="http://www.dpml.net/";>The Digital Product Meta
Library</a>
@@ -49,7 +52,6 @@
if( null == TRANSIT )
{
System.setProperty( "java.protocol.handler.pkgs",
"net.dpml.transit" );
- System.setProperty( "dpml.transit.secured.disable", "true" );
System.setProperty( "java.util.logging.config.class",
"net.dpml.transit.util.ConfigurationHandler" );
Preferences prefs =
@@ -58,7 +60,7 @@
Logger logger = Logger.getLogger( "test" );
//logger.setLevel( Level.parse( "FINE" ) );
LoggingAdapter adapter = new LoggingAdapter( logger );
- TransitManager manager = new TransitManager( adapter, prefs,
authority );
+ TransitManager manager = TransitHelper.createTransitManager(
adapter, prefs, authority );
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 00:41:19 2005
@@ -33,7 +33,8 @@

import junit.framework.TestCase;

-import net.dpml.transit.manager.TransitManager;
+import net.dpml.transit.builder.TransitHelper;
+import net.dpml.transit.management.TransitManager;
import net.dpml.transit.adapter.LoggingAdapter;
import net.dpml.transit.Transit;

@@ -62,7 +63,7 @@
Logger logger = Logger.getLogger( "test" );
//logger.setLevel( Level.parse( "FINE" ) );
LoggingAdapter adapter = new LoggingAdapter( logger );
- TransitManager manager = new TransitManager( adapter, prefs,
authority );
+ TransitManager manager = TransitHelper.createTransitManager(
adapter, prefs, authority );
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 00:41:19 2005
@@ -20,7 +20,6 @@

import java.io.File;
import java.net.URL;
-import java.util.prefs.Preferences;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
@@ -32,7 +31,8 @@
import net.dpml.transit.monitors.Monitor;
import net.dpml.transit.model.Logger;
import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.manager.TransitManager;
+import net.dpml.transit.management.TransitManager;
+import net.dpml.transit.builder.TransitHelper;

/**
* Ant task that provides support for the import of build file templates
@@ -54,8 +54,7 @@
try
{
Logger logger = new AntAdapter( this );
- Preferences prefs = Preferences.userNodeForPackage(
Transit.class );
- TransitModel model = new TransitManager( logger, prefs );
+ TransitModel model = TransitHelper.createTransitManager( logger
);
Transit.getInstance( model );
}
catch( TransitAlreadyInitializedException e )



  • svn commit: r2703 - in development/main: . depot depot/console/src/main/net/dpml/depot/lang depot/prefs/src/main/net/dpml/depot/prefs depot/station depot/test depot/test/src depot/test/src/main depot/test/src/main/net depot/test/src/main/net/dpml depot/test/src/main/net/dpml/depot depot/test/src/main/net/dpml/depot/test metro/composition/content/src/main/net/dpml/composition/content test/plugins/layout/src/main/net/dpml/test/layout test/unit/plus/src/test/net/dpml/test/acme/plus 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/cache transit/core/handler/src/main/net/dpml/transit/content transit/core/handler/src/main/net/dpml/transit/host transit/core/handler/src/main/net/dpml/transit/management transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/main/net/dpml/transit/model 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/04/2005

Archive powered by MHonArc 2.6.24.

Top of Page