1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.neo4j.server.webadmin.rest;
21
22 import org.neo4j.server.database.Database;
23 import org.neo4j.server.webadmin.console.GremlinSession;
24 import org.neo4j.server.webadmin.console.ScriptSession;
25
26 import javax.servlet.http.HttpSession;
27
28 public class SessionFactoryImpl implements SessionFactory
29 {
30 private HttpSession httpSession;
31
32 public SessionFactoryImpl(HttpSession httpSession)
33 {
34 this.httpSession = httpSession;
35 }
36
37 @Override
38 public ScriptSession createSession( String engineName, Database database )
39 {
40 Object session = httpSession.getAttribute( "consoleSession" );
41 if ( session == null )
42 {
43 session = new GremlinSession( database );
44 httpSession.setAttribute( "consoleSession", session );
45 }
46 return (ScriptSession) session;
47 }
48 }