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


Java SessionHandler类代码示例

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


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

示例1: start

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
public void start() throws Exception {
	Router router = Router.router(vertx);
	int serverPort = Config.getIntValue("serverPort");
	
	router.route().handler(BodyHandler.create().setUploadsDirectory("files"));
	router.route().handler(CookieHandler.create());
	router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
	Routing.route(router, "com.planb.restful");
	
	router.route().handler(StaticHandler.create());
	new Parser().start();
	
	Log.info("Server Started At : " + serverPort);
	vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
}
 
开发者ID:JoMingyu,项目名称:Bobsim-Server,代码行数:17,代码来源:MainVerticle.java

示例2: start

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
public void start() throws Exception {
	Router router = Router.router(vertx);
	int serverPort = Config.getIntValue("serverPort");
	
	router.route().handler(BodyHandler.create().setUploadsDirectory("files"));
	router.route().handler(CookieHandler.create());
	router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
	router.route().handler(CORSHandler.create());
	router.route().handler(LogHandler.create());
	Routing.route(router, "com.planb.restful");
	
	router.route().handler(StaticHandler.create());
	
	Log.info("Server Started At : " + serverPort);
	vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
}
 
开发者ID:JoMingyu,项目名称:Server-Quickstart-Vert.x,代码行数:18,代码来源:MainVerticle.java

示例3: start

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
public void start() throws Exception {
     Router router = Router.router(vertx);

     router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
     router.route().handler(CookieHandler.create());
     router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)).setNagHttps(false));
     router.route().handler(RequestSecurePreprocessor.create());
     RouteRegister.registerRouters(router, "com.dms.secure", "com.dms.api", "com.dms.templates");
     router.route("/js/*").handler(StaticHandler.create().setCachingEnabled(false).setWebRoot("WEB-INF/js/"));
     
     /*
      * @see com.dms.planb.support .TableDropper
*/
     HttpServerOptions httpOpts = new HttpServerOptions();
     /*System.out.println(SecureConfig.get("SSL_PATH"));
     System.out.println(SecureConfig.get("SSL"));
     httpOpts.setSsl(true)
             .setKeyStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")))
             .setTrustStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")));
     */
     vertx.createHttpServer(httpOpts).requestHandler(router::accept).listen(Integer.parseInt(SecureConfig.get("SERVER_PORT")));
 }
 
开发者ID:DSM-DMS,项目名称:DMS,代码行数:23,代码来源:DmsVerticle.java

示例4: start

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
public void start() throws Exception {
		Router router = Router.router(vertx);
		int serverPort = Config.getIntValue("serverPort");
		
		router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
		router.route().handler(CookieHandler.create());
		router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
		router.route().handler(CORSHandler.create());
		router.route().handler(LogHandler.create());
		
		Routing.route(router, "com.planb.restful");

		router.route().handler(StaticHandler.create());

//		new ParserThread().start();

		Log.info("Server Started");
		vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
	}
 
开发者ID:JoMingyu,项目名称:Daejeon-People,代码行数:20,代码来源:CoreVerticle.java

示例5: start

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
public void start() {
    Router router = Router.router(vertx);

    router.route().handler(CookieHandler.create());
    router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));

    AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, new JsonObject());
    router.route().handler(UserSessionHandler.create(authProvider));
    router.route("/private/*").handler(RedirectAuthHandler.create(authProvider, "/login.html"));

    router.mountSubRouter("/tokens", tokenRouter(authProvider));
    router.mountSubRouter("/api", auctionApiRouter());

    router.route().failureHandler(ErrorHandler.create(true));
    router.route("/private/*").handler(staticHandler("private"));
    router.route().handler(staticHandler("public"));

    vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
 
开发者ID:mwarc,项目名称:atm8-realtime-auctions-example,代码行数:21,代码来源:AuctionFrontendVerticle.java

示例6: start

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
public void start() {
    Router router = Router.router(vertx);

    router.route().handler(CookieHandler.create());
    router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));

    AuthProvider authProvider = ShiroAuth.create(
        vertx,
        new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(new JsonObject())
    );
    router.route().handler(UserSessionHandler.create(authProvider));
    router.route("/private/*").handler(RedirectAuthHandler.create(authProvider, "/login.html"));

    router.mountSubRouter("/tokens", tokenRouter(authProvider));
    router.mountSubRouter("/api", auctionApiRouter());

    router.route().failureHandler(ErrorHandler.create(true));
    router.route("/private/*").handler(staticHandler("private"));
    router.route().handler(staticHandler("public"));

    vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
 
开发者ID:mwarc,项目名称:realtime-auctions-vertx3-example,代码行数:24,代码来源:AuctionFrontendVerticle.java

示例7: setUp

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();
  client = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(8080));
  router = Router.router(vertx);
  router.route().handler(CookieHandler.create());
  router.route()
      .handler(SessionHandler.create(LocalSessionStore.create(vertx))
          .setNagHttps(false)
          .setSessionTimeout(60 * 60 * 1000));
  addHandlersBeforeSockJSHandler(router);
  SockJSHandlerOptions options = new SockJSHandlerOptions().setHeartbeatInterval(2000);
  sockJSHandler = SockJSHandler.create(vertx, options);
  router.route("/test/*").handler(sockJSHandler);
  server = vertx.createHttpServer(new HttpServerOptions().setPort(8080).setHost("localhost"));
  CountDownLatch latch = new CountDownLatch(1);
  server.requestHandler(router::accept).listen(ar -> latch.countDown());
  awaitLatch(latch);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:20,代码来源:SockJSTestBase.java

示例8: router

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
protected Router router() {

	return RouterBuilder.create(vertx)
			.scanClasspath(true)
			.authHandler(this::authHandler)
			.addHandler(SessionHandler.create(ClusteredSessionStore.create(vertx)))
			.build();
}
 
开发者ID:pflima92,项目名称:jspare-vertx-ms-blueprint,代码行数:10,代码来源:UtilityAPIVerticle.java

示例9: router

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
protected Router router() {
	
	// TODO retrieve plug and play routes to api
	
	return RouterBuilder.create(vertx)
				.scanClasspath(false)
				.authHandler(this::authHandler)
				.addHandler(TidHandler.create())
				.addHandler(ResponseTimeHandler.create())
				.addHandler(SessionHandler.create(ClusteredSessionStore.create(vertx)))
				.addRoute(GatewayProxyRoute.class)
				.addRoute(UAARoute.class)
				.build();
}
 
开发者ID:pflima92,项目名称:jspare-vertx-ms-blueprint,代码行数:16,代码来源:ProxyAPIVerticle.java

示例10: startWebApp

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
private void startWebApp(int port){
	SessionStore store = LocalSessionStore.create(vertx, appName + ".sessionmap");
	SessionHandler sessionHandler = SessionHandler.create(store);
	
	ServerVerticle serverVerticle = context.getBean(ServerVerticle.class);
   	serverVerticle.setPort(port);
   	serverVerticle.setSessionHandler(sessionHandler);
   	
       vertx.deployVerticle(serverVerticle);
}
 
开发者ID:quebic-source,项目名称:puppy-io,代码行数:11,代码来源:PuppyAppLauncher.java

示例11: addBasicRoute

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
private void addBasicRoute(JsonObject conf) {
	router.route().handler(CookieHandler.create());

	BodyHandler bh = BodyHandler.create();
	bh.setMergeFormAttributes(false);
	bh.setUploadsDirectory(this.upload_dir);
	// bh.setDeleteUploadedFilesOnEnd(false);
	router.route().handler(bh);

	String hasSession = conf.getString("session","true");
	if("true".equals(hasSession)){		
		SessionStore sessionStore = null;
		if (vertx.isClustered())
			sessionStore = ClusteredSessionStore.create(vertx,SessionName);
		else
			sessionStore = LocalSessionStore.create(vertx,SessionName);		
		
		SessionHandler sessionHandler = SessionHandler.create(sessionStore);
		sessionHandler.setNagHttps(false).setCookieHttpOnlyFlag(true);
		Long sessionTimeount = conf.getLong("session.timeout");
		if(sessionTimeount!=null && sessionTimeount>0)
			sessionHandler.setSessionTimeout(sessionTimeount);
		
		router.route().handler(sessionHandler);

		if(gsetting.hasAuth()  && !this.appContain.isEmpty()){
			router.route().handler(UserSessionHandler.create(authMgr.authProvider));
			
			GateAuthHandler authHandler = new GateAuthHandler(authMgr);
			router.route().handler(authHandler::handle);
			
		}
	}
	
	router.route().failureHandler(rc->{
		
		HttpServerResponse response = rc.response();
		
		if(response.ended())
			return;
		
		int statusCode = rc.statusCode() == -1 ? 500 : rc.statusCode();

           log.error("Error,status code: {}. ",statusCode);
           response.setStatusCode(statusCode).end("status code:"+statusCode);
	});

}
 
开发者ID:troopson,项目名称:etagate,代码行数:49,代码来源:OutServerVerticle.java

示例12: preconfigureRouting

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
protected void preconfigureRouting(final Router router) {
    router.route().handler(CookieHandler.create());
    router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)).setSessionTimeout(SESSION_TTL));
}
 
开发者ID:travelaudience,项目名称:nexus-proxy,代码行数:6,代码来源:CloudIamAuthNexusProxyVerticle.java

示例13: createRouter

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
static Router createRouter() {

        Router router = Router.router(vertx);

        SockJSHandler sockJSHandler = SockJSHandler.create(vertx);

        sockJSHandler.bridge(eventBusBridgeOptions());

        router.route("/eventbus/*").handler(sockJSHandler);

        router.route().handler(CookieHandler.create());

        SessionStore store = LocalSessionStore.create(vertx);

        SessionHandler sessionHandler = SessionHandler.create(store);

        router.route().handler(sessionHandler);

        return router;
    }
 
开发者ID:codefacts,项目名称:Elastic-Components,代码行数:21,代码来源:TrackerServer.java

示例14: enableLocalSession

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
/**
 * Enable local session storage in requests.
 *
 * @param router router instance
 */
protected void enableLocalSession(Router router) {
  router.route().handler(CookieHandler.create());
  router.route().handler(SessionHandler.create(
    LocalSessionStore.create(vertx, "shopping.user.session")));
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:11,代码来源:RestAPIVerticle.java

示例15: enableClusteredSession

import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
/**
 * Enable clustered session storage in requests.
 *
 * @param router router instance
 */
protected void enableClusteredSession(Router router) {
  router.route().handler(CookieHandler.create());
  router.route().handler(SessionHandler.create(
    ClusteredSessionStore.create(vertx, "shopping.user.session")));
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:11,代码来源:RestAPIVerticle.java


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