Package nexj.core.util

Examples of nexj.core.util.HTTPClient$Connection


     * Check if we can connect using password auth
     * @return true|false
     */
    public boolean checkPasswordAuth() {
        boolean status = false;
        Connection c = null;
        try {
            c = new Connection(host, port);
            c.connect();
            if(logger.isLoggable(Level.FINER)) {
                logger.finer("Checking connection...");
            }
            status = c.authenticateWithPassword(userName, password);
            if (status) {
                logger.finer("Successfully connected to " + userName + "@" + host + " using password authentication");
            }
        } catch(IOException ioe) {
            //logger.printExceptionStackTrace(ioe);
            if (logger.isLoggable(Level.FINER)) {
                ioe.printStackTrace();
            }
        } finally {
            c.close();
        }
        return status;
    }
View Full Code Here


   /**
    * Returns a new connection.
    */
   Connection getConnection()
   {
      return new Connection(getAccessKeyId(), getSecretAccessKey(),
            isSecure(), getServer(), getPort(), getCallingFormat());
   }
View Full Code Here

      checkAttributes();

      try
      {
         m_httpClient = new HTTPClient();

         attemptLogin(); // login

         sEditToken = getEditToken(); // get edit token for target page
         log("Edit token: " + sEditToken, Project.MSG_DEBUG);
View Full Code Here

   /**
    * @see nexj.core.tools.GenericTool#execute(java.lang.String)
    */
   protected void execute(String sCommand) throws Exception
   {
      HTTPClient client = new HTTPClient();

      client.setPasswordProvider(new PasswordAuthenticationProvider()
      {
         public PasswordAuthentication getPasswordAuthentication()
         {
            return new PasswordAuthentication("nexjsa", "nexj".toCharArray());
         }

         public boolean isAuthenticationDeterministic()
         {
            return true;
         }
      });

      int nReqCount = Integer.parseInt(getProperty("req.count", "1"));

      final Request request = new Request();
      TransferObject tobj = new TransferObject();
     
      tobj.setClassName("TestMessage");
      tobj.setEventName("runTest");
     
      request.addInvocation(tobj);
      request.setAsync(StringUtil.parseBoolean(getProperty("async", "0")));

      for (int nReq = 0; nReq < nReqCount; ++ nReq)
      {
         Object response = client.invoke(new URI(getProperty("url", "http://localhost:8080/nexj/text")), HTTP.METHOD_POST,
            new HTTPClient.RequestHandler()
            {
               public void handleRequest(HTTPClient client, OutputStream ostream) throws IOException
               {
                  Writer writer = new OutputStreamWriter(ostream, XMLUtil.ENCODING);
  
                  new TextMarshaller(null).serialize(request, writer);
                  writer.close();
               }
            },
            new HTTPClient.ResponseHandler()
            {
               public Object handleResponse(HTTPClient client, InputStream istream) throws IOException
               {
                  int nResult = client.getResponseStatus();
  
                  if (nResult != HTTP.STATUS_OK)
                  {
                     RuntimeException e = null;
  
                     if (nResult == HTTP.STATUS_UNAUTHORIZED ||
                        nResult == HTTP.STATUS_FORBIDDEN)
                     {
                        e = new LoginException("err.auth.login");
                     }
  
                     if (e == null || e.getCause() == null)
                     {
                        RuntimeException x = new HTTPException(nResult, client.getResponseMessage());
  
                        if (e == null)
                        {
                           e = x;
                        }
View Full Code Here

      try
      {
         if (m_client == null)
         {
            m_client = new HTTPClient();
         }

         m_client.setTrustedCertificate(m_channel.getTrustedCertificate());
         m_client.setReadTimeout(m_channel.getReadTimeout());
         m_client.setConnectionTimeout(m_channel.getConnectionTimeout());
View Full Code Here

    private void connectionClosed() {
        if(! reconnect.get()) {
            return; // Nothing to do
        }
        // Wait until the connection is closed before reconnecting
        final Connection connection = this.connection;
        if(connection != null) {
            if(channel == null) {
                connection.closeAsync();
            }
        } else {
            HostControllerLogger.ROOT_LOGGER.lostRemoteDomainConnection();
            executorService.execute(new Runnable() {
                @Override
View Full Code Here

     *
     * @param connectionURI the new connection URI
     */
    protected void reconfigure(final URI connectionURI) {
        configuration.setUri(connectionURI);
        final Connection connection = this.connection;
        if(connection != null) {
            connection.closeAsync();
        }
    }
View Full Code Here

            builder.set(Options.SASL_MECHANISMS, Sequence.of("JBOSS-LOCAL-USER"));
        }

        final IoFuture<Connection> futureConnection = endpoint.connect(connectionURI, builder.getMap(), new AuthenticationCallbackHandler(username, password));
        // wait for the connection to be established
        final Connection connection = IoFutureHelper.get(futureConnection, 5000, TimeUnit.MILLISECONDS);
        // create a remoting EJB receiver for this connection
        final EJBReceiver receiver = new RemotingConnectionEJBReceiver(connection);
        // associate it with the client context
        EJBClientContext context = EJBClientContext.create();
        context.registerEJBReceiver(receiver);
View Full Code Here

        return this.nodeName;
    }

    @Override
    public EJBReceiver getEJBReceiver() {
        Connection connection;
        final ReconnectHandler reconnectHandler;
        OptionMap channelCreationOptions = OptionMap.EMPTY;
        final EJBClientConfiguration ejbClientConfiguration = this.clusterContext.getEJBClientContext().getEJBClientConfiguration();
        try {
            // if the client configuration is available create the connection using those configs
View Full Code Here

            this.connectionTimeout = connectionTimeoutInMillis;
        }

        @Override
        public void reconnect() throws IOException {
            Connection connection = null;
            try {
                final IoFuture<Connection> futureConnection = NetworkUtil.connect(endpoint, destinationHost, destinationPort, null, connectionCreationOptions, callbackHandler, null);
                connection = IoFutureHelper.get(futureConnection, connectionTimeout, TimeUnit.MILLISECONDS);
                logger.debug("Successfully reconnected to connection " + connection);
View Full Code Here

TOP

Related Classes of nexj.core.util.HTTPClient$Connection

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.