本文整理汇总了Java中org.restexpress.RestExpress.awaitShutdown方法的典型用法代码示例。如果您正苦于以下问题:Java RestExpress.awaitShutdown方法的具体用法?Java RestExpress.awaitShutdown怎么用?Java RestExpress.awaitShutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restexpress.RestExpress
的用法示例。
在下文中一共展示了RestExpress.awaitShutdown方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.restexpress.RestExpress; //导入方法依赖的package包/类
/**
* Main method.
*
* @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.
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
try
{
RestExpress server = initializeServer(args, null);
logger.info("Server started up on port: " + server.getPort() + "!");
server.awaitShutdown();
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
{
@Override
public void run()
{
logger.info("Shutting down Docussandra...");
CacheFactory.shutdownCacheManger();
}
}, "Shutdown-thread"));
} catch (RuntimeException e)
{
logger.error("Runtime exception when starting/running Docussandra/RestExpress. Could not start.", e);
}
}
示例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(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();
}
示例3: 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();
}
示例4: 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();
}
示例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();
}
示例6: main
import org.restexpress.RestExpress; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
RestExpress server = initializeServer(args);
server.awaitShutdown();
}