Package jade.mtp

Examples of jade.mtp.MTPException


        sctx.init(new KeyManager[] { km }, new TrustManager[] { tm }, null);

        _socketFactory = sctx.getSocketFactory();
        _serverSocketFactory = sctx.getServerSocketFactory();
      } catch (Exception e) {
        throw new MTPException("Error initializing secure conection", e);
      }
    } else {
      _socketFactory = SocketFactory.getDefault();
      _serverSocketFactory = ServerSocketFactory.getDefault();
    }
View Full Code Here


    } catch (IOException e) {
      //Remove the inputs of KA object for the current address
      if (kac != null) {
        kac.close();
      }
      throw new MTPException(e.getMessage(), e);
    }
  }
View Full Code Here

        }
        if (code != 200) {
          if(logger.isLoggable(Logger.FINER))
            logger.log(Logger.FINER,"Not OK: " + code +", Closing connection to " + address);
          close();
          throw new MTPException("Description: ResponseMessage is not OK");
        }
      } catch (IOException e) {
        close();
        throw new MTPException(e.getMessage(), e);
      }
    }
View Full Code Here

  /** MTP Interface Methods */
  public TransportAddress strToAddr(String rep) throws MTPException {
    try {
      return new HTTPAddress(rep);
    } catch(MalformedURLException mue) {
      throw new MTPException("Address mismatch: this is not a valid HTTP address.");
    }
  }
View Full Code Here

 
  public String addrToStr(TransportAddress ta) throws MTPException {
    try {
      return ((HTTPAddress) ta).toString();
    } catch(Exception e) {
      throw new MTPException(e.toString());
    }
  }
View Full Code Here

  public TransportAddress activate(InChannel.Dispatcher disp)
  throws MTPException {
    try {
      return activate(disp,new ProfileImpl(new ExtendedProperties()));
    } catch(Exception e) {
      throw new MTPException(e.getMessage());
    }
  }
View Full Code Here

  public void activate(InChannel.Dispatcher disp, TransportAddress ta)
  throws MTPException {
    try {
      activate(disp,ta,new ProfileImpl(new ExtendedProperties()));
    } catch(Exception e) {
      throw new MTPException(e.getMessage());
    }
  }
View Full Code Here

          //#DOTNET_EXCLUDE_END
          /*#DOTNET_INCLUDE_BEGIN
          hta = new HTTPAddress(InetAddress.getLocalHost().getHostName(),port, false);
          #DOTNET_INCLUDE_END*/
        } catch( UnknownHostException ukhexc ) {
          throw new MTPException("Cannot activate MTP on default address: Unknown Host");
        } catch( MalformedURLException mexc ) {
          throw new MTPException("Cannot activate MTP on default address: Malformed URL");
        } catch( NumberFormatException nfexc ) {
          throw new MTPException("Cannot activate MTP on default address: Invalid port");
        }
      }
      port = hta.getPortNo();
      if((port <= 0) || (port > 65535)) {
        throw new MTPException("Invalid port number "+ta.getPort());
      }
     
      // Parse other profile parameters
      numKA     = Integer.parseInt(p.getParameter(PREFIX+"numKeepAlive",MAX_KA));
      policy    = (p.getParameter(PREFIX+"policy",POLICY).equals("aggressive"))?true:false;
      int outPort   = Integer.parseInt(p.getParameter(PREFIX+"outPort",OUT_PORT));
      ka = new KeepAlive(numKA, outPort, policy);
      keepAlive = numKA > 0;
      proxyHost = p.getParameter(PREFIX+"proxyHost",null);
      if (proxyHost != null) {
        useProxy = true;
        proxyPort = Integer.parseInt(p.getParameter(PREFIX+"proxyPort",PROXY_PORT));
      }
      saxClass = p.getParameter(PREFIX+"parser",null);
     
      timeout = Integer.parseInt(p.getParameter(PREFIX+"timeout",TIMEOUT));
     
      //#PJAVA_EXCLUDE_BEGIN
      try{
        HTTPSocketFactory.getInstance().configure(p, hta);
      } catch(Exception e){
        throw new MTPException("Error configuring Socket Factory", e);
      }
      //#PJAVA_EXCLUDE_END
      // System.out.println("Parameters set:");
      // System.out.println("- KA "+numKA);
      // System.out.println("- Policy "+policy);
      // System.out.println("- Out port "+outPort);
      // System.out.println("- Proxy host "+proxyHost);
      // System.out.println("- Proxy port "+proxyPort);
      // System.out.println("- Parser "+saxClass);
      // System.out.println("- Timeout "+timeout);
    } catch (ClassCastException cce) {
      throw new MTPException("User supplied transport address not supported.");
    } catch( NumberFormatException nexc ) {
      throw new MTPException(nexc.getMessage());
    }
   
    //Creation of the Server
    try {
      //Create object server
      HTTPServer srv = new HTTPServer(port,disp,numKA,saxClass,timeout, changePortIfBusy);
      int actualPort = srv.getLocalPort();
      if (actualPort != port) {
        // The selected port is busy and a new one was selected --> Update the transport address
        boolean useHttps = "https".equalsIgnoreCase(hta.getProto());
        //#DOTNET_EXCLUDE_BEGIN
        hta = new HTTPAddress(InetAddress.getLocalHost().getCanonicalHostName(),actualPort, useHttps);
        //#DOTNET_EXCLUDE_END
        /*#DOTNET_INCLUDE_BEGIN
        hta = new HTTPAddress(InetAddress.getLocalHost().getHostName(),actualPort, useHttps);
        #DOTNET_INCLUDE_END*/
      }
      //Save the reference to HTTPServer
      addr2srv.put(hta.toString(),srv);
      //Execute server
      srv.start();
      protocols = new String[]{hta.getProto()};
      return hta;
    } catch( Exception e ) {
      throw new MTPException("While activating MTP got exception "+e);
    }
  }
View Full Code Here

    if( srv != null ) {
      addr2srv.remove(ta.toString());
      srv.desactivate();
      //srv.interrupt();
    } else
      throw new MTPException("No server on address "+ta);
  }
View Full Code Here

      requestStream.flush();
      requestStream.close();
      request = requestStream.toByteArray();
     
    } catch (Exception e) {
      throw new MTPException(e.getMessage());
    }
    ka.send(url, request);
  }
View Full Code Here

TOP

Related Classes of jade.mtp.MTPException

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.