本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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;
}
示例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: 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;
}