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


Java RestExpress.bind方法代码示例

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


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

示例1: main

import org.restexpress.RestExpress; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	RestExpress.setSerializationProvider(new SerializationProvider());

	Configuration config = Environment.load(args, Configuration.class);
	RestExpress server = new RestExpress()
	    .setName(SERVICE_NAME)
	    .setBaseUrl(config.getBaseUrl())
	    .setExecutorThreadCount(config.getExecutorThreadPoolSize())
	    .addPostprocessor(new LastModifiedHeaderPostprocessor())
	    .addMessageObserver(new SimpleConsoleLogMessageObserver());

	Routes.define(config, server);
	Relationships.define(server);
	configurePlugins(config, server);
	mapExceptions(server);
	registerDomainEvents(server, config);
	server.bind(config.getPort());
	server.awaitShutdown();
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:21,代码来源:Main.java

示例2: main

import org.restexpress.RestExpress; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	RestExpress.setSerializationProvider(new SerializationProvider());
	Configuration config = Environment.load(args, Configuration.class);
	RestExpress server = new RestExpress()
	    .setName(config.getName())
	    .setPort(config.getPort());

	defineRoutes(server, config);

	if (config.getWorkerCount() > 0)
	{
		server.setIoThreadCount(config.getWorkerCount());
	}

	if (config.getExecutorThreadCount() > 0)
    {
    	server.setExecutorThreadCount(config.getExecutorThreadCount());
    }

	mapExceptions(server);
	server.bind();
	server.awaitShutdown();
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:25,代码来源:Main.java

示例3: main

import org.restexpress.RestExpress; //导入方法依赖的package包/类
public static void main(String[] args) {
	RestExpress server = new RestExpress().setName("Echo");

	server.uri("/echo", new RestfulHandler()).method(HttpMethod.GET)
			.noSerialization();

	server.bind(8000);
	server.awaitShutdown();
}
 
开发者ID:duchien85,项目名称:netty-cookbook,代码行数:10,代码来源:Echo.java

示例4: startServer

import org.restexpress.RestExpress; //导入方法依赖的package包/类
public static RestExpress startServer(String[] args) throws IOException
{
	RestExpress server = new RestExpress();
	MyResource r = new MyResource();

	server.uri("/myapp/myresource", r)
		.method(HttpMethod.GET)
		.noSerialization();

	server.uri("/myapp/myresource", r)
		.method(HttpMethod.POST);

	server.bind(8080);
	return server;
   }
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:16,代码来源:Main.java

示例5: main

import org.restexpress.RestExpress; //导入方法依赖的package包/类
public static void main(String[] args)
{
    RestExpress server = new RestExpress()
        .setName("Echo");

    server.uri("/echo", new Object()
    {
        @SuppressWarnings("unused")
        public String read(Request req, Response res)
        {
            String value = req.getHeader("echo");
            res.setContentType("text/xml");

            if (value == null)
            {
                return "<http_test><error>no value specified</error></http_test>";
            }
            else
            {
                return String.format("<http_test><value>%s</value></http_test>", value);
            }
        }
    })
    .method(HttpMethod.GET)
    .noSerialization();

    server.bind(8000);
    server.awaitShutdown();
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:30,代码来源:Main.java

示例6: initializeServer

import org.restexpress.RestExpress; //导入方法依赖的package包/类
/**
 * Starts up the server for the specified environment.
 *
 * @param args Command line arguments. Should be one parameter with either
 * an environment or a path to a URL with the proper configuration via a
 * REST GET.
 * @param overrideSeeds If you wish to override the otherwise set Cassandra
 * seeds for testing purposes. Pass null if you don't want to override (most
 * of the time.)
 * @return A running RestExpress REST server.
 * @throws IOException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
public static RestExpress initializeServer(String[] args, String overrideSeeds) throws IOException, IllegalAccessException, InstantiationException
{
    //args = new String[]{"http://docussandra-dev-webw-1.openclass.com:8080/config/A"};
    RestExpress.setSerializationProvider(new SerializationProvider());
    //Identifiers.UUID.useShortUUID(true);
    //load our plugins first
    try
    {
        PluginHolder.build(PluginUtils.getPluginJars());
    } catch (IllegalStateException e)
    {
        logger.warn("Warning: The plugins were already init'ed, this is fine if you are running tests, but if you see this on a running server, there is probably a problem.");
    }
    Configuration config = loadEnvironment(args);
    logger.info("-----Attempting to start up Docussandra server for version: " + config.getProjectVersion() + "-----");
    boolean initDb = true;
    if (overrideSeeds != null)
    {//if we are overriding our seeds list for testing purposes.
        config.overrideSeeds(overrideSeeds);//this will also override the port back to default
        initDb = false;
    }
    config.initialize(initDb);//make the configuration object ready to use
    RestExpress server = new RestExpress()
            .setName(config.getProjectName(SERVICE_NAME))
            .setBaseUrl(config.getBaseUrl())
            .setExecutorThreadCount(config.getExecutorThreadPoolSize())
            .addPostprocessor(new LastModifiedHeaderPostprocessor())
            .addMessageObserver(new SimpleLogMessageObserver())
            .addPreprocessor(new RequestApplicationJsonPreprocessor())
            .addPreprocessor(new RequestXAuthCheck())
            .setMaxContentSize(6000000);

    new VersionPlugin(config.getProjectVersion())
            .register(server);

    new SwaggerPlugin()
            .register(server);

    Routes.define(config, server);
    Relationships.define(server);
    configurePlugins(config, server);
    mapExceptions(server);

    if (config.getPort() == 0)
    {//no port? calculate it off of the version number
        server.setPort(calculatePort(config.getProjectVersion()));
    } else
    {
        server.setPort(config.getPort());
    }
    server.bind(server.getPort());
    logger.info("-----Docussandra server initialized for version: " + config.getProjectVersion() + "-----");
    return server;
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:69,代码来源:Main.java


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