本文整理汇总了Java中org.simpleframework.transport.connect.SocketConnection类的典型用法代码示例。如果您正苦于以下问题:Java SocketConnection类的具体用法?Java SocketConnection怎么用?Java SocketConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SocketConnection类属于org.simpleframework.transport.connect包,在下文中一共展示了SocketConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startHttpServer
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的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.SocketConnection; //导入依赖的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.SocketConnection; //导入依赖的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: createServer
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
public static Connection createServer(boolean certificateRequired, int listenPort) throws Exception {
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
System.setProperty("sun.security.ssl.allowLegacyHelloMessages", "true");
File file = new File("C:\\work\\development\\async_http\\yieldbroker-proxy-trading\\etc\\uat.yieldbroker.com.pfx");
KeyStoreReader reader = new KeyStoreReader(KeyStoreType.PKCS12, file, "p", "p");
SecureSocketContext context = new SecureSocketContext(reader, SecureProtocol.TLS);
SSLContext sslContext = context.getContext();
Agent agent = new MockAgent();
TransportProcessor processor = new TransportProcessor();
ProcessorServer server = new ProcessorServer(processor);
ConfigurableCertificateServer certServer = new ConfigurableCertificateServer(server);
SocketConnection con = new SocketConnection(certServer, agent);
SocketAddress serverAddress = new InetSocketAddress(listenPort);
certServer.setCertRequired(certificateRequired);
con.connect(serverAddress, sslContext);
return con;
}
示例5: startServer
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
/**
* Will start the Server Mock as well as the RabbitMQ Listener
*
* @throws IOException
* @throws IguanaException
* @throws TimeoutException
*/
@BeforeClass
public static void startServer() throws IOException, IguanaException, TimeoutException {
// start ServerMock
mock = new StresstestServerMock();
fastServer = new ContainerServer(mock);
fastConnection = new SocketConnection(fastServer);
address1 = new InetSocketAddress(8024);
fastConnection.connect(address1);
// start RabbitMQ listener
// queue declare
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
connection = factory.newConnection();
channel = connection.createChannel();
channel.queueDeclare(COMMON.CORE2RP_QUEUE_NAME, false, false, false, null);
}
示例6: metaTest
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
/**
* @throws IOException
*/
@Test
public void metaTest() throws IOException{
fastServerContainer = new ServerMock();
fastServer = new ContainerServer(fastServerContainer);
fastConnection = new SocketConnection(fastServer);
SocketAddress address1 = new InetSocketAddress(FAST_SERVER_PORT);
fastConnection.connect(address1);
String host = "http://localhost:8023";
TriplestoreStorage store = new TriplestoreStorage(host, host);
Properties p = new Properties();
p.put(COMMON.EXPERIMENT_TASK_ID_KEY, "1/1/1");
p.setProperty(COMMON.EXPERIMENT_ID_KEY, "1/1");
p.setProperty(COMMON.CONNECTION_ID_KEY, "virtuoso");
p.setProperty(COMMON.SUITE_ID_KEY, "1");
p.setProperty(COMMON.DATASET_ID_KEY, "dbpedia");
p.put(COMMON.RECEIVE_DATA_START_KEY, "true");
p.put(COMMON.EXTRA_META_KEY, new Properties());
p.put(COMMON.NO_OF_QUERIES, 2);
store.addMetaData(p);
assertEquals(metaExp.trim(), fastServerContainer.getActualContent().trim());
}
示例7: dataTest
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
/**
* @throws IOException
*/
@Test
public void dataTest() throws IOException{
fastServerContainer = new ServerMock();
fastServer = new ContainerServer(fastServerContainer);
fastConnection = new SocketConnection(fastServer);
SocketAddress address1 = new InetSocketAddress(FAST_SERVER_PORT);
fastConnection.connect(address1);
String host = "http://localhost:8023";
TriplestoreStorage store = new TriplestoreStorage(host, host);
Properties p = new Properties();
p.setProperty(COMMON.EXPERIMENT_TASK_ID_KEY, "1/1/1");
p.put(COMMON.METRICS_PROPERTIES_KEY, "testMetric");
p.put(COMMON.EXTRA_META_KEY, new Properties());
Triple[] t = new Triple[1];
t[0] = new Triple("a", "b", "c");
store.addData(p, t);
store.commit();
assertEquals(dataExp.trim(),fastServerContainer.getActualContent().trim());
}
示例8: main
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的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 + ".");
}
示例9: startServer
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
@Before
public void startServer() throws IOException {
server = new ContainerServer(container);
connection = new SocketConnection(server);
SocketAddress address = new InetSocketAddress(SERVER_PORT);
connection.connect(address);
}
示例10: Tracker
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
/**
* Create a new BitTorrent tracker listening at the given address.
*
* @param address The address to bind to.
* @param version A version string served in the HTTP headers
* @throws IOException Throws an <em>IOException</em> if the tracker
* cannot be initialized.
*/
public Tracker(InetSocketAddress address, String version)
throws IOException {
this.address = address;
this.torrents = new ConcurrentHashMap<String, TrackedTorrent>();
this.connection = new SocketConnection(
new TrackerService(version, this.torrents));
}
示例11: startServer
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
@Before
public void startServer() throws IOException {
fastServerContainer = new WaitingDocumentReturningServerMock(DOCUMENTS, 0);
fastServer = new ContainerServer(fastServerContainer);
fastConnection = new SocketConnection(fastServer);
SocketAddress address1 = new InetSocketAddress(FAST_SERVER_PORT);
fastConnection.connect(address1);
slowServer = new ContainerServer(new WaitingDocumentReturningServerMock(DOCUMENTS, SLOW_SERVER_WAITING_TIME));
slowConnection = new SocketConnection(slowServer);
SocketAddress address2 = new InetSocketAddress(SLOW_SERVER_PORT);
slowConnection.connect(address2);
}
示例12: init
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
@Override
public void init(DaemonContext dc) throws DaemonInitException, Exception {
log.info("initializing ...");
// Init ApiServer
container = new ApiServer();
server = new ContainerServer(container);
connection = new SocketConnection(server);
address = new InetSocketAddress(8082);
}
示例13: main
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的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);
}
示例14: MockRenegotiationServer
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的package包/类
public MockRenegotiationServer(SSLContext context, boolean certRequired, int port) throws IOException {
Allocator allocator = new FileAllocator();
ContainerProcessor processor = new ContainerProcessor(this, allocator, 4);
TransportGrabber grabber = new TransportGrabber(processor);
ProcessorServer processorServer = new ProcessorServer(grabber);
this.server = new ConfigurableCertificateServer(processorServer, certRequired);
this.agent = new ConsoleAgent();
this.connection = new SocketConnection(server, agent);
this.address = new InetSocketAddress(port);
this.context = context;
}
示例15: HttpMockServer
import org.simpleframework.transport.connect.SocketConnection; //导入依赖的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);
}