Package java.net

Examples of java.net.ConnectException


   *
   * @exception IOException  if the connection can't be established
   */
  final Socket createSocket(ServerDesc server) throws IOException {
    if (server == null)
      throw new ConnectException("Cannot connect to null server");
   
    for (Enumeration e = server.getSockAddrs(); e.hasMoreElements();) {
      SocketAddress sa = (SocketAddress) e.nextElement();

      if (this.logmon.isLoggable(BasicLevel.DEBUG))
        this.logmon.log(BasicLevel.DEBUG,
                        this.getName() + ", try to connect server#" +
                        server.getServerId() +
                        ", addr=" + sa.getHostname() +
                        ", port=" + sa.getPort());
                 
      try {
        Socket socket = createSocket(sa);

        if (this.logmon.isLoggable(BasicLevel.DEBUG))
          this.logmon.log(BasicLevel.DEBUG, this.getName() + ", connected");

        // Memorize the right address for next try.
        server.moveToFirst(sa);
        return socket;
      } catch (IOException exc) {
        this.logmon.log(BasicLevel.DEBUG,
                        this.getName() + ", connection refused, try next element");
        continue;
      }
    }
          
    throw new ConnectException("Cannot connect to server#" + server.getServerId());
  }
View Full Code Here


        if (this.logmon.isLoggable(BasicLevel.DEBUG))
          this.logmon.log(BasicLevel.DEBUG,
                          this.getName() + ", wait ack");
        is = socket.getInputStream();
        if (is.read() == -1)
          throw new ConnectException("Connection broken");

        if (this.logmon.isLoggable(BasicLevel.DEBUG))
          this.logmon.log(BasicLevel.DEBUG,
                          this.getName() + ", receive ack");
      } finally {
View Full Code Here

          //  The connection is already established, or a "local" connection
          // is in progress from this server with a greater priority.
          //  In all cases, stops this "remote" attempt. If the "local"
          // attempt has a lower priority, it will fail due to a remote
          // reject.
          throw new ConnectException("Already connected");

        // Accept this connection.
        if (logmon.isLoggable(BasicLevel.DEBUG))
          logmon.log(BasicLevel.DEBUG, getName() + ", send AckStatus");
View Full Code Here

      }
    } catch (JMSException exc) {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG,
                   "AdminRequestor.request() connection failed.", exc);
      throw new ConnectException("Connection failed: " + exc.getMessage());
    }
   
    try {
      reply = (AdminReply) ((AdminMessage) replyMsg).getAdminMessage();
    } catch (ClassCastException exc) {
View Full Code Here

      consumer = session.createConsumer(tmpTopic);
    } catch (JMSException exc) {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG,
                   "AdminRequestor.abort() connection failed.", exc);
      throw new ConnectException("Connection failed: " + exc.getMessage());
    }
  }
View Full Code Here

   * @return The administration wrapper.
   * @throws ConnectException if no wrapper is defined.
   */
  public static AdminWrapper getWrapper() throws ConnectException {
    if (wrapper == null)
      throw new ConnectException();
   
    return wrapper;
  }
View Full Code Here

    synchronized(lock) {
      if (wrapper != null) {
        // We should throw an exception, the asked connection may use a different CF in
        // order to connect to another server!
        logger.log(BasicLevel.DEBUG, "AdminModule.doConnect: Already connected.");
        throw new ConnectException("Already connected.");
      }

      //  set identity className
      cf.setIdentityClassName(identityClass);

      try {
        cnx = cf.createConnection(name, password);
        cnx.start();
        wrapper = new AdminWrapper(cnx);

        FactoryParameters params = cf.getParameters();
        localHost = params.getHost();
        localPort = params.getPort();
      } catch (JMSSecurityException exc) {
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, "AdminModule.doConnect", exc);
        throw new AdminException(exc.getMessage());
      } catch (JMSException exc) {
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, "AdminModule.doConnect", exc);
        throw new ConnectException("Connecting failed: " + exc);
      }
    }
  }
View Full Code Here

  public static AdminReply doRequest(AdminRequest request) throws AdminException, ConnectException {
    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG, "Admin.doRequest(" + request + ')');

    if (wrapper == null)
      throw new ConnectException("Admin connection not established.");

    return wrapper.doRequest(request);
  }
View Full Code Here

   * @param timeOut the maximum time in ms before aborting request.
   * @throws ConnectException if the connection is not established.
   */
  public final void setTimeOutToAbortRequest(long timeOut) throws ConnectException {
    if (requestor == null)
      throw new ConnectException("Connection not established.");
   
    requestor.setRequestTimeout(timeOut);
  }
View Full Code Here

   * @return the maximum time in ms before aborting request.
   * @throws ConnectException if the connection is not established.
   */
  public final long getTimeOutToAbortRequest() throws ConnectException {
    if (requestor == null)
      throw new ConnectException("Connection not established.");

    return requestor.getRequestTimeout();
  }
View Full Code Here

TOP

Related Classes of java.net.ConnectException

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.