diff options
author | slewis | 2006-05-13 06:26:49 +0000 |
---|---|---|
committer | slewis | 2006-05-13 06:26:49 +0000 |
commit | 363b815f74693900be5eeb2c9efaf46082b9a2c5 (patch) | |
tree | e6e353a226e9e49c4c4f6b6cbe1d9671ac8bb804 /providers/bundles/org.eclipse.ecf.provider.datashare | |
parent | a1c3d6762a74fe9d9384b00075661d7f218b4967 (diff) | |
download | org.eclipse.ecf-363b815f74693900be5eeb2c9efaf46082b9a2c5.tar.gz org.eclipse.ecf-363b815f74693900be5eeb2c9efaf46082b9a2c5.tar.xz org.eclipse.ecf-363b815f74693900be5eeb2c9efaf46082b9a2c5.zip |
Datashare API additions (IChannelContainerListener and associateed events). Also changed version to 0.8.1
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.datashare')
4 files changed, 77 insertions, 10 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.datashare/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.datashare/META-INF/MANIFEST.MF index 89879e2a2..6861fbc7d 100644 --- a/providers/bundles/org.eclipse.ecf.provider.datashare/META-INF/MANIFEST.MF +++ b/providers/bundles/org.eclipse.ecf.provider.datashare/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ECF Datashare Provider Plug-in Bundle-SymbolicName: org.eclipse.ecf.provider.datashare;singleton:=true -Bundle-Version: 0.8.0 +Bundle-Version: 0.8.1 Bundle-Activator: org.eclipse.ecf.provider.datashare.Activator Bundle-Vendor: Eclipse.org Bundle-Localization: plugin diff --git a/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/BaseChannel.java b/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/BaseChannel.java index d56ed36a8..56ab45cf4 100644 --- a/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/BaseChannel.java +++ b/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/BaseChannel.java @@ -9,7 +9,6 @@ package org.eclipse.ecf.provider.datashare; import java.io.Serializable; -import java.util.Arrays; import java.util.Map; import org.eclipse.ecf.core.ISharedObjectTransactionConfig; import org.eclipse.ecf.core.ReplicaSharedObjectDescription; @@ -126,16 +125,12 @@ public class BaseChannel extends TransactionSharedObject implements IChannel { }); IChannelListener l = getListener(); IChannelInitializeEvent initEvent = new IChannelInitializeEvent() { - public ID[] getGroupMembers() { - return getContext().getGroupMemberIDs(); - } public ID getChannelID() { return getID(); } public String toString() { StringBuffer buf = new StringBuffer("ChannelInitializeEvent["); - buf.append("chid=").append(getChannelID()).append( - ";groupMembers=").append(Arrays.asList(getGroupMembers())).append("]"); + buf.append("channelid=").append(getChannelID()).append("]"); return buf.toString(); } }; @@ -166,7 +161,7 @@ public class BaseChannel extends TransactionSharedObject implements IChannel { } public String toString() { StringBuffer buf = new StringBuffer("ChannelGroupJoinEvent["); - buf.append("chid=").append(getChannelID()).append(";targetid=") + buf.append("channelid=").append(getChannelID()).append(";targetid=") .append(getTargetID()).append("]"); return buf.toString(); } @@ -185,7 +180,7 @@ public class BaseChannel extends TransactionSharedObject implements IChannel { public String toString() { StringBuffer buf = new StringBuffer( "ChannelGroupDepartedEvent["); - buf.append("chid=").append(getChannelID()).append(";targetid=") + buf.append("channelid=").append(getChannelID()).append(";targetid=") .append(getTargetID()).append("]"); return buf.toString(); } @@ -214,7 +209,7 @@ public class BaseChannel extends TransactionSharedObject implements IChannel { public String toString() { StringBuffer buf = new StringBuffer( "ChannelMessageEvent["); - buf.append("chid=").append(getChannelID()).append( + buf.append("channelid=").append(getChannelID()).append( ";fromid=").append(getFromContainerID()) .append(";data=").append(getData()).append("]"); return buf.toString(); diff --git a/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainer.java b/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainer.java index ee2c8689d..da4244bfb 100644 --- a/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainer.java @@ -19,6 +19,7 @@ import org.eclipse.ecf.core.util.ECFException; import org.eclipse.ecf.datashare.IChannel; import org.eclipse.ecf.datashare.IChannelConfig; import org.eclipse.ecf.datashare.IChannelContainer; +import org.eclipse.ecf.datashare.IChannelContainerListener; import org.eclipse.ecf.datashare.IChannelListener; import org.eclipse.ecf.provider.generic.TCPClientSOContainer; @@ -90,4 +91,10 @@ public class DatashareContainer extends TCPClientSOContainer implements public Namespace getChannelNamespace() { return adapter.getChannelNamespace(); } + public void addChannelContainerListener(IChannelContainerListener listener) { + adapter.addChannelContainerListener(listener); + } + public void removeChannelContainerListener(IChannelContainerListener listener) { + adapter.removeChannelContainerListener(listener); + } } diff --git a/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainerAdapter.java b/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainerAdapter.java index 7683eec94..81b308eec 100644 --- a/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainerAdapter.java +++ b/providers/bundles/org.eclipse.ecf.provider.datashare/src/org/eclipse/ecf/provider/datashare/DatashareContainerAdapter.java @@ -1,8 +1,13 @@ package org.eclipse.ecf.provider.datashare; import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; +import org.eclipse.ecf.core.IContainerListener; import org.eclipse.ecf.core.ISharedObject; import org.eclipse.ecf.core.ISharedObjectTransactionConfig; import org.eclipse.ecf.core.ISharedObjectTransactionParticipantsFilter; @@ -10,6 +15,9 @@ import org.eclipse.ecf.core.SharedObjectCreateException; import org.eclipse.ecf.core.SharedObjectDescription; import org.eclipse.ecf.core.SharedObjectFactory; import org.eclipse.ecf.core.SharedObjectTypeDescription; +import org.eclipse.ecf.core.events.IContainerEvent; +import org.eclipse.ecf.core.events.ISharedObjectActivatedEvent; +import org.eclipse.ecf.core.events.ISharedObjectDeactivatedEvent; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.identity.IDFactory; import org.eclipse.ecf.core.identity.IDInstantiationException; @@ -19,7 +27,11 @@ import org.eclipse.ecf.core.util.ECFException; import org.eclipse.ecf.datashare.IChannel; import org.eclipse.ecf.datashare.IChannelConfig; import org.eclipse.ecf.datashare.IChannelContainer; +import org.eclipse.ecf.datashare.IChannelContainerListener; import org.eclipse.ecf.datashare.IChannelListener; +import org.eclipse.ecf.datashare.events.IChannelContainerChannelActivatedEvent; +import org.eclipse.ecf.datashare.events.IChannelContainerEvent; +import org.eclipse.ecf.datashare.events.IChannelContainerChannelDeactivatedEvent; import org.eclipse.ecf.provider.generic.SOContainer; public class DatashareContainerAdapter implements IChannelContainer { @@ -27,8 +39,55 @@ public class DatashareContainerAdapter implements IChannelContainer { protected SOContainer container = null; protected static final int DEFAULT_TRANSACTION_WAIT = 30000; + protected List channelContainerListener = Collections.synchronizedList(new ArrayList()); + + protected void fireChannelContainerListeners(IChannelContainerEvent event) { + synchronized (channelContainerListener) { + for(Iterator i=channelContainerListener.iterator(); i.hasNext(); ) { + IChannelContainerListener l = (IChannelContainerListener) i.next(); + if (l != null) l.handleChannelContainerEvent(event); + } + } + } public DatashareContainerAdapter(SOContainer container) { this.container = container; + this.container.addListener(new ContainerListener(), null); + } + + protected class ContainerListener implements IContainerListener { + public void handleEvent(final IContainerEvent evt) { + if (evt instanceof ISharedObjectActivatedEvent) { + final ISharedObjectActivatedEvent soae = (ISharedObjectActivatedEvent) evt; + fireChannelContainerListeners(new IChannelContainerChannelActivatedEvent() { + public ID getChannelID() { + return soae.getActivatedID(); + } + public ID getChannelContainerID() { + return soae.getLocalContainerID(); + } + public String toString() { + StringBuffer buf = new StringBuffer("ChannelActivatedEvent["); + buf.append("channelid=").append(soae.getActivatedID()).append(";"); + buf.append("containerid=").append(soae.getLocalContainerID()).append("]"); + return buf.toString(); + }}); + } else if (evt instanceof ISharedObjectDeactivatedEvent) { + final ISharedObjectDeactivatedEvent sode = (ISharedObjectDeactivatedEvent) evt; + fireChannelContainerListeners(new IChannelContainerChannelDeactivatedEvent() { + public ID getChannelID() { + return sode.getDeactivatedID(); + } + public ID getChannelContainerID() { + return sode.getLocalContainerID(); + } + public String toString() { + StringBuffer buf = new StringBuffer("ChannelDeactivatedEvent["); + buf.append("channelid=").append(sode.getDeactivatedID()).append(";"); + buf.append("containerid=").append(sode.getLocalContainerID()).append("]"); + return buf.toString(); + }}); + } + } } /* * (non-Javadoc) @@ -160,4 +219,10 @@ public class DatashareContainerAdapter implements IChannelContainer { public Namespace getChannelNamespace() { return IDFactory.getDefault().getNamespaceByName(StringID.class.getName()); } + public void addChannelContainerListener(IChannelContainerListener listener) { + channelContainerListener.add(listener); + } + public void removeChannelContainerListener(IChannelContainerListener listener) { + channelContainerListener.add(listener); + } } |