diff options
| author | slewis | 2004-12-31 06:16:05 +0000 |
|---|---|---|
| committer | slewis | 2004-12-31 06:16:05 +0000 |
| commit | 11ffd8f51a68dc04e1d467ee871a1227ea1cee41 (patch) | |
| tree | 4cba05941055ce074831a827a5b3404eb675697e | |
| parent | 267caa3dee7d5fac85ea3e16f177c96941f7f9ae (diff) | |
| download | org.eclipse.ecf-11ffd8f51a68dc04e1d467ee871a1227ea1cee41.tar.gz org.eclipse.ecf-11ffd8f51a68dc04e1d467ee871a1227ea1cee41.tar.xz org.eclipse.ecf-11ffd8f51a68dc04e1d467ee871a1227ea1cee41.zip | |
Added tracing to org.eclipse.ecf. Added new test org.eclipse.ecf.test.MultiContainerJoinTest and debugged join/leave group code in provider plugin
6 files changed, 155 insertions, 4 deletions
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ClientSOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ClientSOContainer.java index 7f44e7966..ec5430d2b 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ClientSOContainer.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ClientSOContainer.java @@ -274,7 +274,7 @@ public abstract class ClientSOContainer extends SOContainer { protected void memberLeave(ID fromID, IAsynchConnection conn) { if (fromID.equals(remoteServerID)) { - groupManager.removeAllMembers(); + groupManager.removeNonLocalMembers(); super.memberLeave(fromID, conn); connectionState = UNCONNECTED; connection = null; diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java index 0b3b5a13e..94c5bdbdd 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java @@ -123,6 +123,13 @@ public abstract class SOContainer implements ISharedObjectContainer { protected void memberLeave(ID target, IConnection conn) { debug("memberLeave:" + target + ":" + conn); + if (groupManager.removeMember(target)) { + try { + forwardExcluding(getID(),target,ContainerMessage.makeViewChangeMessage(getID(),null,getNextSequenceNumber(),new ID[] { target },false,null)); + } catch (IOException e) { + logException("Exception in memberLeave.forwardExcluding",e); + } + } if (conn != null) killConnection(conn); } diff --git a/framework/bundles/org.eclipse.ecf/.options b/framework/bundles/org.eclipse.ecf/.options new file mode 100644 index 000000000..5ab3fad6f --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/.options @@ -0,0 +1,6 @@ +org.eclipse.ecf/debug = true +org.eclipse.ecf/debug/filter = * +org.eclipse.ecf/debug/flag = true +org.eclipse.ecf/debug/containerfactory = true +org.eclipse.ecf/debug/idfactory = true +org.eclipse.ecf/debug/connectionfactory = true diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java index 0d77c26aa..7fbecc2a4 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java @@ -15,6 +15,7 @@ import java.util.List; import org.eclipse.ecf.core.provider.ISharedObjectContainerInstantiator; import org.eclipse.ecf.core.util.AbstractFactory; +import org.eclipse.ecf.internal.core.Trace; /** * Factory for creating {@link ISharedObjectContainer} instances. This @@ -35,6 +36,8 @@ import org.eclipse.ecf.core.util.AbstractFactory; */ public class SharedObjectContainerFactory { + private static Trace debug = Trace.create("containerfactory"); + private static Hashtable containerdescriptions = new Hashtable(); /* @@ -47,6 +50,7 @@ public class SharedObjectContainerFactory { */ public final static SharedObjectContainerDescription addDescription( SharedObjectContainerDescription scd) { + debug("addDescription("+scd+")"); return addDescription0(scd); } /** @@ -58,8 +62,20 @@ public class SharedObjectContainerFactory { * @return List of SharedObjectContainerDescription instances */ public final static List getDescriptions() { + debug("getDescriptions()"); return getDescriptions0(); } + private static void debug(String msg) { + if (Trace.ON && debug != null) { + debug.msg(msg); + } + } + + private static void dumpStack(String msg, Throwable e) { + if (Trace.ON && debug != null) { + debug.dumpStack(e, msg); + } + } protected static List getDescriptions0() { return new ArrayList(containerdescriptions.values()); } @@ -80,6 +96,7 @@ public class SharedObjectContainerFactory { */ public final static boolean containsDescription( SharedObjectContainerDescription scd) { + debug("containsDescription("+scd+")"); return containsDescription0(scd); } protected static boolean containsDescription0( @@ -110,6 +127,7 @@ public class SharedObjectContainerFactory { */ public final static SharedObjectContainerDescription getDescriptionByName( String name) throws SharedObjectContainerInstantiationException { + debug("getDescriptionByName("+name+")"); SharedObjectContainerDescription res = getDescription0(name); if (res == null) { throw new SharedObjectContainerInstantiationException( @@ -146,6 +164,7 @@ public class SharedObjectContainerFactory { public static ISharedObjectContainer makeSharedObjectContainer( SharedObjectContainerDescription desc, String[] argTypes, Object[] args) throws SharedObjectContainerInstantiationException { + debug("makeSharedObjectContainer("+desc+","+argTypes+","+args+")"); if (desc == null) throw new SharedObjectContainerInstantiationException( "SharedObjectContainerDescription cannot be null"); @@ -262,6 +281,7 @@ public class SharedObjectContainerFactory { */ public final static SharedObjectContainerDescription removeDescription( SharedObjectContainerDescription scd) { + debug("removeDescription("+scd+")"); return removeDescription0(scd); } protected static SharedObjectContainerDescription removeDescription0( diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java index 7b5143a5b..ee6a32132 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java @@ -16,6 +16,7 @@ import java.util.List; import org.eclipse.ecf.core.identity.provider.IDInstantiator; import org.eclipse.ecf.core.util.AbstractFactory; +import org.eclipse.ecf.internal.core.Trace; /** * A factory class for creating ID instances. This is the factory for plugins to @@ -24,6 +25,8 @@ import org.eclipse.ecf.core.util.AbstractFactory; */ public class IDFactory { + private static final Trace debug = Trace.create("idfactory"); + public static final String SECURITY_PROPERTY = IDFactory.class.getName() + ".security"; @@ -88,6 +91,7 @@ public class IDFactory { */ public final static boolean containsNamespace(Namespace n) throws SecurityException { + debug("containsNamespace("+n+")"); if (n == null) return false; checkPermission(new NamespacePermission(n.getPermissionName(), @@ -95,8 +99,20 @@ public class IDFactory { return containsNamespace0(n); } public final static List getNamespaces() { + debug("getNamespaces()"); return new ArrayList(namespaces.values()); } + private static void debug(String msg) { + if (Trace.ON && debug != null) { + debug.msg(msg); + } + } + + private static void dumpStack(String msg, Throwable e) { + if (Trace.ON && debug != null) { + debug.dumpStack(e, msg); + } + } protected final static boolean containsNamespace0(Namespace n) { if (n == null) return false; @@ -114,6 +130,7 @@ public class IDFactory { */ public final static Namespace getNamespace(Namespace n) throws SecurityException { + debug("getNamespace("+n+")"); if (n == null) return null; checkPermission(new NamespacePermission(n.getPermissionName(), @@ -123,6 +140,7 @@ public class IDFactory { public final static Namespace getNamespaceByName(String name) throws SecurityException { + debug("getNamespaceByName("+name+")"); Namespace ns = new Namespace(null, name, null, null); return getNamespace(ns); } @@ -138,6 +156,7 @@ public class IDFactory { } public static final ID makeGUID(int length) throws IDInstantiationException { + debug("makeGUID("+length+")"); Namespace n = new Namespace(GUID.class.getClassLoader(), GUID.GUID_NAME, GUID.GUID_INSTANTIATOR_CLASS, null); return makeID(n, new String[] { Namespace.class.getName(), @@ -146,11 +165,11 @@ public class IDFactory { } protected static void log(String s) { - // XXX TODO + debug(s); } protected static void logException(String s, Throwable t) { - // XXX TODO + dumpStack(s,t); } protected static void logAndThrow(String s, Throwable t) @@ -164,6 +183,24 @@ public class IDFactory { logException(s, null); throw e; } + private static String convertStringAToString(String [] strings) { + if (strings==null) return ""; + StringBuffer sb = new StringBuffer(); + for(int i=0; i < strings.length; i++) { + sb.append(strings[i]); + if (i != (strings.length-1)) sb.append(";"); + } + return sb.toString(); + } + private static String convertObjectAToString(Object [] objs) { + if (objs==null) return ""; + StringBuffer sb = new StringBuffer(); + for(int i=0; i < objs.length; i++) { + sb.append(objs[i].toString()); + if (i != (objs.length-1)) sb.append(";"); + } + return sb.toString(); + } /** * Make a new identity. Given a classloader, Namespace, constructor argument * types, and an array of arguments, return a new instance of an ID @@ -182,10 +219,10 @@ public class IDFactory { */ public static final ID makeID(Namespace n, String[] argTypes, Object[] args) throws IDInstantiationException { + debug("makeID("+n+","+convertStringAToString(argTypes)+","+convertObjectAToString(args)+")"); // Verify namespace is non-null if (n == null) logAndThrow("Namespace cannot be null"); - log("makeID(" + n.getName() + ")"); // Make sure that namespace is in table of known namespace. If not, // throw...we don't create any instances that we don't know about! Namespace ns = getNamespace0(n); @@ -207,6 +244,7 @@ public class IDFactory { } catch (Exception e) { logAndThrow("Exception in getInstantiator", e); } + debug("makeID:got instantiator:"+instantiator); if (instantiator == null) throw new IDInstantiationException("Instantiator for namespace '" + n.getName() + "' is null"); @@ -277,6 +315,7 @@ public class IDFactory { */ public final static Namespace removeNamespace(Namespace n) throws SecurityException { + debug("removeNamespace("+n+")"); if (n == null) return null; checkPermission(new NamespacePermission(n.getPermissionName(), diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/Trace.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/Trace.java new file mode 100644 index 000000000..bc93b3511 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/Trace.java @@ -0,0 +1,79 @@ +/**************************************************************************** +* 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.core; + +import java.text.SimpleDateFormat; +import java.util.Date; +import org.eclipse.core.runtime.Platform; + +public class 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(); + isEclipse = true; + pluginName = ECFPlugin.getDefault().getBundle() + .getSymbolicName(); + } catch (Exception e) { + // No eclipse Platform available + } + } + + public static void setTrace(boolean on) { + ON = on; + } + + public static Trace create(String key) { + if (isEclipse) { + String res = Platform + .getDebugOption(pluginName + debugPrefix + key); + 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) { + System.err.println(name + "[" + getTimeString() + "]" + msg); + } + + 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 = str; + } + + public static void setThreadDebugGroup(Object obj) { + // Do nothing + } +}
\ No newline at end of file |
