summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-24 16:09:33 (EDT)
committerEike Stepper2006-10-24 16:09:33 (EDT)
commitc93de0a2a0d0ea167a043993e8ae98f800a32710 (patch)
tree4fa56a0146ef29d6b41ea4e11357ce5e51623367
parent09e08ffc0f76b6205c5f79048183e4277066f768 (diff)
downloadcdo-c93de0a2a0d0ea167a043993e8ae98f800a32710.zip
cdo-c93de0a2a0d0ea167a043993e8ae98f800a32710.tar.gz
cdo-c93de0a2a0d0ea167a043993e8ae98f800a32710.tar.bz2
Operations & Maintenance
-rw-r--r--plugins/org.eclipse.net4j/.classpath2
-rw-r--r--plugins/org.eclipse.net4j/.options5
-rw-r--r--plugins/org.eclipse.net4j/META-INF/MANIFEST.MF15
-rw-r--r--plugins/org.eclipse.net4j/TODOS.txt2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Activator.java50
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Log.java121
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Trace.java71
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java46
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/map/AbstractCachingMap.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java)2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/map/AbstractDelegatingMap.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractDelegatingMap.java)2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractDebugOptions.java48
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractLogger.java47
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleDebugOptions.java81
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleLogger.java78
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/ConsoleLogger.java75
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/AbstractTracer.java34
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/IDebugOptions.java33
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ILogger.java39
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ITracer.java27
20 files changed, 683 insertions, 98 deletions
diff --git a/plugins/org.eclipse.net4j/.classpath b/plugins/org.eclipse.net4j/.classpath
index cb25775..1ead822 100644
--- a/plugins/org.eclipse.net4j/.classpath
+++ b/plugins/org.eclipse.net4j/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry excluding="org/eclipse/internal/net4j/bundle/Log.java|org/eclipse/internal/net4j/component/InactiveException.java|org/eclipse/net4j/transport/ChannelMultiplexer.java" kind="src" path="src"/>
+ <classpathentry excluding="org/eclipse/internal/net4j/component/InactiveException.java|org/eclipse/net4j/transport/ChannelMultiplexer.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/org.eclipse.net4j/.options b/plugins/org.eclipse.net4j/.options
new file mode 100644
index 0000000..c5168cd
--- /dev/null
+++ b/plugins/org.eclipse.net4j/.options
@@ -0,0 +1,5 @@
+org.eclipse.net4j/debug = false
+
+org.eclipse.net4j/debug.connector = false
+org.eclipse.net4j/debug.connector.state = false
+org.eclipse.net4j/debug.connector.channels = false
diff --git a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
index 58030c9..595f2d5 100644
--- a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
@@ -1,15 +1,21 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.net4j
Bundle-Version: 0.8.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
Bundle-Localization: plugin
+Bundle-Activator: org.eclipse.internal.net4j.bundle.Activator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.osgi.framework;version="1.3.0";resolution:=optional
+Import-Package: org.eclipse.osgi.service.debug;version="1.0.0";resolution:=optional,
+ org.osgi.framework;version="1.3.0";resolution:=optional,
+ org.osgi.service.log;version="1.3.0";resolution:=optional,
+ org.osgi.util.tracker;version="1.3.2";resolution:=optional
Export-Package: org.eclipse.internal.net4j.transport;version="0.8.0",
org.eclipse.internal.net4j.transport.embedded;version="0.8.0",
org.eclipse.internal.net4j.transport.tcp;version="0.8.0",
- org.eclipse.internal.net4j.util;version="0.8.0",
+ org.eclipse.internal.net4j.util.map;version="0.8.0",
+ org.eclipse.internal.net4j.util.operation;version="0.8.0",
org.eclipse.net4j;version="0.8.0",
org.eclipse.net4j.message;version="0.8.0",
org.eclipse.net4j.remote;version="0.8.0",
@@ -22,5 +28,4 @@ Export-Package: org.eclipse.internal.net4j.transport;version="0.8.0",
org.eclipse.net4j.util.lifecycle;version="0.8.0",
org.eclipse.net4j.util.registry;version="0.8.0",
org.eclipse.net4j.util.stream;version="0.8.0"
-Bundle-Vendor: %providerName
-Bundle-Activator: org.eclipse.internal.net4j.bundle.Activator
+Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.net4j/TODOS.txt b/plugins/org.eclipse.net4j/TODOS.txt
index e69de29..e6b9e18 100644
--- a/plugins/org.eclipse.net4j/TODOS.txt
+++ b/plugins/org.eclipse.net4j/TODOS.txt
@@ -0,0 +1,2 @@
+SSL
+SoftReferences in BufferPool
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Activator.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Activator.java
index 9b4150a..3f20844 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Activator.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Activator.java
@@ -1,15 +1,65 @@
+/***************************************************************************
+ * 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.internal.net4j.bundle;
+import org.eclipse.internal.net4j.util.operation.BundleDebugOptions;
+import org.eclipse.internal.net4j.util.operation.BundleLogger;
+
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+/**
+ * @author Eike Stepper
+ */
public class Activator implements BundleActivator
{
+ public static final String BUNDLE_ID = "org.eclipse.net4j";
+
+ private BundleLogger logger;
+
+ private BundleDebugOptions debugOptions;
+
public void start(BundleContext context) throws Exception
{
+ try
+ {
+ Log.setLogger(logger = new BundleLogger(context));
+ Trace.setDebugOptions(debugOptions = new BundleDebugOptions(context));
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
}
public void stop(BundleContext context) throws Exception
{
+ try
+ {
+ Trace.unsetDebugOptions(debugOptions);
+ debugOptions.dispose();
+ }
+ finally
+ {
+ debugOptions = null;
+ }
+
+ try
+ {
+ Log.unsetLogger(logger);
+ logger.dispose();
+ }
+ finally
+ {
+ logger = null;
+ }
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Log.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Log.java
index ade141c..7a08943 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Log.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Log.java
@@ -1,113 +1,76 @@
-package org.eclipse.internal.net4j.util.bundle;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-
+/***************************************************************************
+ * 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.internal.net4j.bundle;
+
+import org.eclipse.net4j.util.operation.ILogger;
+import org.eclipse.net4j.util.operation.ILogger.Level;
+
+import org.eclipse.internal.net4j.util.operation.ConsoleLogger;
+
+/**
+ * @author Eike Stepper
+ */
public final class Log
{
- private static ServiceTracker logTracker;
+ private static ILogger logger;
private Log()
{
};
- static void init(BundleContext bc)
+ public static void log(Level level, Object plastic)
{
- logTracker = new ServiceTracker(bc, LogService.class.getName(), null);
- logTracker.open();
+ getLogger().log(level, plastic);
}
- static void dispose()
+ public static void error(Object plastic)
{
- if (logTracker != null)
- {
- logTracker.close();
- logTracker = null;
- }
+ getLogger().error(plastic);
}
- public static void debug(String message)
+ public static void warn(Object plastic)
{
- log(LogService.LOG_DEBUG, message, null);
+ getLogger().warn(plastic);
}
- public static void debug(String message, Throwable t)
+ public static void info(Object plastic)
{
- log(LogService.LOG_DEBUG, message, null);
+ getLogger().info(plastic);
}
- public static void info(String message)
+ public static void debug(Object plastic)
{
- log(LogService.LOG_INFO, message, null);
+ getLogger().debug(plastic);
}
- public static void info(String message, Throwable t)
+ public static synchronized ILogger getLogger()
{
- log(LogService.LOG_INFO, message, null);
- }
-
- public static void warn(String message)
- {
- log(LogService.LOG_WARNING, message, null);
- }
-
- public static void warn(String message, Throwable t)
- {
- log(LogService.LOG_WARNING, message, null);
- }
-
- public static void error(String message)
- {
- log(LogService.LOG_ERROR, message, null);
- }
+ if (logger == null)
+ {
+ logger = new ConsoleLogger(Activator.BUNDLE_ID);
+ }
- public static void error(String message, Throwable t)
- {
- log(LogService.LOG_ERROR, message, null);
+ return logger;
}
- public static void log(int level, String message)
+ public static void setLogger(ILogger logger)
{
- log(level, message, null);
+ Log.logger = logger;
}
- public static void log(int level, String message, Throwable t)
+ public static void unsetLogger(ILogger logger)
{
- LogService logService = (LogService)logTracker.getService();
- if (logService != null)
- {
- logService.log(level, message, t);
- }
- else
+ if (Log.logger == logger)
{
- switch (level)
- {
- case LogService.LOG_DEBUG:
- System.out.print("[DEBUG] ");
- break;
-
- case LogService.LOG_INFO:
- System.out.print("[INFO] ");
- break;
-
- case LogService.LOG_WARNING:
- System.out.print("[WARN] ");
- break;
-
- case LogService.LOG_ERROR:
- System.out.print("[ERROR] ");
- break;
-
- default:
- break;
- }
-
- System.out.println(message);
- if (t != null)
- {
- t.printStackTrace();
- }
+ Log.logger = null;
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Trace.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Trace.java
new file mode 100644
index 0000000..e5159c6
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Trace.java
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * 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.internal.net4j.bundle;
+
+import org.eclipse.net4j.util.operation.AbstractTracer;
+import org.eclipse.net4j.util.operation.IDebugOptions;
+import org.eclipse.net4j.util.operation.ITracer;
+
+/**
+ * @author Eike Stepper
+ */
+public final class Trace
+{
+ public static final ITracer DEBUG = new Tracer("debug");
+
+ public static final ITracer CONNECTOR = DEBUG.child("connector");
+
+ public static final ITracer CONNECTOR_STATE = CONNECTOR.child("state");
+
+ public static final ITracer CONNECTOR_CHANNELS = CONNECTOR.child("channels");
+
+ private static IDebugOptions debugOptions;
+
+ private Trace()
+ {
+ }
+
+ public static void setDebugOptions(IDebugOptions debugOptions)
+ {
+ Trace.debugOptions = debugOptions;
+ }
+
+ public static void unsetDebugOptions(IDebugOptions options)
+ {
+ if (Trace.debugOptions == debugOptions)
+ {
+ Trace.debugOptions = null;
+ }
+ }
+
+ private static class Tracer extends AbstractTracer
+ {
+ public Tracer(String tracerName)
+ {
+ super(tracerName);
+ }
+
+ public boolean isEnabled()
+ {
+ return debugOptions.isDebugging() && debugOptions.getBooleanOption(getTracerName(), false);
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ debugOptions.setOption(getTracerName(), Boolean.toString(enabled));
+ }
+
+ public ITracer child(String tracerName)
+ {
+ return new Tracer(getTracerName() + "." + tracerName);
+ }
+ }
+}
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 5fdcf22..ac51654 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
@@ -24,6 +24,9 @@ import org.eclipse.net4j.util.lifecycle.LifecycleNotifier;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.registry.IRegistry;
+import org.eclipse.internal.net4j.bundle.Log;
+import org.eclipse.internal.net4j.bundle.Trace;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
@@ -189,8 +192,12 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
State oldState = getState();
if (newState != oldState)
{
- System.out.println(toString() + ": Setting state " + newState + " (was " //$NON-NLS-1$ //$NON-NLS-2$
- + oldState.toString().toLowerCase() + ")"); //$NON-NLS-1$
+ if (Trace.CONNECTOR_STATE.isEnabled())
+ {
+ Trace.CONNECTOR_STATE.trace(AbstractConnector.class, "Setting state " + newState + " (was " //$NON-NLS-1$ //$NON-NLS-2$
+ + oldState.toString().toLowerCase() + ")"); //$NON-NLS-1$
+ }
+
state = newState;
fireStateChanged(newState, oldState);
@@ -264,7 +271,11 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
try
{
- System.out.println(toString() + ": Waiting for connection..."); //$NON-NLS-1$
+ if (Trace.CONNECTOR_STATE.isEnabled())
+ {
+ Trace.CONNECTOR_STATE.trace(AbstractConnector.class, "Waiting for connection..."); //$NON-NLS-1$
+ }
+
return finishedNegotiating.await(timeout, TimeUnit.MILLISECONDS);
}
catch (InterruptedException ex)
@@ -343,8 +354,11 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
ChannelImpl channel = new ChannelImpl(receiveExecutor);
Protocol protocol = createProtocol(protocolID, channel);
- System.out.println(toString() + ": Opening channel " + channelID //$NON-NLS-1$
- + (protocol == null ? " without protocol" : " with protocol " + protocolID)); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Trace.CONNECTOR_CHANNELS.isEnabled())
+ {
+ Trace.CONNECTOR_CHANNELS.trace(AbstractConnector.class, "Opening channel " + channelID //$NON-NLS-1$
+ + (protocol == null ? " without protocol" : " with protocol " + protocolID)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
channel.setChannelID(channelID);
channel.setConnector(this);
@@ -368,7 +382,11 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
}
catch (IndexOutOfBoundsException ex)
{
- System.out.println(toString() + ": Invalid channelID " + channelID); //$NON-NLS-1$
+ if (Trace.CONNECTOR_CHANNELS.isEnabled())
+ {
+ Trace.CONNECTOR_CHANNELS.trace(AbstractConnector.class, "Invalid channelID " + channelID); //$NON-NLS-1$
+ }
+
return null;
}
}
@@ -423,8 +441,11 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
channel.removeLifecycleListener(channelLifecycleListener);
int channelID = channel.getChannelID();
+ if (Trace.CONNECTOR_CHANNELS.isEnabled())
+ {
+ Trace.CONNECTOR_CHANNELS.trace(AbstractConnector.class, "Removing channel " + channelID); //$NON-NLS-1$
+ }
- System.out.println(toString() + ": Removing channel " + channelID); //$NON-NLS-1$
channels.set(channelID, NULL_CHANNEL);
}
@@ -444,7 +465,11 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
ProtocolFactory factory = registry.lookup(protocolID);
if (factory == null)
{
- System.out.println(toString() + ": Unknown protocol " + protocolID); //$NON-NLS-1$
+ if (Trace.CONNECTOR_CHANNELS.isEnabled())
+ {
+ Trace.CONNECTOR_CHANNELS.trace(AbstractConnector.class, "Unknown protocol " + protocolID); //$NON-NLS-1$
+ }
+
return null;
}
@@ -465,6 +490,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
}
}
}
+
protected void fireChannelOpened(Channel channel)
{
for (ChannelListener listener : channelListeners)
@@ -521,12 +547,12 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
if (protocolFactoryRegistry == null)
{
- System.out.println(toString() + ": (INFO) protocolFactoryRegistry == null"); //$NON-NLS-1$
+ Log.info("protocolFactoryRegistry == null"); //$NON-NLS-1$
}
if (receiveExecutor == null)
{
- System.out.println(toString() + ": (INFO) receiveExecutor == null"); //$NON-NLS-1$
+ Log.info("receiveExecutor == null"); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/map/AbstractCachingMap.java
index bb69be2..398eac0 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/map/AbstractCachingMap.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.internal.net4j.util;
+package org.eclipse.internal.net4j.util.map;
import java.util.AbstractMap;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractDelegatingMap.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/map/AbstractDelegatingMap.java
index 3b17776..9e04356 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractDelegatingMap.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/map/AbstractDelegatingMap.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.internal.net4j.util;
+package org.eclipse.internal.net4j.util.map;
import java.util.Collection;
import java.util.Map;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractDebugOptions.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractDebugOptions.java
new file mode 100644
index 0000000..1711586
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractDebugOptions.java
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * 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.internal.net4j.util.operation;
+
+import org.eclipse.net4j.util.operation.IDebugOptions;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractDebugOptions implements IDebugOptions
+{
+ private boolean initialized;
+
+ private boolean debugging;
+
+ public AbstractDebugOptions()
+ {
+ }
+
+ public void dispose()
+ {
+ }
+
+ public boolean isDebugging()
+ {
+ if (!initialized)
+ {
+ debugging = getBooleanOption("debug", false);
+ initialized = true;
+ }
+
+ return debugging;
+ }
+
+ public void setDebugging(boolean debugging)
+ {
+ this.debugging = debugging;
+ initialized = true;
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractLogger.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractLogger.java
new file mode 100644
index 0000000..39e866f
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/AbstractLogger.java
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * 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.internal.net4j.util.operation;
+
+import org.eclipse.net4j.util.operation.ILogger;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractLogger implements ILogger
+{
+ public AbstractLogger()
+ {
+ }
+
+ public void error(Object plastic)
+ {
+ log(Level.ERROR, plastic);
+ }
+
+ public void warn(Object plastic)
+ {
+ log(Level.WARN, plastic);
+ }
+
+ public void info(Object plastic)
+ {
+ log(Level.INFO, plastic);
+ }
+
+ public void debug(Object plastic)
+ {
+ log(Level.DEBUG, plastic);
+ }
+
+ public void dispose()
+ {
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleDebugOptions.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleDebugOptions.java
new file mode 100644
index 0000000..4f910b8
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleDebugOptions.java
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * 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.internal.net4j.util.operation;
+
+import org.eclipse.osgi.service.debug.DebugOptions;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Eike Stepper
+ */
+public class BundleDebugOptions extends AbstractDebugOptions
+{
+ private String bundleName;
+
+ private ServiceTracker debugTracker;
+
+ public BundleDebugOptions(BundleContext context)
+ {
+ bundleName = context.getBundle().getSymbolicName();
+ debugTracker = new ServiceTracker(context, DebugOptions.class.getName(), null);
+ debugTracker.open();
+ }
+
+ @Override
+ public void dispose()
+ {
+ debugTracker.close();
+ debugTracker = null;
+ }
+
+ public String getOption(String option)
+ {
+ return getDebugService().getOption(getPrefixedOption(option));
+ }
+
+ public String getOption(String option, String defaultValue)
+ {
+ return getDebugService().getOption(getPrefixedOption(option), defaultValue);
+ }
+
+ public boolean getBooleanOption(String option, boolean defaultValue)
+ {
+ return getDebugService().getBooleanOption(getPrefixedOption(option), defaultValue);
+ }
+
+ public int getIntegerOption(String option, int defaultValue)
+ {
+ return getDebugService().getIntegerOption(getPrefixedOption(option), defaultValue);
+ }
+
+ public void setOption(String option, String value)
+ {
+ getDebugService().setOption(getPrefixedOption(option), value);
+ }
+
+ private DebugOptions getDebugService()
+ {
+ DebugOptions debugService = (DebugOptions)debugTracker.getService();
+ if (debugService == null)
+ {
+ throw new IllegalStateException("debugService == null");
+ }
+
+ return debugService;
+ }
+
+ private String getPrefixedOption(String option)
+ {
+ return bundleName + "/" + option;
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleLogger.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleLogger.java
new file mode 100644
index 0000000..395b4a9
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/BundleLogger.java
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * 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.internal.net4j.util.operation;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Eike Stepper
+ */
+public class BundleLogger extends AbstractLogger
+{
+ private String bundleName;
+
+ private ServiceTracker logTracker;
+
+ public BundleLogger(BundleContext context)
+ {
+ bundleName = context.getBundle().getSymbolicName();
+ logTracker = new ServiceTracker(context, LogService.class.getName(), null);
+ logTracker.open();
+ }
+
+ @Override
+ public void dispose()
+ {
+ logTracker.close();
+ logTracker = null;
+ }
+
+ public String getLoggerName()
+ {
+ return bundleName;
+ }
+
+ public void log(Level level, Object plastic)
+ {
+ LogService logService = (LogService)logTracker.getService();
+ if (logService != null)
+ {
+ if (plastic instanceof Throwable)
+ {
+ Throwable t = (Throwable)plastic;
+ logService.log(toOSGi(level), t.getLocalizedMessage(), t);
+ }
+ else
+ {
+ logService.log(toOSGi(level), plastic.toString());
+ }
+ }
+ }
+
+ private static int toOSGi(Level level)
+ {
+ switch (level)
+ {
+ case ERROR:
+ return LogService.LOG_ERROR;
+ case WARN:
+ return LogService.LOG_WARNING;
+ case INFO:
+ return LogService.LOG_INFO;
+ case DEBUG:
+ return LogService.LOG_DEBUG;
+ default:
+ throw new IllegalArgumentException("Illegal log level: " + level);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/ConsoleLogger.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/ConsoleLogger.java
new file mode 100644
index 0000000..d8c4211
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/operation/ConsoleLogger.java
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * 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.internal.net4j.util.operation;
+
+import java.io.PrintStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ConsoleLogger extends AbstractLogger
+{
+ private String loggerName;
+
+ private PrintStream out;
+
+ private PrintStream err;
+
+ public ConsoleLogger(String loggerName, PrintStream out, PrintStream err)
+ {
+ this.loggerName = loggerName;
+ this.out = out;
+ this.err = err;
+ }
+
+ public ConsoleLogger(String loggerName)
+ {
+ this(loggerName, System.out, System.err);
+ }
+
+ public String getLoggerName()
+ {
+ return loggerName;
+ }
+
+ public void log(Level level, Object plastic)
+ {
+ PrintStream stream = level == Level.ERROR ? err : out;
+ String prefix = toString(level) + " ";
+ if (plastic instanceof Throwable)
+ {
+ Throwable t = (Throwable)plastic;
+ stream.println(prefix + t.getLocalizedMessage());
+ t.printStackTrace(stream);
+ }
+ else
+ {
+ stream.println(prefix + plastic.toString());
+ }
+ }
+
+ private static String toString(Level level)
+ {
+ switch (level)
+ {
+ case ERROR:
+ return "[ERROR]";
+ case WARN:
+ return "[WARN]";
+ case INFO:
+ return "[INFO]";
+ case DEBUG:
+ return "[DEBUG]";
+ default:
+ throw new IllegalArgumentException("Illegal log level: " + level);
+ }
+ }
+}
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 51d3464..8ae147b 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
@@ -51,7 +51,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
{
ReflectUtil.dump(this, toString() + ": DUMP "); //$NON-NLS-1$
}
-}
+ }
}
public final synchronized Exception deactivate()
@@ -111,6 +111,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
}
}
}
+
protected void fireLifecycleActivated()
{
for (LifecycleListener listener : listeners)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/AbstractTracer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/AbstractTracer.java
new file mode 100644
index 0000000..2ec5e6b
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/AbstractTracer.java
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * 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.operation;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractTracer implements ITracer
+{
+ private String tracerName;
+
+ public AbstractTracer(String tracerName)
+ {
+ this.tracerName = tracerName;
+ }
+
+ public String getTracerName()
+ {
+ return tracerName;
+ }
+
+ public void trace(Class context, String msg)
+ {
+ System.out.println(context.getName() + ": " + msg);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/IDebugOptions.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/IDebugOptions.java
new file mode 100644
index 0000000..d42e2b2
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/IDebugOptions.java
@@ -0,0 +1,33 @@
+/***************************************************************************
+ * 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.operation;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IDebugOptions
+{
+ public boolean isDebugging();
+
+ public void setDebugging(boolean debugging);
+
+ public String getOption(String option);
+
+ public String getOption(String option, String defaultValue);
+
+ public boolean getBooleanOption(String option, boolean defaultValue);
+
+ public int getIntegerOption(String option, int defaultValue);
+
+ public void setOption(String option, String value);
+
+ public void dispose();
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ILogger.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ILogger.java
new file mode 100644
index 0000000..009c0d5
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ILogger.java
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * 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.operation;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ILogger
+{
+ public String getLoggerName();
+
+ public void log(Level level, Object plastic);
+
+ public void error(Object plastic);
+
+ public void warn(Object plastic);
+
+ public void info(Object plastic);
+
+ public void debug(Object plastic);
+
+ public void dispose();
+
+ /**
+ * @author Eike Stepper
+ */
+ public enum Level
+ {
+ ERROR, WARN, INFO, DEBUG
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ITracer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ITracer.java
new file mode 100644
index 0000000..1637413
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/operation/ITracer.java
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * 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.operation;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ITracer
+{
+ public String getTracerName();
+
+ public boolean isEnabled();
+
+ public void setEnabled(boolean enabled);
+
+ public void trace(Class context, String msg);
+
+ public ITracer child(String tracerName);
+}