本文整理汇总了Java中io.vertx.ext.web.sstore.ClusteredSessionStore类的典型用法代码示例。如果您正苦于以下问题:Java ClusteredSessionStore类的具体用法?Java ClusteredSessionStore怎么用?Java ClusteredSessionStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClusteredSessionStore类属于io.vertx.ext.web.sstore包,在下文中一共展示了ClusteredSessionStore类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldFireSessionExpiredEventForHazelcastSessionStore
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的package包/类
@Test(timeout = 15000L)
public void shouldFireSessionExpiredEventForHazelcastSessionStore(TestContext context) {
Async async = context.async();
Vertx.clusteredVertx(new VertxOptions().setClusterManager(new HazelcastClusterManager()), res -> {
vertx = res.result();
SessionStore adapted = SessionStoreAdapter.adapt(vertx, ClusteredSessionStore.create(vertx));
Session session = adapted.createSession(2000);
sessionExpiredConsumer = SessionStoreAdapter.sessionExpiredHandler(vertx, event -> {
context.assertEquals(session.id(), event.body());
async.countDown();
});
adapted.put(session, Future.<Boolean>future().completer());
session.put("a", "b");
});
}
示例2: example32
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的package包/类
public void example32() {
// a clustered Vert.x
Vertx.clusteredVertx(new VertxOptions().setClustered(true), res -> {
Vertx vertx = res.result();
// Create a clustered session store using defaults
SessionStore store1 = ClusteredSessionStore.create(vertx);
// Create a clustered session store specifying the distributed map name to use
// This might be useful if you have more than one application in the cluster
// and want to use different maps for different applications
SessionStore store2 = ClusteredSessionStore.create(vertx, "myclusteredapp3.sessionmap");
});
}
示例3: addSessionHandler
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的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)
);
}
示例4: router
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的package包/类
@Override
protected Router router() {
return RouterBuilder.create(vertx)
.scanClasspath(true)
.authHandler(this::authHandler)
.addHandler(SessionHandler.create(ClusteredSessionStore.create(vertx)))
.build();
}
示例5: router
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的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();
}
示例6: shouldAdaptClusteredLocalSessionStore
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的package包/类
@Test
public void shouldAdaptClusteredLocalSessionStore() {
long before = Instant.now().toEpochMilli();
SessionStore adapted = SessionStoreAdapter.adapt(vertx, ClusteredSessionStore.create(vertx));
assertThat(adapted).isInstanceOf(ClusteredSessionStoreAdapter.class);
Session session = adapted.createSession(1000);
assertThat(session).isInstanceOf(ExtendedSession.class);
ExtendedSession extendedSession = (ExtendedSession) session;
assertThat(extendedSession.createdAt()).isBetween(before, Instant.now().toEpochMilli());
}
示例7: addBasicRoute
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的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);
});
}
示例8: createSessionStore
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的package包/类
protected SessionStore createSessionStore() {
if (vertx.isClustered()) {
return ClusteredSessionStore.create(vertx);
}
return LocalSessionStore.create(vertx);
}
示例9: setUp
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的package包/类
@Before
public void setUp(TestContext context) {
vertx = Vertx.vertx();
sessionStore = ClusteredSessionStore.create(vertx);
}
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:6,代码来源:VertxWrappedSessionWithClusteredSessionStoreUT.java
示例10: enableClusteredSession
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的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")));
}
示例11: example33
import io.vertx.ext.web.sstore.ClusteredSessionStore; //导入依赖的package包/类
public void example33(Vertx vertx) {
Router router = Router.router(vertx);
// We need a cookie handler first
router.route().handler(CookieHandler.create());
// Create a clustered session store using defaults
SessionStore store = ClusteredSessionStore.create(vertx);
SessionHandler sessionHandler = SessionHandler.create(store);
// Make sure all requests are routed through the session handler too
router.route().handler(sessionHandler);
// Now your application handlers
router.route("/somepath/blah/").handler(routingContext -> {
Session session = routingContext.session();
session.put("foo", "bar");
// etc
});
}