Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
23959cee
提交
23959cee
authored
9月 03, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify SessionFactory a bit.
上级
b557fb3f
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
15 行增加
和
19 行删除
+15
-19
Engine.java
h2/src/main/org/h2/engine/Engine.java
+11
-10
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-6
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+1
-1
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+1
-2
没有找到文件。
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
23959cee
...
...
@@ -24,15 +24,12 @@ import org.h2.util.StringUtils;
* It is also responsible for opening and creating new databases.
* This is a singleton class.
*/
public
class
Engine
{
public
class
Engine
implements
SessionFactory
{
private
static
final
Engine
INSTANCE
=
new
Engine
();
private
static
final
HashMap
<
String
,
Database
>
DATABASES
=
New
.
hashMap
();
private
volatile
long
wrongPasswordDelay
=
SysProperties
.
DELAY_WRONG_PASSWORD_MIN
;
private
Engine
()
{
// don't allow others to instantiate
}
private
final
HashMap
<
String
,
Database
>
databases
=
New
.
hashMap
();
private
volatile
long
wrongPasswordDelay
=
SysProperties
.
DELAY_WRONG_PASSWORD_MIN
;
public
static
Engine
getInstance
()
{
return
INSTANCE
;
...
...
@@ -45,7 +42,7 @@ public class Engine {
if
(
openNew
||
ci
.
isUnnamedInMemory
())
{
database
=
null
;
}
else
{
database
=
DATABASES
.
get
(
name
);
database
=
databases
.
get
(
name
);
}
User
user
=
null
;
boolean
opened
=
false
;
...
...
@@ -64,7 +61,7 @@ public class Engine {
database
.
setMasterUser
(
user
);
}
if
(!
ci
.
isUnnamedInMemory
())
{
DATABASES
.
put
(
name
,
database
);
databases
.
put
(
name
,
database
);
}
}
synchronized
(
database
)
{
...
...
@@ -108,7 +105,11 @@ public class Engine {
* @param ci the connection information
* @return the session
*/
public
Session
getSession
(
ConnectionInfo
ci
)
{
public
Session
createSession
(
ConnectionInfo
ci
)
{
return
INSTANCE
.
createSessionAndValidate
(
ci
);
}
private
Session
createSessionAndValidate
(
ConnectionInfo
ci
)
{
try
{
ConnectionInfo
backup
=
null
;
String
lockMethodName
=
ci
.
getProperty
(
"FILE_LOCK"
,
null
);
...
...
@@ -213,7 +214,7 @@ public class Engine {
* @param name the database name
*/
public
void
close
(
String
name
)
{
DATABASES
.
remove
(
name
);
databases
.
remove
(
name
);
}
/**
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
23959cee
...
...
@@ -42,7 +42,7 @@ import org.h2.value.ValueString;
* mode, this object resides on the server side and communicates with a
* SessionRemote object on the client side.
*/
public
class
Session
extends
SessionWithState
implements
SessionFactory
{
public
class
Session
extends
SessionWithState
{
/**
* This special log position means that the log entry has been written.
...
...
@@ -118,10 +118,6 @@ public class Session extends SessionWithState implements SessionFactory {
this
.
currentSchemaName
=
Constants
.
SCHEMA_MAIN
;
}
public
SessionInterface
createSession
(
ConnectionInfo
ci
)
{
return
Engine
.
getInstance
().
getSession
(
ci
);
}
public
boolean
setCommitOrRollbackDisabled
(
boolean
x
)
{
boolean
old
=
commitOrRollbackDisabled
;
commitOrRollbackDisabled
=
x
;
...
...
@@ -1178,7 +1174,7 @@ public class Session extends SessionWithState implements SessionFactory {
public
SessionInterface
reconnect
(
boolean
write
)
{
readSessionState
();
close
();
Session
newSession
=
Engine
.
getInstance
().
get
Session
(
connectionInfo
);
Session
newSession
=
Engine
.
getInstance
().
create
Session
(
connectionInfo
);
newSession
.
sessionState
=
sessionState
;
newSession
.
recreateSessionState
();
if
(
write
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
23959cee
...
...
@@ -108,7 +108,7 @@ public class JdbcConnection extends TraceObject implements Connection {
}
checkJavaVersion
();
// this will return an embedded or server connection
session
=
new
SessionRemote
().
createSession
(
ci
);
session
=
new
SessionRemote
(
ci
).
createSession
(
ci
);
trace
=
session
.
getTrace
();
int
id
=
getNextId
(
TraceObject
.
CONNECTION
);
setTrace
(
trace
,
TraceObject
.
CONNECTION
,
id
);
...
...
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
23959cee
...
...
@@ -121,8 +121,7 @@ public class TcpServerThread implements Runnable {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ci
.
setProperty
(
transfer
.
readString
(),
transfer
.
readString
());
}
Engine
engine
=
Engine
.
getInstance
();
session
=
engine
.
getSession
(
ci
);
session
=
Engine
.
getInstance
().
createSession
(
ci
);
transfer
.
setSession
(
session
);
transfer
.
writeInt
(
SessionRemote
.
STATUS_OK
);
transfer
.
writeInt
(
clientVersion
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论