summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 14:37:26 (EDT)
committerEike Stepper2007-10-11 14:37:26 (EDT)
commit8d55117f4e34215e93c6da180914e79809828543 (patch)
tree615a8fbb9122b882a99e5058b7044c1a57f1b658
parent5b85336ac1d70cf0131425df881fdf72ab6adecf (diff)
downloadcdo-8d55117f4e34215e93c6da180914e79809828543.zip
cdo-8d55117f4e34215e93c6da180914e79809828543.tar.gz
cdo-8d55117f4e34215e93c6da180914e79809828543.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/protocol/FacilityInstalledNotification.java48
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java17
3 files changed, 62 insertions, 4 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
new file mode 100644
index 0000000..e2b67b3
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * 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.internal.server.protocol;
+
+import org.eclipse.net4j.IChannel;
+import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class FacilityInstalledNotification extends Request
+{
+ private long collaborationID;
+
+ private String facilityType;
+
+ public FacilityInstalledNotification(IChannel channel, long collaborationID, String facilityType)
+ {
+ super(channel);
+ this.collaborationID = collaborationID;
+ this.facilityType = facilityType;
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return ProtocolConstants.SIGNAL_FACILITY_INSTALLED;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
+ {
+ out.writeLong(collaborationID);
+ out.writeString(facilityType);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
index a903b08..cb8cf76 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
@@ -52,6 +52,7 @@ public class InstallFacilityIndication extends IndicationWithResponse
{
String description = String.valueOf(collaborationID);
IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, facilityType, description);
+
Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
facility.setCollaboration(collaboration);
collaboration.addFacility(facility, true);
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
index be65709..0707145 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
@@ -51,10 +51,7 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
{
try
{
- IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, type, String
- .valueOf(getID()));
- facility.setCollaboration(this);
-
+ IFacility facility = createFacility(type);
IChannel channel = session.getChannel();
boolean success = new InstallFacilityRequest(channel, getID(), type).send(ProtocolConstants.TIMEOUT);
if (success)
@@ -71,6 +68,13 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
}
}
+ public IFacility createFacility(String type)
+ {
+ IFacility facility = (IFacility)getContainer().getElement(FACILITY_GROUP, type, String.valueOf(getID()));
+ facility.setCollaboration(this);
+ return facility;
+ }
+
@Override
public void sendMessage(IMessage message)
{
@@ -98,4 +102,9 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
public void leave()
{
}
+
+ protected IPluginContainer getContainer()
+ {
+ return IPluginContainer.INSTANCE;
+ }
}