Package org.eclipse.ecf.core.identity

Examples of org.eclipse.ecf.core.identity.ID


  }

  protected ID getRemoteCallTargetID() {
    // First synchronize on connect lock
    synchronized (connectLock) {
      ID cID = getConnectedID();
      return (cID == null) ? getID() : cID;
    }
  }
View Full Code Here


    Collection deadSockets = null;
    Collection processedMessages = null;

    for (Iterator it = messages.iterator(); it.hasNext();) {
      ChannelMessage message = (ChannelMessage) it.next();
      ID id = message.getId();
      SocketChannel channel = (SocketChannel) connectedSockets.get(id);
      // check if we have a socket for the target of this message
      if (channel != null) {
        byte[] data = message.getData();

        try {
          // flush the data directly with regular IO, this method
          // saves us the extra work of having to constantly flip and
          // clear a ByteBuffer and in a way ensures the message is
          // sent in one piece instead of chunks
          channel.configureBlocking(true);
          channel.socket().getOutputStream().write(data);
          channel.socket().getOutputStream().flush();
          // turn off blocking
          channel.configureBlocking(false);
        } catch (IOException e) {
          log(new Status(IStatus.ERROR, Util.PLUGIN_ID,
              "Error occurred while sending message", e)); //$NON-NLS-1$
          if (deadSockets == null) {
            deadSockets = new HashSet();
          }
          deadSockets.add(id);
        }

        if (processedMessages == null) {
          processedMessages = new LinkedList();
        }
        // store the processed message
        processedMessages.add(message);
      }
    }

    // remove all messages that have been processed
    if (processedMessages != null) {
      messages.removeAll(processedMessages);
    }

    if (deadSockets != null) {
      for (Iterator it = deadSockets.iterator(); it.hasNext();) {
        ID id = (ID) it.next();
        SocketChannel channel = (SocketChannel) connectedSockets
            .remove(id);
        Util.closeChannel(channel);
      }
    }
View Full Code Here

      }
    }

    if (deadSockets != null) {
      for (Iterator it = deadSockets.iterator(); it.hasNext();) {
        ID id = (ID) it.next();
        SocketChannel channel = (SocketChannel) connectedSockets
            .remove(id);
        Util.closeChannel(channel);
      }
    }
View Full Code Here

      final byte[] data) {
    // search for the id of the corresponding channel
    for (Iterator it = connectedSockets.entrySet().iterator(); it.hasNext();) {
      Map.Entry entry = (Map.Entry) it.next();
      if (channel == entry.getValue()) {
        final ID fromId = (ID) entry.getKey();

        return new IChannelMessageEvent() {
          public byte[] getData() {
            return data;
          }
View Full Code Here

    StringBuffer buffer = new StringBuffer(name);
    buffer.append('@').append(userId.getHost());
    buffer.append(':').append(userId.getPort());

    // now create a new ID
    ID modifiedId = receiverNamespace.createInstance(new Object[] { buffer
        .toString() });
    // send the message with the new ID
    super.sendMessage(modifiedId, message);
  }
View Full Code Here

 
  public void createAndConnect() throws ECFException {
    // create container instance from ECF ContainerFactory
    container = ContainerFactory.getDefault().createContainer(CONTAINER_TYPE);
    // create target ID
    ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(),TARGET_SERVER);
    // connect container to target
    container.connect(targetID, null);
  }
View Full Code Here

    container.addListener(new IContainerListener() {
      public void handleEvent(final IContainerEvent evt) {
        Display.getDefault().syncExec(new Runnable() {
          public void run() {
            if (evt instanceof IContainerDisconnectedEvent || evt instanceof IContainerEjectedEvent) {
              final ID departedContainerID = ((evt instanceof IContainerDisconnectedEvent) ? ((IContainerDisconnectedEvent) evt).getTargetID() : ((IContainerEjectedEvent) evt).getTargetID());
              ID connectedID = targetID;
              if (connectedID == null || connectedID.equals(departedContainerID)) {
                chatroomview.disconnected();
                isContainerConnected = false;
              }
            } else if (evt instanceof IContainerConnectedEvent) {
              isContainerConnected = true;
View Full Code Here

  protected void setUp() throws Exception {
    super.setUp();
    final int clientIndex = 0;
    client = getClient(clientIndex);
    assertNull(client.getConnectedID());
    final ID serverConnectID = getServerConnectID(clientIndex);
    assertNotNull(serverConnectID);

    connectClient(client, serverConnectID, getConnectContext(clientIndex));
    assertEquals(serverConnectID, client.getConnectedID());
View Full Code Here

  public void testSharedDocClient() throws Exception {
    IDocumentSynchronizationStrategyFactory factory = Activator
        .getDefault().getColaSynchronizationStrategyFactory();

    assertNotNull(factory);
    ID channelId = IDFactory.getDefault().createStringID(COLA);

    String text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
    SharedDocClient client1 = new SharedDocClient("client1",factory
        .createDocumentSynchronizationStrategy(channelId, true),text);
View Full Code Here

    assertNotNull(containerEntries);
    assertTrue(containerEntries.length == 1);
  }

  public void testAndRetrieveStoreContainerByID() throws Exception {
    final ID containerID = testStoreContainer();

    // Now retrieve from container store with given ID
    final IContainerEntry containerEntry = containerStore.retrieve(containerID);
    assertNotNull(containerEntry);
    final ID containerIDa = containerEntry.getContainerID();
    assertNotNull(containerIDa);
    assertTrue(containerIDa.equals(containerID));

  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.core.identity.ID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.