Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2868 - in development/main: depot/console/etc/bin depot/console/src/main/net/dpml/depot depot/console/src/main/net/dpml/depot/logging depot/prefs/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/station transit/core/handler/src/main/net/dpml/transit/model

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: r2868 - in development/main: depot/console/etc/bin depot/console/src/main/net/dpml/depot depot/console/src/main/net/dpml/depot/logging depot/prefs/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/station transit/core/handler/src/main/net/dpml/transit/model
  • Date: Fri, 17 Jun 2005 13:01:10 -0400

Author: mcconnell AT dpml.net
Date: Fri Jun 17 13:01:10 2005
New Revision: 2868

Added:
development/main/depot/console/etc/bin/rmid-process.bat

development/main/depot/console/src/main/net/dpml/depot/logging/StationConfigurationHandler.java
Modified:
development/main/depot/console/src/main/net/dpml/depot/Main.java

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

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

development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java

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

development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultHostModel.java
Log:
Updates mainly dealing with Transit management over RMI.

Added: development/main/depot/console/etc/bin/rmid-process.bat
==============================================================================
--- (empty file)
+++ development/main/depot/console/etc/bin/rmid-process.bat Fri Jun 17
13:01:10 2005
@@ -0,0 +1,33 @@
+@echo off
+
+rem -------------------------- RMID CLI
---------------------------------------------------
+rem This is an example commandfile that launches the RMID server.
Typically the
+rem server would be mounted as a service in Windows with an equivalent
command line
+rem argument. It is provided here as it is helpful to run the RMID
process locally
+rem when debugging RMI aspects. Two important additions are included in
this command
+rem file: firstly the RMI trace property is enabled, and secondly, Transit
is appended
+rem to the bootstrap classpath (and the system property
java.protocol.handler is declared
+rem to include Transit as the handler. The inclusion of Transit enables
the usage of
+rem Transit URIs as the source for activatable server applications.
+rem
---------------------------------------------------------------------------------------
+
+setlocal
+
+:SET_RMID
+if "%DPML_HOME%" == "" set DPML_HOME=%APPDATA%\DPML
+if "%DPML_SYSTEM%" == "" set DPML_SYSTEM=%DPML_HOME%\Shared
+set DPML_TRANSIT_JAR=%DPML_HOME%\Data\lib\@TRANSIT-PATH@
+set $POLICY=-Djava.security.policy=%DPML_SYSTEM%\bin\security.policy
+set $BOOTCLASSPATH=-Xbootclasspath/a:%DPML_TRANSIT_JAR%
+set $TRACE=-Dsun.rmi.server.exceptionTrace=true
+set $TRANSIT=-Djava.protocol.handler.pkgs=net.dpml.transit
+
+:RUN_RMID
+@echo on
+rmid -log %DPML_HOME%\Data\logs\rmid -J%$POLICY% -J%$BOOTCLASSPATH%
-J%$TRACE% -J%$TRANSIT%
+@echo off
+
+goto EndOfScript
+:EndOfScript
+
+endlocal

Modified: development/main/depot/console/src/main/net/dpml/depot/Main.java
==============================================================================
--- development/main/depot/console/src/main/net/dpml/depot/Main.java
(original)
+++ development/main/depot/console/src/main/net/dpml/depot/Main.java Fri
Jun 17 13:01:10 2005
@@ -26,6 +26,8 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.rmi.Remote;
+import java.rmi.NotBoundException;
+import java.rmi.activation.ActivationSystem;
import java.rmi.ConnectException;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
@@ -84,8 +86,20 @@
System.setSecurityManager(new RMISecurityManager());
boolean termination = false;

+ for( int i=0; i < args.length; i++ )
+ {
+ String arg = args[i];
+ if( arg.equals( "-station" ) )
+ {
+ System.setProperty(
+ "java.util.logging.config.class",
+ "net.dpml.depot.logging.StationConfigurationHandler" );
+ break;
+ }
+ }
+
//
- // check if debug level logging should be enabled
+ // check if -debug level logging should be enabled
//

for( int i=0; i < args.length; i++ )
@@ -102,7 +116,7 @@
Logger logger = getLogger();

//
- // check if a preferences reset has been requested
+ // check if a preferences -reset has been requested
//

for( int i=0; i < args.length; i++ )
@@ -117,7 +131,7 @@
}

//
- // check if help has been requested
+ // check if -help has been requested
//

for( int i=0; i < args.length; i++ )
@@ -131,7 +145,7 @@
}

//
- // check if version info has been requested
+ // check if -version info has been requested
//

for( int i=0; i < args.length; i++ )
@@ -145,7 +159,7 @@
}

//
- // check if get has been requested
+ // check if -get has been requested
//

for( int i=0; i < args.length; i++ )
@@ -184,22 +198,26 @@
// check for the prefs or station option
//

+ TransitModel model = null;
ApplicationProfile profile = null;
for( int i=0; i < args.length; i++ )
{
String arg = args[i];
if( arg.equals( "-prefs" ) )
{
+ model = loadTransitModel( args, logger, true );
profile = createPrefsProfile( logger );
break;
}
else if( arg.equals( "-station" ) )
{
+ model = loadTransitModel( args, logger, false );
profile = createStationProfile( logger );
break;
}
else if( arg.equals( "-profile" ) )
{
+ model = loadTransitModel( args, logger, true );
String target = getTargetProfile( args );
if( null != target )
{
@@ -228,35 +246,35 @@
Properties properties = profile.getSystemProperties();
applySystemProperties( properties );
DepotClassLoader system = getSystemClassLoader();
- Connection connection = profile.getConnection();
- Registry registry = getRegistry( connection );
+ //Connection connection = profile.getConnection();
+ //Registry registry = getRegistry( connection, true );

URI uri = profile.getCodeBaseURI();
try
{
String id = profile.getID();
- TransitModel model = loadTransitModel( args, logger );
Transit transit = Transit.getInstance( model );
Logger log = logger.getChildLogger( id );
Repository loader = transit.getRepository();
Object object = loader.getPlugin( system, uri, new Object[]{
args, manager, model, log } );
- if( registry != null )
- {
- registry.bind( id, (Remote) object );
- if( null == connection.getHost() )
- {
- logger.info(
- "service bound to "
- + connection.getPort() + "/" + id );
- }
- else
- {
- logger.info(
- "service bound to " + connection.getHost()
- + ":" + connection.getPort() + "/" + id );
- }
- }
- else if( object instanceof Runnable )
+ //if( registry != null )
+ //{
+ // registry.bind( id, (Remote) object );
+ // if( null == connection.getHost() )
+ // {
+ // logger.info(
+ // "service bound to "
+ // + connection.getPort() + "/" + id );
+ // }
+ // else
+ // {
+ // logger.info(
+ // "service bound to " + connection.getHost()
+ // + ":" + connection.getPort() + "/" + id );
+ // }
+ //}
+ //else
+ if( object instanceof Runnable )
{
//
// run the plugin
@@ -314,7 +332,7 @@

private static void handleGet( Logger logger, String[] args, String path
) throws HandledError
{
- TransitModel model = loadTransitModel( args, logger );
+ TransitModel model = loadTransitModel( args, logger, false );
try
{
Transit transit = Transit.getInstance( model );
@@ -403,7 +421,7 @@
}
}

- public static Registry getRegistry( Connection connection )
+ public static Registry getRegistry( Connection connection, boolean
create ) throws RemoteException, ConnectException
{
if( null == connection )
{
@@ -416,26 +434,22 @@

if( ( null == host ) || ( "localhost".equals( host ) ) )
{
+
try
{
- Registry registry = LocateRegistry.createRegistry( port
);
- getLogger().debug( "created local registry on port " +
port );
- return registry;
+ return getLocalRegistry( port );
}
catch( RemoteException e )
{
- try
+ if( create )
{
- Registry registry = LocateRegistry.getRegistry( port
);
- getLogger().debug( "using local registry on port " +
port );
+ Registry registry = LocateRegistry.createRegistry(
port );
+ getLogger().debug( "created local registry on port "
+ port );
return registry;
}
- catch( RemoteException ee )
+ else
{
- final String error =
- "Unable to locate the RMI Registry.";
- getLogger().error( error, ee );
- throw new HandledError();
+ throw e;
}
}
}
@@ -456,6 +470,13 @@
}
}

+ private static Registry getLocalRegistry( int port ) throws
RemoteException
+ {
+ Registry registry = LocateRegistry.getRegistry( port );
+ getLogger().debug( "using local registry on port " + port );
+ return registry;
+ }
+
private static ApplicationProfile getApplicationProfile( DepotModel
manager, String target )
{
try
@@ -664,14 +685,50 @@

// TODO: add support for transit configuration profile selection

- private static TransitModel loadTransitModel( String[] args, Logger
logger )
+ private static TransitModel loadTransitModel( String[] args, Logger
logger, boolean resolve )
+ {
+ //int port = ActivationSystem.SYSTEM_PORT;
+ int port = Registry.REGISTRY_PORT;
+ Connection connection = new Connection( null, port, true, true );
+
+ if( false == resolve )
+ {
+ return createTransitModel( args, logger );
+ }
+
+ logger.info( "resolving transit model" );
+
+ try
+ {
+ Registry registry = getRegistry( connection, false );
+ return (TransitModel) registry.lookup( "//dpml/transit/default"
);
+ }
+ catch( ConnectException e )
+ {
+ return createTransitModel( args, logger );
+ }
+ catch( NotBoundException e )
+ {
+ return createTransitModel( args, logger );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to construct the transit
model.";
+ getLogger().error( error, e );
+ throw new HandledError();
+ }
+ }
+
+ private static TransitModel createTransitModel( String[] args, Logger
logger )
{
+ logger.info( "creating new transit model" );
try
{
TransitHome home = new TransitStorageUnit();
return home.create();
}
- catch( ClassCastException e )
+ catch( Throwable e )
{
final String error =
"Unexpected error while attempting to construct the transit
model.";

Added:
development/main/depot/console/src/main/net/dpml/depot/logging/StationConfigurationHandler.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/logging/StationConfigurationHandler.java
Fri Jun 17 13:01:10 2005
@@ -0,0 +1,90 @@
+/*
+ * 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.depot.logging;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Properties;
+import java.util.logging.LogManager;
+import java.util.prefs.Preferences;
+
+/**
+ * Utility class used to establish the logging configuration. The contents
of
+ * this class are subject to radical change but that's largely academic
because
+ * this class does not expose any operations. Changes will include reading
+ * logging configuration info from preferences (and initialization of prefs
if
+ * required).
+ */
+public class StationConfigurationHandler
+{
+ /**
+ * Creation of the logging controller.
+ */
+ public StationConfigurationHandler()
+ {
+ Preferences prefs = Preferences.userNodeForPackage( getClass()
).node( "nodes" );
+ String defaultLevel = prefs.get( "level", "INFO" );
+ String rootLevel = System.getProperty( "dpml.logging.level",
defaultLevel ).toUpperCase();
+
+ Properties properties = new Properties();
+ properties.setProperty(
+ "handlers",
+ "java.util.logging.FileHandler, java.util.logging.ConsoleHandler"
);
+ properties.setProperty(
+ "java.util.logging.ConsoleHandler.formatter",
+ "net.dpml.depot.logging.StandardFormatter" );
+
+ //
+ // set the file handler properties
+ //
+
+ properties.setProperty( "java.util.logging.FileHandler.pattern",
"%h/depot-station%u.log" );
+ properties.setProperty( "java.util.logging.FileHandler.limit",
"50000" );
+ properties.setProperty( "java.util.logging.FileHandler.count", "1" );
+ properties.setProperty( "java.util.logging.FileHandler.formatter",
"net.dpml.depot.logging.StandardFormatter" );
+
+ //
+ // set the default level by setting the root logger level
+ //
+
+ properties.setProperty( ".level", rootLevel );
+
+ //
+ // set the level that the console handler will handle
+ //
+
+ properties.setProperty(
+ "java.util.logging.ConsoleHandler.level",
+ "FINEST" );
+
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ properties.store( out, "DPML Logging properties" );
+ byte[] bytes = out.toByteArray();
+ ByteArrayInputStream input = new ByteArrayInputStream( bytes );
+ LogManager manager = LogManager.getLogManager();
+ manager.readConfiguration( input );
+ }
+ catch( Throwable e )
+ {
+ e.printStackTrace();
+ }
+ }
+}

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
Fri Jun 17 13:01:10 2005
@@ -19,6 +19,8 @@
import java.util.Arrays;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
+import java.util.logging.Logger;
+import java.util.logging.Level;

import javax.swing.Icon;
import javax.swing.table.AbstractTableModel;
@@ -207,11 +209,13 @@
try
{
HostModel[] hosts = m_manager.getHostModels();
- Arrays.sort( hosts );
+ HostModel host = hosts[ row ];
return hosts[ row ].getID();
}
catch( Throwable e )
{
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, "ERROR ON ROW: " + row, e );
return "";
}
}

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostModelPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostModelPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostModelPanel.java
Fri Jun 17 13:01:10 2005
@@ -45,6 +45,7 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import javax.swing.JList;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
@@ -52,6 +53,7 @@
import javax.swing.event.DocumentListener;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListDataEvent;
+import javax.swing.plaf.basic.BasicComboBoxRenderer;

import net.dpml.transit.model.HostModel;
import net.dpml.transit.model.LayoutRegistryModel;
@@ -195,6 +197,7 @@
m_strategy = new LayoutComboBoxModel( m_layouts, m_model );
m_strategy.addListDataListener( this );
JComboBox strategy = new JComboBox( m_strategy );
+ strategy.setRenderer( new LayoutRenderer() );
layout.add( strategy, BorderLayout.SOUTH );

// sign-on credentials
@@ -305,6 +308,32 @@
// HostListener
//--------------------------------------------------------------

+ private class LayoutRenderer extends BasicComboBoxRenderer
+ {
+ public Component getListCellRendererComponent(
+ JList list, Object value, int index, boolean isSelected, boolean
cellHasFocus)
+ {
+ if( value instanceof LayoutModel )
+ {
+ try
+ {
+ LayoutModel model = (LayoutModel) value;
+ String title = " " + model.getTitle();
+ return super.getListCellRendererComponent(
+ list, title, index, isSelected, cellHasFocus );
+ }
+ catch( RemoteException e )
+ {
+ throw new RuntimeException( e.getMessage(),
e.getCause() );
+ }
+ }
+ else
+ {
+ return super.getListCellRendererComponent( list, value,
index, isSelected, cellHasFocus );
+ }
+ }
+ }
+
private class RemoteHostListener extends UnicastRemoteObject implements
HostListener
{
public RemoteHostListener() throws RemoteException
@@ -317,7 +346,7 @@
* @param event the host change event
*/
public void hostChanged( HostChangeEvent event )
- {
+ {
}

/**

Modified:
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
Fri Jun 17 13:01:10 2005
@@ -85,8 +85,6 @@
}
try
{
- logger.info( "Listing tree: " + prefs );
- prefs.exportSubtree( System.out );
String[] names = prefs.childrenNames();
logger.info( "Station Entry Count: " + names.length );
CodeBaseProfile[] profiles = new CodeBaseProfile[ names.length ];

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultCacheModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultCacheModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultCacheModel.java
Fri Jun 17 13:01:10 2005
@@ -64,6 +64,8 @@

private final Set m_list = Collections.synchronizedSortedSet( new
TreeSet() );

+ private HostModel[] m_sortedHosts;
+
private File m_cache;

private LayoutModel m_layout;
@@ -93,6 +95,7 @@
m_registry = registry;
setCacheDirectory( cache, false );
m_layout.addDisposalListener( this );
+ m_sortedHosts = sortHosts();
for( int i=0; i<hosts.length; i++ )
{
HostModel host = hosts[i];
@@ -203,7 +206,7 @@
{
synchronized( m_lock )
{
- return (HostModel[]) m_list.toArray( new HostModel[0] );
+ return m_sortedHosts;
}
}

@@ -248,6 +251,7 @@
catch( UnknownKeyException e )
{
m_list.add( manager );
+ m_sortedHosts = sortHosts();
if( notify )
{
HostAddedEvent event = new HostAddedEvent( this, manager
);
@@ -263,6 +267,7 @@
{
model.dispose();
m_list.remove( model );
+ m_sortedHosts = sortHosts();
HostRemovedEvent event = new HostRemovedEvent( this, model );
enqueueEvent( event );
}
@@ -387,6 +392,21 @@
}
}

+ private HostModel[] sortHosts() throws RemoteException
+ {
+ synchronized( m_lock )
+ {
+ HostModel[] hosts = (HostModel[]) m_list.toArray( new
HostModel[0] );
+ HostModel[] list = new HostModel[ hosts.length ];
+ for( int i=0; i<hosts.length; i++ )
+ {
+ list[i] = hosts[i];
+ }
+ Arrays.sort( list );
+ return list;
+ }
+ }
+
private File getAnchorDirectory()
{
return Transit.DPML_DATA;

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultHostModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultHostModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultHostModel.java
Fri Jun 17 13:01:10 2005
@@ -276,7 +276,7 @@
catch( RemoteException e )
{
final String error =
- "Unable to compare host dur to a remote exception.";
+ "Unable to compare host due to a remote exception.";
throw new ModelRuntimeException( error, e );
}
}



  • svn commit: r2868 - in development/main: depot/console/etc/bin depot/console/src/main/net/dpml/depot depot/console/src/main/net/dpml/depot/logging depot/prefs/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/station transit/core/handler/src/main/net/dpml/transit/model, mcconnell, 06/17/2005

Archive powered by MHonArc 2.6.24.

Top of Page