Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-28 05:14:50 -0400
committerEike Stepper2006-10-28 05:14:50 -0400
commiteb098fcb074b0e34826d861db793df6b3cbe2d10 (patch)
treea0a6129f2b19560aca8e917dc868d2e25f6dcd2e /plugins/org.eclipse.net4j
parentd58e62c0c8163cc0f578afdb3554ec00899c2e82 (diff)
downloadcdo-eb098fcb074b0e34826d861db793df6b3cbe2d10.tar.gz
cdo-eb098fcb074b0e34826d861db793df6b3cbe2d10.tar.xz
cdo-eb098fcb074b0e34826d861db793df6b3cbe2d10.zip
Added instance tracer
Diffstat (limited to 'plugins/org.eclipse.net4j')
-rw-r--r--plugins/org.eclipse.net4j/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OMTracerImpl.java37
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactoryImpl.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPoolImpl.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java4
-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/internal/net4j/transport/tcp/TCPSelectorImpl.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java20
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ReflectUtil.java30
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/AsynchronousWorkSerializer.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java16
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTraceHandler.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTracer.java12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/log/EclipseLoggingBridge.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/EclipseLoggingBridge.java)7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/log/OSGiLoggingBridge.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OSGiLoggingBridge.java)7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/log/PrintLogHandler.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamLogHandler.java)12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/ContextTracer.java110
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/InstanceTracer.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/ContextTracer.java)28
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/PrintTraceHandler.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/PrintStreamTraceHandler.java)14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceHandler.java158
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceServer.java344
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java4
36 files changed, 822 insertions, 113 deletions
diff --git a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
index 979bbb0e55..9b12f7d343 100644
--- a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
@@ -25,6 +25,8 @@ Export-Package: org.eclipse.internal.net4j.transport;version="0.8.0",
org.eclipse.net4j.util.concurrent;version="0.8.0",
org.eclipse.net4j.util.lifecycle;version="0.8.0",
org.eclipse.net4j.util.om;version="0.8.0",
+ org.eclipse.net4j.util.om.log,
+ org.eclipse.net4j.util.om.trace,
org.eclipse.net4j.util.registry;version="0.8.0",
org.eclipse.net4j.util.stream;version="0.8.0"
Eclipse-LazyStart: true
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 f692808a15..7b43fd04aa 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,7 +10,6 @@
**************************************************************************/
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;
@@ -18,6 +17,7 @@ import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OMTraceHandler;
import org.eclipse.net4j.util.om.OMTracer;
import org.eclipse.net4j.util.om.OMLogger.Level;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.util.Map;
import java.util.Queue;
@@ -105,25 +105,25 @@ public abstract class AbstractOMPlatform implements OMPlatform
{
if (TRACER().isEnabled())
{
- TRACER().trace(ex);
+ TRACER().trace(this, ex);
}
}
}
}
- protected void trace(OMTracer tracer, Class context, String msg, Throwable t)
+ protected void trace(OMTracer tracer, Class context, Object instance, String msg, Throwable t)
{
for (OMTraceHandler traceHandler : traceHandlers)
{
try
{
- traceHandler.traced(tracer, context, msg, t);
+ traceHandler.traced(tracer, context, instance, msg, t);
}
catch (Exception ex)
{
if (TRACER().isEnabled())
{
- TRACER().trace(ex);
+ TRACER().trace(this, ex);
}
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OMTracerImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OMTracerImpl.java
index 6cb3e0a678..bd43e09514 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OMTracerImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OMTracerImpl.java
@@ -73,30 +73,55 @@ public class OMTracerImpl implements OMTracer
bundle.setDebugOption(fullName, enabled);
}
+ public void trace(Class context, Object instance, String msg, Throwable t)
+ {
+ ((AbstractOMPlatform)bundle.getPlatform()).trace(this, context, instance, msg, t);
+ }
+
+ public void trace(Class context, Object instance, String msg)
+ {
+ trace(context, instance, msg, (Throwable)null);
+ }
+
+ public void trace(Class context, Object instance, Throwable t)
+ {
+ trace(context, instance, t.getLocalizedMessage(), t);
+ }
+
+ public void trace(Class context, Object instance, String pattern, Object... args)
+ {
+ trace(context, instance, pattern, (Throwable)null, args);
+ }
+
+ public void trace(Class context, Object instance, String pattern, Throwable t, Object... args)
+ {
+ String msg = MessageFormat.format(pattern, args);
+ trace(context, instance, msg, t);
+ }
+
public void trace(Class context, String pattern, Object... args)
{
- trace(context, pattern, null, args);
+ trace(context, NO_INSTANCE, pattern, (Throwable)null, args);
}
public void trace(Class context, String pattern, Throwable t, Object... args)
{
- String msg = MessageFormat.format(pattern, args);
- trace(context, msg, t);
+ trace(context, NO_INSTANCE, pattern, t, args);
}
public void trace(Class context, String msg, Throwable t)
{
- ((AbstractOMPlatform)bundle.getPlatform()).trace(this, context, msg, t);
+ trace(context, NO_INSTANCE, msg, t);
}
public void trace(Class context, String msg)
{
- trace(context, msg, (Throwable)null);
+ trace(context, NO_INSTANCE, msg);
}
public void trace(Class context, Throwable t)
{
- trace(context, t.getLocalizedMessage(), t);
+ trace(context, NO_INSTANCE, t);
}
public OMTracer tracer(String name)
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 f2873f4a64..1f041040c8 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
@@ -22,7 +22,7 @@ import org.eclipse.net4j.util.lifecycle.AbstractLifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleListener;
import org.eclipse.net4j.util.lifecycle.LifecycleNotifier;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -210,9 +210,9 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString()
- + ": Setting state " + newState + " (was " + oldState.toString().toLowerCase() //$NON-NLS-1$ //$NON-NLS-2$
- + ")"); //$NON-NLS-1$
+ TRACER.trace(this,
+ "Setting state " + newState + " (was " + oldState.toString().toLowerCase() //$NON-NLS-1$ //$NON-NLS-2$
+ + ")"); //$NON-NLS-1$
}
state = newState;
@@ -291,7 +291,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Waiting for connection..."); //$NON-NLS-1$
+ TRACER.trace(this, "Waiting for connection..."); //$NON-NLS-1$
}
return finishedNegotiating.await(timeout, TimeUnit.MILLISECONDS);
@@ -374,7 +374,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
Protocol protocol = createProtocol(protocolID, channel);
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Opening channel " + channelIndex //$NON-NLS-1$
+ TRACER.trace(this, "Opening channel " + channelIndex //$NON-NLS-1$
+ (protocol == null ? " without protocol" : " with protocol " + protocolID)); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -402,7 +402,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Invalid channelIndex " + channelIndex); //$NON-NLS-1$
+ TRACER.trace(this, "Invalid channelIndex " + channelIndex); //$NON-NLS-1$
}
return null;
@@ -461,7 +461,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
int channelIndex = channel.getChannelIndex();
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Removing channel " + channelIndex); //$NON-NLS-1$
+ TRACER.trace(this, "Removing channel " + channelIndex); //$NON-NLS-1$
}
channels.set(channelIndex, NULL_CHANNEL);
@@ -485,7 +485,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Unknown protocol " + protocolID); //$NON-NLS-1$
+ TRACER.trace(this, "Unknown protocol " + protocolID); //$NON-NLS-1$
}
return null;
@@ -565,12 +565,12 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
if (protocolFactoryRegistry == null && TRACER.isEnabled())
{
- TRACER.trace(toString() + ": No protocol factory registry!"); //$NON-NLS-1$
+ TRACER.trace(this, "No protocol factory registry!"); //$NON-NLS-1$
}
if (receiveExecutor == null && TRACER.isEnabled())
{
- TRACER.trace(toString() + ": No receive executor!"); //$NON-NLS-1$
+ TRACER.trace(this, "No receive executor!"); //$NON-NLS-1$
}
}
@@ -608,7 +608,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": ID wrap around"); //$NON-NLS-1$
+ TRACER.trace(this, "ID wrap around"); //$NON-NLS-1$
}
nextConnectorID = MIN_CONNECTOR_ID;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactoryImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactoryImpl.java
index beac29a1db..b5926f43ee 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactoryImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactoryImpl.java
@@ -11,7 +11,7 @@
package org.eclipse.internal.net4j.transport;
import org.eclipse.net4j.transport.Buffer;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -34,7 +34,7 @@ public class BufferFactoryImpl extends BufferProviderImpl
BufferImpl buffer = new BufferImpl(this, getBufferCapacity());
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Created " + buffer); //$NON-NLS-1$
+ TRACER.trace(this, "Created " + buffer); //$NON-NLS-1$
}
return buffer;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
index bfaed8ed40..ea86cc4f1a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
@@ -14,7 +14,7 @@ import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.util.HexUtil;
import org.eclipse.net4j.util.ReflectUtil;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -185,7 +185,7 @@ public class BufferImpl implements Buffer
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Read " + byteBuffer.limit() + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
+ TRACER.trace(this, "Read " + byteBuffer.limit() + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
+ (eos ? " (EOS)" : "") + NL + formatContent()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -241,7 +241,7 @@ public class BufferImpl implements Buffer
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Writing " + (payloadSize - 1) + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
+ TRACER.trace(this, "Writing " + (payloadSize - 1) + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
+ (eos ? " (EOS)" : "") + NL + formatContent()); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPoolImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPoolImpl.java
index e7021bd521..b3f1352af3 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPoolImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPoolImpl.java
@@ -13,7 +13,7 @@ package org.eclipse.internal.net4j.transport;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferPool;
import org.eclipse.net4j.transport.BufferProvider;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -56,7 +56,7 @@ public class BufferPoolImpl extends BufferProviderImpl implements BufferPool,
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Evicting " + buffer); //$NON-NLS-1$
+ TRACER.trace(this, "Evicting " + buffer); //$NON-NLS-1$
}
factory.retainBuffer(buffer);
@@ -95,7 +95,7 @@ public class BufferPoolImpl extends BufferProviderImpl implements BufferPool,
buffer.clear();
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Obtained " + buffer); //$NON-NLS-1$
+ TRACER.trace(this, "Obtained " + buffer); //$NON-NLS-1$
}
return buffer;
@@ -111,7 +111,7 @@ public class BufferPoolImpl extends BufferProviderImpl implements BufferPool,
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Retaining " + buffer); //$NON-NLS-1$
+ TRACER.trace(this, "Retaining " + buffer); //$NON-NLS-1$
}
queue.add(buffer);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
index 42e6e780dd..e98c08e04a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
@@ -21,7 +21,7 @@ import org.eclipse.net4j.util.concurrent.AsynchronousWorkSerializer;
import org.eclipse.net4j.util.concurrent.SynchronousWorkSerializer;
import org.eclipse.net4j.util.concurrent.WorkSerializer;
import org.eclipse.net4j.util.lifecycle.AbstractLifecycle;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.transport.BufferImpl.State;
@@ -146,7 +146,7 @@ public class ChannelImpl extends AbstractLifecycle implements Channel, BufferPro
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Handling buffer from client: " + buffer); //$NON-NLS-1$
+ TRACER.trace(this, "Handling buffer from client: " + buffer); //$NON-NLS-1$
}
sendQueue.add(buffer);
@@ -164,7 +164,7 @@ public class ChannelImpl extends AbstractLifecycle implements Channel, BufferPro
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Handling buffer from multiplexer: " + buffer); //$NON-NLS-1$
+ TRACER.trace(this, "Handling buffer from multiplexer: " + buffer); //$NON-NLS-1$
}
receiveSerializer.addWork(new Runnable()
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
index 6df749f60e..76350c5eff 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
@@ -18,7 +18,7 @@ import org.eclipse.net4j.transport.tcp.TCPSelector;
import org.eclipse.net4j.transport.tcp.TCPSelectorListener;
import org.eclipse.net4j.util.Net4jUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.transport.AbstractConnector;
@@ -159,7 +159,7 @@ public abstract class AbstractTCPConnector extends AbstractConnector implements
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Discarding buffer from unknown channel"); //$NON-NLS-1$
+ TRACER.trace(this, "Discarding buffer from unknown channel"); //$NON-NLS-1$
}
inputBuffer.release();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
index 850dbcfc5d..38bbe2d756 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
@@ -13,7 +13,7 @@ package org.eclipse.internal.net4j.transport.tcp;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.util.concurrent.Synchronizer;
import org.eclipse.net4j.util.concurrent.SynchronizingCorrelator;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.transport.BufferUtil;
@@ -149,7 +149,7 @@ public final class ControlChannelImpl extends ChannelImpl
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Invalid channel id: " + channelIndex); //$NON-NLS-1$
+ TRACER.trace(this, "Invalid channel id: " + channelIndex); //$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 b0ba67c16a..b283cbfa80 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
@@ -23,7 +23,7 @@ import org.eclipse.net4j.util.lifecycle.AbstractLifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleListener;
import org.eclipse.net4j.util.lifecycle.LifecycleNotifier;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -249,7 +249,7 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Accepted connector " + connector); //$NON-NLS-1$
+ TRACER.trace(this, "Accepted connector " + connector); //$NON-NLS-1$
}
fireConnectorAccepted(connector);
@@ -301,12 +301,12 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
if (protocolFactoryRegistry == null && TRACER.isEnabled())
{
- TRACER.trace(toString() + ": No protocol factory registry!"); //$NON-NLS-1$
+ TRACER.trace(this, "No protocol factory registry!"); //$NON-NLS-1$
}
if (receiveExecutor == null && TRACER.isEnabled())
{
- TRACER.trace(toString() + ": No receive executor!"); //$NON-NLS-1$
+ TRACER.trace(this, "No receive executor!"); //$NON-NLS-1$
}
if (selector == null)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java
index 568083d52a..7c52c7772c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java
@@ -13,7 +13,7 @@ package org.eclipse.internal.net4j.transport.tcp;
import org.eclipse.net4j.transport.tcp.TCPSelector;
import org.eclipse.net4j.transport.tcp.TCPSelectorListener;
import org.eclipse.net4j.util.lifecycle.AbstractLifecycle;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -56,7 +56,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Registering " + TCPUtil.toString(channel)); //$NON-NLS-1$
+ TRACER.trace(this, "Registering " + TCPUtil.toString(channel)); //$NON-NLS-1$
}
return channel.register(selector, SelectionKey.OP_ACCEPT, listener);
@@ -72,7 +72,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Registering " + TCPUtil.toString(channel)); //$NON-NLS-1$
+ TRACER.trace(this, "Registering " + TCPUtil.toString(channel)); //$NON-NLS-1$
}
return channel.register(selector, SelectionKey.OP_CONNECT | SelectionKey.OP_READ, listener);
@@ -145,7 +145,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Accepting " + TCPUtil.toString(ssChannel)); //$NON-NLS-1$
+ TRACER.trace(this, "Accepting " + TCPUtil.toString(ssChannel)); //$NON-NLS-1$
}
listener.handleAccept(this, ssChannel);
@@ -160,7 +160,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Connecting " + TCPUtil.toString(sChannel)); //$NON-NLS-1$
+ TRACER.trace(this, "Connecting " + TCPUtil.toString(sChannel)); //$NON-NLS-1$
}
listener.handleConnect(this, sChannel);
@@ -170,7 +170,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Reading " + TCPUtil.toString(sChannel)); //$NON-NLS-1$
+ TRACER.trace(this, "Reading " + TCPUtil.toString(sChannel)); //$NON-NLS-1$
}
listener.handleRead(this, sChannel);
@@ -180,7 +180,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Writing " + TCPUtil.toString(sChannel)); //$NON-NLS-1$
+ TRACER.trace(this, "Writing " + TCPUtil.toString(sChannel)); //$NON-NLS-1$
}
listener.handleWrite(this, sChannel);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java
index 74ec0be3b8..3ad736abd3 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.internal.net4j.transport.tcp;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -82,7 +82,7 @@ public final class TCPUtil
{
if (TRACER.isEnabled())
{
- TRACER.trace(selectionKey.channel().toString() + ": Setting interest " //$NON-NLS-1$
+ TRACER.trace(selectionKey, "Setting interest " //$NON-NLS-1$
+ formatInterestOps(newOps) + " (was " + formatInterestOps(oldOps).toLowerCase() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
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 eea8b8377e..55c85052a9 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,7 +12,7 @@ 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.om.trace.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -36,7 +36,7 @@ public abstract class Indication extends SignalReactor
{
if (TRACER.isEnabled())
{
- TRACER.trace("================ Indicating " + this); //$NON-NLS-1$
+ TRACER.trace(this, "================ Indicating"); //$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 ce38b9e589..e217bb0706 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,7 +12,7 @@ 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.om.trace.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
@@ -37,13 +37,13 @@ public abstract class IndicationWithResponse extends SignalReactor
{
if (TRACER.isEnabled())
{
- TRACER.trace("================ Indicating " + this); //$NON-NLS-1$
+ TRACER.trace(this, "================ Indicating"); //$NON-NLS-1$
}
indicating(new ExtendedDataInputStream(in));
if (TRACER.isEnabled())
{
- TRACER.trace("================ Responding " + this); //$NON-NLS-1$
+ TRACER.trace(this, "================ Responding"); //$NON-NLS-1$
}
responding(new ExtendedDataOutputStream(out));
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 88b74417e2..5e5549392c 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,7 +13,7 @@ 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.om.trace.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -37,7 +37,7 @@ public abstract class Request extends SignalActor
{
if (TRACER.isEnabled())
{
- TRACER.trace("================ Requesting " + this); //$NON-NLS-1$
+ TRACER.trace(this, "================ Requesting"); //$NON-NLS-1$
}
requesting(new ExtendedDataOutputStream(out));
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 67cd9f64e9..8f4e6e4819 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,7 +13,7 @@ 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.om.trace.ContextTracer;
import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
@@ -39,14 +39,14 @@ public abstract class RequestWithConfirmation<RESULT> extends SignalActor<RESULT
{
if (TRACER.isEnabled())
{
- TRACER.trace("================ Requesting " + this); //$NON-NLS-1$
+ TRACER.trace(this, "================ Requesting"); //$NON-NLS-1$
}
requesting(new ExtendedDataOutputStream(out));
out.flush();
if (TRACER.isEnabled())
{
- TRACER.trace("================ Confirming " + this); //$NON-NLS-1$
+ TRACER.trace(this, "================ Confirming"); //$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 0704374e34..4146d66358 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,7 +12,7 @@ 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.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -65,7 +65,7 @@ public abstract class Signal implements Runnable
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, 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 5c0252ee9e..170f48aa5f 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,7 @@ 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.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.transport.AbstractProtocol;
@@ -41,6 +41,9 @@ public abstract class SignalProtocol extends AbstractProtocol
private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SIGNAL,
SignalProtocol.class);
+ private static final ContextTracer STREAM_TRACER = new ContextTracer(Net4j.DEBUG_BUFFER_STREAM,
+ SignalOutputStream.class);
+
private ExecutorService executorService;
private Map<Integer, Signal> signals = new ConcurrentHashMap(0);
@@ -70,7 +73,7 @@ public abstract class SignalProtocol extends AbstractProtocol
int correlationID = byteBuffer.getInt();
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Received buffer for correlation " + correlationID); //$NON-NLS-1$
+ TRACER.trace(this, "Received buffer for correlation " + correlationID); //$NON-NLS-1$
}
Signal signal;
@@ -83,7 +86,7 @@ public abstract class SignalProtocol extends AbstractProtocol
short signalID = byteBuffer.getShort();
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Got signal id " + signalID); //$NON-NLS-1$
+ TRACER.trace(this, "Got signal id " + signalID); //$NON-NLS-1$
}
signal = createSignalReactor(signalID);
@@ -103,7 +106,7 @@ public abstract class SignalProtocol extends AbstractProtocol
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Discarding buffer"); //$NON-NLS-1$
+ TRACER.trace(this, "Discarding buffer"); //$NON-NLS-1$
}
buffer.release();
@@ -155,7 +158,7 @@ public abstract class SignalProtocol extends AbstractProtocol
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Correlation wrap around"); //$NON-NLS-1$
+ TRACER.trace(this, "Correlation wrap around"); //$NON-NLS-1$
}
nextCorrelationID = MIN_CORRELATION_ID;
@@ -210,9 +213,9 @@ public abstract class SignalProtocol extends AbstractProtocol
{
Buffer buffer = delegate.provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(getChannel().getChannelIndex());
- if (SignalProtocol.TRACER.isEnabled())
+ if (STREAM_TRACER.isEnabled())
{
- SignalProtocol.TRACER.trace("Providing buffer for correlation " + correlationID); //$NON-NLS-1$
+ STREAM_TRACER.trace(this, "Providing buffer for correlation " + correlationID); //$NON-NLS-1$
}
byteBuffer.putInt(correlationID);
@@ -220,8 +223,7 @@ public abstract class SignalProtocol extends AbstractProtocol
{
if (SignalProtocol.TRACER.isEnabled())
{
- SignalProtocol.TRACER.trace(SignalProtocol.this.toString()
- + ": Put signal id " + signalID); //$NON-NLS-1$
+ STREAM_TRACER.trace(this, "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 0435510999..36ab72a5df 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,7 +13,7 @@ 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.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -71,7 +71,7 @@ public class BufferInputStream extends InputStream implements BufferHandler
final int result = b < 0 ? ~b : b;
if (TRACER.isEnabled())
{
- TRACER.trace("<-- " + HexUtil.toHex(result) //$NON-NLS-1$
+ TRACER.trace(this, "<-- " + 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 9beebff3a6..bbe5badead 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,7 +15,7 @@ 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.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -70,7 +70,7 @@ public class BufferOutputStream extends OutputStream
ensureBuffer();
if (TRACER.isEnabled())
{
- TRACER.trace("--> " + HexUtil.toHex(b) //$NON-NLS-1$
+ TRACER.trace(this, "--> " + 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/ReflectUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ReflectUtil.java
index b4fa20a391..ad33239438 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
@@ -72,11 +72,21 @@ public final class ReflectUtil
public static String getPackageName(Class<? extends Object> c)
{
+ if (c == null)
+ {
+ return null;
+ }
+
return getPackageName(c.getName());
}
public static String getPackageName(String className)
{
+ if (className == null)
+ {
+ return null;
+ }
+
int lastDot = className.lastIndexOf('.');
if (lastDot != -1)
{
@@ -88,11 +98,21 @@ public final class ReflectUtil
public static String getSimpleName(Class<? extends Object> c)
{
+ if (c == null)
+ {
+ return null;
+ }
+
return getSimpleClassName(c.getName());
}
public static String getSimpleClassName(String name)
{
+ if (name == null)
+ {
+ return null;
+ }
+
int lastDot = name.lastIndexOf('.');
if (lastDot != -1)
{
@@ -104,11 +124,21 @@ public final class ReflectUtil
public static String getSimpleClassName(Object object)
{
+ if (object == null)
+ {
+ return null;
+ }
+
return getSimpleName(object.getClass());
}
public static String getLabel(Object object)
{
+ if (object == null)
+ {
+ return null;
+ }
+
return getSimpleClassName(object) + "@" + getID(object); //$NON-NLS-1$
}
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 847de1dba9..f37b20864d 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,7 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.util.concurrent;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -67,7 +67,7 @@ public class AsynchronousWorkSerializer implements WorkSerializer, Runnable
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Notifying executor service"); //$NON-NLS-1$
+ TRACER.trace(this, "Notifying executor service"); //$NON-NLS-1$
}
executorService.execute(this);
@@ -94,7 +94,7 @@ public class AsynchronousWorkSerializer implements WorkSerializer, Runnable
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, 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 2c4a9883df..d9b56607e1 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
@@ -11,7 +11,7 @@
package org.eclipse.net4j.util.lifecycle;
import org.eclipse.net4j.util.ReflectUtil;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -58,14 +58,14 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Activating");//$NON-NLS-1$
+ TRACER.trace(this, "Activating");//$NON-NLS-1$
}
onAboutToActivate();
fireLifecycleAboutToActivate();
if (DUMPER.isEnabled())
{
- DUMPER.trace("DUMP " + ReflectUtil.toString(this)); //$NON-NLS-1$
+ DUMPER.trace(this, "DUMP " + ReflectUtil.toString(this)); //$NON-NLS-1$
}
onActivate();
@@ -81,7 +81,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Deactivating");//$NON-NLS-1$
+ TRACER.trace(this, "Deactivating");//$NON-NLS-1$
}
fireLifecycleDeactivating();
@@ -94,7 +94,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, ex);
}
return ex;
@@ -138,7 +138,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, ex);
}
}
}
@@ -156,7 +156,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, ex);
}
}
}
@@ -174,7 +174,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, 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 84735069df..2cae5bd38b 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,7 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.util.lifecycle;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTraceHandler.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTraceHandler.java
index c5c5517835..bb69330339 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTraceHandler.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTraceHandler.java
@@ -15,5 +15,5 @@ package org.eclipse.net4j.util.om;
*/
public interface OMTraceHandler
{
- public void traced(OMTracer tracer, Class context, String msg, Throwable t);
+ public void traced(OMTracer tracer, Class context, Object instance, String msg, Throwable t);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTracer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTracer.java
index 800c8ad9a7..bd6ddb42e4 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTracer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/OMTracer.java
@@ -15,6 +15,8 @@ package org.eclipse.net4j.util.om;
*/
public interface OMTracer
{
+ public static final Object NO_INSTANCE = null;
+
public OMBundle getBundle();
public OMTracer getParent();
@@ -27,6 +29,16 @@ public interface OMTracer
public void setEnabled(boolean enabled);
+ public void trace(Class context, Object instance, String pattern, Object... args);
+
+ public void trace(Class context, Object instance, String pattern, Throwable t, Object... args);
+
+ public void trace(Class context, Object instance, String msg, Throwable t);
+
+ public void trace(Class context, Object instance, String msg);
+
+ public void trace(Class context, Object instance, Throwable t);
+
public void trace(Class context, String pattern, Object... args);
public void trace(Class context, String pattern, Throwable t, Object... args);
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/log/EclipseLoggingBridge.java
index d662a28a24..a2c479f8c9 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/log/EclipseLoggingBridge.java
@@ -8,9 +8,12 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.om;
+package org.eclipse.net4j.util.om.log;
+import org.eclipse.net4j.util.om.OMLogHandler;
+import org.eclipse.net4j.util.om.OMLogger;
import org.eclipse.net4j.util.om.OMLogger.Level;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
@@ -45,7 +48,7 @@ public class EclipseLoggingBridge implements OMLogHandler
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, ex);
}
}
}
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/log/OSGiLoggingBridge.java
index 9c51652859..fcd09a3790 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/log/OSGiLoggingBridge.java
@@ -8,9 +8,12 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.om;
+package org.eclipse.net4j.util.om.log;
+import org.eclipse.net4j.util.om.OMLogHandler;
+import org.eclipse.net4j.util.om.OMLogger;
import org.eclipse.net4j.util.om.OMLogger.Level;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.bundle.OSGiBundle;
@@ -44,7 +47,7 @@ public class OSGiLoggingBridge implements OMLogHandler
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, ex);
}
}
}
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/log/PrintLogHandler.java
index bb949be686..6de0136126 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/log/PrintLogHandler.java
@@ -8,9 +8,11 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.om;
+package org.eclipse.net4j.util.om.log;
import org.eclipse.net4j.util.IOUtil;
+import org.eclipse.net4j.util.om.OMLogHandler;
+import org.eclipse.net4j.util.om.OMLogger;
import org.eclipse.net4j.util.om.OMLogger.Level;
import java.io.PrintStream;
@@ -18,21 +20,21 @@ import java.io.PrintStream;
/**
* @author Eike Stepper
*/
-public class PrintStreamLogHandler implements OMLogHandler
+public class PrintLogHandler implements OMLogHandler
{
- public static final PrintStreamLogHandler CONSOLE = new PrintStreamLogHandler();
+ public static final PrintLogHandler CONSOLE = new PrintLogHandler();
private PrintStream out;
private PrintStream err;
- public PrintStreamLogHandler(PrintStream out, PrintStream err)
+ public PrintLogHandler(PrintStream out, PrintStream err)
{
this.out = out;
this.err = err;
}
- protected PrintStreamLogHandler()
+ protected PrintLogHandler()
{
this(IOUtil.OUT(), IOUtil.ERR());
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/ContextTracer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/ContextTracer.java
new file mode 100644
index 0000000000..fa627b41f9
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/ContextTracer.java
@@ -0,0 +1,110 @@
+/***************************************************************************
+ * 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.util.om.trace;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMTracer;
+
+/**
+ * @author Eike Stepper
+ */
+public class ContextTracer
+{
+ private OMTracer delegate;
+
+ private Class context;
+
+ public ContextTracer(OMTracer delegate, Class context)
+ {
+ this.delegate = delegate;
+ this.context = context;
+ }
+
+ public OMBundle getBundle()
+ {
+ return delegate.getBundle();
+ }
+
+ public String getFullName()
+ {
+ return delegate.getFullName();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public OMTracer getParent()
+ {
+ return delegate.getParent();
+ }
+
+ public boolean isEnabled()
+ {
+ return delegate.isEnabled();
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ delegate.setEnabled(enabled);
+ }
+
+ public void trace(Object instance, String pattern, Object... args)
+ {
+ delegate.trace(context, instance, pattern, args);
+ }
+
+ public void trace(Object instance, String pattern, Throwable t, Object... args)
+ {
+ delegate.trace(context, instance, pattern, t, args);
+ }
+
+ public void trace(Object instance, String msg, Throwable t)
+ {
+ delegate.trace(context, instance, msg, t);
+ }
+
+ public void trace(Object instance, String msg)
+ {
+ delegate.trace(context, instance, msg);
+ }
+
+ public void trace(Object instance, Throwable t)
+ {
+ delegate.trace(context, instance, t);
+ }
+
+ public void trace(String pattern, Object... args)
+ {
+ delegate.trace(context, pattern, args);
+ }
+
+ public void trace(String pattern, Throwable t, Object... args)
+ {
+ delegate.trace(context, pattern, t, args);
+ }
+
+ public void trace(String msg, Throwable t)
+ {
+ delegate.trace(context, msg, t);
+ }
+
+ public void trace(String msg)
+ {
+ delegate.trace(context, msg);
+ }
+
+ public void trace(Throwable t)
+ {
+ delegate.trace(context, t);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/ContextTracer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/InstanceTracer.java
index e0df7dca7f..3d53b806d0 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/ContextTracer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/InstanceTracer.java
@@ -8,21 +8,27 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.om;
+package org.eclipse.net4j.util.om.trace;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMTracer;
/**
* @author Eike Stepper
*/
-public class ContextTracer
+public class InstanceTracer
{
private OMTracer delegate;
private Class context;
- public ContextTracer(OMTracer delegate, Class context)
+ private Object instance;
+
+ public InstanceTracer(OMTracer delegate, Class context, Object instance)
{
this.delegate = delegate;
this.context = context;
+ this.instance = instance;
}
public OMBundle getBundle()
@@ -55,18 +61,28 @@ public class ContextTracer
delegate.setEnabled(enabled);
}
+ public void trace(String pattern, Object... args)
+ {
+ delegate.trace(context, instance, pattern, args);
+ }
+
+ public void trace(String pattern, Throwable t, Object... args)
+ {
+ delegate.trace(context, instance, pattern, t, args);
+ }
+
public void trace(String msg, Throwable t)
{
- delegate.trace(context, msg, t);
+ delegate.trace(context, instance, msg, t);
}
public void trace(String msg)
{
- delegate.trace(context, msg);
+ delegate.trace(context, instance, msg);
}
public void trace(Throwable t)
{
- delegate.trace(context, t);
+ delegate.trace(context, instance, t);
}
}
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/trace/PrintTraceHandler.java
index acb0bb5a86..ea0feac872 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/trace/PrintTraceHandler.java
@@ -8,32 +8,34 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.om;
+package org.eclipse.net4j.util.om.trace;
import org.eclipse.net4j.util.IOUtil;
+import org.eclipse.net4j.util.om.OMTraceHandler;
+import org.eclipse.net4j.util.om.OMTracer;
import java.io.PrintStream;
/**
* @author Eike Stepper
*/
-public class PrintStreamTraceHandler implements OMTraceHandler
+public class PrintTraceHandler implements OMTraceHandler
{
- public static final PrintStreamTraceHandler CONSOLE = new PrintStreamTraceHandler();
+ public static final PrintTraceHandler CONSOLE = new PrintTraceHandler();
private PrintStream stream;
- public PrintStreamTraceHandler(PrintStream stream)
+ public PrintTraceHandler(PrintStream stream)
{
this.stream = stream;
}
- protected PrintStreamTraceHandler()
+ protected PrintTraceHandler()
{
this(IOUtil.OUT());
}
- public void traced(OMTracer tracer, Class context, String msg, Throwable t)
+ public void traced(OMTracer tracer, Class context, Object instance, String msg, Throwable t)
{
stream.println("[TRACE] " + msg); //$NON-NLS-1$
if (t != null)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceHandler.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceHandler.java
new file mode 100644
index 0000000000..06617edeff
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceHandler.java
@@ -0,0 +1,158 @@
+/***************************************************************************
+ * 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.util.om.trace;
+
+import org.eclipse.net4j.util.IOUtil;
+import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.om.OMTraceHandler;
+import org.eclipse.net4j.util.om.OMTracer;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.util.UUID;
+
+/**
+ * @author Eike Stepper
+ */
+public class RemoteTraceHandler implements OMTraceHandler
+{
+ public static final String DEFAULT_HOST = "localhost"; //$NON-NLS-1$
+
+ public static final int DEFAULT_PORT = RemoteTraceServer.DEFAULT_PORT;
+
+ private static int uniqueCounter;
+
+ private String agentID;
+
+ private String host;
+
+ private int port;
+
+ private Socket socket;
+
+ public RemoteTraceHandler() throws IOException
+ {
+ this(uniqueAgentID());
+ }
+
+ public RemoteTraceHandler(String agentID) throws IOException
+ {
+ this(agentID, DEFAULT_HOST);
+ }
+
+ public RemoteTraceHandler(String agentID, String host) throws IOException
+ {
+ this(agentID, host, DEFAULT_PORT);
+ }
+
+ public RemoteTraceHandler(String agentID, String host, int port) throws IOException
+ {
+ this.agentID = agentID;
+ this.host = host;
+ this.port = port;
+ socket = connect();
+ }
+
+ public Exception close()
+ {
+ try
+ {
+ socket.close();
+ return null;
+ }
+ catch (IOException ex)
+ {
+ return ex;
+ }
+ }
+
+ public void traced(OMTracer tracer, Class context, Object instance, String msg, Throwable t)
+ {
+ try
+ {
+ OutputStream outputStream = socket.getOutputStream();
+ DataOutputStream out = new DataOutputStream(outputStream);
+
+ writeUTF(out, agentID);
+ writeUTF(out, tracer.getBundle().getBundleID());
+ writeUTF(out, tracer.getFullName());
+ writeUTF(out, context);
+ writeUTF(out, ReflectUtil.getLabel(instance));
+ writeUTF(out, msg);
+ if (t == null)
+ {
+ out.writeBoolean(false);
+ }
+ else
+ {
+ out.writeBoolean(true);
+ String message = t.getMessage();
+ writeUTF(out, message);
+
+ StackTraceElement[] stackTrace = t.getStackTrace();
+ int size = stackTrace == null ? 0 : stackTrace.length;
+ out.writeInt(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ StackTraceElement element = stackTrace[i];
+ writeUTF(out, element.getClassName());
+ writeUTF(out, element.getMethodName());
+ writeUTF(out, element.getFileName());
+ out.writeInt(element.getLineNumber());
+ }
+ }
+
+ out.flush();
+ }
+ catch (IOException ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+
+ protected Socket connect() throws IOException
+ {
+ return new Socket(host, port);
+ }
+
+ protected void writeUTF(DataOutputStream out, String str) throws IOException
+ {
+ out.writeUTF(str == null ? "" : str);
+ }
+
+ private void writeUTF(DataOutputStream out, Object object) throws IOException
+ {
+ writeUTF(out, object == null ? "" : object.toString());
+ }
+
+ private void writeUTF(DataOutputStream out, Class clazz) throws IOException
+ {
+ writeUTF(out, clazz == null ? "" : clazz.getName());
+ }
+
+ public static String uniqueAgentID()
+ {
+ try
+ {
+ InetAddress localMachine = InetAddress.getLocalHost();
+ return localMachine.getHostName() + "#" + (++uniqueCounter);
+ }
+ catch (Exception ex)
+ {
+ UUID uuid = UUID.randomUUID();
+ return uuid.toString();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceServer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceServer.java
new file mode 100644
index 0000000000..2d0633ff58
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/RemoteTraceServer.java
@@ -0,0 +1,344 @@
+/***************************************************************************
+ * 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.util.om.trace;
+
+import org.eclipse.net4j.util.IOUtil;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.EventObject;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+/**
+ * @author Eike Stepper
+ */
+public class RemoteTraceServer
+{
+ public static final String DEFAULT_ADDRESS = "0.0.0.0"; //$NON-NLS-1$
+
+ public static final int DEFAULT_PORT = 2037;
+
+ public static final int ANY_PORT = 0;
+
+ private int port;
+
+ private String address;
+
+ private ServerSocket serverSocket;
+
+ private Queue<Listener> listeners = new ConcurrentLinkedQueue();
+
+ public RemoteTraceServer() throws IOException
+ {
+ this(DEFAULT_PORT);
+ }
+
+ public RemoteTraceServer(int port) throws IOException
+ {
+ this(port, DEFAULT_ADDRESS);
+ }
+
+ public RemoteTraceServer(int port, String address) throws IOException
+ {
+ this.port = port;
+ this.address = address;
+ serverSocket = bind();
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ handleConnections();
+ }
+ }.start();
+ }
+
+ public void addListener(Listener listener)
+ {
+ if (!listeners.contains(listener))
+ {
+ listeners.add(listener);
+ }
+ }
+
+ public void removeListener(Listener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ public Exception close()
+ {
+ try
+ {
+ serverSocket.close();
+ return null;
+ }
+ catch (IOException ex)
+ {
+ return ex;
+ }
+ }
+
+ protected ServerSocket bind() throws IOException
+ {
+ InetAddress addr = InetAddress.getByName(this.address);
+ return new ServerSocket(port, 5, addr);
+ }
+
+ protected void handleConnections()
+ {
+ for (;;)
+ {
+ try
+ {
+ final Socket socket = serverSocket.accept();
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ handleSession(socket);
+ }
+ }.start();
+ }
+ catch (IOException ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+ }
+
+ protected void handleSession(Socket socket)
+ {
+ try
+ {
+ InputStream inputStream = socket.getInputStream();
+ DataInputStream in = new DataInputStream(inputStream);
+
+ for (;;)
+ {
+ handleTrace(in);
+ }
+ }
+ catch (IOException ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+
+ protected void handleTrace(DataInputStream in) throws IOException
+ {
+ Event event = new Event(this);
+ event.agentID = in.readUTF();
+ event.bundleID = in.readUTF();
+ event.tracerName = in.readUTF();
+ event.context = in.readUTF();
+ event.instance = in.readUTF();
+ event.msg = in.readUTF();
+ if (in.readBoolean())
+ {
+ event.throwable = in.readUTF();
+ int size = in.readInt();
+ event.stackTrace = new StackTraceElement[size];
+ for (int i = 0; i < size; i++)
+ {
+ String className = in.readUTF();
+ String methodName = in.readUTF();
+ String fileName = in.readUTF();
+ int lineNumber = in.readInt();
+ event.stackTrace[i] = new StackTraceElement(className, methodName, fileName, lineNumber);
+ }
+ }
+
+ fireEvent(event);
+ }
+
+ protected void fireEvent(Event event)
+ {
+ for (Listener listener : listeners)
+ {
+ try
+ {
+ listener.notifyRemoteTrace(event);
+ }
+ catch (RuntimeException ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class Event extends EventObject
+ {
+ private static final long serialVersionUID = 1L;
+
+ String agentID;
+
+ String bundleID;
+
+ String tracerName;
+
+ String context;
+
+ String instance;
+
+ String msg;
+
+ String throwable;
+
+ StackTraceElement[] stackTrace;
+
+ Event(RemoteTraceServer source)
+ {
+ super(source);
+ }
+
+ public RemoteTraceServer getRemoteTraceServer()
+ {
+ return (RemoteTraceServer)source;
+ }
+
+ public String getAgentID()
+ {
+ return agentID;
+ }
+
+ public String getBundleID()
+ {
+ return bundleID;
+ }
+
+ public String getContext()
+ {
+ return context;
+ }
+
+ public String getInstance()
+ {
+ return instance;
+ }
+
+ public String getMsg()
+ {
+ return msg;
+ }
+
+ public StackTraceElement[] getStackTrace()
+ {
+ return stackTrace;
+ }
+
+ public String getThrowable()
+ {
+ return throwable;
+ }
+
+ public String getTracerName()
+ {
+ return tracerName;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("TraceEvent[agentID=");
+ builder.append(agentID);
+
+ builder.append(", bundleID=");
+ builder.append(bundleID);
+
+ builder.append(", tracerName=");
+ builder.append(tracerName);
+
+ builder.append(", context=");
+ builder.append(context);
+
+ builder.append(", instance=");
+ builder.append(instance);
+
+ builder.append(", msg=");
+ builder.append(msg);
+
+ builder.append(", throwable=");
+ builder.append(throwable);
+
+ builder.append(", stackTrace=");
+ builder.append(stackTrace);
+
+ builder.append("]");
+ return builder.toString();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public interface Listener
+ {
+ public void notifyRemoteTrace(Event event);
+ }
+
+ public static class PrintListener implements Listener
+ {
+ public static final PrintListener CONSOLE = new PrintListener();
+
+ private PrintStream stream;
+
+ public PrintListener(PrintStream stream)
+ {
+ this.stream = stream;
+ }
+
+ protected PrintListener()
+ {
+ this(IOUtil.OUT());
+ }
+
+ public void notifyRemoteTrace(Event event)
+ {
+ stream.println("[TRACE] " + event.getAgentID());
+ stream.println(event.getBundleID());
+ stream.println(event.getTracerName());
+ stream.println(event.getContext());
+ stream.println(event.getInstance());
+ stream.println(event.getMsg());
+
+ String throwable = event.getThrowable();
+ if (throwable != null && throwable.length() != 0)
+ {
+ stream.println(throwable);
+ }
+
+ StackTraceElement[] stackTrace = event.getStackTrace();
+ if (stackTrace != null)
+ for (StackTraceElement element : stackTrace)
+ {
+ stream.print(element.getClassName());
+ stream.print("." + element.getMethodName());
+ stream.print("(" + element.getFileName());
+ stream.print(":" + element.getLineNumber());
+ stream.println(")");
+ }
+
+ stream.println();
+ }
+ }
+}
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 f67d10cad1..b212bd1494 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,7 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.util.registry;
-import org.eclipse.net4j.util.om.ContextTracer;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.registry.IRegistry.Listener.EventType;
import org.eclipse.net4j.util.registry.IRegistryElement.Descriptor;
@@ -129,7 +129,7 @@ public abstract class AbstractRegistry<ID, E extends IRegistryElement<ID>> imple
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex);
+ TRACER.trace(this, ex);
}
}
}

Back to the top