Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2679 - in development/main: depot/console/src/main/net/dpml/depot/lang depot/prefs/src/main/net/dpml/depot/prefs transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/layout transit/core/handler/src/main/net/dpml/transit/manager 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: r2679 - in development/main: depot/console/src/main/net/dpml/depot/lang depot/prefs/src/main/net/dpml/depot/prefs transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/layout transit/core/handler/src/main/net/dpml/transit/manager transit/core/tools/src/main/net/dpml/transit/tools
  • Date: Mon, 30 May 2005 15:33:06 -0400

Author: mcconnell AT dpml.net
Date: Mon May 30 15:33:05 2005
New Revision: 2679

Added:

development/main/transit/core/handler/src/main/net/dpml/transit/TransitAlreadyInitializedException.java
Modified:
development/main/depot/console/src/main/net/dpml/depot/lang/Main.java

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/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/ProxyManagerPanel.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/transit/core/handler/src/main/net/dpml/transit/Transit.java

development/main/transit/core/handler/src/main/net/dpml/transit/layout/DefaultLayoutRegistry.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/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
Log:
Add an explicit runtime exception if an attempt is made to inialize transit
with a model wheere transit is already initialized. Secondly - updated the
depot classes to release listeners following disposal.

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
Mon May 30 15:33:05 2005
@@ -218,10 +218,18 @@
Method method = c.getDeclaredMethod( "main", new Class[]{
String[].class } );
Object[] params = new Object[]{ args };
method.invoke( null, params );
+ setShutdownHook( null );
}
catch( NoSuchMethodException e )
{
- c.newInstance();
+ Thread thread = null;
+ Object object = c.newInstance();
+ if( object instanceof Runnable )
+ {
+ thread = new Thread( (Runnable) object );
+ thread.start();
+ }
+ setShutdownHook( thread );
}
}

@@ -320,5 +328,39 @@
{
return
Main.class.getProtectionDomain().getCodeSource().getLocation();
}
+
+ /**
+ * Create a shutdown hook that will trigger shutdown of the supplied
plugin.
+ * @param thread the application thread
+ */
+ private static void setShutdownHook( final Thread thread )
+ {
+ //
+ // Create a shutdown hook to trigger clean disposal of the
+ // controller
+ //
+
+ Runtime.getRuntime().addShutdownHook(
+ new Thread()
+ {
+ public void run()
+ {
+ if( null != thread )
+ {
+ try
+ {
+ thread.interrupt();
+ }
+ catch( Throwable e )
+ {
+ // ignore it
+ }
+ }
+ System.runFinalization();
+ }
+ }
+ );
+ }
+
}


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
Mon May 30 15:33:05 2005
@@ -123,6 +123,12 @@
m_propertyChangeSupport.addPropertyChangeListener( this );
}
}
+
+ public void dispose()
+ {
+ m_propertyChangeSupport.removePropertyChangeListener( this );
+ m_manager.removeCacheListener( this );
+ }


//--------------------------------------------------------------------------
// CacheListener

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
Mon May 30 15:33:05 2005
@@ -74,14 +74,16 @@

private final Window m_parent;

- private ClassicTable m_table;
- private EditAction m_editAction;
- private JButton m_edit;
- private JButton m_delete;
+ private final ClassicTable m_table;
+ private final EditAction m_editAction;
+ private final JButton m_edit;
+ private final JButton m_delete;
+ private final CacheManager m_manager;
+ private final LayoutRegistryManager m_layouts;
+ private final CacheAction m_cache;
+ private final CacheTableModel m_tableModel;
+
private String m_selection; // selected hostname
- private CacheManager m_manager;
- private LayoutRegistryManager m_layouts;
- private CacheAction m_cache;

//--------------------------------------------------------------
// constructor
@@ -117,8 +119,8 @@
hostPanel.setBorder( new CompoundBorder( tb, border5 ) );

TableColumnModel columns = createHostsColumnModel();
- CacheTableModel tableModel = new CacheTableModel( manager );
- m_table = new ClassicTable( tableModel, columns );
+ m_tableModel = new CacheTableModel( manager );
+ m_table = new ClassicTable( m_tableModel, columns );
m_table.addPropertyChangeListener( this );
m_table.setShowVerticalLines( false );
m_table.setShowHorizontalLines( false );
@@ -137,6 +139,12 @@
getBody().add( hostPanel, BorderLayout.CENTER );
}

+ public void dispose()
+ {
+ m_table.removePropertyChangeListener( this );
+ m_tableModel.dispose();
+ }
+
/**
* handle property change events raised by the table model.
*/

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
Mon May 30 15:33:05 2005
@@ -80,7 +80,7 @@
manager.addCacheListener( this );
}

- protected void finalize()
+ public void dispose()
{
try
{

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
Mon May 30 15:33:05 2005
@@ -77,6 +77,11 @@
private ButtonPanel m_buttons;

private TransitManager m_manager;
+ private LayoutRegistryManagerPanel m_layoutPanel;
+ private CacheManagerPanel m_cachePanel;
+ private RegistryManagerPanel m_registryPanel;
+ private ProxyManagerPanel m_proxyPanel;
+

public DepotPreferencesPanel( Window window, TransitManager manager )
throws Exception
{
@@ -101,15 +106,15 @@
RegistryManager content = manager.getRegistryManager();
ProxyManager proxy = manager.getProxyManager();
JPanel panel = new JPanel();
- LayoutRegistryManagerPanel layoutPanel = new
LayoutRegistryManagerPanel( window, layouts );
- CacheManagerPanel cachePanel = new CacheManagerPanel( window, cache,
layouts );
- RegistryManagerPanel registryPanel = new RegistryManagerPanel(
window, content );
- ProxyManagerPanel proxyPanel = new ProxyManagerPanel( window, proxy
);
-
- tabbedPane.addTab( "Cache", cachePanel );
- tabbedPane.addTab( "Layout", layoutPanel );
- tabbedPane.addTab( "Content", registryPanel );
- tabbedPane.addTab( "Proxy", proxyPanel );
+ m_layoutPanel = new LayoutRegistryManagerPanel( window, layouts );
+ m_cachePanel = new CacheManagerPanel( window, cache, layouts );
+ m_registryPanel = new RegistryManagerPanel( window, content );
+ m_proxyPanel = new ProxyManagerPanel( window, proxy );
+
+ tabbedPane.addTab( "Cache", m_cachePanel );
+ tabbedPane.addTab( "Layout", m_layoutPanel );
+ tabbedPane.addTab( "Content", m_registryPanel );
+ tabbedPane.addTab( "Proxy", m_proxyPanel );

//tabbedPane.addTab( "Logging", new JPanel() );
//tabbedPane.addTab( "Profiles", new JPanel() );
@@ -118,7 +123,7 @@
// add the Close button
//

- m_buttons = new ButtonPanel();
+ m_buttons = new ButtonPanel( this );
m_buttons.setBorder( new EmptyBorder( 0, 7, 7, 7 ) );

//
@@ -130,6 +135,14 @@
add( m_buttons, BorderLayout.SOUTH );
}

+ public void dispose()
+ {
+ m_layoutPanel.dispose();
+ m_cachePanel.dispose();
+ m_registryPanel.dispose();
+ m_proxyPanel.dispose();
+ }
+
public JButton getDefaultButton()
{
return m_buttons.getDefaultButton();
@@ -139,12 +152,12 @@
{
private JButton m_close;

- ButtonPanel()
+ ButtonPanel( DepotPreferencesPanel panel )
{
super( BoxLayout.Y_AXIS );

m_close = new JButton( );
- Action closeAction = new CancelAction( "Close" );
+ Action closeAction = new CancelAction( "Close", panel );
m_close.setAction( closeAction );
JPanel buttonPanel = new JPanel( new FlowLayout(
FlowLayout.RIGHT ) );
buttonPanel.add( m_close );
@@ -159,9 +172,12 @@

private static class CancelAction extends AbstractAction
{
- public CancelAction( String label )
+ private final DepotPreferencesPanel m_panel;
+
+ public CancelAction( String label, DepotPreferencesPanel panel )
{
super( label );
+ m_panel = panel;
}

/**
@@ -170,6 +186,7 @@
*/
public void actionPerformed( ActionEvent event )
{
+ m_panel.dispose();
System.exit(0);
}
}

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
Mon May 30 15:33:05 2005
@@ -259,7 +259,7 @@
// add commmit/revert controls and assemble the dialog
//

- m_ok = new JButton( new OKAction( "OK", this ) );
+ m_ok = new JButton( new OKAction( "OK" ) );
m_revert = new JButton( new RevertAction( "Undo Changes" ) );
JPanel buttonHolder = new JPanel();
buttonHolder.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
@@ -281,6 +281,15 @@
m_propertyChangeSupport.addPropertyChangeListener( this );
}

+ public void dispose()
+ {
+ m_strategy.removeListDataListener( this );
+ m_propertyChangeSupport.removePropertyChangeListener( this );
+ m_base.getDocument().removeDocumentListener( this );
+ m_manager.removeHostListener( this );
+ m_strategy.dispose();
+ }
+
//--------------------------------------------------------------
// HostListener
//--------------------------------------------------------------
@@ -508,18 +517,16 @@
{
m_parent.hide();
m_ok.setEnabled( false );
+ dispose();
}
}

private class OKAction extends AbstractAction
{
- private PropertyChangeListener m_listener;
-
- OKAction( String name, PropertyChangeListener listener )
+ OKAction( String name )
{
super( name );
setEnabled( false );
- m_listener = listener;
}

// TODO: we need a solution in place under which we log
@@ -528,7 +535,6 @@
public void actionPerformed( ActionEvent event )
{
m_parent.hide();
- m_propertyChangeSupport.removePropertyChangeListener( m_listener
);
{
String value = m_base.getText();
URL base = resolveBaseURL( value );
@@ -550,6 +556,7 @@
m_manager.setLayoutModel( layout );
}
}
+ dispose();
}
}

@@ -573,7 +580,7 @@
dialog.getBody().add( panel );
dialog.setLocationRelativeTo( (Component) event.getSource()
);
dialog.setResizable( false );
- dialog.setVisible(true);
+ dialog.setVisible( true );
}
catch( Throwable e )
{
@@ -641,8 +648,6 @@
new PropertyChangeEvent(
this, "revert", null, null );
m_propertyChangeSupport.firePropertyChange( e );
-
-
}
}


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
Mon May 30 15:33:05 2005
@@ -57,9 +57,12 @@
public LayoutComboBoxModel( LayoutRegistryManager manager, HostManager
host )
{
super( manager.getLayoutModels() );
+
m_manager = manager;
m_host = host;

+ manager.addLayoutRegistryListener( this );
+ host.addHostListener( this );
LayoutModel layout = host.getLayoutModel();
if( null != layout )
{
@@ -67,6 +70,12 @@
}
}

+ public void dispose()
+ {
+ m_manager.removeLayoutRegistryListener( this );
+ m_host.addHostListener( this );
+ }
+

//--------------------------------------------------------------------------
// LayoutRegistryListener (listen to changes to the available layouts)

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

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
Mon May 30 15:33:05 2005
@@ -74,6 +74,7 @@
private String m_selection;

private LayoutRegistryManager m_manager;
+ private LayoutRegistryTableModel m_tableModel;

//--------------------------------------------------------------
// constructor
@@ -95,13 +96,13 @@
panel.setLayout( new BorderLayout() );
TitledBorder tb =
new TitledBorder(
- new EmptyBorder( 0,0,0,0 ), "Location Resolvers",
TitledBorder.LEFT, TitledBorder.TOP );
+ new EmptyBorder( 0,0,0,0 ), "Layout Strategies",
TitledBorder.LEFT, TitledBorder.TOP );
panel.setBorder( new CompoundBorder( tb, border5 ) );

TableColumnModel columns = createResolverHandlerColumnModel();
- LayoutRegistryTableModel model = new LayoutRegistryTableModel(
manager );
+ m_tableModel = new LayoutRegistryTableModel( manager );

- m_table = new ClassicTable( model, columns );
+ m_table = new ClassicTable( m_tableModel, columns );
m_table.addPropertyChangeListener( this );
m_table.setShowVerticalLines( false );
m_table.setShowHorizontalLines( false );
@@ -120,13 +121,19 @@
JLabel label =
IconHelper.createImageIconJLabel(
getClass().getClassLoader(), MISC_IMG_PATH,
- "Artifact", "Location Resolver Controller settings." );
+ "Artifact", "Layout Registry Controller settings." );
label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
ControllerAction controller = new ControllerAction( "Controller" );
- getHeader().addEntry( label, "Location Registry Controller", new
JButton( controller ) );
+ getHeader().addEntry( label, "Layout Registry Controller", new
JButton( controller ) );
getBody().add( panel );
}

+ public void dispose()
+ {
+ m_table.removePropertyChangeListener( this );
+ m_tableModel.dispose();
+ }
+
//--------------------------------------------------------------
// PropertyChangelistener
//--------------------------------------------------------------
@@ -176,7 +183,7 @@
{
try
{
- final String title = "Location Resolver Controller";
+ final String title = "Layout Registry Controller";
final Dimension size = new Dimension( 400, 240 );
ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
PluginManagerPanel panel =

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
Mon May 30 15:33:05 2005
@@ -79,7 +79,7 @@
manager.addLayoutRegistryListener( this );
}

- protected void finalize()
+ protected void dispose()
{
try
{

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
Mon May 30 15:33:05 2005
@@ -103,11 +103,10 @@
//

Preferences prefs = Preferences.userNodeForPackage( Transit.class );
- TransitManager manager = null;
-
try
{
- manager = new TransitManager( logger, prefs );
+ TransitManager manager = new TransitManager( logger, prefs );
+ Transit.getInstance( manager );
new DepotPreferencesFrame( manager );
}
catch( Exception e )

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
Mon May 30 15:33:05 2005
@@ -310,6 +310,15 @@
}
}

+ //--------------------------------------------------------------
+ // utils
+ //--------------------------------------------------------------
+
+ private void dispose()
+ {
+ m_manager.removePluginListener( this );
+ }
+
private class CloseAction extends AbstractAction
{
CloseAction( String name )
@@ -320,6 +329,7 @@
public void actionPerformed( ActionEvent event )
{
m_parent.hide();
+ dispose();
}
}


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
Mon May 30 15:33:05 2005
@@ -47,7 +47,7 @@
model.addProxyListener( this );
}

- protected void finalize()
+ protected void dispose()
{
m_model.removeProxyListener( this );
}

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
Mon May 30 15:33:05 2005
@@ -78,6 +78,8 @@
private RemoveAction m_remove;
private SettingsAction m_settings;
private String m_selection;
+ private ProxyExcludesTableModel m_tableModel;
+ private ClassicTable m_table;

//--------------------------------------------------------------
// constructor
@@ -111,14 +113,25 @@

TableColumnModel columns = new DefaultTableColumnModel();
columns.addColumn( new TableColumn( 0, 100, new
ClassicCellRenderer(), null ) );
- ProxyExcludesTableModel tableModel = new ProxyExcludesTableModel(
manager );
- ClassicTable table = new ClassicTable( tableModel, columns );
- table.addPropertyChangeListener( this );
+ m_tableModel = new ProxyExcludesTableModel( manager );
+ m_table = new ClassicTable( m_tableModel, columns );
+ m_table.addPropertyChangeListener( this );
JButton[] buttons = new JButton[ 3 ];
buttons[0] = new JButton( m_add );
buttons[1] = m_editButton;
buttons[2] = new JButton( m_remove );
- getBody().addScrollingEntry( table, "Excluded hosts", buttons );
+ getBody().addScrollingEntry( m_table, "Excluded hosts", buttons );
+ }
+
+ public void dispose()
+ {
+ m_table.removePropertyChangeListener( this );
+ m_tableModel.dispose();
+ }
+
+ protected void finalize()
+ {
+ dispose();
}

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

Modified:
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/RegistryManagerPanel.java
Mon May 30 15:33:05 2005
@@ -73,6 +73,7 @@
private String m_selection;

private RegistryManager m_manager;
+ private RegistryTableModel m_tableModel;

//--------------------------------------------------------------
// constructor
@@ -98,9 +99,9 @@
panel.setBorder( new CompoundBorder( tb, border5 ) );

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

- m_table = new ClassicTable( model, columns );
+ m_table = new ClassicTable( m_tableModel, columns );
m_table.addPropertyChangeListener( this );
m_table.setShowVerticalLines( false );
m_table.setShowHorizontalLines( false );
@@ -126,6 +127,12 @@
getBody().add( panel );
}

+ public void dispose()
+ {
+ m_table.removePropertyChangeListener( this );
+ m_tableModel.dispose();
+ }
+
//--------------------------------------------------------------
// PropertyChangelistener
//--------------------------------------------------------------

Modified:
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/RegistryTableModel.java
Mon May 30 15:33:05 2005
@@ -79,7 +79,7 @@
manager.addRegistryListener( this );
}

- protected void finalize()
+ public void dispose()
{
try
{
@@ -90,6 +90,11 @@
}
}

+ protected void finalize()
+ {
+ dispose();
+ }
+

//--------------------------------------------------------------------------
// RegistryListener

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

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
Mon May 30 15:33:05 2005
@@ -152,6 +152,7 @@
try
{
Logger logger = new LoggingAdapter();
+ logger.info( "Creating anonomouse Transit instance." );
Preferences prefs = Preferences.userNodeForPackage(
Transit.class );
TransitModel model = new TransitManager( logger, prefs
);
return getInstance( model );
@@ -183,6 +184,8 @@
{
if( m_INSTANCE == null )
{
+ model.getLogger().info( "Creating managed Transit instance."
);
+
m_INSTANCE = new Transit( model );

// before returning from this method we need to give the
transit
@@ -190,8 +193,14 @@
// are themselves dependent on an establish Transit instance

m_INSTANCE.getTransitContext().initialize();
+ return m_INSTANCE;
+ }
+ else
+ {
+ final String error =
+ "Transit has already been initialized.";
+ throw new TransitAlreadyInitializedException( error );
}
- return m_INSTANCE;
}
}


Added:
development/main/transit/core/handler/src/main/net/dpml/transit/TransitAlreadyInitializedException.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/TransitAlreadyInitializedException.java
Mon May 30 15:33:05 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;
+
+/**
+ * Runtime exception to indicate that there was a 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 TransitAlreadyInitializedException extends
TransitRuntimeException
+{
+ /**
+ * Construct a new <code>TransitAlreadyInitializedException</code>
instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public TransitAlreadyInitializedException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>TransitRuntimeException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param cause the root cause of the exception
+ */
+ public TransitAlreadyInitializedException( final String message, final
Throwable cause )
+ {
+ super( message, cause );
+ }
+}
+

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/layout/DefaultLayoutRegistry.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/layout/DefaultLayoutRegistry.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/layout/DefaultLayoutRegistry.java
Mon May 30 15:33:05 2005
@@ -70,6 +70,11 @@
model.addLayoutRegistryListener( this );
}

+ protected void finalize()
+ {
+ m_model.removeLayoutRegistryListener( this );
+ }
+
//
------------------------------------------------------------------------
// LayoutRegistry
//
------------------------------------------------------------------------

Modified:
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/LayoutManager.java
Mon May 30 15:33:05 2005
@@ -55,6 +55,7 @@
public LayoutManager( Logger logger, Preferences prefs )
{
super( logger, prefs );
+
m_id = prefs.name();
m_title = prefs.get( "title", m_id );
m_classname = prefs.get( "classname", null );

Modified:
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/LayoutRegistryManager.java
Mon May 30 15:33:05 2005
@@ -141,7 +141,6 @@
Object listener = listeners[i];
if( listener != this )
{
- System.out.println( "# listener: " +
listener.getClass().getName() );
consumers.add( listener );
}
}
@@ -149,11 +148,11 @@
if( n == 0 )
{
Preferences prefs = getPreferences().node( id );
- removeLayoutModel( prefs );
+ prefs.removeNode();
}
else
{
- // we have a consumer one ormore consumer references
+ // we have one or more consumer references

final String message =
"Cannot remove a layout due to "
@@ -318,7 +317,19 @@
public void childRemoved( NodeChangeEvent event )
{
Preferences prefs = event.getChild();
- removeLayoutModel( prefs );
+ synchronized( m_list )
+ {
+ String id = prefs.name();
+ LayoutManager manager = getLayoutManager( id );
+ if( null != manager )
+ {
+ m_list.remove( manager );
+ manager.removePluginListener( this );
+ manager.dispose();
+ LayoutRemovedEvent e = new LayoutRemovedEvent( this, manager
);
+ super.enqueueEvent( e );
+ }
+ }
}

//
------------------------------------------------------------------------
@@ -355,22 +366,6 @@
}
}

- private void removeLayoutModel( Preferences prefs )
- {
- synchronized( m_list )
- {
- String id = prefs.name();
- LayoutManager manager = getLayoutManager( id );
- if( null != manager )
- {
- m_list.remove( manager );
- manager.removePluginListener( this );
- LayoutRemovedEvent event = new LayoutRemovedEvent( this,
manager );
- super.enqueueEvent( event );
- }
- }
- }
-
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
Mon May 30 15:33:05 2005
@@ -45,6 +45,7 @@

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

public PluginManager( Logger logger, Preferences prefs )
{
@@ -172,6 +173,10 @@
{
// ignore
}
+ finally
+ {
+ m_disposed = true;
+ }
}

//
------------------------------------------------------------------------
@@ -208,17 +213,7 @@

public void finalize()
{
- if( null != m_preferences )
- {
- try
- {
- m_preferences.removePreferenceChangeListener( this );
- }
- catch( Throwable e )
- {
- // ignore
- }
- }
+ dispose();
}

private static URI getPluginURI( Preferences prefs ) throws
IllegalArgumentException

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
Mon May 30 15:33:05 2005
@@ -27,6 +27,7 @@
import org.apache.tools.ant.taskdefs.ImportTask;

import net.dpml.transit.Transit;
+import net.dpml.transit.TransitAlreadyInitializedException;
import net.dpml.transit.artifact.Handler;
import net.dpml.transit.monitors.Monitor;
import net.dpml.transit.model.Logger;
@@ -57,6 +58,10 @@
TransitModel model = new TransitManager( logger, prefs );
Transit.getInstance( model );
}
+ catch( TransitAlreadyInitializedException e )
+ {
+ // Transit is already initialized.
+ }
catch( Throwable e )
{
final String error =



  • svn commit: r2679 - in development/main: depot/console/src/main/net/dpml/depot/lang depot/prefs/src/main/net/dpml/depot/prefs transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/layout transit/core/handler/src/main/net/dpml/transit/manager transit/core/tools/src/main/net/dpml/transit/tools, mcconnell, 05/30/2005

Archive powered by MHonArc 2.6.24.

Top of Page