Skip to Content.
Sympa Menu

notify-dpml - r1496 - trunk/main/metro/runtime/src/main/net/dpml/metro/runtime

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1496 - trunk/main/metro/runtime/src/main/net/dpml/metro/runtime
  • Date: Mon, 5 Jun 2006 13:26:18 +0200

Author: mcconnell
Date: 2006-06-05 13:26:13 +0200 (Mon, 05 Jun 2006)
New Revision: 1496

Modified:

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
Log:
cleanup logging category name creation (trim leading and trailing periods)

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-06-05 06:19:02 UTC (rev 1495)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-06-05 11:26:13 UTC (rev 1496)
@@ -387,79 +387,6 @@
return loadServices( type, classloader );
}

- /*
- private ClassLoader createClassLoader( ClassLoader anchor, Classpath
classpath, String name )
- {
- ClassLoader parent = anchor;
- final ClassLoader base = getClass().getClassLoader();
- final ClasspathDirective[] cpds = directive.getClasspathDirectives();
- for( int i=0; i<cpds.length; i++ )
- {
- ClasspathDirective cpd = cpds[i];
- Category tag = cpd.getCategory();
- URI[] uris = filter( cpd.getURIs(), parent );
- if( uris.length > 0 )
- {
- parent = new CompositionClassLoader( null, tag, base, uris,
parent );
- }
- }
- return parent;
- }
-
- private URI[] filter( URI[] uris, ClassLoader classloader )
- {
- if( classloader instanceof URLClassLoader )
- {
- URLClassLoader loader = (URLClassLoader) classloader;
- return filterURLClassLoader( uris, loader );
- }
- else
- {
- return uris;
- }
- }
-
- private URI[] filterURLClassLoader( URI[] uris, URLClassLoader parent )
- {
- ArrayList list = new ArrayList();
- for( int i = ( uris.length - 1 ); i>-1; i-- )
- {
- URI uri = uris[i];
- String path = uri.toString();
- if( !exists( uri, parent ) )
- {
- list.add( uri );
- }
- }
- return (URI[]) list.toArray( new URI[0] );
- }
-
- private boolean exists( URI uri, URLClassLoader classloader )
- {
- ClassLoader parent = classloader.getParent();
- if( parent instanceof URLClassLoader )
- {
- URLClassLoader loader = (URLClassLoader) parent;
- if( exists( uri, loader ) )
- {
- return true;
- }
- }
- String ref = uri.toString();
- URL[] urls = classloader.getURLs();
- for( int i=0; i<urls.length; i++ )
- {
- URL url = urls[i];
- String spec = url.toString();
- if( spec.equals( ref ) )
- {
- return true;
- }
- }
- return false;
- }
- */
-
private Logger getLogger()
{
return m_logger;
@@ -567,9 +494,35 @@
String getPathForLogger( DefaultComponentHandler handler )
{
String path = handler.getPath();
- return path.replace( '/', '.' );
+ String category = path.replace( '/', '.' );
+ return trimCategoryPath( category );
}

+ String trimCategoryPath( String path )
+ {
+ if( null == path )
+ {
+ return "";
+ }
+ else
+ {
+ if( path.startsWith( "." ) )
+ {
+ String substring = path.substring( 1 );
+ return trimCategoryPath( substring );
+ }
+ else if( path.endsWith( "." ) )
+ {
+ String substring = path.substring( 0, path.length() - 1 );
+ return trimCategoryPath( substring );
+ }
+ else
+ {
+ return path;
+ }
+ }
+ }
+
Object getContextValue( DefaultComponentHandler handler, String key )
throws ControlException
{
try

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-06-05 06:19:02 UTC (rev 1495)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-06-05 11:26:13 UTC (rev 1496)
@@ -262,38 +262,6 @@
return m_controller.getCompositionController();
}

- /**
- * Create a nested component handler.
- * @param anchor the anchor classloader
- * @param uri the component part definition
- * @return the component handler
- * @exception Exception if an error occurs during component loading or
establishment
- */
- //public ComponentHandler createComponentHandler( ClassLoader anchor,
URI uri ) throws Exception
- //{
- /*
- Directive directive = getController().loadDirective( uri );
- if( directive instanceof ComponentDirective )
- {
- ComponentDirective cd = (ComponentDirective) directive;
- String partition = getPath() + "/";
- Classpath classpath = m_model.getClasspath();
- ComponentModel model =
- m_controller.createComponentModel( anchor, classpath,
partition, cd );
- return m_controller.createDefaultComponentHandler(
- this, anchor, model, true );
- }
- else
- {
- final String error =
- "Component directive class ["
- + directive.getClass()
- + "] is not supported.";
- throw new IllegalArgumentException( error );
- }
- */
- //}
-

//--------------------------------------------------------------------------
// ModelListener

//--------------------------------------------------------------------------
@@ -1024,7 +992,8 @@
catch( Exception e )
{
final String error =
- "Per-thread lifestyle policy handler encountered an error
while attempting to establish instance.";
+ "Per-thread lifestyle policy handler encountered an error "
+ + "while attempting to establish instance.";
throw new ControllerRuntimeException( error, e );
}
}




  • r1496 - trunk/main/metro/runtime/src/main/net/dpml/metro/runtime, mcconnell at BerliOS, 06/05/2006

Archive powered by MHonArc 2.6.24.

Top of Page