notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2262 - in development/main/metro: . composition/control/src/main/net/dpml/composition/control composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/unit
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2262 - in development/main/metro: . composition/control/src/main/net/dpml/composition/control composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/unit
- Date: Mon, 11 Apr 2005 01:46:50 -0400
Author: mcconnell AT dpml.net
Date: Mon Apr 11 01:46:49 2005
New Revision: 2262
Added:
development/main/metro/composition/testing/unit/build.properties
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
development/main/metro/composition/testing/acme/build.xml
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadColorException.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadWidget.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/GizmoComponent.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetComponent.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetValue.java
development/main/metro/composition/testing/unit/build.xml
development/main/metro/index.xml
Log:
Update codebase to (a) provide support for java.util.logging.Logger in a
component constructor, (b) initial LogManager configuration in the
CompositionManager, and (c) update all ACME examples to user
java.util.logging.Logger.
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
Mon Apr 11 01:46:49 2005
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Map.Entry;
+import java.util.logging.Logger;
import java.lang.reflect.Proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -58,8 +59,6 @@
import net.dpml.composition.models.StandardComponentModel;
import net.dpml.composition.models.ValueModel;
-import net.dpml.logging.Logger;
-
import net.dpml.system.SystemContext;
import net.dpml.transit.artifact.Handler;
@@ -481,6 +480,14 @@
return this;
}
+ public Logger getLogChannel( StandardComponentModel model )
+ {
+ URI uri = model.getURI();
+ String path = model.getURI().getSchemeSpecificPart();
+ String channel = path.replace( '/', '.' );
+ return Logger.getLogger( channel );
+ }
+
public Object getLoggingChannel( StandardComponentModel model )
{
URI uri = model.getURI();
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
Mon Apr 11 01:46:49 2005
@@ -21,11 +21,19 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import java.util.WeakHashMap;
import java.util.ArrayList;
+import java.util.Properties;
+import java.util.logging.Logger;
+import java.util.logging.Handler;
+import java.util.logging.LogManager;
import net.dpml.automation.part.Part;
@@ -44,8 +52,6 @@
import net.dpml.system.SystemContext;
-import net.dpml.logging.Logger;
-
/**
* The CompositionManager is a top-level manager responsible for the
management
* of an arbitary collection of component models.
@@ -73,13 +79,45 @@
super( new DefaultMonitor( system.getLogger() ), system,
createPartition( system ) );
URI partition = createPartition( system );
- ClassLoader anchor = Logger.class.getClassLoader();
+ ClassLoader anchor = net.dpml.logging.Logger.class.getClassLoader();
m_classloader = new CompositionClassLoader( partition, anchor );
m_context = system;
m_partition = partition;
setShutdownHook( this );
+
+ //
+ // quick-and-dirty log manager setup
+ //
+
+ Properties properties = new Properties();
+ properties.setProperty(
+ ".level",
+ "INFO" );
+ properties.setProperty(
+ "handlers",
+ "java.util.logging.ConsoleHandler" );
+ properties.setProperty(
+ "java.util.logging.ConsoleHandler.formatter",
+ "net.dpml.transit.adapter.StandardFormatter" );
+ properties.setProperty(
+ "java.util.logging.ConsoleHandler.level",
+ "INFO" );
+
+ 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/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
Mon Apr 11 01:46:49 2005
@@ -107,7 +107,11 @@
for( int i=0; i<classes.length; i++ )
{
Class c = classes[i];
- if( Logger.class.isAssignableFrom( c ) )
+ if( java.util.logging.Logger.class.isAssignableFrom( c ) )
+ {
+ args[i] = model.getCompositionController().getLogChannel(
model );
+ }
+ else if( Logger.class.isAssignableFrom( c ) )
{
args[i] =
model.getCompositionController().getLoggingChannel( model );
}
Modified: development/main/metro/composition/testing/acme/build.xml
==============================================================================
--- development/main/metro/composition/testing/acme/build.xml (original)
+++ development/main/metro/composition/testing/acme/build.xml Mon Apr 11
01:46:49 2005
@@ -11,6 +11,7 @@
<types xmlns="plugin:dpml/composition/dpml-composition-builder">
<type class="net.dpml.composition.testing.WidgetComponent"/>
<type class="net.dpml.composition.testing.GizmoComponent"/>
+ <type class="net.dpml.composition.testing.WidgetValue"/>
<type class="net.dpml.composition.testing.BadWidget"/>
<type class="net.dpml.composition.testing.AcmeContainer"/>
</types>
Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
Mon Apr 11 01:46:49 2005
@@ -21,7 +21,7 @@
import java.io.File;
import java.util.Map.Entry;
-import net.dpml.logging.Logger;
+import java.util.logging.Logger;
/**
* A simple class composed of two parts (widget and gizmo).
@@ -73,12 +73,11 @@
// get the widget's color context manager and play with some values
//
- getLogger().debug( "getting widget context manager" );
+ getLogger().info( "getting widget context manager" );
ColorContextManager manager = parts.getGizmoContextManager();
String color = manager.getColor( "purple" );
- getLogger().debug( "initial color: " + color );
+
manager.setColor( "blue" );
- getLogger().debug( "getting gizmo" );
Gizmo gizmo = parts.getGizmo();
gizmo.doGizmoStuff();
manager.setColor( "orange" );
@@ -91,18 +90,17 @@
// our parts interface
//
- getLogger().debug( "getting gizmo impl" );
+ debug( "getting gizmo impl" );
Entry entry = parts.createGizmo();
GizmoComponent newGizmo = (GizmoComponent) entry.getValue();
- getLogger().debug( "getting identified gizmo" );
+ debug( "getting identified gizmo" );
Gizmo myGizmo = parts.getGizmo( "my-gizmo" );
- getLogger().debug( "releasing stuff" );
+ debug( "cleaning up" );
parts.releaseGizmo( gizmo );
parts.releaseGizmo( myGizmo );
parts.releaseGizmo( newGizmo );
- getLogger().debug( "done" );
}
private Logger getLogger()
@@ -167,4 +165,9 @@
void releaseGizmo( Gizmo gizmo );
}
+
+ private void debug( String message )
+ {
+ getLogger().fine( message );
+ }
}
Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadColorException.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadColorException.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadColorException.java
Mon Apr 11 01:46:49 2005
@@ -18,8 +18,6 @@
package net.dpml.composition.testing;
-import net.dpml.logging.Logger;
-
/**
* An exception that is thrown by the BadWidget
*
Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadWidget.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadWidget.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/BadWidget.java
Mon Apr 11 01:46:49 2005
@@ -18,7 +18,7 @@
package net.dpml.composition.testing;
-import net.dpml.logging.Logger;
+import java.util.logging.Logger;
/**
* Component implementation that demonstrates the use of a context
inner-class.
Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/GizmoComponent.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/GizmoComponent.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/GizmoComponent.java
Mon Apr 11 01:46:49 2005
@@ -18,7 +18,7 @@
package net.dpml.composition.testing;
-import net.dpml.logging.Logger;
+import java.util.logging.Logger;
/**
* AbstractCompositionTestCase
@@ -86,7 +86,7 @@
public void dispose()
{
- m_logger.debug( "disposal" );
+ m_logger.fine( "disposal" );
}
//------------------------------------------------------------------
Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetComponent.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetComponent.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetComponent.java
Mon Apr 11 01:46:49 2005
@@ -20,8 +20,7 @@
import java.io.File;
import java.net.URI;
-
-import net.dpml.logging.Logger;
+import java.util.logging.Logger;
/**
* Component implementation that demonstrates the use of a context
inner-class.
@@ -90,7 +89,7 @@
+ "] with a working dir ["
+ work
+ "].";
- logger.debug( message );
+ logger.fine( message );
}
//------------------------------------------------------------------
@@ -120,7 +119,7 @@
*/
public void dispose()
{
- getLogger().debug( "disposal" );
+ getLogger().fine( "disposal" );
}
/**
Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetValue.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetValue.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetValue.java
Mon Apr 11 01:46:49 2005
@@ -19,6 +19,7 @@
package net.dpml.composition.testing;
import java.util.logging.Logger;
+import java.util.logging.Handler;
/**
* Component implementation that demonstrates the use of a context
inner-class.
@@ -29,6 +30,21 @@
public class WidgetValue implements Widget
{
//------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ private final Logger m_logger;
+
+ //------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------
+
+ public WidgetValue( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ //------------------------------------------------------------------
// Widget
//------------------------------------------------------------------
@@ -37,8 +53,7 @@
*/
public void doWidgetStuff( String color )
{
- Logger logger = Logger.getAnonymousLogger();
- logger.info( "Creating a " + color + " widget." );
+ m_logger.info( "Creating a " + color + " widget." );
}
}
Added: development/main/metro/composition/testing/unit/build.properties
==============================================================================
--- (empty file)
+++ development/main/metro/composition/testing/unit/build.properties Mon
Apr 11 01:46:49 2005
@@ -0,0 +1,2 @@
+
+project.test.fork = true
Modified: development/main/metro/composition/testing/unit/build.xml
==============================================================================
--- development/main/metro/composition/testing/unit/build.xml (original)
+++ development/main/metro/composition/testing/unit/build.xml Mon Apr 11
01:46:49 2005
@@ -92,7 +92,7 @@
class="net.dpml.composition.testing.AcmeContainer"
name="acme">
<parts>
- <value key="widget"
class="net.dpml.composition.testing.WidgetValue"/>
+ <component name="widget"
class="net.dpml.composition.testing.WidgetValue"/>
<component name="gizmo"
class="net.dpml.composition.testing.GizmoComponent">
<context>
<value key="color" value="red"/>
Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Mon Apr 11 01:46:49 2005
@@ -447,6 +447,7 @@
<include key="dpml-automation-control" tag="spi"/>
<include key="dpml-composition-api" tag="spi"/>
<include key="dpml-system-api" tag="spi"/>
+ <include key="dpml-util-exception"/>
</dependencies>
</project>
@@ -505,9 +506,6 @@
<type>part</type>
</types>
</info>
- <dependencies>
- <include key="dpml-logging-api"/>
- </dependencies>
<plugins>
<include key="dpml-composition-builder"/>
</plugins>
- svn commit: r2262 - in development/main/metro: . composition/control/src/main/net/dpml/composition/control composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/unit, mcconnell, 04/10/2005
Archive powered by MHonArc 2.6.24.