diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/LoggerController.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/LoggerController.java
index e1d6b22cde1..5e66d53a317 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/LoggerController.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/LoggerController.java
@@ -18,14 +18,11 @@ package org.eclipse.rse.internal.logging;
import java.util.Hashtable;
+import org.eclipse.core.runtime.Plugin;
import org.eclipse.rse.logging.Logger;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
public class LoggerController {
- public static final String Copyright =
- "(C) Copyright IBM Corp. 2002, 2003. All Rights Reserved.";
-
private static Hashtable pluginTable = new Hashtable();
/**
@@ -33,19 +30,19 @@ public class LoggerController {
* It will return null if no Logger instance has been created
* for this plugin before.
*/
- public static Logger getInst(AbstractUIPlugin plugin) {
+ public static Logger getInst(Plugin plugin) {
if (pluginTable.containsKey(plugin))
return (Logger) pluginTable.get(plugin);
else
return null;
}
- public static void registerInst(AbstractUIPlugin plugin, Logger logger) {
+ public static void registerInst(Plugin plugin, Logger logger) {
pluginTable.put(plugin, logger);
return;
}
- public static void freeInst(AbstractUIPlugin plugin) {
+ public static void freeInst(Plugin plugin) {
// get cached instance if one exists.
Logger logger = getInst(plugin);
// no luck, this means we have an incorrect free, do nothing.
diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/RemoteSystemLogListener.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/RemoteSystemLogListener.java
index 52d7fc12b3e..ab09585cc3c 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/RemoteSystemLogListener.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/internal/logging/RemoteSystemLogListener.java
@@ -25,65 +25,59 @@ import java.util.Date;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
+import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.rse.logging.IRemoteSystemsLogging;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* Log Listener is a sink for messages coming from Logger.
*/
-public class RemoteSystemLogListener
- implements ILogListener, IPropertyChangeListener {
-
- public static final String Copyright =
- "(C) Copyright IBM Corp. 2002, 2003. All Rights Reserved.";
+public class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
private PrintWriter log = null;
private File outputFile = null;
private boolean log_to_stdout = false;
- private AbstractUIPlugin plugin = null;
+ private Plugin plugin = null;
- public RemoteSystemLogListener(AbstractUIPlugin plugin) {
+ /**
+ * Create a new log listener for a plugin.
+ * @param plugin The plugin for which to create a log listener.
+ */
+ public RemoteSystemLogListener(Plugin plugin) {
this.plugin = plugin;
- IPath path =
- plugin.getStateLocation().addTrailingSeparator().append(".log");
-
+ IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log");
outputFile = path.toFile();
-
- // make sure to delete old log file.
if ((outputFile != null) && (outputFile.exists())) {
outputFile.delete();
}
-
initialize();
}
+ /**
+ * Initialize the logger. Retrieves the logging location preference and sets up the logger
+ * to log to that location.
+ */
private void initialize() {
try {
- // Initialize log file location here. Check to see
- // if we need to log to file or View.
- IPreferenceStore store = plugin.getPreferenceStore();
- String log_location =
- store.getString(
- IRemoteSystemsLogging.LOG_LOCATION);
-
- if ((log_location != null)
- && (log_location
- .equalsIgnoreCase(IRemoteSystemsLogging.LOG_TO_STDOUT))) {
+ Preferences store = plugin.getPluginPreferences();
+ String log_location = store.getString(IRemoteSystemsLogging.LOG_LOCATION);
+ if ((log_location != null) && (log_location.equalsIgnoreCase(IRemoteSystemsLogging.LOG_TO_STDOUT))) {
doLogToView();
} else {
doLogToFile();
}
} catch (Exception e) {
- // can not log anything.
log = null;
- System.err.println("Exception in RemoteSystemLogListener.initialize(): "+e.getMessage());
+ System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage());
e.printStackTrace();
}
}
+ /**
+ * Logs to standard output.
+ */
private void doLogToView() {
// make sure we free resources first
freeResources();
@@ -153,7 +147,6 @@ public class RemoteSystemLogListener
if (log == null)
return;
else {
- int severity = status.getSeverity();
log.print("\t\t");
log.println(status.getMessage());
if (status.getException() != null)
diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Activator.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Activator.java
index c61191dba11..4f9eaa3bd8a 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Activator.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Activator.java
@@ -16,14 +16,13 @@
package org.eclipse.rse.logging;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The main plugin class to be used in the desktop.
*/
-public class Activator extends AbstractUIPlugin {
+public class Activator extends Plugin {
//The shared instance.
private static Activator plugin;
@@ -57,14 +56,4 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path.
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.rse.logging", path);
- }
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Logger.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Logger.java
index 3264186064a..3cf0f6522a4 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Logger.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/Logger.java
@@ -20,12 +20,12 @@ import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
+import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.rse.internal.logging.RemoteSystemLogListener;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
@@ -92,7 +92,7 @@ public class Logger implements IPropertyChangeListener {
// Cashed Plugin ID, and plugin
private String pluginId = null;
- AbstractUIPlugin systemPlugin = null;
+ Plugin systemPlugin = null;
// Controls logging level
private int debug_level = 0;
@@ -100,7 +100,7 @@ public class Logger implements IPropertyChangeListener {
// Captures initialization errors
private boolean init_ok = true;
- protected Logger(AbstractUIPlugin systemPlugin) {
+ protected Logger(Plugin systemPlugin) {
this.systemPlugin = systemPlugin;
this.pluginId = systemPlugin.getBundle().getSymbolicName();
initialize();
@@ -116,11 +116,11 @@ public class Logger implements IPropertyChangeListener {
// get the debug level from plugin Preference store.
// note: logListener must be initialized before calling getPreference store!
- IPreferenceStore store = systemPlugin.getPreferenceStore();
+ Preferences store = systemPlugin.getPluginPreferences();
debug_level = store.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
- systemPlugin.getPreferenceStore().addPropertyChangeListener(this);
- systemPlugin.getPreferenceStore().addPropertyChangeListener(logListener);
+ store.addPropertyChangeListener(this);
+ store.addPropertyChangeListener(logListener);
} catch (Exception e) {
// Errors occured during initialize, disable logging.
@@ -264,10 +264,8 @@ public class Logger implements IPropertyChangeListener {
*/
public synchronized void propertyChange(PropertyChangeEvent event) {
// refresh the debug level from plugin Preference store
- debug_level =
- systemPlugin.getPreferenceStore().getInt(
- IRemoteSystemsLogging.DEBUG_LEVEL);
-
+ Preferences prefs = systemPlugin.getPluginPreferences();
+ debug_level = prefs.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
}
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggerFactory.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggerFactory.java
index b879ba58786..f2e6d248dcd 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggerFactory.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggerFactory.java
@@ -16,9 +16,8 @@
package org.eclipse.rse.logging;
+import org.eclipse.core.runtime.Plugin;
import org.eclipse.rse.internal.logging.LoggerController;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
/**
* Factory class for creating Logger instances.
@@ -34,7 +33,7 @@ public class LoggerFactory {
* a singelton instance of the Logger class per plugin. You are guarenteed the
* same instance if one has previously been created.
*/
- public static Logger getInst(AbstractUIPlugin plugin) {
+ public static Logger getInst(Plugin plugin) {
// get cached instance from controller if one exists.
Logger inst = LoggerController.getInst(plugin);
@@ -58,7 +57,7 @@ public class LoggerFactory {
* Frees resources used by the Logger instance for the given plugin.
* This methods must be called as part of the the plugin shutdown life cycle.
*/
- public static void freeInst(AbstractUIPlugin plugin) {
+ public static void freeInst(Plugin plugin) {
// delegate to controller
LoggerController.freeInst(plugin);
}
diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggingPreferencePage.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggingPreferencePage.java
index 072c09c6b27..455bb9a6839 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggingPreferencePage.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/LoggingPreferencePage.java
@@ -94,10 +94,10 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
String bundleName = (String)(bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME));
String topLabel1 = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.topLabel1");
topLabel1 = MessageFormat.format(topLabel1, new Object[] {bundleName});
- Label label1 = createLabel(composite_tab, topLabel1);
+ createLabel(composite_tab, topLabel1);
forceSpace(composite_tab);
String topLabel2 = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.topLabel2");
- Label label2 = createLabel(composite_tab, topLabel2);
+ createLabel(composite_tab, topLabel2);
tabForward(composite_tab);
Composite composite1_radioButton = createComposite(composite_tab, 1);
String text = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.errors_only");
@@ -341,12 +341,10 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
* This is needed to get to the plugin id, and then plugin instance.
*/
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- // we are assuming here that only AbstractUIPlugins will be used.
try {
- String nameSpace = config.getDeclaringExtension().getNamespace();
- this.bundle = Platform.getBundle(nameSpace);
+ String pluginName = config.getDeclaringExtension().getContributor().getName();
+ this.bundle = Platform.getBundle(pluginName);
} catch (Exception e) {
- // log error. plugin remains null.
RemoteSystemsLoggingPlugin.out.logError("Failed to create LoggingPreferencePage.", e);
}
}
diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/RemoteSystemsLoggingPlugin.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/RemoteSystemsLoggingPlugin.java
index 2f88a36990c..81eee3703ed 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/RemoteSystemsLoggingPlugin.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/RemoteSystemsLoggingPlugin.java
@@ -20,17 +20,18 @@ import java.net.URL;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Preferences;
import org.osgi.framework.BundleContext;
/**
* Remote Systems Logging plugin.
*/
-public class RemoteSystemsLoggingPlugin extends AbstractUIPlugin {
+public class RemoteSystemsLoggingPlugin extends Plugin {
//The shared instance.
@@ -83,7 +84,7 @@ public class RemoteSystemsLoggingPlugin extends AbstractUIPlugin {
try {
IPath path = new Path("$nl$/RemoteSystemsLogging.properties");
- URL url = Platform.find(getBundle(), path);
+ URL url = FileLocator.find(getBundle(), path, null);
resourceBundle = new PropertyResourceBundle(url.openStream());
} catch (Exception x) {
resourceBundle = null;
@@ -95,16 +96,12 @@ public class RemoteSystemsLoggingPlugin extends AbstractUIPlugin {
}
/**
- * Sets default preference values. These values will be used
- * until some preferences are actually set using Preference dialog.
+ * Sets default preference values.
*/
public void initializeDefaultPreferences() {
- getPreferenceStore().setDefault(
- IRemoteSystemsLogging.DEBUG_LEVEL,
- IRemoteSystemsLogging.LOG_ERROR);
- getPreferenceStore().setDefault(
- IRemoteSystemsLogging.LOG_LOCATION,
- IRemoteSystemsLogging.LOG_TO_FILE);
+ Preferences prefs = getPluginPreferences();
+ prefs.setDefault(IRemoteSystemsLogging.DEBUG_LEVEL, IRemoteSystemsLogging.LOG_ERROR);
+ prefs.setDefault(IRemoteSystemsLogging.LOG_LOCATION, IRemoteSystemsLogging.LOG_TO_FILE);
}
/**
diff --git a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/performance/PerformanceLogger.java b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/performance/PerformanceLogger.java
index 2cf25c76a95..a4e58fad24c 100644
--- a/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/performance/PerformanceLogger.java
+++ b/rse/plugins/org.eclipse.rse.logging/src/org/eclipse/rse/logging/performance/PerformanceLogger.java
@@ -94,6 +94,13 @@ public class PerformanceLogger
static boolean _initialized = false;
static HashMap perfLogRegistry = new HashMap();
+ /*
+ * Static initializer to normalize this logger.
+ */
+ static {
+ normalize();
+ }
+
static class StartData
{
long startTime = -1;
@@ -119,18 +126,7 @@ public class PerformanceLogger
component = comp_id;
}
}
-
-
- /**
- * PerformanceLogger(): class constructor
- * @return
- * - Normalization time generated
- * - XML file for default component created
- */
- private PerformanceLogger() {
- init();
- }
-
+
/**
* public static void enablePerformanceLogging(boolean enable) : enable performance logging
* @param
@@ -241,35 +237,28 @@ public class PerformanceLogger
}
/**
- * private void init() : method for class instance initialization.
- * @return
- * Normalization value generated
+ * Set the normalization unit for this run.based on a standard method for class instance initialization.
+ * @return a string containing the unit.
*/
- private void init() {
- if (samplingTime == -1) {
-
- /*Set normalization values*/
-
- long startTime = System.currentTimeMillis();
-
- /*Trying to make sure it is not optimized by the compiler? */
- /* Excute some standard instruction sets, such that a reasonably elapsed time can be obtained */
- double val = 0;
- Double q = null;
- int i = 0;
- int n = 1000000;
- for ( i = 0; i < n; i++) { /* increment operation for 1000 times */
- Double dd = new Double(n);
- Double dr = new Double(n+i);
- q = new Double(dd.doubleValue()/dr.doubleValue());
- }
- val = q.doubleValue()/i;
-
- long stopTime = System.currentTimeMillis();
- samplingTime = stopTime-startTime;
- System.out.println("SystemPerformanceLogger::Normalization Elapsed time = " + samplingTime);
+ public static String normalize() {
+ /*
+ * Execute some standard code and time it to generate our normalization interval.
+ * Return the value to attempt to make it is not optimized by the compiler.
+ */
+ long startTime = System.currentTimeMillis();
+ Double q = null;
+ int i = 0;
+ int n = 1000000;
+ for ( i = 0; i < n; i++) {
+ Double dd = new Double(n);
+ Double dr = new Double(n+i);
+ q = new Double(dd.doubleValue() / dr.doubleValue());
}
-
+ double val = q.doubleValue() / i;
+ long stopTime = System.currentTimeMillis();
+ samplingTime = stopTime-startTime;
+ String result = "SystemPerformanceLogger::Normalization Elapsed time = " + samplingTime + " " + val;
+ return result;
}
/**
@@ -495,7 +484,7 @@ public class PerformanceLogger
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
- Element root = cd.doc.getDocumentElement();
+ cd.doc.getDocumentElement();
Element task = td.node;
/* Construct Long class insatnce for string manipulation */
@@ -658,19 +647,10 @@ public class PerformanceLogger
* os.version
*/
public static void listSystemProfile() {
- String java_version = System.getProperty("java.version");
System.out.println("java version : " + System.getProperty("java.version"));
- String java_vm_version = System.getProperty("java.vm.version");
- String java_class_version = System.getProperty("java.class.version");
- String java_class_path = System.getProperty("java.class.path");
- String java_library_path = System.getProperty("java.library.path");
- String os_name = System.getProperty("os.name");
System.out.println("OS name : " + System.getProperty("os.name"));
- String os_version = System.getProperty("os.version");
System.out.println("OS version : " + System.getProperty("os.version"));
- String user_dir = System.getProperty("user.dir");
System.out.println("working dir : " + System.getProperty("user.dir"));
- String home_dir = System.getProperty("home.dir");
System.out.println("home dir : " + System.getProperty("home.dir"));
}
@@ -732,8 +712,6 @@ public class PerformanceLogger
key = PerformanceLogger.register(key); // Expect error: already registered
PerformanceLogger.deRegister(key);
key = PerformanceLogger.register(key);
-
- String val = "i = " + i;
}
}
\ No newline at end of file