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


Java RestExpress类代码示例

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


RestExpress类属于org.restexpress包,在下文中一共展示了RestExpress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:30,代码来源:Main.java

示例2: define

import org.restexpress.RestExpress; //导入依赖的package包/类
public static void define(Configuration config, RestExpress server)
    {
		//TODO: Your routes here...

		server.uri("/populates.{format}", config.getPopulateController())
			.action("readAll", HttpMethod.GET)
			.action("deleteAll", HttpMethod.DELETE)
			.name(Constants.Routes.POPULATE_COLLECTION);

                server.uri("/users/{userUuid}.{format}", config.getUserController())
			.method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE)
			.name(Constants.Routes.USER_READ_ROUTE);
		server.uri("/users.{format}", config.getUserController())
			.action("readAll", HttpMethod.GET)
			.method(HttpMethod.POST)
			.name(Constants.Routes.USER_COLLECTION_READ_ROUTE);
                server.uri("/users/{userUuid}/authorizations.{format}", config.getUserAuthorizationController())
                        .action("readAll", HttpMethod.GET)
                        .name(Constants.Routes.USER_AUTHORIZATIONS_ROUTE);
                server.uri("/users/{userUuid}/authorizations/{authorizationName}.{format}", config.getUserAuthorizationController())
			.method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE)
                        .action("addAuthorizationToUser", HttpMethod.POST)
                        .name(Constants.Routes.USER_AUTHORIZATION_ROUTE);
//// or...
//		server.regex("/some.regex", config.getRouteController());
    }
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:27,代码来源:Routes.java

示例3: register

import org.restexpress.RestExpress; //导入依赖的package包/类
@Override
public Plugin register(RestExpress server) {
    if (isRegistered) {
        return this;
    }

    server.registerPlugin(this);
    this.isRegistered = true;

    server
            .addMessageObserver(this)
            .addPreprocessor(this)
            .addFinallyProcessor(this);

    return this;
}
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:17,代码来源:OpenTransactionPlugin.java

示例4: 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

示例5: configurePlugins

import org.restexpress.RestExpress; //导入依赖的package包/类
private static void configurePlugins(Configuration config, RestExpress server)
  {
   configureMetrics(config, server);

new SwaggerPlugin()
	.flag(Flags.Auth.PUBLIC_ROUTE)
	.register(server);

new CacheControlPlugin()							// Support caching headers.
		.register(server);

new HyperExpressPlugin(Linkable.class)
	.register(server);

new CorsHeaderPlugin("*")
	.flag(PUBLIC_ROUTE)
    .allowHeaders(CONTENT_TYPE, ACCEPT, AUTHORIZATION, REFERER, LOCATION)
    .exposeHeaders(LOCATION)
    .register(server);
  }
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:21,代码来源:Main.java

示例6: registerDomainEvents

import org.restexpress.RestExpress; //导入依赖的package包/类
private static void registerDomainEvents(RestExpress server, Configuration config)
{
	EventBus localBus = new LocalEventBusBuilder()
		.subscribe(new BlogCascadeDeleteHandler(config.getBlogEntryRepository(), config.getCommentRepository()))
		.subscribe(new BlogEntryCascadeDeleteHandler(config.getCommentRepository()))
		.build();
	DomainEvents.addBus("local", localBus);

	Runtime.getRuntime().addShutdownHook(new Thread()
	{
		@Override
		public void run()
		{
			DomainEvents.shutdown();
		}
	});
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:18,代码来源:Main.java

示例7: 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

示例8: defineRoutes

import org.restexpress.RestExpress; //导入依赖的package包/类
/**
   * @param server
   * @param config
   */
  private static void defineRoutes(RestExpress server, Configuration config)
  {
// This route supports GET, POST, PUT, DELETE echoing the 'echo' query-string parameter in the response.
  	// GET and DELETE are also supported but require an 'echo' header or query-string parameter.
server.uri("/echo/{delay_ms}", config.getEchoController())
	.noSerialization();

// Waits the delay_ms number of milliseconds and responds with a 200.
// Supports GET, PUT, POST, DELETE methods.
server.uri("/success/{delay_ms}.{format}", config.getSuccessController());

// Waits the delay_ms number of milliseconds and responds with the
// specified HTTP response code.
// Supports GET, PUT, POST, DELETE methods.
server.uri("/status/{delay_ms}/{http_response_code}.{format}", config.getStatusController());
  }
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:21,代码来源:Main.java

示例9: fillValues

import org.restexpress.RestExpress; //导入依赖的package包/类
@Override
protected void fillValues(Properties p) {
    this.port = Integer.parseInt(p.getProperty(PORT_PROPERTY, String.valueOf(RestExpress.DEFAULT_PORT)));
    this.baseUrl = p.getProperty(BASE_URL_PROPERTY, "http://localhost:" + String.valueOf(port));
    this.executorThreadPoolSize = Integer.parseInt(p.getProperty(EXECUTOR_THREAD_POOL_SIZE, DEFAULT_EXECUTOR_THREAD_POOL_SIZE));
    initialize();
}
 
开发者ID:kislayverma,项目名称:rulette-server,代码行数:8,代码来源:Configuration.java

示例10: Server

import org.restexpress.RestExpress; //导入依赖的package包/类
public Server(Configuration config) {
    this.config = config;
    RestExpress.setDefaultSerializationProvider(new SerializationProvider());

    this.server = new RestExpress()
        .setName(SERVICE_NAME)
        .setBaseUrl(config.getBaseUrl())
        .setExecutorThreadCount(config.getExecutorThreadPoolSize())
        .addMessageObserver(new SimpleConsoleLogMessageObserver());

    Routes.define(config, server);
}
 
开发者ID:kislayverma,项目名称:rulette-server,代码行数:13,代码来源:Server.java

示例11: define

import org.restexpress.RestExpress; //导入依赖的package包/类
public static void define(Configuration config, RestExpress server) {
    // Get all rules in a rule system
    server.uri("/getAllRules/{ruleSystemName}.{format}", config.getRuleSystemController())
        .action("getAllRules", HttpMethod.GET)
        .name(Constants.Routes.SAMPLE_COLLECTION);

    server.uri("/getApplicableRule/{ruleSystemName}.{format}", config.getRuleSystemController())
        .action("getApplicableRule", HttpMethod.POST)
        .name(Constants.Routes.SINGLE_SAMPLE);

    server.uri("/getNextApplicableRule/{ruleSystemName}.{format}", config.getRuleSystemController())
        .action("getNextApplicableRule", HttpMethod.POST)
        .name(Constants.Routes.SINGLE_SAMPLE);

    server.uri("/getRule/{ruleSystemName}/{ruleId}.{format}", config.getRuleSystemController())
        .action("getRule", HttpMethod.GET)
        .name(Constants.Routes.SINGLE_SAMPLE);

    server.uri("/addRule/{ruleSystemName}.{format}", config.getRuleSystemController())
        .action("addRule", HttpMethod.POST)
        .name(Constants.Routes.SINGLE_SAMPLE);

    server.uri("/updateRule/{ruleSystemName}/{ruleId}.{format}", config.getRuleSystemController())
        .action("updateRule", HttpMethod.PUT)
        .name(Constants.Routes.SINGLE_SAMPLE);

    server.uri("/deleteRule/{ruleSystemName}/{ruleId}.{format}", config.getRuleSystemController())
        .action("deleteRule", HttpMethod.DELETE)
        .name(Constants.Routes.SINGLE_SAMPLE);

    server.uri("/reload/{ruleSystemName}.{format}", config.getRuleSystemController())
        .action("reloadRuleSystem", HttpMethod.PUT)
        .name(Constants.Routes.SINGLE_SAMPLE);
}
 
开发者ID:kislayverma,项目名称:rulette-server,代码行数:35,代码来源:Routes.java

示例12: configurePlugins

import org.restexpress.RestExpress; //导入依赖的package包/类
/**
 * Configures RestExpress plugins (not Docussandra plugins).
 *
 * @param config Configuration object.
 * @param server RestExpress server object.
 */
private static void configurePlugins(Configuration config, RestExpress server)
{
    configureMetrics(config, server);

    new HyperExpressPlugin(Linkable.class)
            .register(server);

    new CorsHeaderPlugin("*")
            .flag(PUBLIC_ROUTE)
            .allowHeaders(CONTENT_TYPE, ACCEPT, LOCATION)
            .exposeHeaders(LOCATION)
            .register(server);
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:20,代码来源:Main.java

示例13: configureMetrics

import org.restexpress.RestExpress; //导入依赖的package包/类
private static void configureMetrics(Configuration config, RestExpress server)
{
    MetricsConfig mc = config.getMetricsConfig();

    if (mc.isEnabled())
    {
        MetricRegistry registry = new MetricRegistry();
        new MetricsPlugin(registry)
                .register(server);

        if (mc.isGraphiteEnabled())
        {
            final Graphite graphite = new Graphite(new InetSocketAddress(mc.getGraphiteHost(), mc.getGraphitePort()));
            final GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
                    .prefixedWith(mc.getPrefix())
                    .convertRatesTo(TimeUnit.SECONDS)
                    .convertDurationsTo(TimeUnit.MILLISECONDS)
                    .filter(MetricFilter.ALL)
                    .build(graphite);
            reporter.start(mc.getPublishSeconds(), TimeUnit.SECONDS);
        } else
        {
            logger.warn("*** Graphite Metrics Publishing is Disabled ***");
        }
    } else
    {
        logger.warn("*** Metrics Generation is Disabled ***");
    }
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:30,代码来源:Main.java

示例14: mapExceptions

import org.restexpress.RestExpress; //导入依赖的package包/类
private static void mapExceptions(RestExpress server)
{
    server
            .mapException(ItemNotFoundException.class, NotFoundException.class)
            .mapException(DuplicateItemException.class, ConflictException.class)
            .mapException(ValidationException.class, BadRequestException.class)
            .mapException(InvalidObjectIdException.class, BadRequestException.class);
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:9,代码来源:Main.java

示例15: 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


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