当前位置: 首页>>代码示例>>Java>>正文


Java Connection.connect方法代码示例

本文整理汇总了Java中org.simpleframework.transport.connect.Connection.connect方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.connect方法的具体用法?Java Connection.connect怎么用?Java Connection.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.simpleframework.transport.connect.Connection的用法示例。


在下文中一共展示了Connection.connect方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startHttpServer

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public synchronized static void startHttpServer(int port) {
    if (!started) {
        try {
            Container container = new CommandListener();
            @SuppressWarnings("resource") Connection connection = new SocketConnection(container);
            SocketAddress address = new InetSocketAddress(port);
            System.out.println("Starting httpserver on port " + port);
            LOG.info("Starting httpserver on port " + port);
            connection.connect(address);
            started = true;
        } catch (IOException e) {
            LOG.error(LogUtil.getLogMessage("Error starting httpServer: " + e), e);
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:17,代码来源:CommandListener.java

示例2: startHttpServer

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public synchronized static void startHttpServer(int port, StandaloneAgentStartup standaloneAgentStartup) {
    if (!started) {
        agentStarter = standaloneAgentStartup;
        try {
            Container container = new CommandListener();
            @SuppressWarnings("resource") Connection connection = new SocketConnection(container);
            SocketAddress address = new InetSocketAddress(port);
            System.out.println("Starting httpserver on port " + port);
            connection.connect(address);
            started = true;
        } catch (IOException e) {
            LOG.error("Error starting httpServer: " + e, e);
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:17,代码来源:CommandListener.java

示例3: createServer

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public static ServerCriteria createServer() throws Exception {
   Container container = new Container() {
      public void handle(Request request, Response response) {
         try {
            PrintStream out = response.getPrintStream();
            response.setValue("Content-Type", "text/plain");
            response.setValue("Connection", "close");
            
            out.print("TEST " + new Date());
            response.close();
         }catch(Exception e) {
            e.printStackTrace();
            try {
               response.close();
            }catch(Exception ex) {
               ex.printStackTrace();
            }
         }
      }
   };
   ContainerServer server = new ContainerServer(container);
   Connection connection = new SocketConnection(server);
   InetSocketAddress address = (InetSocketAddress)connection.connect(null); // ephemeral port
   
   return new ServerCriteria(connection, address);
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:27,代码来源:StopTest.java

示例4: main

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    // use port if given
    try {
        port = Integer.parseInt(args[0]);
    } catch(Exception e) {
        // silently keep port at 8080
    }

    // initialize the Stanford Core NLP
    pipeline = new StanfordCoreNLP();

    // start the server
    Container container = new StanfordCoreNLPXMLServer();
    Server server = new ContainerServer(container);
    Connection connection = new SocketConnection(server);
    SocketAddress address = new InetSocketAddress(port);
    connection.connect(address);

    log.info("Initialized server at port " + port + ".");
}
 
开发者ID:nlohmann,项目名称:StanfordCoreNLPXMLServer,代码行数:21,代码来源:StanfordCoreNLPXMLServer.java

示例5: main

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public static void main(String[] list) throws Exception {
   Container container = new BlobStationServer();
   Server server = new ContainerServer(container);
   Connection connection = new SocketConnection(server);
   SocketAddress address = new InetSocketAddress(8080);

   connection.connect(address);   
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:9,代码来源:BlobStationServer.java

示例6: connect

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public Connection connect() throws Exception {
    Server server = new ContainerServer(this);
    Connection connection = new SocketConnection(server);
    SocketAddress address = new InetSocketAddress(port);
    connection.connect(address);
    return connection;
}
 
开发者ID:bazaarvoice,项目名称:jersey-hmac-auth,代码行数:8,代码来源:ValidatingHttpServer.java

示例7: startServing

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
/**
 * Starts serving HTTPS encrypted traffic from this container.
 *
 * @param numThreads the number of threads to handle the HTTP requests.
 * @param context a valid SSLContext for serving secure connections.
 * @throws IOException thrown if HTTP serving could not be started.
 */
void startServing(int numThreads, SSLContext context) throws IOException {
  final ContainerSocketProcessor processor = new ContainerSocketProcessor(this, numThreads);

  // Since this server will run forever, no need to close connection.
  final Connection connection = new SocketConnection(processor);
  final SocketAddress address = new InetSocketAddress(mPort);
  connection.connect(address, context);
  LOG.info("Listening to: " + address.toString());
}
 
开发者ID:shaeberling,项目名称:winston,代码行数:17,代码来源:MasterContainer.java

示例8: startServing

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public void startServing(Container container) {
  try {
    ContainerSocketProcessor processor =
        new ContainerSocketProcessor(container, mNumThreads);
    Connection connection = new SocketConnection(processor);
    SocketAddress address = new InetSocketAddress(mPort);
    connection.connect(address);
    LOG.info("Listening to: " + address.toString());
  } catch (IOException e) {
    LOG.error("Cannot start webserver: " + e.getMessage());
  }
}
 
开发者ID:shaeberling,项目名称:winston,代码行数:13,代码来源:ContainerServer.java

示例9: startServing

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public void startServing(int numThreads)
    throws IOException {
  final ContainerSocketProcessor processor = new ContainerSocketProcessor(this, numThreads);

  // Since this server will run forever, no need to close connection.
  @SuppressWarnings("resource")
  final Connection connection = new SocketConnection(processor);
  final SocketAddress address = new InetSocketAddress(mPort);
  LOG.info("Listening to: " + address.toString());
  connection.connect(address);
}
 
开发者ID:shaeberling,项目名称:winston,代码行数:12,代码来源:NodeContainer.java

示例10: run

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
@Override
public void run() {
    try {
        Server server = new ContainerServer(this);
        Connection connection = new SocketConnection(server);
        SocketAddress address = new InetSocketAddress(port);
        connection.connect(address);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:tarjeir,项目名称:vitus-elasticsearch-webintegration,代码行数:12,代码来源:WebServer.java

示例11: start

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public void start(){
	org.simpleframework.transport.Server server;
	try {
		server = (org.simpleframework.transport.Server) new ContainerServer(reqHandler);
		@SuppressWarnings("resource")
		Connection connection = new SocketConnection(server);
	    SocketAddress address = new InetSocketAddress(port);
	    connection.connect(address);
	    System.out.println("Server runnung on port: "+port);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:ael-code,项目名称:preston,代码行数:14,代码来源:Server.java

示例12: main

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public static void main(String[] list) throws Exception
{
	try {
      Container container = new WebApp();
      Server server = new ContainerServer(container);
      Connection connection = new SocketConnection(server);
      SocketAddress address = new InetSocketAddress(port);

      connection.connect(address);
	} catch(InternalException e)
	{
		System.err.println(e.what);
	}
}
 
开发者ID:wetneb,项目名称:MorozParser,代码行数:15,代码来源:WebApp.java

示例13: main

import org.simpleframework.transport.connect.Connection; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	// Starting the server
	Container container = new DistantAPISimulator();
	Server server = new ContainerServer(container);
	Connection connection = new SocketConnection(server);
	SocketAddress address = new InetSocketAddress(1337);
	connection.connect(address);

	try {
		// Creating the pixie instance
		APIPixie pixie = new APIPixie("http://localhost:1337");

		// Create a user
		APIService<User, Long> userService = pixie.getService(User.class);
		User user = new User();
		user.setName("Vincent DURMONT");
		user.setEmail("[email protected]");
		user = userService.post(user);
		System.out.println("Created user: " + user);

		// Create a project
		APIService<Project, Long> projectService = pixie.getService(Project.class);
		Project project = new Project();
		project.setOwner(user);
		project.setTitle("My awesome project");

		// Create some tags
		List<String> tags = new LinkedList<>();
		tags.add("test");
		tags.add("java");
		project.setTags(tags);

		// Create some issues
		List<Issue> issues = new LinkedList<>();

		Issue issue1 = new Issue();
		issue1.setAuthor(user);
		issue1.setText("the first issue!");
		issues.add(issue1);

		Issue issue2 = new Issue();
		issue2.setAuthor(user);
		issue2.setText("the second issue!");
		issues.add(issue2);

		project.setIssues(issues);
		project = projectService.post(project);
		System.out.println("Created project: " + project);

		System.out.println("List of users: " + userService.getAll());
		System.out.println("List of projects: " + projectService.getAll());
		APIService<Issue, Long> issueService = pixie.getService(Issue.class);
		System.out.println("List of issues: " + issueService.getAll());

	} catch (Exception e) {
		e.printStackTrace();
	}

	// Stopping the server
	server.stop();
	connection.close();
}
 
开发者ID:vdurmont,项目名称:apipixie,代码行数:63,代码来源:Main.java


注:本文中的org.simpleframework.transport.connect.Connection.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。