notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1778 - in development/main/home/transit/handler/src/main/net/dpml/transit: . monitors
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1778 - in development/main/home/transit/handler/src/main/net/dpml/transit: . monitors
- Date: Mon, 14 Feb 2005 15:56:24 +0100
Author: mcconnell
Date: Mon Feb 14 15:56:24 2005
New Revision: 1778
Added:
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/ConsoleSystemMonitor.java
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/SilentSystemMonitor.java
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/SystemMonitor.java
Modified:
development/main/home/transit/handler/src/main/net/dpml/transit/Main.java
Log:
Enhancements concerning system monitoring.
Modified:
development/main/home/transit/handler/src/main/net/dpml/transit/Main.java
==============================================================================
--- development/main/home/transit/handler/src/main/net/dpml/transit/Main.java
(original)
+++ development/main/home/transit/handler/src/main/net/dpml/transit/Main.java
Mon Feb 14 15:56:24 2005
@@ -36,6 +36,9 @@
import net.dpml.transit.monitors.RepositoryMonitor;
import net.dpml.transit.monitors.CacheMonitor;
import net.dpml.transit.monitors.NetworkMonitor;
+import net.dpml.transit.monitors.SystemMonitor;
+import net.dpml.transit.monitors.ConsoleSystemMonitor;
+import net.dpml.transit.monitors.SilentSystemMonitor;
import net.dpml.transit.util.Dictionary;
/**
@@ -115,10 +118,25 @@
}
//
+ // Setup the system monitor.
+ //
+
+ boolean silent = false;
+ for( int i=0; i < args.length; i++ )
+ {
+ String arg = args[i];
+ if( "-Xsilent".equals( args[i] ) )
+ {
+ silent = true;
+ break;
+ }
+ }
+
+ //
// setup transit
//
- Monitor monitor = new BootstrapMonitor( debug );
+ SystemMonitor monitor = getSystemMonitor( silent, debug );
Transit transit = Transit.getInstance( monitor );
Adapter adapter = new ConsoleAdapter( debug );
RepositoryMonitor repoMonitor = new RepositoryMonitorAdapter(
adapter );
@@ -179,6 +197,7 @@
URI uri = Artifact.createArtifact( path ).toURI();
Map data = new Hashtable();
+ data.put( "urn:transit.system.monitor", monitor );
data.put( "urn:transit.repository.monitor", repoMonitor );
data.put( "urn:transit.cache.monitor", cacheMonitor );
data.put( "urn:transit.network.monitor", netMonitor );
@@ -194,6 +213,25 @@
}
/**
+ * Return the system monitor
+ *
+ * @param silent if TRUE return a silent monitor elese return a console
monitor
+ * @param debug the debug policy
+ * @return the system monitor
+ */
+ private static SystemMonitor getSystemMonitor( boolean console, boolean
debug )
+ {
+ if( console )
+ {
+ return new ConsoleSystemMonitor( debug );
+ }
+ else
+ {
+ return new SilentSystemMonitor( debug );
+ }
+ }
+
+ /**
* Remove any locally handled command line parameters from the supplied
args.
* @param args the commandline args
* @return the applications arugments
@@ -227,54 +265,5 @@
{
// disabled
}
-
- /**
- * Internal monitor used to handle debug level trace messages
- * produced by transit during initialization.
- */
- private static class BootstrapMonitor implements Monitor
- {
- /**
- * The transit lead tag.
- */
- private static final String TAG = "[transit] ";
-
- /**
- * The trace enabled state.
- */
- private final boolean m_trace;
-
- /**
- * Creation of a new bootstrap monitor.
- * @param trace the trace enable flag
- */
- public BootstrapMonitor( boolean trace )
- {
- m_trace = trace;
- }
-
- /**
- * Test is trace monitoring is enabled.
- * @return true if debug trace messages are enabled elese false
- */
- public boolean isTraceEnabled()
- {
- return m_trace;
- }
-
- /**
- * Process a trace message.
- *
- * @param message the trace level message
- */
- public void trace( String message )
- {
- if( isTraceEnabled() )
- {
- System.out.print( TAG );
- System.out.println( message );
- }
- }
- }
}
Added:
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/ConsoleSystemMonitor.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/ConsoleSystemMonitor.java
Mon Feb 14 15:56:24 2005
@@ -0,0 +1,80 @@
+/*
+ * 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.transit.monitors;
+
+import java.net.URL;
+
+/**
+ * Monitor used to handle debug level trace messages
+ * produced by transit during initialization.
+ */
+ public class ConsoleSystemMonitor implements SystemMonitor
+ {
+ /**
+ * The transit lead tag.
+ */
+ private static final String TAG = "[transit] ";
+
+ /**
+ * The trace enabled state.
+ */
+ private final boolean m_trace;
+
+ /**
+ * Creation of a new bootstrap monitor.
+ * @param trace the trace enable flag
+ */
+ public ConsoleSystemMonitor( boolean trace )
+ {
+ m_trace = trace;
+ }
+
+ /**
+ * Test is trace monitoring is enabled.
+ * @return true if debug trace messages are enabled elese false
+ */
+ public boolean isTraceEnabled()
+ {
+ return m_trace;
+ }
+
+ /**
+ * Process a trace message.
+ *
+ * @param message the trace level message
+ */
+ public void trace( String message )
+ {
+ if( isTraceEnabled() )
+ {
+ System.out.print( TAG );
+ System.out.println( message );
+ }
+ }
+
+ /**
+ * Notification of the authority url established by Transit.
+ * @param authority URL authority url
+ */
+ public void notifyAuthority( URL authority )
+ {
+ trace( "authority established on: " + authority );
+ }
+}
+
Added:
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/SilentSystemMonitor.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/SilentSystemMonitor.java
Mon Feb 14 15:56:24 2005
@@ -0,0 +1,81 @@
+/*
+ * 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.transit.monitors;
+
+import java.net.URL;
+
+/**
+ * Monitor used to hold information about the transit establishment and
settings.
+ */
+ public class SilentSystemMonitor implements SystemMonitor
+ {
+ /**
+ * The transit lead tag.
+ */
+ private static final String TAG = "[transit] ";
+
+ private URL m_authority;
+
+ /**
+ * The trace enabled state.
+ */
+ private final boolean m_trace;
+
+ /**
+ * Creation of a new bootstrap monitor.
+ * @param trace the trace enable flag
+ */
+ public SilentSystemMonitor( boolean trace )
+ {
+ m_trace = trace;
+ }
+
+ /**
+ * Test is trace monitoring is enabled.
+ * @return true if debug trace messages are enabled elese false
+ */
+ public boolean isTraceEnabled()
+ {
+ return m_trace;
+ }
+
+ /**
+ * Process a trace message.
+ *
+ * @param message the trace level message
+ */
+ public void trace( String message )
+ {
+ if( isTraceEnabled() )
+ {
+ System.out.print( TAG ); // change me
+ System.out.println( message ); // change me
+ }
+ }
+
+ /**
+ * Notification of the authority url established by Transit.
+ * @param authority URL authority url
+ */
+ public void notifyAuthority( URL authority )
+ {
+ m_authority = authority;
+ }
+}
+
Added:
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/SystemMonitor.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/handler/src/main/net/dpml/transit/monitors/SystemMonitor.java
Mon Feb 14 15:56:24 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004 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.monitors;
+
+import java.net.URL;
+
+/**
+ * Genric interface marking a class as a monitor.
+ */
+public interface SystemMonitor extends Monitor
+{
+ /**
+ * Notification of the authority url established by Transit.
+ * @param authority URL authority url
+ */
+ void notifyAuthority( URL authority );
+}
+
- svn commit: r1778 - in development/main/home/transit/handler/src/main/net/dpml/transit: . monitors, mcconnell, 02/14/2005
Archive powered by MHonArc 2.6.24.