From bf3498c214d93cec972d62e57ca6ed3a8ff5fbae Mon Sep 17 00:00:00 2001 From: slewis Date: Mon, 30 Oct 2006 02:35:18 +0000 Subject: Moved DiscoveryPlugin to internal package. Removed Trace and .options file --- .../org/eclipse/ecf/discovery/DiscoveryPlugin.java | 82 -------------- .../src/org/eclipse/ecf/discovery/Trace.java | 125 --------------------- .../ecf/internal/discovery/DiscoveryPlugin.java | 82 ++++++++++++++ 3 files changed, 82 insertions(+), 207 deletions(-) delete mode 100644 framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryPlugin.java delete mode 100644 framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/Trace.java create mode 100644 framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/DiscoveryPlugin.java (limited to 'framework/bundles/org.eclipse.ecf.discovery/src') diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryPlugin.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryPlugin.java deleted file mode 100644 index 1433e0fa8..000000000 --- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryPlugin.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 Composent, Inc. and others. 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: Composent, Inc. - initial API and implementation - ******************************************************************************/ - -package org.eclipse.ecf.discovery; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; -import java.util.*; - -/** - * The main plugin class to be used in the desktop. - */ -public class DiscoveryPlugin extends Plugin { - //The shared instance. - private static DiscoveryPlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; - - /** - * The constructor. - */ - public DiscoveryPlugin() { - super(); - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - resourceBundle = null; - } - - /** - * Returns the shared instance. - */ - public static DiscoveryPlugin getDefault() { - return plugin; - } - - /** - * Returns the string from the plugin's resource bundle, - * or 'key' if not found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = DiscoveryPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - try { - if (resourceBundle == null) - resourceBundle = ResourceBundle.getBundle("org.eclipse.ecf.discovery.DiscoveryPluginResources"); - } catch (MissingResourceException x) { - resourceBundle = null; - } - return resourceBundle; - } - -} diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/Trace.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/Trace.java deleted file mode 100644 index a5c22eaae..000000000 --- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/Trace.java +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -* Copyright (c) 2004 Composent, Inc. and others. -* 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: -* Composent, Inc. - initial API and implementation -*****************************************************************************/ - -package org.eclipse.ecf.discovery; - -import java.text.SimpleDateFormat; -import java.util.Date; -import org.eclipse.core.runtime.Platform; - -public class Trace { - public static final String tracePrefix = "(trace)"; - - public static boolean ON = false; - protected static boolean isEclipse = false; - protected static String pluginName = ""; - protected static String debugPrefix = "/debug/"; - static { - try { - ON = Platform.inDebugMode(); - String bundleName = DiscoveryPlugin.getDefault().getBundle().getSymbolicName(); - String val = System.getProperty(bundleName+".Trace"); - if (val != null) { - setTrace(true); - isEclipse = false; - // No eclipse Platform available - System.out.println("WARNING: Eclipse platform not available for trace...overridden by system property org.eclipse.ecf.Trace"); - } else { - isEclipse = true; - pluginName = bundleName; - } - } catch (Exception e) { - try { - String val = System.getProperty("org.eclipse.ecf.discovery.Trace"); - if (val != null) { - setTrace(true); - isEclipse = false; - // No eclipse Platform available - System.out.println("WARNING: Eclipse platform not available for trace...using system.out for org.eclipse.ecf"); - } else { - System.out.println(Trace.class.getName()+": OFF"); - } - } catch (Exception except) { - } - } - } - public static void setTrace(boolean on) { - ON = on; - } - - public static Trace create(String key) { - if (isEclipse) { - String res = ""; - try { - res = Platform.getDebugOption(pluginName + debugPrefix + key); - } catch (Exception e) { - // ignore...this means that the Platform class not found. - } - if (res != null) { - Boolean on = new Boolean(res); - if (on.booleanValue()) - return new Trace(pluginName + "(" + key + ")"); - else - return null; - } else { - return null; - } - } else - return new Trace(key); - } - - String name; - - public void dumpStack(Throwable e, String msg) { - msg(msg); - e.printStackTrace(System.err); - } - - public void msg(String msg) { - StringBuffer sb = new StringBuffer(name); - sb.append(getTimeString()).append(msg); - System.out.println(sb.toString()); - } - - protected static String getTimeString() { - Date d = new Date(); - SimpleDateFormat df = new SimpleDateFormat("[MM/dd/yy;HH:mm:ss:SSS]"); - return df.format(d); - } - - protected Trace(String str) { - name = tracePrefix+str; - } - public static String convertStringAToString(String [] strings) { - if (strings==null) return ""; - StringBuffer sb = new StringBuffer(); - for(int i=0; i < strings.length; i++) { - if (strings[i]==null) sb.append("(null)"); - else sb.append(strings[i]); - if (i != (strings.length-1)) sb.append(";"); - } - return sb.toString(); - } - public static String convertObjectAToString(Object [] objs) { - if (objs==null) return ""; - StringBuffer sb = new StringBuffer(); - for(int i=0; i < objs.length; i++) { - if (objs[i]==null) sb.append("(null)"); - else sb.append(objs[i].toString()); - if (i != (objs.length-1)) sb.append(";"); - } - return sb.toString(); - } - - public static void setThreadDebugGroup(Object obj) { - // Do nothing - } -} \ No newline at end of file diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/DiscoveryPlugin.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/DiscoveryPlugin.java new file mode 100644 index 000000000..1867089a3 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/DiscoveryPlugin.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2004 Composent, Inc. and others. 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: Composent, Inc. - initial API and implementation + ******************************************************************************/ + +package org.eclipse.ecf.internal.discovery; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; +import java.util.*; + +/** + * The main plugin class to be used in the desktop. + */ +public class DiscoveryPlugin extends Plugin { + //The shared instance. + private static DiscoveryPlugin plugin; + //Resource bundle. + private ResourceBundle resourceBundle; + + /** + * The constructor. + */ + public DiscoveryPlugin() { + super(); + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + resourceBundle = null; + } + + /** + * Returns the shared instance. + */ + public static DiscoveryPlugin getDefault() { + return plugin; + } + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + */ + public static String getResourceString(String key) { + ResourceBundle bundle = DiscoveryPlugin.getDefault().getResourceBundle(); + try { + return (bundle != null) ? bundle.getString(key) : key; + } catch (MissingResourceException e) { + return key; + } + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() { + try { + if (resourceBundle == null) + resourceBundle = ResourceBundle.getBundle("org.eclipse.ecf.discovery.DiscoveryPluginResources"); + } catch (MissingResourceException x) { + resourceBundle = null; + } + return resourceBundle; + } + +} -- cgit v1.2.3