Package org.eclipse.ecf.core

Examples of org.eclipse.ecf.core.ContainerConnectException


  }*/
  public void connect(ID targetID, IConnectContext connectContext)
      throws ContainerConnectException {
    TwipseLog.logInfo("Twipse container connect - targetID == "+targetID);
    if (!(targetID instanceof TwitterID)) {
      ContainerConnectException e = new ContainerConnectException(
          "Errore ID");
      TwipseLog.logError("ErroreID", e);
      throw e;
    }

View Full Code Here


  public void connect(ID targetID, IConnectContext joinContext) throws ContainerConnectException {
    try {
      if (isClosing)
        throw new IllegalStateException("Container closing"); //$NON-NLS-1$
      if (targetID == null)
        throw new ContainerConnectException("targetID cannot be null"); //$NON-NLS-1$
      Object response = null;
      synchronized (getConnectLock()) {
        // Throw if already connected
        if (isConnected())
          throw new IllegalStateException("Container already connected connectedID=" + getConnectedID()); //$NON-NLS-1$
        // Throw if connecting
        if (isConnecting())
          throw new IllegalStateException("Container connecting"); //$NON-NLS-1$
        // else we're entering connecting state
        // first notify synchonously
        final ISynchAsynchConnection aConnection = createConnection(targetID, joinContext);
        setStateConnecting(aConnection);

        fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID, joinContext));

        final Object connectData = getConnectData(targetID, joinContext);
        final int connectTimeout = getConnectTimeout();

        synchronized (aConnection) {

          try {
            // Make connect call
            response = aConnection.connect(targetID, connectData, connectTimeout);
          } catch (final ECFException e) {
            if (getConnection() != aConnection)
              disconnect(aConnection);
            else
              setStateDisconnected(aConnection);
            throw e;
          }
          // If not in correct state, disconnect and return
          if (getConnection() != aConnection) {
            disconnect(aConnection);
            throw new IllegalStateException("Container connect failed because not in correct state"); //$NON-NLS-1$
          }
          ID serverID = null;
          try {
            serverID = handleConnectResponse(targetID, response);
          } catch (final Exception e) {
            setStateDisconnected(aConnection);
            throw e;
          }
          setStateConnected(serverID, aConnection);
          // notify listeners
          fireContainerEvent(new ContainerConnectedEvent(this.getID(), remoteServerID));
          aConnection.start();
        }
      }
    } catch (final ContainerConnectException e) {
      throw e;
    } catch (final ECFException e) {
      final IStatus s = e.getStatus();
      throw new ContainerConnectException(s.getMessage(), s.getException());
    } catch (final Exception e) {
      throw new ContainerConnectException(e.getLocalizedMessage(), e);
    }
  }
View Full Code Here

    Trace.trace(Activator.PLUGIN_ID, DnsSdDebugOptions.METHODS_TRACING, this.getClass(), "connect(ID aTargetID, IConnectContext connectContext)", "connecting container"); //$NON-NLS-1$ //$NON-NLS-2$

    // connect can only be called once
    if (targetID != null || getConfig() == null) {
      throw new ContainerConnectException(Messages.DnsSdDiscoveryAdvertiser_Container_Already_Connected);
    }

    //TODO convert non DnsSdServiceTypeIDs into DSTIDs
    if(aTargetID == null) {
      targetID = new DnsSdServiceTypeID();
    } else {
      final Namespace ns = getConnectNamespace();
      try {
        targetID = (DnsSdServiceTypeID) ns.createInstance(new Object[]{aTargetID});
      } catch(IDCreateException e) {
        throw new ContainerConnectException(e);
      }
    }
   
    // instantiate a default resolver
    if(resolver == null) {
      try {
        resolver = new SimpleResolver();
        resolver.setTCP(true);
      } catch (UnknownHostException e) {
        throw new ContainerConnectException(e);
      }
    }

    // done setting up this provider, send event
    fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID,
View Full Code Here

  public void connect(ID aTargetID, IConnectContext connectContext)
      throws ContainerConnectException {

    // connect can only be called once
    if (targetID != null || getConfig() == null) {
      throw new ContainerConnectException(Messages.DnsSdDiscoveryLocator_Container_Already_Connected);
    }
   
    // fall back to the search path as last resort
    if(aTargetID == null || !(aTargetID instanceof DnsSdServiceTypeID)) {
      ResolverConfig config = new ResolverConfig();
      Name[] searchPaths = config.searchPath();
      if(searchPaths != null && searchPaths.length > 0) {
        targetID = new DnsSdServiceTypeID();
        targetID.setSearchPath(searchPaths);
      } else {
        throw new ContainerConnectException(Messages.DnsSdDiscoveryLocator_No_Target_ID);
      }
    } else {
      final Namespace ns = getConnectNamespace();
      try {
        targetID = (DnsSdServiceTypeID) ns.createInstance(new Object[]{aTargetID});
      } catch(IDCreateException e) {
        throw new ContainerConnectException(e);
      }
    }
   
    // instantiate a default resolver
    if(resolver == null) {
      try {
        resolver = new SimpleResolver();
      } catch (UnknownHostException e) {
        throw new ContainerConnectException(e);
      }
    }
   
    // read browsing domains for the given targetID/searchpath and merge with existing
    targetID.addSearchPath(getBrowsingDomains(targetID));
View Full Code Here

   * @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, org.eclipse.ecf.core.security.IConnectContext)
   */
  public void connect(final ID targetID1, final IConnectContext joinContext) throws ContainerConnectException {
    synchronized (lock) {
      if (disposed)
        throw new ContainerConnectException("Container has been disposed"); //$NON-NLS-1$
      if (this.targetID != null)
        throw new ContainerConnectException("Already connected"); //$NON-NLS-1$
      this.targetID = (targetID1 == null) ? getConfig().getID() : targetID1;
      fireContainerEvent(new ContainerConnectingEvent(this.getID(), this.targetID, joinContext));
      initializeQueue();
      try {
        this.jmdns = JmDNS.create();
        jmdns.addServiceTypeListener(this);
      } catch (final IOException e) {
        Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "connect", e); //$NON-NLS-1$
        if (this.jmdns != null) {
          jmdns.close();
          jmdns = null;
        }
        throw new ContainerConnectException("Cannot create JmDNS instance", e); //$NON-NLS-1$
      }
      fireContainerEvent(new ContainerConnectedEvent(this.getID(), this.targetID));
    }
  }
View Full Code Here

  }

  // IContainer implementation methods
  public void connect(ID targetID, IConnectContext connectContext1) throws ContainerConnectException {
    if (targetID == null)
      throw new ContainerConnectException("targetID cannot be null"); //$NON-NLS-1$
    Namespace targetNamespace = targetID.getNamespace();
    Namespace connectNamespace = getConnectNamespace();
    if (connectNamespace == null)
      throw new ContainerConnectException("targetID namespace cannot be null"); //$NON-NLS-1$
    if (!(targetNamespace.getName().equals(connectNamespace.getName())))
      throw new ContainerConnectException("targetID of incorrect type"); //$NON-NLS-1$
    fireContainerEvent(new ContainerConnectingEvent(containerID, targetID));
    synchronized (connectLock) {
      if (connectedID == null) {
        connectedID = targetID;
        this.connectContext = connectContext1;
      } else if (!connectedID.equals(targetID))
        throw new ContainerConnectException("Already connected to " + connectedID.getName()); //$NON-NLS-1$
    }
    fireContainerEvent(new ContainerConnectedEvent(containerID, targetID));
  }
View Full Code Here

      if (container == null) {
        container = ContainerFactory.getDefault().createContainer(
            bot.getContainerFactoryName());
        namespace = container.getConnectNamespace();
      } else
        throw new ContainerConnectException("Already connected"); //$NON-NLS-1$

      targetID = IDFactory.getDefault().createID(namespace,
          bot.getConnectID());

      IChatRoomManager manager = (IChatRoomManager) container
View Full Code Here

      if (container == null) {
        container = ContainerFactory.getDefault().createContainer(
            bot.getContainerFactoryName());
        namespace = container.getConnectNamespace();
      } else
        throw new ContainerConnectException("Already connected");

      targetID = IDFactory.getDefault().createID(namespace,
          bot.getConnectID());

      firePreConnect();
View Full Code Here

   */
  public void connect(ID connectID, IConnectContext connectContext)
      throws ContainerConnectException {
    // Actually do join here
    if (connectID == null)
      throw new ContainerConnectException(
          Messages.IRCChannelContainer_Exception_TargetID_Null);
    if (connectWaiting)
      throw new ContainerConnectException(
          Messages.IRCChannelContainer_Exception_Connecting);
    // Get channel name
    String channelName = connectID.getName();
    fireContainerEvent(new ContainerConnectingEvent(this.getID(),
        connectID, connectContext));
    // Get password via callback in connectContext
    String pw = getPasswordFromConnectContext(connectContext);
    synchronized (connectLock) {
      connectWaiting = true;
      try {
        rootContainer.doJoinChannel(channelName, pw);
        long timeout = CONNECT_TIMEOUT + System.currentTimeMillis();
        while (connectWaiting && timeout > System.currentTimeMillis()) {
          connectLock.wait(2000);
        }
        if (connectWaiting)
          throw new TimeoutException(
              NLS.bind(
                  Messages.IRCChannelContainer_Exception_Connect_Timeout,
                  connectID.getName()), CONNECT_TIMEOUT);
        this.targetID = connectID;
        fireContainerEvent(new ContainerConnectedEvent(this.getID(),
            this.targetID));
      } catch (Exception e) {
        this.targetID = null;
        throw new ContainerConnectException(NLS.bind(
            Messages.IRCChannelContainer_Exception_Connect_Failed,
            connectID.getName()), e);
      } finally {
        connectWaiting = false;
      }
View Full Code Here

    return ZooDiscoveryContainer.zooKeeperServer;
  }

  public void connect(ID id, IConnectContext connectContext) throws ContainerConnectException {
    if (isDisposed)
      throw new ContainerConnectException("Container already disposed!");
    if (this.isConnected)
      throw new ContainerConnectException("Container already connected!");
    this.targetId = id;
    if (this.targetId == null) {
      this.targetId = this.getConnectNamespace().createInstance(new String[] { DefaultDiscoveryConfig.getDefaultTarget() });
    }
    init(this.targetId);
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.