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


Java LocalSessionStore类代码示例

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


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

示例1: start

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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.sstore.LocalSessionStore; //导入依赖的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.sstore.LocalSessionStore; //导入依赖的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.sstore.LocalSessionStore; //导入依赖的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: createRouter

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
private Router createRouter() {
	Router router = Router.router(vertx);
	router.route().failureHandler(ErrorHandler.create(true));

	/* Static resources */
	staticHandler(router);

	/* Session / cookies for users */
	router.route().handler(CookieHandler.create());
	SessionStore sessionStore = LocalSessionStore.create(vertx);
	SessionHandler sessionHandler = SessionHandler.create(sessionStore);
	router.route().handler(sessionHandler);
	userContextHandler = new UserContextHandler(mongo);

	/* Dynamic pages */
	dynamicPages(router);

	/* API */
	router.mountSubRouter("/api", apiRouter());

	/* SockJS / EventBus */
	router.route("/eventbus/*").handler(eventBusHandler());

	return router;
}
 
开发者ID:aesteve,项目名称:vertx-feeds,代码行数:26,代码来源:WebServer.java

示例6: start

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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

示例7: attachHandlersToRouter

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
public void attachHandlersToRouter(Router router) {
  config.forEachGlobalHandler(handler -> router.route(httpMethod, path).handler(handler));
  final Vertx vertx = config.getVertx();
  if (authHandler != null) {
    attachAuthHandler(router, vertx);
  } else if (usesSession) {
    router.route(httpMethod, path).handler(SessionHandler.create(LocalSessionStore.create(vertx)));
  }
  handlers.forEach(handler ->
    router.route(httpMethod, path).handler(handler)
  );
  attachPreProcessingHandlers(router);
  boolean hasPostProcessors = redirectRoute != null || postInterceptor != null || !afterFilters.isEmpty()|| !processors.isEmpty();
  setHandler(router, mainHandler, hasPostProcessors);
  if (redirectRoute != null) {
    // intercepted -> redirected => do not call post processing handlers
    router.route(httpMethod, path).handler(ctx ->
      ctx.reroute(redirectRoute.method(), redirectRoute.path())
    );
  }
  attachPostProcessingHandlers(router);
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:23,代码来源:MVCRoute.java

示例8: start

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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

示例9: testGetSessionById

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Test
public void testGetSessionById() throws Exception {

    final Vertx vertx = Vertx.vertx();

    // We need to create a pre-programmed vertx session so we can validate
    final LocalSessionStore vertxSessionStore = LocalSessionStore.create(vertx);
    final io.vertx.ext.web.Session vertxSession = vertxSessionStore.createSession(300000);
    final CountDownLatch latch = new CountDownLatch(1);
    vertxSessionStore.put(vertxSession, b -> latch.countDown());
    latch.await(1, TimeUnit.SECONDS);
    vertxSession.put(TEST_SESSION_KEY, TEST_SESSION_VALUE);
    final String sessionId = vertxSession.id();

    // Now let's wrap in a pac4j sessionStore
    final ExtendedSessionStore<VertxWebContext> pac4jSessionStore = new VertxSessionStore(vertxSessionStore);
    final org.pac4j.vertx.context.session.Session pac4jSession = pac4jSessionStore.getSession(sessionId);
    assertThat(pac4jSession, is(notNullValue()));
    assertThat(pac4jSession.get(TEST_SESSION_KEY), is(TEST_SESSION_VALUE));
}
 
开发者ID:pac4j,项目名称:vertx-pac4j,代码行数:21,代码来源:VertxSessionStoreTest.java

示例10: setUp

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();

  JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
  AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, authConfig);

  // create a chain
  chain = ChainAuthHandler.create();

  chain
    .append(JWTAuthHandler.create(null))
    .append(BasicAuthHandler.create(authProvider))
    .append(RedirectAuthHandler.create(authProvider));

  router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
  router.route().handler(chain);
  router.route().handler(ctx -> ctx.response().end());
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:20,代码来源:ChainAuthHandlerTest.java

示例11: setUp

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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

示例12: addSessionHandler

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
private void addSessionHandler(Vertx vertx, Router router) {
    SessionStore
            sessionStore = clustered ? ClusteredSessionStore.create(vertx) : LocalSessionStore
            .create(vertx);
    router.route().handler(CookieHandler.create());
    router.route().handler(SessionHandler
            .create(sessionStore)
            .setCookieHttpOnlyFlag(true)
            .setCookieSecureFlag(true)
    );
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:12,代码来源:RouterConfigurator.java

示例13: shouldAdaptLocalSessionStore

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Test
public void shouldAdaptLocalSessionStore() {
    long before = Instant.now().toEpochMilli();
    SessionStore adapted = SessionStoreAdapter.adapt(vertx, LocalSessionStore.create(vertx));
    assertThat(adapted).isInstanceOf(LocalSessionStoreAdapter.class);
    Session session = adapted.createSession(1000);
    assertThat(session).isInstanceOf(ExtendedSession.class);
    ExtendedSession extendedSession = (ExtendedSession) session;
    assertThat(extendedSession.createdAt()).isBetween(before, Instant.now().toEpochMilli());
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:11,代码来源:SessionStoreAdapterUT.java

示例14: shouldFireSessionExpiredEventForLocalSessionStore

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Test(timeout = 5000L)
public void shouldFireSessionExpiredEventForLocalSessionStore(TestContext context) {
    Async async = context.async();
    SessionStore adapted = SessionStoreAdapter.adapt(vertx, LocalSessionStore.create(vertx));
    Session session = adapted.createSession(1000);

    sessionExpiredConsumer = SessionStoreAdapter.sessionExpiredHandler(vertx, event -> {
        context.assertEquals(session.id(), event.body());
        async.countDown();
    });
    adapted.put(session, Future.<Boolean>future().completer());
    session.put("a", "b");
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:14,代码来源:SessionStoreAdapterUT.java

示例15: startWebApp

import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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


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