本文整理汇总了Java中org.simpleframework.transport.Server类的典型用法代码示例。如果您正苦于以下问题:Java Server类的具体用法?Java Server怎么用?Java Server使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Server类属于org.simpleframework.transport包,在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.simpleframework.transport.Server; //导入依赖的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 + ".");
}
示例2: main
import org.simpleframework.transport.Server; //导入依赖的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);
}
示例3: PingServer
import org.simpleframework.transport.Server; //导入依赖的package包/类
public PingServer(int port, String message) throws Exception {
Allocator allocator = new FileAllocator();
Processor processor = new ContainerProcessor(this, allocator, 5);
Server server = new ProcessorServer(processor);
DebugServer debug = new DebugServer(server);
this.connection = new SocketConnection(debug);
this.address = new InetSocketAddress(port);
this.message = message;
}
示例4: HttpMockServer
import org.simpleframework.transport.Server; //导入依赖的package包/类
public HttpMockServer(@Nonnull JSONObject jsonObject, @Nonnull ConfigReader configReader, @Nonnull NetworkType simulatedNetworkType)
throws IOException, JSONException {
ConfigResult config = new ConfigParser(configReader).parseConfig(jsonObject);
MockNetworkLag networkLag = new MockNetworkLag(simulatedNetworkType);
this.responseHandler = new ResponseHandler(config.responses, networkLag, configReader);
Server server = new ContainerServer(this);
conn = new SocketConnection(server);
final SocketAddress sa = new InetSocketAddress(config.port);
conn.connect(sa);
}
示例5: setUp
import org.simpleframework.transport.Server; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Server server = new ContainerServer(testContainer);
connection = new SocketConnection(server);
ServerSocket socketServer = new ServerSocket(0);
port = socketServer.getLocalPort();
socketServer.close();
connection.connect(new InetSocketAddress(port));
}
示例6: connect
import org.simpleframework.transport.Server; //导入依赖的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: run
import org.simpleframework.transport.Server; //导入依赖的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();
}
}
示例8: main
import org.simpleframework.transport.Server; //导入依赖的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);
}
}
示例9: start
import org.simpleframework.transport.Server; //导入依赖的package包/类
/**
* Start the tracker thread.
*/
public void start() throws IOException {
LOG.info("Starting BitTorrent tracker on {}...", getAnnounceUrls());
synchronized (lock) {
if (this.metrics == null) {
Object trackerId = Iterables.getFirst(getListenAddresses(), System.identityHashCode(this));
this.metrics = new TrackerMetrics(getMetricsRegistry(), trackerId);
metrics.addGauge("torrentCount", new Gauge<Integer>() {
@Override
public Integer value() {
return torrents.size();
}
});
}
for (Map.Entry<InetSocketAddress, Listener> e : listeners.entrySet()) {
Listener listener = e.getValue();
if (listener.connection == null) {
// Creates a thread via: SocketConnection
// -> ListenerManager -> Listener
// -> DirectReactor -> ActionDistributor -> Daemon
Container container = new TrackerService(version, torrents, metrics);
Server server = new ContainerServer(container);
listener.connection = new SocketConnection(server);
listener.connectionAddress = listener.connection.connect(e.getKey());
}
}
if (this.scheduler == null || this.scheduler.isShutdown()) {
// TODO: Set a thread timeout, nothing is time critical.
this.scheduler = new ScheduledThreadPoolExecutor(1);
this.scheduler.scheduleWithFixedDelay(new PeerCollector(),
PEER_COLLECTION_FREQUENCY_SECONDS,
PEER_COLLECTION_FREQUENCY_SECONDS,
TimeUnit.SECONDS);
}
}
LOG.info("Started BitTorrent tracker on {}...", getAnnounceUrls());
}
示例10: TicketProcessor
import org.simpleframework.transport.Server; //导入依赖的package包/类
public TicketProcessor(Server delegate) {
this.delegate = delegate;
}
示例11: DebugServer
import org.simpleframework.transport.Server; //导入依赖的package包/类
public DebugServer(Server server) {
this.server = server;
}
示例12: main
import org.simpleframework.transport.Server; //导入依赖的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();
}
示例13: SocketAcceptor
import org.simpleframework.transport.Server; //导入依赖的package包/类
/**
* Constructor for the <code>SocketAcceptor</code> object. This
* accepts new TCP connections from the specified server socket.
* Each of the connections that is accepted is configured for
* performance for HTTP applications.
*
* @param address this is the address to accept connections from
* @param context this is the SSL context used for secure HTTPS
* @param server this is used to initiate the HTTP processing
* @param agent this is the tracing agent associated with this
*/
public SocketAcceptor(SocketAddress address, SSLContext context, Server server, Agent agent) throws IOException {
this.listener = ServerSocketChannel.open();
this.socket = listener.socket();
this.context = context;
this.agent = agent;
this.server = server;
this.bind(address);
}
示例14: SocketAcceptor
import org.simpleframework.transport.Server; //导入依赖的package包/类
/**
* Constructor for the <code>SocketAcceptor</code> object. This accepts new
* TCP connections from the specified server socket. Each of the connections
* that is accepted is configured for performance for HTTP applications.
*
* @param address
* this is the address to accept connections from
* @param context
* this is the SSL context used for secure HTTPS
* @param server
* this is used to initiate the HTTP processing
* @param agent
* this is the tracing agent associated with this
*/
public SocketAcceptor(SocketAddress address, SSLContext context,
Server server, Agent agent) throws IOException {
this.listener = ServerSocketChannel.open();
this.socket = this.listener.socket();
this.context = context;
this.agent = agent;
this.server = server;
this.bind(address);
}
示例15: SocketListener
import org.simpleframework.transport.Server; //导入依赖的package包/类
/**
* Constructor for the <code>Listener</code> object. This needs a socket
* address and a processor to hand created sockets to. This creates a
* <code>Reactor</code> which will notify the acceptor when there is a new
* connection waiting to be accepted.
*
* @param address
* this is the address to listen for new sockets
* @param context
* this is the SSL context used for secure HTTPS
* @param server
* this is the server that pipelines are handed to
* @param agent
* this is used to create a trace to monitor events
*/
public SocketListener(SocketAddress address, SSLContext context,
Server server, Agent agent) throws IOException {
this.acceptor = new SocketAcceptor(address, context, server, agent);
this.reactor = new DirectReactor();
this.process();
}