本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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 + ".");
}
示例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);
}
示例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;
}
示例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());
}
示例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());
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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();
}