Search in sources :

Example 1 with HttpPathConfigJsonBuilder

use of com.robo4j.socket.http.util.HttpPathConfigJsonBuilder in project robo4j by Robo4J.

the class RoboHttpUnitGetTestApp method systemWithHttpServerOnlyTest.

/**
 * Run the system with only server unit
 *
 * @throws Exception
 *             exception
 */
public void systemWithHttpServerOnlyTest() throws Exception {
    final String httpServerUnitName = "http_server";
    final HttpPathConfigJsonBuilder pathBuilder = HttpPathConfigJsonBuilder.Builder().addPath(httpServerUnitName, HttpMethod.GET);
    // @formatter:off
    Configuration systemConfiguration = new ConfigurationBuilder().addInteger("poolSizeScheduler", 3).addInteger("poolSizeWorker", 2).addInteger("poolSizeBlocking", 2).build();
    RoboBuilder builder = new RoboBuilder("roboSystem1", systemConfiguration);
    // @formatter:on
    // @formatter:off
    Configuration config = new ConfigurationBuilder().addInteger(PROPERTY_SOCKET_PORT, SERVER_PORT).addString("packages", "com.robo4j.socket.http.codec").addString(PROPERTY_UNIT_PATHS_CONFIG, pathBuilder.build()).build();
    // @formatter:on
    builder.add(HttpServerUnit.class, config, httpServerUnitName);
    RoboContext system = builder.build();
    system.start();
    System.out.println("systemPong: State after start:");
    System.out.println(SystemUtil.printStateReport(system));
    System.out.println("Press <Enter>...");
    System.in.read();
    system.shutdown();
}
Also used : ConfigurationBuilder(com.robo4j.configuration.ConfigurationBuilder) Configuration(com.robo4j.configuration.Configuration) HttpPathConfigJsonBuilder(com.robo4j.socket.http.util.HttpPathConfigJsonBuilder) RoboBuilder(com.robo4j.RoboBuilder) RoboContext(com.robo4j.RoboContext)

Example 2 with HttpPathConfigJsonBuilder

use of com.robo4j.socket.http.util.HttpPathConfigJsonBuilder in project robo4j by Robo4J.

the class RoboHttpUnitGetTestApp method twoAttributesSystem.

private RoboContext twoAttributesSystem() throws Exception {
    Configuration systemConfiguration = new ConfigurationBuilder().addInteger("poolSizeScheduler", 4).addInteger("poolSizeWorker", 2).addInteger("poolSizeBlocking", 3).build();
    RoboBuilder builder = new RoboBuilder(systemConfiguration);
    final HttpPathConfigJsonBuilder pathBuilder = HttpPathConfigJsonBuilder.Builder().addPath("controller", HttpMethod.GET);
    Configuration config = new ConfigurationBuilder().addInteger(PROPERTY_SOCKET_PORT, SERVER_PORT).addString("packages", PACKAGE_CODECS).addString(PROPERTY_UNIT_PATHS_CONFIG, pathBuilder.build()).build();
    builder.add(HttpServerUnit.class, config, "http_server");
    config = new ConfigurationBuilder().addInteger(StringConsumer.PROP_TOTAL_NUMBER_MESSAGES, 1).build();
    builder.add(StringConsumer.class, config, "request_consumer");
    config = new ConfigurationBuilder().addString("target", "request_consumer").build();
    builder.add(HttpTwoAttributesGetController.class, config, "controller");
    return builder.build();
}
Also used : ConfigurationBuilder(com.robo4j.configuration.ConfigurationBuilder) Configuration(com.robo4j.configuration.Configuration) HttpPathConfigJsonBuilder(com.robo4j.socket.http.util.HttpPathConfigJsonBuilder) RoboBuilder(com.robo4j.RoboBuilder)

Example 3 with HttpPathConfigJsonBuilder

use of com.robo4j.socket.http.util.HttpPathConfigJsonBuilder in project robo4j by Robo4J.

the class RoboHttpPingPongTest method configurePongSystem.

// Private Methods
private RoboContext configurePongSystem(int totalMessageNumber) throws Exception {
    RoboBuilder builder = new RoboBuilder();
    final HttpPathConfigJsonBuilder pathBuilder = HttpPathConfigJsonBuilder.Builder().addPath(CONTROLLER_PING_PONG, HttpMethod.POST);
    Configuration config = new ConfigurationBuilder().addInteger(PROPERTY_SOCKET_PORT, PORT).addString("packages", PACKAGE_CODECS).addString(PROPERTY_UNIT_PATHS_CONFIG, pathBuilder.build()).build();
    builder.add(HttpServerUnit.class, config, ID_HTTP_SERVER);
    config = new ConfigurationBuilder().addInteger(StringConsumer.PROP_TOTAL_NUMBER_MESSAGES, totalMessageNumber).build();
    builder.add(StringConsumer.class, config, REQUEST_CONSUMER);
    config = new ConfigurationBuilder().addString("target", REQUEST_CONSUMER).build();
    builder.add(HttpCommandTestController.class, config, CONTROLLER_PING_PONG);
    return builder.build();
}
Also used : ConfigurationBuilder(com.robo4j.configuration.ConfigurationBuilder) Configuration(com.robo4j.configuration.Configuration) HttpPathConfigJsonBuilder(com.robo4j.socket.http.util.HttpPathConfigJsonBuilder) RoboBuilder(com.robo4j.RoboBuilder)

Example 4 with HttpPathConfigJsonBuilder

use of com.robo4j.socket.http.util.HttpPathConfigJsonBuilder in project robo4j by Robo4J.

the class RoboHttpUnitGetTestApp method oneKnownAttributeTest.

/**
 * Run the system with known attributes
 *
 * @throws Exception
 *             exception
 */
public void oneKnownAttributeTest() throws Exception {
    final HttpPathConfigJsonBuilder pathBuilder = HttpPathConfigJsonBuilder.Builder().addPath("controller", HttpMethod.GET);
    // @formatter:off
    Configuration systemConfiguration = new ConfigurationBuilder().addInteger("poolSizeScheduler", 4).addInteger("poolSizeWorker", 2).addInteger("poolSizeBlocking", 3).build();
    RoboBuilder builder = new RoboBuilder("roboSystem1", systemConfiguration);
    // @formatter:on
    // @formatter:off
    Configuration config = new ConfigurationBuilder().addInteger(PROPERTY_SOCKET_PORT, SERVER_PORT).addString("packages", PACKAGE_CODECS).addString(PROPERTY_UNIT_PATHS_CONFIG, pathBuilder.build()).build();
    // @formatter:on
    builder.add(HttpServerUnit.class, config, "http_server");
    config = new ConfigurationBuilder().addInteger(StringConsumer.PROP_TOTAL_NUMBER_MESSAGES, 1).build();
    builder.add(StringConsumer.class, config, "request_consumer");
    config = new ConfigurationBuilder().addString("target", "request_consumer").build();
    builder.add(HttpOneAttributeGetController.class, config, "controller");
    RoboContext system = builder.build();
    system.start();
    System.out.println("systemPong: State after start:");
    System.out.println(SystemUtil.printStateReport(system));
    System.out.println("Press <Enter>...");
    System.in.read();
    system.shutdown();
}
Also used : ConfigurationBuilder(com.robo4j.configuration.ConfigurationBuilder) Configuration(com.robo4j.configuration.Configuration) HttpPathConfigJsonBuilder(com.robo4j.socket.http.util.HttpPathConfigJsonBuilder) RoboBuilder(com.robo4j.RoboBuilder) RoboContext(com.robo4j.RoboContext)

Aggregations

RoboBuilder (com.robo4j.RoboBuilder)4 Configuration (com.robo4j.configuration.Configuration)4 ConfigurationBuilder (com.robo4j.configuration.ConfigurationBuilder)4 HttpPathConfigJsonBuilder (com.robo4j.socket.http.util.HttpPathConfigJsonBuilder)4 RoboContext (com.robo4j.RoboContext)2