作成中の
1.0.6 > 1.1.2 に
コンパイルエラーが
コンパイルエラー情報を
以下、
Chapter 36. Upgrading Jetty
上記を
変更点に ついて
修正前の 実装
問題が
も
で
/** * setSessionHandlerTo * * @param env */ private void setSessionHandlerTo(Environment env) throws UnknownHostException { // Set SessionHandler MongoClientURI mongoURI = new MongoClientURI(MongoDBResource.getUriString()); // Not Close... MongoClient mongoClient = new MongoClient(mongoURI); // 非推奨だが、ライブラリが対応していないので使う.. DB db = mongoClient.getDB("jetty_session"); DBCollection collection = db.getCollection("jetty_session_collection"); env.lifecycle().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarting(LifeCycle event) { log.info("lifeCycleStarting start event = {}", event); if (!(event instanceof Server)) { return; } Server server = (Server) event; MongoSessionIdManager sessionIdManager = new MongoSessionIdManager(server, collection); MongoSessionManager sessionManager = null; try { sessionManager = new MongoSessionManager(); } catch (UnknownHostException e) { throw new IllegalStateException(e); } sessionIdManager.setWorkerName("node1"); sessionIdManager.setScavengePeriod(1800000L); sessionIdManager.setScavengeBlockSize(0); sessionIdManager.setPurge(true); sessionIdManager.setPurgeDelay(1800000L); sessionIdManager.setPurgeInvalidAge(1800000L); sessionIdManager.setPurgeValidAge(5400000L); sessionIdManager.setPurgeLimit(0); sessionManager.setSessionIdManager(sessionIdManager); sessionManager.setPreserveOnStop(true); sessionManager.setHttpOnly(true); sessionManager.setMaxInactiveInterval(1800); env.servlets().setSessionHandler(new SessionHandler(sessionManager)); } }); }
変更点1. SessionManager が 削除された
SessionManager
の が
SessionManager
が
期待値: 引数がありません 検出値: org.eclipse.jetty.nosql.mongodb.MongoSessionManager 理由: 実引数リストと仮引数リストの長さが異なります
SessionManager
がSessionHandler
に
実装を
変更点2. Session を ストレージに 登録する Module が 変更された
作成している
Jetty 9.3 では、nosql
だったのが、
Jetty 9.4 では、session-store-mongo
に
Clustered Session Management: MongoDB
jetty コマンドを
dropwizard 経由なのでやり方が
再度、
を
SessionIdManager Previously there was a different class of SessionIdManager - with different configuration options - depending upon which type of >clustering technology chosen. In Jetty 9.4, there is only one type, the org.eclipse.jetty.server.session.DefaultSessionIdManager.
DefaultSessionIdManager
を
変更点3. 修正はし、 コンパイルは 通ったが、 起動しない。
コンパイルは
org.eclipse.jetty.nosql.mongodb.MongoSessionDataStoreFactory.getSavePeriodSec()I
どうも、jetty
のsession-store-mongo
が
session-store-mongo
の
修正後の 実装
修正後の
いくつか、MongoSessionIdManager
からDefaultSessionIdManager
には
どうやって
/** * setSessionHandlerTo * * @param env */ private void setSessionHandlerTo(Environment env) throws UnknownHostException { env.lifecycle().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarting(LifeCycle event) { log.info("lifeCycleStarting start event = {}", event); if (!(event instanceof Server)) { return; } Server server = (Server) event; MongoSessionDataStoreFactory storeFactory = new MongoSessionDataStoreFactory(); storeFactory.setHost(MongoDBResource.getHost()); storeFactory.setPort(Integer.valueOf(MongoDBResource.getPort())); storeFactory.setDbName("jetty_session"); storeFactory.setCollectionName("jetty_session_collection"); storeFactory.setGracePeriodSec(3600); server.addBean(storeFactory); DefaultSessionIdManager sessionIdManager = new DefaultSessionIdManager(server); sessionIdManager.setServer(server); sessionIdManager.setWorkerName("node1"); SessionHandler handler = new SessionHandler(); handler.setHttpOnly(true); handler.setMaxInactiveInterval(1800); handler.setSessionIdManager(sessionIdManager); server.setSessionIdManager(sessionIdManager); env.servlets().setSessionHandler(handler); } }); }
pom.xml の 記載
9.3.16.v20170120
から、9.4.2.v20170220
へ、
名前は
<dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-nosql</artifactId> <version>9.4.2.v20170220</version> <exclusions> <exclusion> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> </exclusion> <exclusion> <groupId>org.eclipse.jetty.toolchain</groupId> <artifactId>jetty-test-helper</artifactId> </exclusion> <exclusion> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> </exclusion> <exclusion> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>test-sessions-common</artifactId> </exclusion> <exclusion> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-jmx</artifactId> </exclusion> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency>
以上です。
コメント