summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-09 02:20:28 (EDT)
committerEike Stepper2007-10-09 02:20:28 (EDT)
commit6c2384b3618e92f2ea68feb8dd24e3bd6865fd78 (patch)
treeb1af96b0d4330a0f76af592b35bb54262f7502da
parent2a3ed94865faa226d1457918df84cc5cb1f1d8af (diff)
downloadcdo-6c2384b3618e92f2ea68feb8dd24e3bd6865fd78.zip
cdo-6c2384b3618e92f2ea68feb8dd24e3bd6865fd78.tar.gz
cdo-6c2384b3618e92f2ea68feb8dd24e3bd6865fd78.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.java40
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java (renamed from plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/Buddy.java)12
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java (renamed from plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddySession.java)30
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java10
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java14
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java9
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddySession.java26
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java3
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java (renamed from plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java)18
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java (renamed from plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java)23
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java16
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java8
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java8
17 files changed, 118 insertions, 117 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 8a1c9a5..7fb80f7 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
@@ -12,14 +12,14 @@ package org.eclipse.net4j.buddies.internal.server;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.IProtocol;
-import org.eclipse.net4j.buddies.internal.protocol.BuddyAccount;
+import org.eclipse.net4j.buddies.internal.protocol.Account;
import org.eclipse.net4j.buddies.internal.protocol.BuddyStateNotification;
import org.eclipse.net4j.buddies.internal.server.bundle.OM;
import org.eclipse.net4j.buddies.internal.server.protocol.BuddyRemovedNotification;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.protocol.IAccount;
+import org.eclipse.net4j.buddies.protocol.ISession;
import org.eclipse.net4j.buddies.protocol.IBuddyStateChangedEvent;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.buddies.server.IBuddySession;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.ObjectUtil;
@@ -40,33 +40,33 @@ public class BuddyAdmin extends Lifecycle implements IBuddyAdmin, IListener
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, BuddyAdmin.class);
- private Map<String, IBuddyAccount> accounts = new HashMap<String, IBuddyAccount>();
+ private Map<String, IAccount> accounts = new HashMap<String, IAccount>();
- private Map<String, IBuddySession> sessions = new HashMap<String, IBuddySession>();
+ private Map<String, ISession> sessions = new HashMap<String, ISession>();
public BuddyAdmin()
{
LifecycleUtil.activate(this);
}
- public Map<String, IBuddyAccount> getAccounts()
+ public Map<String, IAccount> getAccounts()
{
return accounts;
}
- public Map<String, IBuddySession> getSessions()
+ public Map<String, ISession> getSessions()
{
return sessions;
}
- public synchronized IBuddySession openSession(IChannel channel, String userID, String password)
+ public synchronized ISession openSession(IChannel channel, String userID, String password)
{
if (sessions.containsKey(userID))
{
return null;
}
- IBuddyAccount account = accounts.get(userID);
+ IAccount account = accounts.get(userID);
if (account != null)
{
if (!account.authenticate(password))
@@ -76,14 +76,14 @@ public class BuddyAdmin extends Lifecycle implements IBuddyAdmin, IListener
}
else
{
- account = new BuddyAccount(userID, password);
+ account = new Account(userID, password);
accounts.put(userID, account);
}
- Buddy buddy = new Buddy(account);
+ ServerBuddy buddy = new ServerBuddy(account);
buddy.addListener(this);
- BuddySession session = new BuddySession(channel, buddy);
+ ServerSession session = new ServerSession(channel, buddy);
((IProtocol)channel.getReceiveHandler()).setInfraStructure(session);
sessions.put(userID, session);
@@ -94,21 +94,21 @@ public class BuddyAdmin extends Lifecycle implements IBuddyAdmin, IListener
public void notifyEvent(IEvent event)
{
- if (event.getSource() instanceof BuddySession)
+ if (event.getSource() instanceof ServerSession)
{
if (event instanceof ILifecycleEvent)
{
if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED)
{
- String userID = ((BuddySession)event.getSource()).getBuddy().getUserID();
+ String userID = ((ServerSession)event.getSource()).getSelf().getUserID();
synchronized (this)
{
- BuddySession removed = (BuddySession)sessions.remove(userID);
+ ServerSession removed = (ServerSession)sessions.remove(userID);
if (removed != null)
{
removed.removeListener(this);
- removed.getBuddy().removeListener(this);
- for (IBuddySession session : sessions.values())
+ removed.getSelf().removeListener(this);
+ for (ISession session : sessions.values())
{
try
{
@@ -124,18 +124,18 @@ public class BuddyAdmin extends Lifecycle implements IBuddyAdmin, IListener
}
}
}
- else if (event.getSource() instanceof Buddy)
+ else if (event.getSource() instanceof ServerBuddy)
{
if (event instanceof IBuddyStateChangedEvent)
{
IBuddyStateChangedEvent e = (IBuddyStateChangedEvent)event;
synchronized (this)
{
- for (IBuddySession session : sessions.values())
+ for (ISession session : sessions.values())
{
try
{
- if (!ObjectUtil.equals(session.getBuddy(), e.getBuddy()))
+ if (!ObjectUtil.equals(session.getSelf(), e.getBuddy()))
{
new BuddyStateNotification(session.getChannel(), e.getBuddy().getUserID(), e.getNewState()).send();
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/Buddy.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
index ec3e66c..22f70b3 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/Buddy.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
@@ -10,17 +10,17 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.server;
-import org.eclipse.net4j.buddies.internal.protocol.AbstractBuddy;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.internal.protocol.Buddy;
+import org.eclipse.net4j.buddies.protocol.IAccount;
/**
* @author Eike Stepper
*/
-public class Buddy extends AbstractBuddy
+public class ServerBuddy extends Buddy
{
- private IBuddyAccount account;
+ private IAccount account;
- public Buddy(IBuddyAccount account)
+ public ServerBuddy(IAccount account)
{
this.account = account;
}
@@ -30,7 +30,7 @@ public class Buddy extends AbstractBuddy
return account.getUserID();
}
- public IBuddyAccount getAccount()
+ public IAccount getAccount()
{
return account;
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddySession.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java
index 8a2867f..0716c4b 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddySession.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java
@@ -12,26 +12,29 @@ package org.eclipse.net4j.buddies.internal.server;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.protocol.IBuddy;
-import org.eclipse.net4j.buddies.server.IBuddySession;
+import org.eclipse.net4j.buddies.protocol.ISession;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+
/**
* @author Eike Stepper
*/
-public class BuddySession extends Lifecycle implements IBuddySession, IListener
+public class ServerSession extends Lifecycle implements ISession, IListener
{
private IChannel channel;
- private IBuddy buddy;
+ private IBuddy self;
- public BuddySession(IChannel channel, IBuddy buddy)
+ public ServerSession(IChannel channel, IBuddy self)
{
this.channel = channel;
- this.buddy = buddy;
+ this.self = self;
LifecycleUtil.activate(this);
}
@@ -40,9 +43,9 @@ public class BuddySession extends Lifecycle implements IBuddySession, IListener
return channel;
}
- public IBuddy getBuddy()
+ public IBuddy getSelf()
{
- return buddy;
+ return self;
}
public void close()
@@ -51,6 +54,15 @@ public class BuddySession extends Lifecycle implements IBuddySession, IListener
deactivate();
}
+ /**
+ * @see PlatformObject#getAdapter(Class)
+ */
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter)
+ {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
public void notifyEvent(IEvent event)
{
if (event.getSource() == channel)
@@ -70,13 +82,13 @@ public class BuddySession extends Lifecycle implements IBuddySession, IListener
{
super.doActivate();
channel.addListener(this);
- buddy.getAccount().touch();
+ self.getAccount().touch();
}
@Override
protected void doDeactivate() throws Exception
{
- buddy.getAccount().touch();
+ self.getAccount().touch();
channel.removeListener(this);
super.doDeactivate();
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
index c43caa7..ce8ea53 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
@@ -12,10 +12,10 @@ package org.eclipse.net4j.buddies.internal.server.protocol;
import org.eclipse.net4j.buddies.internal.protocol.BuddyStateIndication;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.server.Buddy;
+import org.eclipse.net4j.buddies.internal.server.ServerBuddy;
+import org.eclipse.net4j.buddies.protocol.ISession;
import org.eclipse.net4j.buddies.protocol.IBuddy.State;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.buddies.server.IBuddySession;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
@@ -51,11 +51,11 @@ public class BuddiesServerProtocol extends SignalProtocol
{
synchronized (IBuddyAdmin.INSTANCE)
{
- Map<String, IBuddySession> sessions = IBuddyAdmin.INSTANCE.getSessions();
- IBuddySession session = sessions.get(userID);
+ Map<String, ISession> sessions = IBuddyAdmin.INSTANCE.getSessions();
+ ISession session = sessions.get(userID);
if (session != null)
{
- Buddy buddy = (Buddy)session.getBuddy();
+ ServerBuddy buddy = (ServerBuddy)session.getSelf();
buddy.setState(state);
}
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
index 992b352..a6f8f76 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
@@ -12,7 +12,7 @@ package org.eclipse.net4j.buddies.internal.server.protocol;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.protocol.IAccount;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -25,7 +25,7 @@ import java.io.IOException;
*/
public class LoadAccountIndication extends IndicationWithResponse
{
- private IBuddyAccount account;
+ private IAccount account;
public LoadAccountIndication()
{
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 246207a..81b0794 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
@@ -13,10 +13,10 @@ package org.eclipse.net4j.buddies.internal.server.protocol;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.internal.server.bundle.OM;
+import org.eclipse.net4j.buddies.protocol.ISession;
import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.protocol.IAccount;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.buddies.server.IBuddySession;
import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -31,7 +31,7 @@ import java.util.Map;
*/
public class OpenSessionIndication extends IndicationWithResponse
{
- private IBuddyAccount account;
+ private IAccount account;
private String[] buddies;
@@ -52,13 +52,13 @@ public class OpenSessionIndication extends IndicationWithResponse
String password = in.readString();
synchronized (IBuddyAdmin.INSTANCE)
{
- Map<String, IBuddySession> sessions = IBuddyAdmin.INSTANCE.getSessions();
+ Map<String, ISession> sessions = IBuddyAdmin.INSTANCE.getSessions();
buddies = sessions.keySet().toArray(new String[sessions.size()]);
- IBuddySession session = IBuddyAdmin.INSTANCE.openSession(getProtocol().getChannel(), userID, password);
+ ISession session = IBuddyAdmin.INSTANCE.openSession(getProtocol().getChannel(), userID, password);
if (session != null)
{
- account = session.getBuddy().getAccount();
+ account = session.getSelf().getAccount();
}
else
{
@@ -78,7 +78,7 @@ public class OpenSessionIndication extends IndicationWithResponse
for (String buddy : buddies)
{
out.writeString(buddy);
- IBuddySession buddySession = IBuddyAdmin.INSTANCE.getSessions().get(buddy);
+ ISession buddySession = IBuddyAdmin.INSTANCE.getSessions().get(buddy);
if (buddySession != null)
{
channels.add(buddySession.getChannel());
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 d21981b..c421e6b 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
@@ -12,7 +12,8 @@ package org.eclipse.net4j.buddies.server;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.protocol.IAccount;
+import org.eclipse.net4j.buddies.protocol.ISession;
import java.util.Map;
@@ -23,9 +24,9 @@ public interface IBuddyAdmin
{
public static final IBuddyAdmin INSTANCE = BuddyAdmin.INSTANCE;
- public Map<String, IBuddyAccount> getAccounts();
+ public Map<String, IAccount> getAccounts();
- public Map<String, IBuddySession> getSessions();
+ public Map<String, ISession> getSessions();
- public IBuddySession openSession(IChannel channel, String userID, String password);
+ public ISession openSession(IChannel channel, String userID, String password);
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddySession.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddySession.java
deleted file mode 100644
index f2c38ce..0000000
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddySession.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.net4j.buddies.server;
-
-import org.eclipse.net4j.IChannel;
-import org.eclipse.net4j.buddies.protocol.IBuddy;
-
-/**
- * @author Eike Stepper
- */
-public interface IBuddySession
-{
- public IChannel getChannel();
-
- public IBuddy getBuddy();
-
- public void close();
-}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java
index 5d8ef39..9c7fe96 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java
@@ -13,11 +13,12 @@ package org.eclipse.net4j.buddies;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.buddies.protocol.IBuddyContainer;
+import org.eclipse.net4j.buddies.protocol.ISession;
/**
* @author Eike Stepper
*/
-public interface IBuddySession extends IBuddyContainer
+public interface IBuddySession extends ISession, IBuddyContainer
{
public IChannel getChannel();
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
index aa237d3..5d13acb 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
@@ -10,27 +10,27 @@
**************************************************************************/
package org.eclipse.net4j.internal.buddies;
-import org.eclipse.net4j.buddies.internal.protocol.AbstractBuddy;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.internal.protocol.Buddy;
+import org.eclipse.net4j.buddies.protocol.IAccount;
/**
* @author Eike Stepper
*/
-public class Buddy extends AbstractBuddy
+public class ClientBuddy extends Buddy
{
- private BuddySession session;
+ private ClientSession session;
private String userID;
- private IBuddyAccount account;
+ private IAccount account;
- public Buddy(BuddySession session, String userID)
+ public ClientBuddy(ClientSession session, String userID)
{
this.session = session;
this.userID = userID;
}
- public BuddySession getSession()
+ public ClientSession getSession()
{
return session;
}
@@ -40,7 +40,7 @@ public class Buddy extends AbstractBuddy
return userID;
}
- public IBuddyAccount getAccount()
+ public IAccount getAccount()
{
if (account == null)
{
@@ -50,7 +50,7 @@ public class Buddy extends AbstractBuddy
return account;
}
- protected IBuddyAccount loadAccount(String userID)
+ protected IAccount loadAccount(String userID)
{
return null;
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
index 945384d..8570dee 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
@@ -14,23 +14,26 @@ import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.protocol.BuddyContainer;
import org.eclipse.net4j.buddies.internal.protocol.BuddyStateNotification;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.protocol.IAccount;
import org.eclipse.net4j.buddies.protocol.IBuddyStateChangedEvent;
import org.eclipse.net4j.internal.buddies.bundle.OM;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+
/**
* @author Eike Stepper
*/
-public class BuddySession extends BuddyContainer implements IBuddySession, IListener
+public class ClientSession extends BuddyContainer implements IBuddySession, IListener
{
private IChannel channel;
private Self self;
- public BuddySession(IChannel channel)
+ public ClientSession(IChannel channel)
{
this.channel = channel;
}
@@ -45,7 +48,7 @@ public class BuddySession extends BuddyContainer implements IBuddySession, IList
return self;
}
- public void setSelf(IBuddyAccount account)
+ public void setSelf(IAccount account)
{
self = new Self(this, account);
self.addListener(this);
@@ -57,6 +60,16 @@ public class BuddySession extends BuddyContainer implements IBuddySession, IList
deactivate();
}
+ /**
+ * @see PlatformObject#getAdapter(Class)
+ */
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter)
+ {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
+ @Override
public void notifyEvent(IEvent event)
{
if (event.getSource() == channel)
@@ -87,7 +100,7 @@ public class BuddySession extends BuddyContainer implements IBuddySession, IList
public void buddyAdded(String userID)
{
- Buddy buddy = new Buddy(this, userID);
+ ClientBuddy buddy = new ClientBuddy(this, userID);
addBuddy(buddy);
}
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 cb47fe2..7769b38 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
@@ -10,25 +10,25 @@
**************************************************************************/
package org.eclipse.net4j.internal.buddies;
-import org.eclipse.net4j.buddies.internal.protocol.AbstractBuddy;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.internal.protocol.Buddy;
+import org.eclipse.net4j.buddies.protocol.IAccount;
/**
* @author Eike Stepper
*/
-public class Self extends AbstractBuddy
+public class Self extends Buddy
{
- private BuddySession session;
+ private ClientSession session;
- private IBuddyAccount account;
+ private IAccount account;
- protected Self(BuddySession session, IBuddyAccount account)
+ protected Self(ClientSession session, IAccount account)
{
this.session = session;
this.account = account;
}
- public BuddySession getSession()
+ public ClientSession getSession()
{
return session;
}
@@ -38,7 +38,7 @@ public class Self extends AbstractBuddy
return account.getUserID();
}
- public IBuddyAccount getAccount()
+ public IAccount getAccount()
{
return account;
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java
index d655bb8..e56e4f3 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java
@@ -13,8 +13,8 @@ package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.buddies.internal.protocol.BuddyStateIndication;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddy.State;
-import org.eclipse.net4j.internal.buddies.Buddy;
-import org.eclipse.net4j.internal.buddies.BuddySession;
+import org.eclipse.net4j.internal.buddies.ClientBuddy;
+import org.eclipse.net4j.internal.buddies.ClientSession;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
@@ -52,14 +52,14 @@ public class BuddiesClientProtocol extends SignalProtocol
{
for (int i = 0; i < 50; i++)
{
- BuddySession session = (BuddySession)getProtocol().getInfraStructure();
+ ClientSession session = (ClientSession)getProtocol().getInfraStructure();
if (session == null)
{
ConcurrencyUtil.sleep(100);
}
else
{
- Buddy buddy = (Buddy)session.getBuddies().get(userID);
+ ClientBuddy buddy = (ClientBuddy)session.getBuddies().get(userID);
if (buddy != null)
{
buddy.setState(state);
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
index cd4dea0..64b48dc 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
@@ -11,7 +11,7 @@
package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
-import org.eclipse.net4j.internal.buddies.BuddySession;
+import org.eclipse.net4j.internal.buddies.ClientSession;
import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -39,7 +39,7 @@ public class BuddyAddedIndication extends Indication
String buddy = in.readString();
for (int i = 0; i < 50; i++)
{
- BuddySession session = (BuddySession)getProtocol().getInfraStructure();
+ ClientSession session = (ClientSession)getProtocol().getInfraStructure();
if (session == null)
{
ConcurrencyUtil.sleep(100);
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
index 7ebccf7..6cf03b6 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
@@ -11,7 +11,7 @@
package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
-import org.eclipse.net4j.internal.buddies.BuddySession;
+import org.eclipse.net4j.internal.buddies.ClientSession;
import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -39,7 +39,7 @@ public class BuddyRemovedIndication extends Indication
String buddy = in.readString();
for (int i = 0; i < 50; i++)
{
- BuddySession session = (BuddySession)getProtocol().getInfraStructure();
+ ClientSession session = (ClientSession)getProtocol().getInfraStructure();
if (session == null)
{
ConcurrencyUtil.sleep(100);
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java
index b6ac9d4..2d306cd 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java
@@ -13,7 +13,7 @@ package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
+import org.eclipse.net4j.buddies.protocol.IAccount;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -23,7 +23,7 @@ import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class LoadAccountRequest extends RequestWithConfirmation<IBuddyAccount>
+public class LoadAccountRequest extends RequestWithConfirmation<IAccount>
{
private String userID;
@@ -46,7 +46,7 @@ public class LoadAccountRequest extends RequestWithConfirmation<IBuddyAccount>
}
@Override
- protected IBuddyAccount confirming(ExtendedDataInputStream in) throws IOException
+ protected IAccount confirming(ExtendedDataInputStream in) throws IOException
{
return ProtocolUtil.readAccount(in);
}
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 4988d1a..c0cb2a2 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
@@ -13,9 +13,9 @@ package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.IAccount;
import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
-import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
-import org.eclipse.net4j.internal.buddies.BuddySession;
+import org.eclipse.net4j.internal.buddies.ClientSession;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -55,13 +55,13 @@ public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession>
@Override
protected IBuddySession confirming(ExtendedDataInputStream in) throws IOException
{
- IBuddyAccount account = ProtocolUtil.readAccount(in);
+ IAccount account = ProtocolUtil.readAccount(in);
if (account == null)
{
return null;
}
- BuddySession session = new BuddySession(getProtocol().getChannel());
+ ClientSession session = new ClientSession(getProtocol().getChannel());
getProtocol().setInfraStructure(session);
session.setSelf(account);