summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-09 06:08:22 (EDT)
committerEike Stepper2007-10-09 06:08:22 (EDT)
commit9d0929ee2b107df939b331878fba022da7eadced (patch)
tree1baa8ae315672674e2829c17c0294506c72a0695
parent9f4563d8f41de0348870c45e160222dc8dc8761d (diff)
downloadcdo-9d0929ee2b107df939b331878fba022da7eadced.zip
cdo-9d0929ee2b107df939b331878fba022da7eadced.tar.gz
cdo-9d0929ee2b107df939b331878fba022da7eadced.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java12
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java7
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java9
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java11
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java14
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java13
9 files changed, 65 insertions, 15 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
index 3ea43f5..228669a 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
@@ -15,6 +15,7 @@ import org.eclipse.net4j.IProtocol;
import org.eclipse.net4j.buddies.internal.protocol.Account;
import org.eclipse.net4j.buddies.internal.protocol.BuddyStateNotification;
import org.eclipse.net4j.buddies.internal.protocol.CollaborationContainer;
+import org.eclipse.net4j.buddies.internal.protocol.ServerFacilityFactory;
import org.eclipse.net4j.buddies.internal.server.bundle.OM;
import org.eclipse.net4j.buddies.internal.server.protocol.BuddyRemovedNotification;
import org.eclipse.net4j.buddies.protocol.IAccount;
@@ -23,6 +24,7 @@ import org.eclipse.net4j.buddies.protocol.ISession;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
@@ -30,6 +32,7 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -59,7 +62,7 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
return sessions;
}
- public synchronized ISession openSession(IChannel channel, String userID, String password)
+ public synchronized ISession openSession(IChannel channel, String userID, String password, String[] facilityTypes)
{
if (sessions.containsKey(userID))
{
@@ -80,7 +83,7 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
accounts.put(userID, account);
}
- ServerBuddy buddy = new ServerBuddy(account);
+ ServerBuddy buddy = new ServerBuddy(account, facilityTypes);
buddy.addListener(this);
ServerSession session = new ServerSession(channel, buddy);
@@ -152,4 +155,9 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
}
}
}
+
+ public static Set<String> getFacilityTypes()
+ {
+ return IPluginContainer.INSTANCE.getFactoryTypes(ServerFacilityFactory.PRODUCT_GROUP);
+ }
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
index 04b0cf8..839e7a6 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
@@ -13,6 +13,9 @@ package org.eclipse.net4j.buddies.internal.server;
import org.eclipse.net4j.buddies.internal.protocol.Buddy;
import org.eclipse.net4j.buddies.protocol.IAccount;
+import java.util.Arrays;
+import java.util.HashSet;
+
/**
* @author Eike Stepper
*/
@@ -20,9 +23,9 @@ public class ServerBuddy extends Buddy
{
private IAccount account;
- public ServerBuddy(IAccount account)
+ public ServerBuddy(IAccount account, String[] facilityTypes)
{
- super(null);
+ super(null, new HashSet<String>(Arrays.asList(facilityTypes)));
this.account = account;
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
index 81b0794..64c81cd 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
@@ -50,12 +50,19 @@ public class OpenSessionIndication extends IndicationWithResponse
{
String userID = in.readString();
String password = in.readString();
+ int size = in.readInt();
+ String[] facilityTypes = new String[size];
+ for (int i = 0; i < size; i++)
+ {
+ facilityTypes[i] = in.readString();
+ }
+
synchronized (IBuddyAdmin.INSTANCE)
{
Map<String, ISession> sessions = IBuddyAdmin.INSTANCE.getSessions();
buddies = sessions.keySet().toArray(new String[sessions.size()]);
- ISession session = IBuddyAdmin.INSTANCE.openSession(getProtocol().getChannel(), userID, password);
+ ISession session = IBuddyAdmin.INSTANCE.openSession(getProtocol().getChannel(), userID, password, facilityTypes);
if (session != null)
{
account = session.getSelf().getAccount();
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java
index f2b6a16..821aaa7 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java
@@ -29,5 +29,5 @@ public interface IBuddyAdmin extends ICollaborationContainer
public Map<String, ISession> getSessions();
- public ISession openSession(IChannel channel, String userID, String password);
+ public ISession openSession(IChannel channel, String userID, String password, String[] facilityTypes);
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java
index 0425e95..3fac729 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java
@@ -12,10 +12,14 @@ package org.eclipse.net4j.buddies;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.IConnector;
+import org.eclipse.net4j.buddies.internal.protocol.ClientFacilityFactory;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.internal.buddies.protocol.OpenSessionRequest;
import org.eclipse.net4j.signal.SignalActor;
import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import java.util.Set;
/**
* @author Eike Stepper
@@ -26,12 +30,17 @@ public final class BuddiesUtil
{
}
+ public static Set<String> getFacilityTypes()
+ {
+ return IPluginContainer.INSTANCE.getFactoryTypes(ClientFacilityFactory.PRODUCT_GROUP);
+ }
+
public static IBuddySession openSession(IConnector connector, String userID, String password, long timeout)
{
try
{
IChannel channel = connector.openChannel(ProtocolConstants.PROTOCOL_NAME, null);
- OpenSessionRequest request = new OpenSessionRequest(channel, userID, password);
+ OpenSessionRequest request = new OpenSessionRequest(channel, userID, password, getFacilityTypes());
return request.send(timeout);
}
catch (Exception ex)
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
index e618120..df5c38b 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
@@ -13,6 +13,8 @@ package org.eclipse.net4j.internal.buddies;
import org.eclipse.net4j.buddies.internal.protocol.Buddy;
import org.eclipse.net4j.buddies.protocol.IAccount;
+import java.util.Set;
+
/**
* @author Eike Stepper
*/
@@ -24,7 +26,7 @@ public class ClientBuddy extends Buddy
public ClientBuddy(ClientSession session, String userID)
{
- super(session);
+ super(session, null);
this.userID = userID;
}
@@ -51,6 +53,14 @@ public class ClientBuddy extends Buddy
protected IAccount loadAccount(String userID)
{
- return null;
+ // TODO Implement method ClientBuddy.loadAccount()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ @Override
+ protected Set<String> loadFacilityTypes()
+ {
+ // TODO Implement method ClientBuddy.loadFacilityTypes()
+ throw new UnsupportedOperationException("Not yet implemented");
}
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
index 8570dee..77f277a 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
@@ -24,6 +24,8 @@ import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
+import java.util.Set;
+
/**
* @author Eike Stepper
*/
@@ -48,9 +50,9 @@ public class ClientSession extends BuddyContainer implements IBuddySession, ILis
return self;
}
- public void setSelf(IAccount account)
+ public void setSelf(IAccount account, Set<String> facilityTypes)
{
- self = new Self(this, account);
+ self = new Self(this, account, facilityTypes);
self.addListener(this);
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
index a9038403..c711e9b 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
@@ -13,6 +13,8 @@ package org.eclipse.net4j.internal.buddies;
import org.eclipse.net4j.buddies.internal.protocol.Buddy;
import org.eclipse.net4j.buddies.protocol.IAccount;
+import java.util.Set;
+
/**
* @author Eike Stepper
*/
@@ -20,9 +22,9 @@ public class Self extends Buddy
{
private IAccount account;
- protected Self(ClientSession session, IAccount account)
+ protected Self(ClientSession session, IAccount account, Set<String> facilityTypes)
{
- super(session);
+ super(session, facilityTypes);
this.account = account;
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java
index c0cb2a2..7844d01 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java
@@ -22,6 +22,7 @@ import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import java.io.IOException;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -32,11 +33,14 @@ public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession>
private String password;
- public OpenSessionRequest(IChannel channel, String userID, String password)
+ private Set<String> facilityTypes;
+
+ public OpenSessionRequest(IChannel channel, String userID, String password, Set<String> facilityTypes)
{
super(channel);
this.userID = userID;
this.password = password;
+ this.facilityTypes = facilityTypes;
}
@Override
@@ -50,6 +54,11 @@ public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession>
{
out.writeString(userID);
out.writeString(password);
+ out.writeInt(facilityTypes.size());
+ for (String facilityType : facilityTypes)
+ {
+ out.writeString(facilityType);
+ }
}
@Override
@@ -63,7 +72,7 @@ public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession>
ClientSession session = new ClientSession(getProtocol().getChannel());
getProtocol().setInfraStructure(session);
- session.setSelf(account);
+ session.setSelf(account, facilityTypes);
int size = in.readInt();
for (int i = 0; i < size; i++)