Package org.eclipse.ecf.core

Examples of org.eclipse.ecf.core.ContainerConnectException


  /* (non-Javadoc)
   * @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, org.eclipse.ecf.core.security.IConnectContext)
   */
  public void connect(final ID aTargetID, final IConnectContext connectContext) throws ContainerConnectException {
    if (targetID != null || getConfig() == null) {
      throw new ContainerConnectException("Already connected"); //$NON-NLS-1$
    }
    targetID = (aTargetID == null) ? getConfig().getID() : aTargetID;
    fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID, connectContext));
    synchronized (containers) {
      final Collection containersFailedToConnect = new HashSet();
View Full Code Here


    } catch (final ContainerConnectException e) {
      disconnect();
      throw e;
    } catch (final SharedObjectAddException e1) {
      disconnect();
      throw new ContainerConnectException(NLS.bind(
          Messages.XMPPContainer_EXCEPTION_ADDING_SHARED_OBJECT,
          presenceHelperID), e1);
    }
  }
View Full Code Here

  }

  public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException {
    if (targetID.equals(targetID))
      return;
    throw new ContainerConnectException("Local container cannot be connected to targetID" + targetID); //$NON-NLS-1$
  }
View Full Code Here

  }

  public void connect(ID targetID, IConnectContext connectContext)
      throws ContainerConnectException {
    if (!(targetID instanceof MSNID)) {
      throw new ContainerConnectException(
          Messages.MSNContainer_TargetIDNotMSNID);
    }

    client = new MsnClient();
    ObjectCallback[] cb = { new ObjectCallback() };
    try {
      connectContext.getCallbackHandler().handle(cb);
      client.addSessionListener(new ISessionListener() {
        public void sessionConnected(ChatSession session) {
          try {
            Contact contact = session.getParticipants()[0];
            final ID toID = namespace
                .createInstance(new Object[] { contact
                    .getEmail() });
            chatSessions.put(toID, session);
            session.addChatSessionListener(new ChatSessionListener(
                toID));
          } catch (IDCreateException e) {
            // ignored since this should not be possible
          }
        }
      });

      client.getContactList().addContactListListener(
          new IContactListListener() {
            public void contactAdded(Contact contact) {
              final MSNRosterEntry entry = new MSNRosterEntry(
                  MSNContainer.this, contact, namespace);

              for (int i = 0; i < entries.size(); i++) {
                Object e = entries.get(i);
                if (e instanceof MSNRosterGroup) {
                  MSNRosterGroup group = (MSNRosterGroup) e;
                  if (group.getGroup().contains(contact)) {
                    MSNRosterEntry check = group
                        .getEntryFor(contact);
                    if (check == null) {
                      check = entry;
                      contact
                          .addContactListener(new IContactListener() {
                            public void nameChanged(
                                String name) {
                              firePresence(
                                  entry
                                      .getID(),
                                  entry
                                      .getPresence());
                              fireRosterUpdate(entry);
                            }

                            public void personalMessageChanged(
                                String personalMessage) {
                              entry
                                  .updatePersonalMessage();
                              firePresence(
                                  entry
                                      .getID(),
                                  entry
                                      .getPresence());
                              fireRosterUpdate(entry);
                            }

                            public void statusChanged(
                                Status status) {
                              firePresence(
                                  entry
                                      .getID(),
                                  entry
                                      .getPresence());
                              fireRosterUpdate(entry);
                            }
                          });
                      group.add(check);
                      fireRosterEntryAdded(check);
                    }
                    fireRosterUpdate(group);
                    return;
                  }
                } else {
                  MSNRosterEntry check = (MSNRosterEntry) e;
                  if (entry.getContact().equals(
                      check.getContact())) {
                    fireRosterEntryAdded(check);
                    fireRosterUpdate(check.getParent());
                    return;
                  }
                }
              }

              contact.addContactListener(new IContactListener() {
                public void nameChanged(String name) {
                  firePresence(entry.getID(), entry
                      .getPresence());
                  fireRosterUpdate(entry);
                }

                public void personalMessageChanged(
                    String personalMessage) {
                  entry.updatePersonalMessage();
                  firePresence(entry.getID(), entry
                      .getPresence());
                  fireRosterUpdate(entry);
                }

                public void statusChanged(Status status) {
                  firePresence(entry.getID(), entry
                      .getPresence());
                  fireRosterUpdate(entry);
                }
              });
              entries.add(entry);
              entry.setParent(MSNContainer.this);
              fireRosterEntryAdded(entry);
              fireRosterUpdate(MSNContainer.this);
            }

            public void contactRemoved(Contact contact) {
              MSNRosterEntry entry = findEntry(entries, contact
                  .getEmail());
              if (entry != null) {
                fireHandleUnsubscribed(entry.getUser().getID());
                fireRosterEntryRemoved(entry);
                fireRosterUpdate(entry.getParent());
                if (entry.getContact().getGroups().isEmpty()) {
                  entry.setParent(MSNContainer.this);
                  fireRosterUpdate(MSNContainer.this);
                }
              }
            }

            public void contactAddedUser(String email) {
              try {
                fireHandleSubscriptionRequest(namespace
                    .createInstance(new Object[] { email }));
              } catch (IDCreateException e) {
                // ignored
              }
            }

            public void contactRemovedUser(String email) {
              // nothing to do
            }

            public void groupAdded(Group group) {
              entries.add(new MSNRosterGroup(MSNContainer.this,
                  group));
            }
          });

      fireContainerEvent(new ContainerConnectingEvent(guid, targetID));
      client.connect(targetID.getName(), (String) cb[0].getObject());
      connectID = (MSNID) targetID;
      fireContainerEvent(new ContainerConnectedEvent(guid, connectID));
      Activator.getDefault().registerService(this);
    } catch (UnsupportedCallbackException e) {
      throw new ContainerConnectException(e);
    } catch (IOException e) {
      throw new ContainerConnectException(e);
    }
  }
View Full Code Here

      while (!rsConnected && (endTime >= System.currentTimeMillis())) {
        try {
          // wait for asynchronous notification of getting connected
          rsConnectLock.wait(rsTimeout / 10);
        } catch (InterruptedException e) {
          throw new ContainerConnectException("No notification of registry connect complete for connect targetID=" + targetID); //$NON-NLS-1$
        }
      }
      if (!rsConnected)
        throw new ContainerConnectException("Could not complete registry connect for targetID=" + targetID); //$NON-NLS-1$
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.core.ContainerConnectException

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.