notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1237 - in trunk/main: depot/library/src/main/net/dpml/library/impl station/server/src/main/net/dpml/station/server
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1237 - in trunk/main: depot/library/src/main/net/dpml/library/impl station/server/src/main/net/dpml/station/server
- Date: Tue, 21 Mar 2006 04:12:52 +0100
Author: mcconnell
Date: 2006-03-21 04:12:33 +0100 (Tue, 21 Mar 2006)
New Revision: 1237
Modified:
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultLibrary.java
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
Log:
* first steps on resolving module issue
* extra error handling in station server
Modified:
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultLibrary.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultLibrary.java
2006-03-21 01:01:02 UTC (rev 1236)
+++
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultLibrary.java
2006-03-21 03:12:33 UTC (rev 1237)
@@ -129,12 +129,13 @@
}
}
}
- DefaultModule[] importModules = new DefaultModule[
importModuleDirectives.length ];
- m_imports = new DefaultModule( this, m_directive, importModules );
+ //DefaultModule[] importModules = new DefaultModule[
importModuleDirectives.length ];
+ m_imports = new DefaultModule( this, m_directive );
for( int i=0; i<importModuleDirectives.length; i++ )
{
ModuleDirective importModuleDirective =
importModuleDirectives[i];
- importModules[i] = new DefaultModule( this, m_imports,
importModuleDirective );
+ m_imports.addResource( importModuleDirective );
+ //importModules[i] = new DefaultModule( this, m_imports,
importModuleDirective );
}
// create the top-level modules
@@ -156,13 +157,16 @@
throw new IllegalArgumentException( error );
}
}
+
ModuleDirective[] values = (ModuleDirective[])
moduleDirectives.toArray( new ModuleDirective[0] );
- DefaultModule[] modules = new DefaultModule[ values.length ];
- m_module = new DefaultModule( this, m_directive, modules );
- for( int i=0; i<modules.length; i++ )
+ //DefaultModule[] modules = new DefaultModule[ values.length ];
+ //m_module = new DefaultModule( this, m_directive, modules );
+ m_module = new DefaultModule( this, m_directive );
+ for( int i=0; i<values.length; i++ )
{
ModuleDirective md = values[i];
- modules[i] = new DefaultModule( this, m_module, md );
+ m_module.addResource( md );
+ //modules[i] = new DefaultModule( this, m_module, md );
}
}
@@ -422,8 +426,10 @@
}
try
{
- DefaultModule module = new DefaultModule( this, m_module,
enclosing );
- DefaultModule root = new DefaultModule( this, m_directive, new
DefaultModule[]{module} );
+ //DefaultModule module = new DefaultModule( this, m_module,
enclosing );
+ //DefaultModule root = new DefaultModule( this, m_directive, new
DefaultModule[]{module} );
+ DefaultModule root = new DefaultModule( this, m_directive );
+ root.addResource( enclosing );
DefaultResource resource = root.getDefaultResource( group + "/"
+ name );
m_anonymous.put( urn, resource );
return resource;
Modified:
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
2006-03-21 01:01:02 UTC (rev 1236)
+++
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
2006-03-21 03:12:33 UTC (rev 1237)
@@ -25,6 +25,8 @@
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.Properties;
+import java.util.Hashtable;
+import java.util.Map;
import net.dpml.library.info.Scope;
import net.dpml.library.info.AbstractDirective;
@@ -39,6 +41,7 @@
import net.dpml.library.ModuleNotFoundException;
import net.dpml.lang.Category;
+import net.dpml.lang.DuplicateKeyException;
/**
* A Module is a collection of resources. It serves to establish a
@@ -52,8 +55,9 @@
public final class DefaultModule extends DefaultResource implements Module
{
private final boolean m_root;
- private final DefaultResource[] m_resources;
+ //private final DefaultResource[] m_resources;
private final ModuleDirective m_directive;
+ private final Map m_map = new Hashtable();
/**
* Constructor used by the library to create a virtual root module os
shared
@@ -62,18 +66,16 @@
* @param directive the library directive from which common properties
are established
* @param resources the array of top-level modules
*/
- DefaultModule( DefaultLibrary library, AbstractDirective directive,
DefaultResource[] resources )
- throws Exception
+ DefaultModule( DefaultLibrary library, AbstractDirective directive )
{
super( library, directive );
- m_resources = resources;
+ //m_resources = resources;
m_root = true;
m_directive = null;
-
}
DefaultModule( DefaultLibrary library, DefaultModule module,
ModuleDirective directive )
- throws Exception
+ throws DuplicateKeyException
{
super( library, module, directive );
@@ -82,30 +84,40 @@
ResourceDirective[] directives = directive.getResourceDirectives();
for( int i=0; i<directives.length; i++ )
{
- if( null == directives[i] )
- {
- throw new NullPointerException( "directive" );
- }
+ ResourceDirective res = directives[i];
+ addResource( res );
}
- DefaultResource[] resources = new DefaultResource[ directives.length
];
- for( int i=0; i<directives.length; i++ )
+ }
+
+ DefaultResource addResource( ResourceDirective directive ) throws
DuplicateKeyException
+ {
+ if( null == directive )
{
- ResourceDirective res = directives[i];
- if( null == res )
+ throw new NullPointerException( "directive" );
+ }
+
+ String key = directive.getName();
+ if( m_map.containsKey( key ) )
+ {
+ throw new DuplicateKeyException( key );
+ }
+ else
+ {
+ DefaultLibrary library = getDefaultLibrary();
+ if( directive instanceof ModuleDirective )
{
- throw new NullPointerException( "resource" );
+ ModuleDirective d = (ModuleDirective) directive;
+ DefaultModule module = new DefaultModule( library, this, d );
+ m_map.put( key, module );
+ return module;
}
- if( res instanceof ModuleDirective )
- {
- ModuleDirective d = (ModuleDirective) res;
- resources[i] = new DefaultModule( library, this, d );
- }
else
{
- resources[i] = new DefaultResource( library, this, res );
+ DefaultResource resource = new DefaultResource( library,
this, directive );
+ m_map.put( key, resource );
+ return resource;
}
}
- m_resources = resources;
}
//----------------------------------------------------------------------------
@@ -417,7 +429,8 @@
DefaultResource[] getDefaultResources()
{
- return m_resources;
+ return (DefaultResource[]) m_map.values().toArray( new
DefaultResource[0] );
+ //return m_resources;
}
DefaultResource getDefaultResource( String ref )
Modified:
trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
2006-03-21 01:01:02 UTC (rev 1236)
+++
trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
2006-03-21 03:12:33 UTC (rev 1237)
@@ -25,6 +25,7 @@
import net.dpml.cli.Option;
import net.dpml.cli.Group;
import net.dpml.cli.CommandLine;
+import net.dpml.cli.OptionException;
import net.dpml.cli.commandline.Parser;
import net.dpml.cli.builder.ArgumentBuilder;
import net.dpml.cli.builder.GroupBuilder;
@@ -54,7 +55,7 @@
private RemoteStation m_station;
/**
- * Creation of a ne station server plugin for station commandline
+ * Creation of a new station server plugin for station commandline
* handling.
* @param logger the assigned logging channel
* @param args the command line arguments array
@@ -68,7 +69,22 @@
Parser parser = new Parser();
parser.setGroup( COMMAND_GROUP );
- m_line = parser.parse( args );
+ try
+ {
+ m_line = parser.parse( args );
+ }
+ catch( OptionException e )
+ {
+ final String message = "Server commandline processing error.";
+ StringBuffer buffer = new StringBuffer( message );
+ buffer.append( "\nArgument count: " + args.length );
+ for( int i=0; i<args.length; i++ )
+ {
+ buffer.append( "\n arg (" + i + "): [" + args[i] + "]" );
+ }
+ String error = buffer.toString();
+ throw new Exception( error, e );
+ }
}
/**
- r1237 - in trunk/main: depot/library/src/main/net/dpml/library/impl station/server/src/main/net/dpml/station/server, mcconnell at BerliOS, 03/20/2006
Archive powered by MHonArc 2.6.24.