summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-27 02:52:17 (EDT)
committerEike Stepper2006-10-27 02:52:17 (EDT)
commit1a1db40e2e0c080b5207199cdd4afccaf69657aa (patch)
tree0427bcfe24a0817c5e601ce64d32520a68de3e71
parent09ab88a0e03e429735c75a88365586d18f21c839 (diff)
downloadcdo-1a1db40e2e0c080b5207199cdd4afccaf69657aa.zip
cdo-1a1db40e2e0c080b5207199cdd4afccaf69657aa.tar.gz
cdo-1a1db40e2e0c080b5207199cdd4afccaf69657aa.tar.bz2
Operations & Maintenance
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractOMTest.java49
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java17
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SynchronizingCorrelatorTest.java13
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java32
-rw-r--r--plugins/org.eclipse.net4j/.options10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java41
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyBundle.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiBundle.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiPlatform.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java17
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java11
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java17
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java39
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/IOUtil.java32
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ReflectUtil.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/AsynchronousWorkSerializer.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java21
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java17
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/EclipseLoggingBridge.java13
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMPlatform.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OSGiLoggingBridge.java13
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamLogHandler.java9
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamTraceHandler.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java11
32 files changed, 386 insertions, 99 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractOMTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractOMTest.java
new file mode 100644
index 0000000..251b62b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractOMTest.java
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.tests;
+
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.PrintStreamLogHandler;
+import org.eclipse.net4j.util.om.PrintStreamTraceHandler;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractOMTest extends TestCase
+{
+ protected AbstractOMTest()
+ {
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ this.setUp();
+ System.out.print("================================= ");
+ System.out.print(getName());
+ System.out.println(" =================================");
+
+ OMPlatform.INSTANCE.addLogHandler(PrintStreamLogHandler.CONSOLE);
+ OMPlatform.INSTANCE.addTraceHandler(PrintStreamTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.setDebugging(true);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ System.out.println();
+ System.out.println();
+ Thread.sleep(20);
+ super.tearDown();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
index a06840e..9a0d625 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
@@ -17,8 +17,6 @@ import org.eclipse.net4j.tests.signal.TestSignalProtocol;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.ProtocolFactory;
-import org.eclipse.net4j.transport.util.BufferInputStream;
-import org.eclipse.net4j.transport.util.BufferOutputStream;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.PrintStreamLogHandler;
@@ -39,7 +37,7 @@ import junit.framework.TestCase;
/**
* @author Eike Stepper
*/
-public class SignalTest extends TestCase
+public class SignalTest extends AbstractOMTest
{
private BufferProvider bufferPool;
@@ -53,16 +51,6 @@ public class SignalTest extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- OMPlatform.INSTANCE.addLogHandler(PrintStreamLogHandler.CONSOLE);
- OMPlatform.INSTANCE.addTraceHandler(PrintStreamTraceHandler.CONSOLE);
-
- BufferInputStream.TRACE = true;
- BufferOutputStream.TRACE = true;
-
- System.out.print("================================= ");
- System.out.print(getName());
- System.out.println(" =================================");
-
bufferPool = Net4jFactory.createBufferPool((short)64);
LifecycleUtil.activate(bufferPool);
assertTrue(LifecycleUtil.isActive(bufferPool));
@@ -125,9 +113,6 @@ public class SignalTest extends TestCase
ex.printStackTrace();
}
- System.out.println();
- System.out.println();
- Thread.sleep(100);
super.tearDown();
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SynchronizingCorrelatorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SynchronizingCorrelatorTest.java
index 0a2c4a4..08c063b 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SynchronizingCorrelatorTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SynchronizingCorrelatorTest.java
@@ -12,13 +12,16 @@ package org.eclipse.net4j.tests;
import org.eclipse.net4j.util.concurrent.Synchronizer;
import org.eclipse.net4j.util.concurrent.SynchronizingCorrelator;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.PrintStreamLogHandler;
+import org.eclipse.net4j.util.om.PrintStreamTraceHandler;
import junit.framework.TestCase;
/**
* @author Eike Stepper
*/
-public class SynchronizingCorrelatorTest extends TestCase
+public class SynchronizingCorrelatorTest extends AbstractOMTest
{
public void testPutConsumerFirst() throws Exception
{
@@ -30,7 +33,7 @@ public class SynchronizingCorrelatorTest extends TestCase
public void run()
{
Synchronizer<Boolean> eike = correlator.correlate("eike");
- result[0] = eike.get(10000);
+ result[0] = eike.get(5000);
System.out.println("RESULT: " + result[0]);
}
};
@@ -61,7 +64,7 @@ public class SynchronizingCorrelatorTest extends TestCase
public void run()
{
Synchronizer<Boolean> eike = correlator.correlate("eike");
- result[0] = eike.get(10000);
+ result[0] = eike.get(5000);
System.out.println("RESULT: " + result[0]);
}
};
@@ -97,7 +100,7 @@ public class SynchronizingCorrelatorTest extends TestCase
public void run()
{
Synchronizer<Boolean> eike = correlator.correlate("eike");
- result[0] = eike.get(10000);
+ result[0] = eike.get(5000);
System.out.println("RESULT: " + result[0]);
}
};
@@ -131,7 +134,7 @@ public class SynchronizingCorrelatorTest extends TestCase
public void run()
{
Synchronizer<Boolean> eike = correlator.correlate("eike");
- result[0] = eike.get(10000);
+ result[0] = eike.get(5000);
System.out.println("RESULT: " + result[0]);
}
};
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
index 1688830..e7b5d84 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
@@ -50,7 +50,7 @@ import junit.framework.TestCase;
/**
* @author Eike Stepper
*/
-public class TCPTransportTest extends TestCase
+public class TCPTransportTest extends AbstractOMTest
{
private BufferProvider bufferPool;
@@ -64,13 +64,6 @@ public class TCPTransportTest extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- OMPlatform.INSTANCE.addLogHandler(PrintStreamLogHandler.CONSOLE);
- OMPlatform.INSTANCE.addTraceHandler(PrintStreamTraceHandler.CONSOLE);
-
- System.out.print("================================= ");
- System.out.print(getName());
- System.out.println(" =================================");
-
bufferPool = Net4jFactory.createBufferPool();
LifecycleUtil.activate(bufferPool);
assertTrue(LifecycleUtil.isActive(bufferPool));
@@ -133,9 +126,6 @@ public class TCPTransportTest extends TestCase
ex.printStackTrace();
}
- System.out.println();
- System.out.println();
- Thread.sleep(10);
super.tearDown();
}
@@ -143,14 +133,14 @@ public class TCPTransportTest extends TestCase
{
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
}
public void testSendBuffer() throws Exception
{
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel();
for (int i = 0; i < 3; i++)
@@ -173,7 +163,7 @@ public class TCPTransportTest extends TestCase
acceptor.setProtocolFactoryRegistry(protocolFactoryRegistry);
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel(TestProtocolFactory.PROTOCOL_ID);
for (int i = 0; i < COUNT; i++)
@@ -201,7 +191,7 @@ public class TCPTransportTest extends TestCase
acceptor.setProtocolFactoryRegistry(local);
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel(TestProtocolFactory.PROTOCOL_ID);
for (int i = 0; i < COUNT; i++)
@@ -229,7 +219,7 @@ public class TCPTransportTest extends TestCase
acceptor.setProtocolFactoryRegistry(local);
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel(TestProtocolFactory.PROTOCOL_ID);
for (int i = 0; i < COUNT; i++)
@@ -255,7 +245,7 @@ public class TCPTransportTest extends TestCase
acceptor.setReceiveExecutor(Executors.newCachedThreadPool());
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel(TestProtocolFactory.PROTOCOL_ID);
for (int i = 0; i < COUNT; i++)
@@ -301,7 +291,7 @@ public class TCPTransportTest extends TestCase
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel();
assertTrue(counter.await(2, TimeUnit.SECONDS));
@@ -362,7 +352,7 @@ public class TCPTransportTest extends TestCase
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel();
assertTrue(counter.await(2, TimeUnit.SECONDS));
@@ -430,7 +420,7 @@ public class TCPTransportTest extends TestCase
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
final Channel channel = connector.openChannel();
assertTrue(counter.await(2, TimeUnit.SECONDS));
@@ -512,7 +502,7 @@ public class TCPTransportTest extends TestCase
acceptor.activate();
assertTrue(acceptor.isActive());
- assertTrue(connector.connect(1000));
+ assertTrue(connector.connect(5000));
Channel channel = connector.openChannel();
assertTrue(counter.await(2, TimeUnit.SECONDS));
diff --git a/plugins/org.eclipse.net4j/.options b/plugins/org.eclipse.net4j/.options
index 918a378..2aa7225 100644
--- a/plugins/org.eclipse.net4j/.options
+++ b/plugins/org.eclipse.net4j/.options
@@ -1,10 +1,18 @@
-org.eclipse.net4j/debug = false
+org.eclipse.net4j/debug = true
+
org.eclipse.net4j/debug.lifecycle = true
org.eclipse.net4j/debug.lifecycle.dump = true
+org.eclipse.net4j/debug.concurrency = true
+org.eclipse.net4j/debug.registry = true
+org.eclipse.net4j/debug.om = true
+
org.eclipse.net4j/debug.buffer = true
+org.eclipse.net4j/debug.buffer.stream = true
org.eclipse.net4j/debug.channel = true
org.eclipse.net4j/debug.selector = true
org.eclipse.net4j/debug.acceptor = true
org.eclipse.net4j/debug.connector = true
+org.eclipse.net4j/debug.signal = true
+
org.eclipse.net4j/perf = false
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java
index 9d175ef..7699045 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java
@@ -93,6 +93,11 @@ public abstract class AbstractOMBundle implements OMBundle
public boolean isDebugging()
{
+ if (!platform.isDebugging())
+ {
+ return false;
+ }
+
if (!debuggingInitialized)
{
debugging = getDebugOption("debug", false); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java
index 06d73ea..c58f839 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.internal.net4j.bundle;
+import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMLogHandler;
import org.eclipse.net4j.util.om.OMLogger;
@@ -30,14 +31,19 @@ public abstract class AbstractOMPlatform implements OMPlatform
{
static Object systemContext;
+ private static ContextTracer __TRACER__;
+
private Map<String, AbstractOMBundle> bundles = new ConcurrentHashMap();
private Queue<OMLogHandler> logHandlers = new ConcurrentLinkedQueue();
private Queue<OMTraceHandler> traceHandlers = new ConcurrentLinkedQueue();
+ private boolean debugging;
+
protected AbstractOMPlatform()
{
+ debugging = Boolean.parseBoolean(System.getProperty("debug", "false"));
}
public OMBundle bundle(String bundleID, Class accessor)
@@ -77,6 +83,16 @@ public abstract class AbstractOMPlatform implements OMPlatform
traceHandlers.remove(traceHandler);
}
+ public boolean isDebugging()
+ {
+ return debugging;
+ }
+
+ public void setDebugging(boolean debugging)
+ {
+ this.debugging = debugging;
+ }
+
protected void log(OMLogger logger, Level level, String msg, Throwable t)
{
for (OMLogHandler logHandler : logHandlers)
@@ -87,7 +103,10 @@ public abstract class AbstractOMPlatform implements OMPlatform
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER().isEnabled())
+ {
+ TRACER().trace(ex);
+ }
}
}
}
@@ -102,7 +121,10 @@ public abstract class AbstractOMPlatform implements OMPlatform
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER().isEnabled())
+ {
+ TRACER().trace(ex);
+ }
}
}
}
@@ -124,9 +146,22 @@ public abstract class AbstractOMPlatform implements OMPlatform
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER().isEnabled())
+ {
+ TRACER().trace(ex);
+ }
}
return new LegacyPlatform();
}
+
+ private static ContextTracer TRACER()
+ {
+ if (__TRACER__ == null)
+ {
+ __TRACER__ = new ContextTracer(Net4j.DEBUG_OM, AbstractOMPlatform.class);
+ }
+
+ return __TRACER__;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyBundle.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyBundle.java
index 4cc32b2..548249c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyBundle.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyBundle.java
@@ -40,7 +40,7 @@ public class LegacyBundle extends AbstractOMBundle
}
catch (Exception ex)
{
- ex.printStackTrace();
+ IOUtil.print(ex);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java
index 1131a9c..824d480 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java
@@ -30,8 +30,16 @@ public final class Net4j
public static final OMTracer DEBUG_LIFECYCLE_DUMP = DEBUG_LIFECYCLE.tracer("dump"); //$NON-NLS-1$
+ public static final OMTracer DEBUG_CONCURRENCY = DEBUG.tracer("concurrency"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_REGISTRY = DEBUG.tracer("registry"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_OM = DEBUG.tracer("om"); //$NON-NLS-1$
+
public static final OMTracer DEBUG_BUFFER = DEBUG.tracer("buffer"); //$NON-NLS-1$
+ public static final OMTracer DEBUG_BUFFER_STREAM = DEBUG_BUFFER.tracer("stream"); //$NON-NLS-1$
+
public static final OMTracer DEBUG_CHANNEL = DEBUG.tracer("channel"); //$NON-NLS-1$
public static final OMTracer DEBUG_SELECTOR = DEBUG.tracer("selector"); //$NON-NLS-1$
@@ -40,6 +48,8 @@ public final class Net4j
public static final OMTracer DEBUG_CONNECTOR = DEBUG.tracer("connector"); //$NON-NLS-1$
+ public static final OMTracer DEBUG_SIGNAL = DEBUG.tracer("signal"); //$NON-NLS-1$
+
public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$
public static final OMLogger LOG = BUNDLE.logger();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiBundle.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiBundle.java
index 971a972..ce33622 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiBundle.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiBundle.java
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.internal.net4j.bundle;
+import org.eclipse.net4j.util.IOUtil;
+
import org.eclipse.core.runtime.FileLocator;
import org.osgi.framework.BundleContext;
@@ -42,7 +44,7 @@ public class OSGiBundle extends AbstractOMBundle
}
catch (IOException ex)
{
- ex.printStackTrace();
+ IOUtil.print(ex);
return null;
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiPlatform.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiPlatform.java
index a877305..8cf2b11 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiPlatform.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OSGiPlatform.java
@@ -12,6 +12,7 @@ package org.eclipse.internal.net4j.bundle;
import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.osgi.framework.BundleContext;
@@ -27,6 +28,15 @@ public class OSGiPlatform extends AbstractOMPlatform
public OSGiPlatform(Object systemContext)
{
this.systemContext = (BundleContext)systemContext;
+
+ try
+ {
+ setDebugging(Platform.inDebugMode());
+ }
+ catch (RuntimeException ignore)
+ {
+ ;
+ }
}
@Override
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
index 5c88ad4..dec095a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
@@ -549,14 +549,14 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
throw new IllegalStateException("bufferProvider == null"); //$NON-NLS-1$
}
- if (protocolFactoryRegistry == null)
+ if (protocolFactoryRegistry == null && TRACER.isEnabled())
{
- Net4j.LOG.info("No protocol factory registry for " + this); //$NON-NLS-1$
+ TRACER.trace(toString() + ": No protocol factory registry!"); //$NON-NLS-1$
}
- if (receiveExecutor == null)
+ if (receiveExecutor == null && TRACER.isEnabled())
{
- Net4j.LOG.info("No receive executor for " + this); //$NON-NLS-1$
+ TRACER.trace(toString() + ": No receive executor!"); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
index d7c11c3..c93c9b5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
@@ -299,14 +299,14 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
throw new IllegalStateException("bufferProvider == null"); //$NON-NLS-1$
}
- if (protocolFactoryRegistry == null)
+ if (protocolFactoryRegistry == null && TRACER.isEnabled())
{
- Net4j.LOG.info("No protocol factory registry in " + this); //$NON-NLS-1$
+ TRACER.trace(toString() + ": No protocol factory registry!"); //$NON-NLS-1$
}
- if (receiveExecutor == null)
+ if (receiveExecutor == null && TRACER.isEnabled())
{
- Net4j.LOG.info("No receive executor in " + this); //$NON-NLS-1$
+ TRACER.trace(toString() + ": No receive executor!"); //$NON-NLS-1$
}
if (selector == null)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
index 0675320..eea8b83 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
@@ -12,8 +12,11 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.util.BufferInputStream;
import org.eclipse.net4j.transport.util.BufferOutputStream;
+import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.io.IOException;
/**
@@ -21,6 +24,9 @@ import java.io.IOException;
*/
public abstract class Indication extends SignalReactor
{
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SIGNAL,
+ Indication.class);
+
protected Indication()
{
}
@@ -28,7 +34,11 @@ public abstract class Indication extends SignalReactor
@Override
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
- System.out.println("================ Indicating " + this); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("================ Indicating " + this); //$NON-NLS-1$
+ }
+
indicating(new ExtendedDataInputStream(in));
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
index fc2db11..ce38b9e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
@@ -12,9 +12,12 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.util.BufferInputStream;
import org.eclipse.net4j.transport.util.BufferOutputStream;
+import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.io.IOException;
/**
@@ -22,6 +25,9 @@ import java.io.IOException;
*/
public abstract class IndicationWithResponse extends SignalReactor
{
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SIGNAL,
+ IndicationWithResponse.class);
+
protected IndicationWithResponse()
{
}
@@ -29,10 +35,17 @@ public abstract class IndicationWithResponse extends SignalReactor
@Override
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
- System.out.println("================ Indicating " + this); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("================ Indicating " + this); //$NON-NLS-1$
+ }
+
indicating(new ExtendedDataInputStream(in));
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("================ Responding " + this); //$NON-NLS-1$
+ }
- System.out.println("================ Responding " + this); //$NON-NLS-1$
responding(new ExtendedDataOutputStream(out));
out.flush();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
index 66335f9..e6ef9ae 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
@@ -13,8 +13,11 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.util.BufferInputStream;
import org.eclipse.net4j.transport.util.BufferOutputStream;
+import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.io.IOException;
/**
@@ -22,6 +25,8 @@ import java.io.IOException;
*/
public abstract class Request<RESULT> extends SignalActor<RESULT>
{
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SIGNAL, Request.class);
+
protected Request(Channel channel)
{
super(channel);
@@ -30,7 +35,11 @@ public abstract class Request<RESULT> extends SignalActor<RESULT>
@Override
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
- System.out.println("================ Requesting " + this); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("================ Requesting " + this); //$NON-NLS-1$
+ }
+
requesting(new ExtendedDataOutputStream(out));
out.flush();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
index 40d8544..67cd9f6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
@@ -13,9 +13,12 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.util.BufferInputStream;
import org.eclipse.net4j.transport.util.BufferOutputStream;
+import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.io.IOException;
/**
@@ -23,6 +26,9 @@ import java.io.IOException;
*/
public abstract class RequestWithConfirmation<RESULT> extends SignalActor<RESULT>
{
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SIGNAL,
+ RequestWithConfirmation.class);
+
protected RequestWithConfirmation(Channel channel)
{
super(channel);
@@ -31,11 +37,18 @@ public abstract class RequestWithConfirmation<RESULT> extends SignalActor<RESULT
@Override
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
- System.out.println("================ Requesting " + this); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("================ Requesting " + this); //$NON-NLS-1$
+ }
+
requesting(new ExtendedDataOutputStream(out));
out.flush();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("================ Confirming " + this); //$NON-NLS-1$
+ }
- System.out.println("================ Confirming " + this); //$NON-NLS-1$
setResult(confirming(new ExtendedDataInputStream(in)));
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
index 9a8d10c..0704374 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
@@ -12,12 +12,17 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.util.BufferInputStream;
import org.eclipse.net4j.transport.util.BufferOutputStream;
+import org.eclipse.net4j.util.om.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.Net4j;
/**
* @author Eike Stepper
*/
public abstract class Signal implements Runnable
{
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SIGNAL, Signal.class);
+
private SignalProtocol protocol;
private int correlationID;
@@ -58,7 +63,10 @@ public abstract class Signal implements Runnable
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
finally
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index 2397768..2afc01f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -15,7 +15,9 @@ import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.util.BufferInputStream;
import org.eclipse.net4j.transport.util.ChannelOutputStream;
+import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.transport.AbstractProtocol;
import org.eclipse.internal.net4j.transport.BufferUtil;
import org.eclipse.internal.net4j.transport.ChannelImpl;
@@ -36,6 +38,9 @@ public abstract class SignalProtocol extends AbstractProtocol
private static final int MAX_CORRELATION_ID = Integer.MAX_VALUE;
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SIGNAL,
+ SignalProtocol.class);
+
private ExecutorService executorService;
private Map<Integer, Signal> signals = new ConcurrentHashMap();
@@ -63,7 +68,10 @@ public abstract class SignalProtocol extends AbstractProtocol
{
ByteBuffer byteBuffer = buffer.getByteBuffer();
int correlationID = byteBuffer.getInt();
- System.out.println(toString() + ": Received buffer for correlation " + correlationID); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(toString() + ": Received buffer for correlation " + correlationID); //$NON-NLS-1$
+ }
Signal signal;
if (correlationID > 0)
@@ -73,7 +81,10 @@ public abstract class SignalProtocol extends AbstractProtocol
if (signal == null)
{
short signalID = byteBuffer.getShort();
- System.out.println(toString() + ": Got signal id " + signalID); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(toString() + ": Got signal id " + signalID); //$NON-NLS-1$
+ }
signal = createSignalReactor(signalID);
signal.setProtocol(this);
@@ -90,7 +101,11 @@ public abstract class SignalProtocol extends AbstractProtocol
signal = signals.get(-correlationID);
if (signal == null)
{
- System.out.println(toString() + ": Discarding buffer"); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(toString() + ": Discarding buffer"); //$NON-NLS-1$
+ }
+
buffer.release();
}
}
@@ -138,7 +153,11 @@ public abstract class SignalProtocol extends AbstractProtocol
int correlationID = nextCorrelationID;
if (nextCorrelationID == MAX_CORRELATION_ID)
{
- System.out.println(toString() + ": Correlation wrap around"); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(toString() + ": Correlation wrap around"); //$NON-NLS-1$
+ }
+
nextCorrelationID = MIN_CORRELATION_ID;
}
else
@@ -185,12 +204,20 @@ public abstract class SignalProtocol extends AbstractProtocol
{
Buffer buffer = delegate.provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(getChannel().getChannelID());
+ if (SignalProtocol.TRACER.isEnabled())
+ {
+ SignalProtocol.TRACER.trace("Providing buffer for correlation " + correlationID); //$NON-NLS-1$
+ }
- System.out.println("Providing buffer for correlation " + correlationID); //$NON-NLS-1$
byteBuffer.putInt(correlationID);
if (firstBuffer)
{
- System.out.println(SignalProtocol.this.toString() + ": Put signal id " + signalID); //$NON-NLS-1$
+ if (SignalProtocol.TRACER.isEnabled())
+ {
+ SignalProtocol.TRACER.trace(SignalProtocol.this.toString()
+ + ": Put signal id " + signalID); //$NON-NLS-1$
+ }
+
byteBuffer.putShort(signalID);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java
index d1d5b44..0435510 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java
@@ -13,6 +13,9 @@ package org.eclipse.net4j.transport.util;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferHandler;
import org.eclipse.net4j.util.HexUtil;
+import org.eclipse.net4j.util.om.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.Net4j;
import java.io.IOException;
import java.io.InputStream;
@@ -31,7 +34,8 @@ public class BufferInputStream extends InputStream implements BufferHandler
public static final long DEFAULT_MILLIS_INTERRUPT_CHECK = 100;
- public static boolean TRACE = false;
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_BUFFER_STREAM,
+ BufferInputStream.class);
private BlockingQueue<Buffer> buffers = new LinkedBlockingQueue<Buffer>();
@@ -65,9 +69,9 @@ public class BufferInputStream extends InputStream implements BufferHandler
final byte b = currentBuffer.getByteBuffer().get();
final int result = b < 0 ? ~b : b;
- if (TRACE)
+ if (TRACER.isEnabled())
{
- System.out.println("<-- " + HexUtil.toHex(result) //$NON-NLS-1$
+ TRACER.trace("<-- " + HexUtil.toHex(result) //$NON-NLS-1$
+ (result >= 32 ? " " + Character.toString((char)result) : "")); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
index 1065931..5de5d85 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
@@ -15,6 +15,9 @@ import org.eclipse.net4j.transport.BufferHandler;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.util.HexUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.Net4j;
import java.io.IOException;
import java.io.OutputStream;
@@ -27,7 +30,8 @@ public class BufferOutputStream extends OutputStream
{
public static final boolean DEFAULT_PROPAGATE_CLOSE = false;
- public static boolean TRACE = false;
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_BUFFER_STREAM,
+ BufferOutputStream.class);
private BufferHandler bufferHandler;
@@ -64,9 +68,9 @@ public class BufferOutputStream extends OutputStream
public void write(int b) throws IOException
{
ensureBuffer();
- if (TRACE)
+ if (TRACER.isEnabled())
{
- System.out.println("--> " + HexUtil.toHex(b) //$NON-NLS-1$
+ TRACER.trace("--> " + HexUtil.toHex(b) //$NON-NLS-1$
+ (b >= 32 ? " " + Character.toString((char)b) : "")); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/IOUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/IOUtil.java
index 064b786..b44428c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/IOUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/IOUtil.java
@@ -12,6 +12,7 @@ package org.eclipse.net4j.util;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintStream;
import java.io.Reader;
import java.io.Writer;
@@ -20,10 +21,41 @@ import java.io.Writer;
*/
public final class IOUtil
{
+ private static final InputStream IN = System.in;
+
+ private static final PrintStream OUT = System.out;
+
+ private static final PrintStream ERR = System.err;
+
private IOUtil()
{
}
+ public static InputStream IN()
+ {
+ return IN;
+ }
+
+ public static PrintStream OUT()
+ {
+ return OUT;
+ }
+
+ public static PrintStream ERR()
+ {
+ return ERR;
+ }
+
+ public static void print(Throwable t, PrintStream stream)
+ {
+ t.printStackTrace(stream);
+ }
+
+ public static void print(Throwable t)
+ {
+ print(t, ERR);
+ }
+
public static Exception closeSilent(InputStream stream)
{
try
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ReflectUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ReflectUtil.java
index 56834bf..b4fa20a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ReflectUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ReflectUtil.java
@@ -52,7 +52,7 @@ public final class ReflectUtil
}
catch (Exception ex)
{
- ex.printStackTrace();
+ IOUtil.print(ex);
}
return 0;
@@ -119,7 +119,7 @@ public final class ReflectUtil
public static void dump(Object object, String prefix)
{
- dump(object, prefix, System.out);
+ dump(object, prefix, IOUtil.OUT());
}
public static void dump(Object object, String prefix, PrintStream out)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/AsynchronousWorkSerializer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/AsynchronousWorkSerializer.java
index 62ca646..847de1d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/AsynchronousWorkSerializer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/AsynchronousWorkSerializer.java
@@ -10,6 +10,10 @@
**************************************************************************/
package org.eclipse.net4j.util.concurrent;
+import org.eclipse.net4j.util.om.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
@@ -19,6 +23,9 @@ import java.util.concurrent.ExecutorService;
*/
public class AsynchronousWorkSerializer implements WorkSerializer, Runnable
{
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_CONCURRENCY,
+ AsynchronousWorkSerializer.class);
+
private ExecutorService executorService;
private Queue<Runnable> workQueue;
@@ -58,7 +65,11 @@ public class AsynchronousWorkSerializer implements WorkSerializer, Runnable
occupation.setOccupied(true);
}
- System.out.println(toString() + ": Notifying executor service"); //$NON-NLS-1$
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(toString() + ": Notifying executor service"); //$NON-NLS-1$
+ }
+
executorService.execute(this);
}
}
@@ -81,7 +92,10 @@ public class AsynchronousWorkSerializer implements WorkSerializer, Runnable
}
catch (RuntimeException ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java
index 4587a40..00bd60c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java
@@ -82,7 +82,11 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+
return ex;
}
finally
@@ -122,7 +126,10 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
}
@@ -137,7 +144,10 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
}
@@ -152,7 +162,10 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
index 0eeec29..8473506 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
@@ -10,6 +10,10 @@
**************************************************************************/
package org.eclipse.net4j.util.lifecycle;
+import org.eclipse.net4j.util.om.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
@@ -18,6 +22,9 @@ import java.lang.reflect.Method;
*/
public final class LifecycleUtil
{
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_LIFECYCLE,
+ LifecycleUtil.class);
+
private LifecycleUtil()
{
}
@@ -152,12 +159,18 @@ public final class LifecycleUtil
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
return null;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/EclipseLoggingBridge.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/EclipseLoggingBridge.java
index fca5e03..d662a28 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/EclipseLoggingBridge.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/EclipseLoggingBridge.java
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.bundle.OSGiBundle;
/**
@@ -25,7 +26,10 @@ public class EclipseLoggingBridge implements OMLogHandler
{
public static final EclipseLoggingBridge INSTANCE = new EclipseLoggingBridge();
- private EclipseLoggingBridge()
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_OM,
+ EclipseLoggingBridge.class);
+
+ protected EclipseLoggingBridge()
{
}
@@ -39,11 +43,14 @@ public class EclipseLoggingBridge implements OMLogHandler
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
- private static int toEclipse(Level level)
+ public static int toEclipse(Level level)
{
switch (level)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMPlatform.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMPlatform.java
index 87dda41..ee1a754 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMPlatform.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMPlatform.java
@@ -21,6 +21,10 @@ public interface OMPlatform
public OMBundle bundle(String bundleID, Class accessor);
+ public boolean isDebugging();
+
+ public void setDebugging(boolean debugging);
+
public void addLogHandler(OMLogHandler logHandler);
public void removeLogHandler(OMLogHandler logHandler);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OSGiLoggingBridge.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OSGiLoggingBridge.java
index 1bbe255..9c51652 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OSGiLoggingBridge.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OSGiLoggingBridge.java
@@ -12,6 +12,7 @@ package org.eclipse.net4j.util.om;
import org.eclipse.net4j.util.om.OMLogger.Level;
+import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.bundle.OSGiBundle;
import org.osgi.framework.BundleContext;
@@ -25,7 +26,10 @@ public class OSGiLoggingBridge implements OMLogHandler
{
public static final OSGiLoggingBridge INSTANCE = new OSGiLoggingBridge();
- private OSGiLoggingBridge()
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_OM,
+ OSGiLoggingBridge.class);
+
+ protected OSGiLoggingBridge()
{
}
@@ -38,7 +42,10 @@ public class OSGiLoggingBridge implements OMLogHandler
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
@@ -63,7 +70,7 @@ public class OSGiLoggingBridge implements OMLogHandler
}
}
- private static int toOSGi(Level level)
+ public static int toOSGi(Level level)
{
switch (level)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamLogHandler.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamLogHandler.java
index 15e11e9..bb949be 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamLogHandler.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamLogHandler.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.util.om;
+import org.eclipse.net4j.util.IOUtil;
import org.eclipse.net4j.util.om.OMLogger.Level;
import java.io.PrintStream;
@@ -31,9 +32,9 @@ public class PrintStreamLogHandler implements OMLogHandler
this.err = err;
}
- private PrintStreamLogHandler()
+ protected PrintStreamLogHandler()
{
- this(System.out, System.err);
+ this(IOUtil.OUT(), IOUtil.ERR());
}
public void logged(OMLogger logger, Level level, String msg, Throwable t)
@@ -42,11 +43,11 @@ public class PrintStreamLogHandler implements OMLogHandler
stream.println((toString(level) + " ") + msg); //$NON-NLS-1$
if (t != null)
{
- t.printStackTrace(stream);
+ IOUtil.print(t, stream);
}
}
- private static String toString(Level level)
+ public static String toString(Level level)
{
switch (level)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamTraceHandler.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamTraceHandler.java
index 362e234..acb0bb5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamTraceHandler.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamTraceHandler.java
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.net4j.util.om;
+import org.eclipse.net4j.util.IOUtil;
+
import java.io.PrintStream;
/**
@@ -26,9 +28,9 @@ public class PrintStreamTraceHandler implements OMTraceHandler
this.stream = stream;
}
- private PrintStreamTraceHandler()
+ protected PrintStreamTraceHandler()
{
- this(System.out);
+ this(IOUtil.OUT());
}
public void traced(OMTracer tracer, Class context, String msg, Throwable t)
@@ -36,7 +38,7 @@ public class PrintStreamTraceHandler implements OMTraceHandler
stream.println("[TRACE] " + msg); //$NON-NLS-1$
if (t != null)
{
- t.printStackTrace(stream);
+ IOUtil.print(t, stream);
}
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
index 3bba721..809fc09 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
@@ -10,9 +10,12 @@
**************************************************************************/
package org.eclipse.net4j.util.registry;
+import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.net4j.util.registry.IRegistry.Listener.EventType;
import org.eclipse.net4j.util.registry.IRegistryElement.Descriptor;
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -28,6 +31,9 @@ public abstract class AbstractRegistry<ID, E extends IRegistryElement<ID>> imple
{
public static final boolean DEFAULT_RESOLVING = true;
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_REGISTRY,
+ AbstractRegistry.class);
+
private boolean resolving;
/**
@@ -121,7 +127,10 @@ public abstract class AbstractRegistry<ID, E extends IRegistryElement<ID>> imple
}
catch (Exception ex)
{
- ex.printStackTrace();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
}
}
}