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


Java App类代码示例

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


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


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