• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java App类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: makeFormHandler

import ninja.siden.App; //导入依赖的package包/类
protected HttpHandler makeFormHandler(App root, OptionMap config,
		HttpHandler next) {
	FormParserFactory.Builder builder = FormParserFactory.builder(false);
	FormEncodedDataDefinition form = new FormEncodedDataDefinition();
	String cn = config.get(Config.CHARSET).name();
	form.setDefaultEncoding(cn);

	MultiPartParserDefinition mult = new MultiPartParserDefinition(
			config.get(Config.TEMP_DIR));
	mult.setDefaultEncoding(cn);
	mult.setMaxIndividualFileSize(config.get(Config.MAX_FILE_SIZE));

	builder.addParsers(form, mult);

	EagerFormParsingHandler efp = new EagerFormParsingHandler(
			builder.build());
	return efp.setNext(next);
}
 
开发者ID:taichi,项目名称:siden,代码行数:19,代码来源:DefaultAppBuilder.java


示例2: nestedRoutesTwoTimes

import ninja.siden.App; //导入依赖的package包/类
@Test
public void nestedRoutesTwoTimes() throws Exception {
	App sub = new App();
	sub.head("/def", (req, res) -> "def");
	target.use("/abc", sub);
	target.use("/efg", sub);
	this.listen();

	ObjectName abc = new ObjectName(
			"ninja.siden:type=Request,path=\"/abc/def\",method=HEAD");
	server.getMBeanInfo(abc);

	ObjectName efg = new ObjectName(
			"ninja.siden:type=Request,path=\"/efg/def\",method=HEAD");
	server.getMBeanInfo(efg);
}
 
开发者ID:taichi,项目名称:siden,代码行数:17,代码来源:MetricsAppBuilderTest.java


示例3: deeplyNestedRoutes

import ninja.siden.App; //导入依赖的package包/类
@Test
public void deeplyNestedRoutes() throws Exception {
	App subsub = new App();
	subsub.get("/jkl", (req, res) -> "eee");
	App sub = new App();
	sub.head("/def", (req, res) -> "def");
	sub.use("/ghi", subsub);

	target.use("/abc", sub);
	this.listen();

	ObjectName def = new ObjectName(
			"ninja.siden:type=Request,path=\"/abc/def\",method=HEAD");
	server.getMBeanInfo(def);

	ObjectName jkl = new ObjectName(
			"ninja.siden:type=Request,path=\"/abc/ghi/jkl\",method=GET");
	server.getMBeanInfo(jkl);
}
 
开发者ID:taichi,项目名称:siden,代码行数:20,代码来源:MetricsAppBuilderTest.java


示例4: main

import ninja.siden.App; //导入依赖的package包/类
public static void main(String[] args) {
	// setup react server side rendering
	React rc = new React("HelloMessage", "content", Arrays.asList(
			// https://github.com/paulmillr/console-polyfill
			// Nashorn don't contain console object.
			Paths.get("assets", "console-polyfill.js"),
			// https://github.com/facebook/react
			Paths.get("assets", "react.js"),
			// npm install -g react-tools
			// jsx -x jsx assets build
			// siden-react don't support jsx compile.
			Paths.get("build", "hello.js")));

	App app = new App();
	app.get("/", (q, s) -> {
			// serialized json
			String props = "{\"name\":\"john\"}";
			// server side rendering
			return "<html><body>" + rc.toHtml(props) + "</body></html>";
		}).type("text/html");
	app.listen().addShutdownHook();
}
 
开发者ID:taichi,项目名称:siden,代码行数:23,代码来源:UseReactSSR.java


示例5: main

import ninja.siden.App; //导入依赖的package包/类
public static void main(String[] args) {
	App app = new App();
	ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
	app.post("/", (req, res) -> {
		Optional<String> opt = req.body();
		return opt.map(s -> {
			String k = Integer.toHexString(s.hashCode());
			map.put(k, s);
			return String.format("http://%s/%s",
					req.raw().getHostAndPort(), k);
		});
	});

	app.get("/:k", (req, res) -> req.params("k").map(key -> map.get(key))
			.map(res::redirect).orElse(404));

	app.listen();
}
 
开发者ID:taichi,项目名称:siden,代码行数:19,代码来源:URLShortener.java


示例6: main

import ninja.siden.App; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	App app = App.configure(conf -> {
		conf.set(Config.RENDERER_REPOSITORY, new HandleBarsRepo());
		return conf;
	});

	// see. https://github.com/jknack/handlebars.java
	Handlebars engine = new Handlebars();
	Template t = engine.compileInline("Hello {{this}}!");

	// use handlebars simply
	app.get("/bars",
			(req, res) -> res.render("john", Renderer.of(t::apply)));

	// read template from templates/say/hello.html
	app.get("/hello",
			(req, res) -> res.render(new User("peter"), "say/hello"));
	
	app.listen().addShutdownHook();
}
 
开发者ID:taichi,项目名称:siden,代码行数:21,代码来源:UseHandlebars.java


示例7: main

import ninja.siden.App; //导入依赖的package包/类
public static void main(String[] args) {
	App app = new App() {
		@Override
		protected HttpHandler wrap(OptionMap config, HttpHandler handler) {
			DirectBufferCache cache = new DirectBufferCache(1024, 10,
					1024 * 1024 * 200);
			return new CacheHandler(cache, super.wrap(config, handler));
		}
	};
	new Sirusi(app);
	app.listen(port()).asShutdownHook();
}
 
开发者ID:taichi,项目名称:sirusi,代码行数:13,代码来源:Sirusi.java


示例8: Sirusi

import ninja.siden.App; //导入依赖的package包/类
public Sirusi(App app) {
	app.get("/favicon.ico", (req, res) -> getClass().getClassLoader()
			.getResource("favicon.ico"));
	app.get("/:seed.:type", this::identicon);
	app.get("/", (req, res) -> "I'm running!! yey!");
	this.types = new HashSet<>(Arrays.asList(ImageIO
			.getWriterFileSuffixes()));
}
 
开发者ID:taichi,项目名称:sirusi,代码行数:9,代码来源:Sirusi.java


示例9: Uml

import ninja.siden.App; //导入依赖的package包/类
Uml(App app, String url, Set<String> tokens) {
	this.url = url;
	this.tokens = tokens;
	app.get("/favicon.ico", (req, res) -> Uml.class.getClassLoader().getResource("favicon.ico"));
	app.get("/:encoded", this::imgs);
	app.get("/", (req, res) -> "I'm running!! yey!");
	app.post("/", this::outgoing).type("application/json");
}
 
开发者ID:taichi,项目名称:umlbot,代码行数:9,代码来源:Uml.java


示例10: setUp

import ninja.siden.App; //导入依赖的package包/类
@Before
public void setUp() {
	App app = new App();
	Set<String> set = new HashSet<>();
	set.add(TOKEN);
	this.target = new Uml(app, HOST, set);
	this.stopper = app.listen();
}
 
开发者ID:taichi,项目名称:umlbot,代码行数:9,代码来源:UmlTest.java


示例11: makeSessionHandler

import ninja.siden.App; //导入依赖的package包/类
@Override
protected HttpHandler makeSessionHandler(App root, OptionMap config,
		HttpHandler next) {
	InMemorySessionManager sessionManager = new InMemorySessionManager(
			"SessionManagerOfSiden", config.get(Config.MAX_SESSIONS));
	sessionManager.setDefaultSessionTimeout(config
			.get(Config.DEFAULT_SESSION_TIMEOUT_SECONDS));
	SessionCookieConfig sessionConfig = new SessionCookieConfig();
	sessionConfig.setCookieName(config.get(Config.SESSION_COOKIE_NAME));

	register(root, SessionMetrics.to(sessionManager),
			Arrays.asList("type", "Session"));

	return new SessionAttachmentHandler(next, sessionManager, sessionConfig);
}
 
开发者ID:taichi,项目名称:siden,代码行数:16,代码来源:MetricsAppBuilder.java


示例12: makeSharedHandlers

import ninja.siden.App; //导入依赖的package包/类
@Override
protected HttpHandler makeSharedHandlers(App root, OptionMap config,
		HttpHandler next) {
	HttpHandler shared = super.makeSharedHandlers(root, config, next);
	register(root, RequestMetrics.to(new MetricsHandler(shared)),
			Arrays.asList("type", "Request", "name", "Global"));
	return shared;
}
 
开发者ID:taichi,项目名称:siden,代码行数:9,代码来源:MetricsAppBuilder.java


示例13: register

import ninja.siden.App; //导入依赖的package包/类
protected void register(App root, Object bean, List<String> attrs) {
	try {
		ObjectName name = ObjectNames.to("ninja.siden", attrs);
		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
		server.registerMBean(bean, name);
		ExactlyOnceCloseable ec = ExactlyOnceCloseable.wrap(() -> server
				.unregisterMBean(name));
		root.stopOn(app -> ec.close());
	} catch (Exception e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:taichi,项目名称:siden,代码行数:13,代码来源:MetricsAppBuilder.java


示例14: makeSharedHandlers

import ninja.siden.App; //导入依赖的package包/类
protected HttpHandler makeSharedHandlers(App root, OptionMap config,
		HttpHandler next) {
	HttpHandler hh = next;
	if (config.get(Config.METHOD_OVERRIDE)) {
		hh = new MethodOverrideHandler(hh);
	}
	hh = makeSessionHandler(root, config, hh);
	hh = makeFormHandler(root, config, hh);

	if (Config.isInDev(config)) {
		hh = Handlers.disableCache(hh);
	} else {
		GracefulShutdownHandler gsh = Handlers.gracefulShutdown(hh);
		root.stopOn(app -> {
			gsh.shutdown();
			try {
				gsh.awaitShutdown(config.get(
						Config.WAIT_FOR_GRACEFUL_SHUTDOWN, 500));
			} catch (InterruptedException e) {
				// ignore
			}
		});
		hh = gsh;
	}

	hh = new SecurityHandler(hh);
	return new Core(config, hh);
}
 
开发者ID:taichi,项目名称:siden,代码行数:29,代码来源:DefaultAppBuilder.java


示例15: makeSessionHandler

import ninja.siden.App; //导入依赖的package包/类
protected HttpHandler makeSessionHandler(App root, OptionMap config,
		HttpHandler next) {
	InMemorySessionManager sessionManager = new InMemorySessionManager(
			"SessionManagerOfSiden", config.get(Config.MAX_SESSIONS));
	sessionManager.setDefaultSessionTimeout(config
			.get(Config.DEFAULT_SESSION_TIMEOUT_SECONDS));
	SessionCookieConfig sessionConfig = new SessionCookieConfig();
	sessionConfig.setCookieName(config.get(Config.SESSION_COOKIE_NAME));
	return new SessionAttachmentHandler(next, sessionManager, sessionConfig);
}
 
开发者ID:taichi,项目名称:siden,代码行数:11,代码来源:DefaultAppBuilder.java


示例16: nestedRoutes

import ninja.siden.App; //导入依赖的package包/类
@Test
public void nestedRoutes() throws Exception {
	App sub = new App();
	sub.head("/def", (req, res) -> "def");
	target.use("/abc", sub);
	this.listen();
	ObjectName abc = new ObjectName(
			"ninja.siden:type=Request,path=\"/abc/def\",method=HEAD");
	server.getMBeanInfo(abc);
}
 
开发者ID:taichi,项目名称:siden,代码行数:11,代码来源:MetricsAppBuilderTest.java


示例17: websockets

import ninja.siden.App; //导入依赖的package包/类
@Test
public void websockets() throws Exception {
	App sub = new App();
	sub.websocket("/ws").onText((c, s) -> c.send(s));
	target.use("/aaa", sub);
	this.listen();

	ObjectName ws = new ObjectName(
			"ninja.siden:type=WebSocket,path=\"/aaa/ws\"");
	server.getMBeanInfo(ws);
}
 
开发者ID:taichi,项目名称:siden,代码行数:12,代码来源:MetricsAppBuilderTest.java


示例18: main

import ninja.siden.App; //导入依赖的package包/类
public static void main(String[] args) {
	// development environments don't need metrics.
	App app = App.configure(b -> b.set(Config.ENV, "stable"));

	app.get("/", (req, res) -> "hello");

	App sub = new App();
	sub.get("/hoi", (req, res) -> "HOIHOI");
	sub.websocket("/ws").onText((c, s) -> c.send(s));

	app.use("/aaa", sub);
	app.use("/bbb", sub);

	app.listen().addShutdownHook();
}
 
开发者ID:taichi,项目名称:siden,代码行数:16,代码来源:CollectMetrics.java


示例19: setUp

import ninja.siden.App; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this.target = new Sirusi(new App());
}
 
开发者ID:taichi,项目名称:sirusi,代码行数:5,代码来源:SirusiTest.java


示例20: main

import ninja.siden.App; //导入依赖的package包/类
public static void main(String[] args) {
	// https://devcenter.heroku.com/articles/dynos#local-environment-variables
	LOG.info(System.getenv());

	String url = System.getenv("URL");
	if (url == null || url.isEmpty()) {
		LOG.fatal("URL is not defined.");
		return;
	}
	try {
		URL u = new URL(url);
		if (u.getProtocol().startsWith("http") == false) {
			LOG.fatal("URL protocol must be http");
			return;
		}
	} catch (IOException e) {
		LOG.fatal("URL is not valid.");
		return;
	}

	String token = System.getenv("TOKEN");
	if (token == null || token.isEmpty()) {
		LOG.fatal("TOKEN is not defined.");
		return;
	}
	Set<String> tokens = new HashSet<>(Arrays.asList(token.split(",")));

	String port = System.getenv("PORT");
	int p = 8080;
	if (port != null && Pattern.matches("\\d{1,5}", port)) {
		int i = Integer.parseInt(port);
		if (0 < i && i < 65536) {
			p = i;
		}
	}

	App app = new App() {
		@Override
		protected HttpHandler buildHandlers() {
			DirectBufferCache cache = new DirectBufferCache(1024, 10, 1024 * 1024 * 200);
			return new CacheHandler(cache, super.buildHandlers());
		}
	};
	new Uml(app, url, tokens);
	app.listen(p).addShutdownHook();
}
 
开发者ID:taichi,项目名称:umlbot,代码行数:47,代码来源:Uml.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OrderSetListSearchCriteriaVo类代码示例发布时间:2022-05-15
下一篇:
Java Mode类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap