Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8dabf1e3
提交
8dabf1e3
authored
6月 21, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
42e01bf9
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
319 行增加
和
33 行删除
+319
-33
ant-build.properties
h2/ant-build.properties
+1
-0
build.xml
h2/build.xml
+31
-32
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+17
-0
console.html
h2/src/tools/WEB-INF/console.html
+9
-0
web.xml
h2/src/tools/WEB-INF/web.xml
+52
-0
DbStarter.java
h2/src/tools/org/h2/server/web/DbStarter.java
+2
-1
WebServlet.java
h2/src/tools/org/h2/server/web/WebServlet.java
+207
-0
没有找到文件。
h2/ant-build.properties
浏览文件 @
8dabf1e3
...
...
@@ -2,4 +2,5 @@
javac
=
javac
benchmark.drivers.dir
=
D
\:
/data/java
version.name.maven
=
1.0.20070617
path.servlet.jar
=
C
\:
/data/classpath/servlet-api-2.3.jar
jdk
=
1.4
h2/build.xml
浏览文件 @
8dabf1e3
...
...
@@ -2,8 +2,8 @@
<property
file=
"ant-build.properties"
/>
<!-- jar files required by the benchmark -->
<path
id=
"benchmark.drivers.path"
>
<!-- jar files required by the benchmark -->
<pathelement
location=
"bin"
/>
<pathelement
path=
"${java.class.path}/"
/>
<fileset
dir=
"${benchmark.drivers.dir}"
>
...
...
@@ -38,7 +38,7 @@
<java
fork=
"true"
classname=
"org.h2.test.bench.TestPerformance"
classpathref=
"benchmark.drivers.path"
dir=
"."
maxmemory=
"128m"
><arg
line=
"-db 9 -out ps.html"
/></java>
</target>
<target
name=
"clean"
>
<target
name=
"clean"
depends=
"init"
>
<mkdir
dir=
"bin"
/>
<mkdir
dir=
"odbc"
/>
<mkdir
dir=
"docs"
/>
...
...
@@ -52,11 +52,11 @@
<delete
file=
"src/tools/org/h2/tools/code/CodeSwitch.class"
/>
</target>
<target
name=
"codeswitch
_p
repare"
>
<target
name=
"codeswitch
P
repare"
>
<javac
executable=
"${javac}"
srcdir=
"src/tools"
debug=
"true"
includes=
"org/h2/tools/code/CodeSwitch.java"
/>
</target>
<target
name=
"codeswitch
_jdk13"
depends=
"codeswitch_p
repare"
>
<target
name=
"codeswitch
Jdk13"
depends=
"codeswitchP
repare"
>
<propertyfile
file=
"ant-build.properties"
>
<entry
key=
"jdk"
value=
"1.3"
/>
</propertyfile>
...
...
@@ -65,7 +65,7 @@
</java>
</target>
<target
name=
"codeswitch
_jdk14"
depends=
"codeswitch_p
repare"
>
<target
name=
"codeswitch
Jdk14"
depends=
"codeswitchP
repare"
>
<propertyfile
file=
"ant-build.properties"
>
<entry
key=
"jdk"
value=
"1.4"
/>
</propertyfile>
...
...
@@ -74,7 +74,7 @@
</java>
</target>
<target
name=
"codeswitch
_jdk16"
depends=
"codeswitch_p
repare"
>
<target
name=
"codeswitch
Jdk16"
depends=
"codeswitchP
repare"
>
<propertyfile
file=
"ant-build.properties"
>
<entry
key=
"jdk"
value=
"1.6"
/>
</propertyfile>
...
...
@@ -94,11 +94,25 @@
<fileset
dir=
"bin"
includes=
"org/h2/util/ResourceData.java"
/>
</delete>
</target>
<target
name=
"compileServlet"
depends=
"compileServletTest, compile"
if=
"servlet.jar.present"
>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"src/tools"
destdir=
"bin"
debug=
"true"
>
<classpath
location=
"${path.servlet.jar}"
/>
<include
name=
"org/h2/server/web/*.*"
/>
</javac>
</target>
<target
name=
"compileServletTest"
depends=
"init"
unless=
"servlet.jar.present"
>
<echo
message=
"Servlet API jar not found, console servlet not compiled."
/>
<echo
message=
"Please set ant-build.properties / path.servlet.jar"
/>
</target>
<target
name=
"compile"
depends=
"compileResources"
>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"src/main"
destdir=
"bin"
debug=
"true"
/>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"src/test"
destdir=
"bin"
debug=
"true"
/>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"src/tools"
destdir=
"bin"
debug=
"true"
/>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"src/tools"
destdir=
"bin"
debug=
"true"
>
<exclude
name=
"org/h2/server/web/*.*"
/>
</javac>
<unzip
src=
"src/systray/systray4j.jar"
dest=
"bin"
/>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"src/systray"
destdir=
"bin"
debug=
"true"
/>
<copy
todir=
"bin"
overwrite=
"true"
>
...
...
@@ -138,32 +152,11 @@
<java
classname=
"org.h2.tools.doc.SpellChecker"
classpath=
"bin"
/>
</target>
<target
name=
"gcj"
depends=
"compileResources"
>
<copy
todir=
"bin"
>
<fileset
dir=
"src/main"
/>
<fileset
dir=
"src/test"
/>
</copy>
<replace
file=
"bin/org/h2/util/StringUtils.java"
token=
"//#GCJHACK"
value=
""
/>
<exec
dir=
"bin"
executable=
"cmd"
>
<arg
line=
"/c dir /b /s *.java >files.txt"
/>
</exec>
<exec
dir=
"bin"
executable=
"gcj"
>
<arg
line=
"-O1 -c --classpath=. -o db.o @files.txt"
/>
</exec>
<!-- -g0 -fomit-frame-pointer -fno-bounds-check -fno-store-check -O2 -->
<exec
dir=
"bin"
executable=
"gcj"
>
<arg
line=
"--main=org.h2.tools.Server -s -o h2-server.exe db.o"
/>
</exec>
<exec
dir=
"bin"
executable=
"gcj"
>
<arg
line=
"--main=org.h2.test.TestAll -s -o h2-test.exe db.o"
/>
</exec>
<delete
includeemptydirs=
"true"
>
<fileset
dir=
"bin"
includes=
"**/*.java"
/>
<fileset
dir=
"bin"
includes=
"**/*.o"
/>
</delete>
<target
name=
"init"
>
<available
file=
"${path.servlet.jar}"
property=
"servlet.jar.present"
/>
</target>
<target
name=
"jar"
depends=
"compile"
>
<target
name=
"jar"
depends=
"compile
, compileServlet
"
>
<mkdir
dir=
"bin/META-INF"
/>
<manifest
file=
"bin/META-INF/MANIFEST.MF"
>
<!--
...
...
@@ -278,6 +271,12 @@
<!-- <jvmarg value="-agentlib:hprof=help"/> -->
</java>
</target>
<target
name=
"warConsole"
depends=
"compileServlet, jar"
>
<war
destfile=
"bin/h2console.war"
webxml=
"src/tools/WEB-INF/web.xml"
>
<lib
file=
"bin/h2.jar"
/>
</war>
</target>
<target
name=
"zip"
>
<zip
destfile=
"../h2.zip"
>
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
8dabf1e3
...
...
@@ -93,6 +93,23 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
test
.
printSystem
();
/*
set new console to be the default (still support old)
set new index mechanism to be the default (still support old)
add test case:
create table test1(id int);
insert into test1 values(1);
insert into test1 values(1);
insert into test1 values(2);
insert into test1 values(3);
select sum(C0) from (
select count(*) AS C0 from (select distinct * from
test1) as temp
)
todo: challenge response authentication
h2 console system tray: menu item to open window
Set h2.indexNew to false
...
...
h2/src/tools/WEB-INF/console.html
0 → 100644
浏览文件 @
8dabf1e3
<html>
<head>
<title>
H2 Console
</title>
<META
HTTP-EQUIV=
"Refresh"
CONTENT=
"0; URL=console/"
>
</head>
<body>
<a
href=
"console/"
>
H2 Console
</a>
</body>
</html>
h2/src/tools/WEB-INF/web.xml
0 → 100644
浏览文件 @
8dabf1e3
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version=
"2.5"
>
<display-name>
H2 Console Web Application
</display-name>
<description>
A web application that includes the H2 Console servlet.
</description>
<servlet>
<servlet-name>
H2Console
</servlet-name>
<servlet-class>
org.h2.server.web.WebServlet
</servlet-class>
<init-param>
<param-name>
log
</param-name>
<param-value>
true
</param-value>
</init-param>
<load-on-startup>
1
</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>
H2Console
</servlet-name>
<url-pattern>
/console/*
</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
/console.html
</welcome-file>
</welcome-file-list>
<security-constraint>
<!--
<web-resource-collection>
<web-resource-name>H2 Console</web-resource-name>
<url-pattern>/console/*</url-pattern>
</web-resource-collection>
-->
<auth-constraint>
<role-name>
admin
</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>
BASIC
</auth-method>
<realm-name>
H2 Console
</realm-name>
</login-config>
<security-role>
<role-name>
admin
</role-name>
</security-role>
</web-app>
h2/src/tools/org/h2/
tools/servlet/DbStarter.java.txt
→
h2/src/tools/org/h2/
server/web/DbStarter.java
浏览文件 @
8dabf1e3
package org.h2.
tools.servlet
;
package
org
.
h2
.
server
.
web
;
import
javax.servlet.*
;
import
java.sql.*
;
public
class
DbStarter
implements
ServletContextListener
{
private
Connection
conn
;
public
void
contextInitialized
(
ServletContextEvent
servletContextEvent
)
{
...
...
h2/src/tools/org/h2/server/web/WebServlet.java
0 → 100644
浏览文件 @
8dabf1e3
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
server
.
web
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Enumeration
;
import
java.util.Properties
;
import
javax.servlet.ServletConfig
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.h2.util.StringUtils
;
public
class
WebServlet
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
9171446624885086692L
;
private
WebServer
server
;
private
void
testLog
(
String
s
)
{
int
todoRefactorSimplify
;
int
todoRemoveTestLogMethod
;
int
todoTestWithTomcat
;
int
todoTestWithJetty
;
System
.
out
.
println
(
s
);
}
public
void
init
()
throws
ServletException
{
ServletConfig
config
=
getServletConfig
();
Enumeration
en
=
config
.
getInitParameterNames
();
ArrayList
list
=
new
ArrayList
();
while
(
en
.
hasMoreElements
())
{
String
name
=
(
String
)
en
.
nextElement
();
String
value
=
config
.
getInitParameter
(
name
);
if
(!
name
.
startsWith
(
"-"
))
{
name
=
"-"
+
name
;
}
list
.
add
(
name
);
list
.
add
(
value
);
}
String
[]
args
=
new
String
[
list
.
size
()];
list
.
toArray
(
args
);
server
=
new
WebServer
();
server
.
setAllowShutdown
(
false
);
try
{
server
.
init
(
args
);
}
catch
(
Exception
e
)
{
throw
new
ServletException
(
"Init failed"
,
e
);
}
}
public
void
destroy
()
{
}
boolean
allow
(
HttpServletRequest
req
)
{
if
(
server
.
getAllowOthers
())
{
return
true
;
}
String
addr
=
req
.
getRemoteAddr
();
InetAddress
address
;
try
{
address
=
InetAddress
.
getByName
(
addr
);
}
catch
(
UnknownHostException
e
)
{
return
false
;
}
return
address
.
isLoopbackAddress
();
}
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
String
file
=
req
.
getPathInfo
();
trace
(
"get "
+
file
);
if
(
file
==
null
)
{
resp
.
sendRedirect
(
req
.
getRequestURI
()
+
"/"
);
return
;
}
else
if
(
file
.
startsWith
(
"/"
))
{
file
=
file
.
substring
(
1
);
}
if
(
file
.
length
()
==
0
)
{
file
=
"index.do"
;
}
if
(!
allow
(
req
))
{
file
=
"notAllowed.jsp"
;
}
byte
[]
bytes
=
null
;
Properties
attributes
=
new
Properties
();
Enumeration
en
=
req
.
getAttributeNames
();
while
(
en
.
hasMoreElements
())
{
String
name
=
(
String
)
en
.
nextElement
();
String
value
=
(
String
)
req
.
getAttribute
(
name
);
attributes
.
put
(
name
,
value
);
}
en
=
req
.
getParameterNames
();
while
(
en
.
hasMoreElements
())
{
String
name
=
(
String
)
en
.
nextElement
();
String
value
=
(
String
)
req
.
getParameter
(
name
);
attributes
.
put
(
name
,
value
);
}
WebSession
session
=
null
;
String
sessionId
=
attributes
.
getProperty
(
"jsessionid"
);
if
(
sessionId
!=
null
)
{
session
=
server
.
getSession
(
sessionId
);
}
int
todoSupportCache
;
String
mimeType
;
boolean
cache
;
int
index
=
file
.
lastIndexOf
(
'.'
);
String
suffix
;
if
(
index
>=
0
)
{
suffix
=
file
.
substring
(
index
+
1
);
}
else
{
suffix
=
""
;
}
if
(
suffix
.
equals
(
"ico"
))
{
mimeType
=
"image/x-icon"
;
cache
=
true
;
}
else
if
(
suffix
.
equals
(
"gif"
))
{
mimeType
=
"image/gif"
;
cache
=
true
;
}
else
if
(
suffix
.
equals
(
"css"
))
{
cache
=
true
;
mimeType
=
"text/css"
;
}
else
if
(
suffix
.
equals
(
"html"
)
||
suffix
.
equals
(
"do"
)
||
suffix
.
equals
(
"jsp"
))
{
cache
=
false
;
mimeType
=
"text/html"
;
if
(
session
==
null
)
{
int
todoTest
;
String
hostname
=
req
.
getRemoteHost
();
session
=
server
.
createNewSession
(
hostname
);
if
(!
file
.
equals
(
"notAllowed.jsp"
))
{
file
=
"index.do"
;
}
}
}
else
if
(
suffix
.
equals
(
"js"
))
{
cache
=
true
;
mimeType
=
"text/javascript"
;
}
else
{
cache
=
false
;
mimeType
=
"text/html"
;
file
=
"error.jsp"
;
server
.
trace
(
"unknown mime type, file "
+
file
);
}
server
.
trace
(
"mimeType="
+
mimeType
);
// parseHeader();
String
ifModifiedSince
=
req
.
getHeader
(
"if-modified-since"
);
testLog
(
"@ifmod="
+
ifModifiedSince
);
server
.
trace
(
file
);
WebThread
app
=
new
WebThread
(
null
,
server
);
if
(
file
.
endsWith
(
".do"
))
{
app
.
setSession
(
session
,
attributes
);
file
=
app
.
process
(
file
);
}
if
(
cache
&&
server
.
getStartDateTime
().
equals
(
ifModifiedSince
))
{
resp
.
sendError
(
HttpServletResponse
.
SC_NOT_MODIFIED
);
bytes
=
null
;
}
else
{
bytes
=
server
.
getFile
(
file
);
}
if
(
bytes
==
null
)
{
resp
.
sendError
(
HttpServletResponse
.
SC_NOT_FOUND
);
try
{
bytes
=
StringUtils
.
utf8Encode
(
"File not found: "
+
file
);
}
catch
(
SQLException
e
)
{
int
todoNotIgnore
;
}
}
else
{
if
(
session
!=
null
&&
file
.
endsWith
(
".jsp"
))
{
String
page
=
StringUtils
.
utf8Decode
(
bytes
);
page
=
PageParser
.
parse
(
server
,
page
,
session
.
map
);
try
{
bytes
=
StringUtils
.
utf8Encode
(
page
);
}
catch
(
SQLException
e
)
{
int
todoNotIgnore
;
}
}
resp
.
setContentType
(
mimeType
);
if
(!
cache
)
{
resp
.
setHeader
(
"Cache-Control"
,
"no-cache"
);
}
else
{
resp
.
setHeader
(
"Cache-Control"
,
"max-age=10"
);
resp
.
setHeader
(
"Last-Modified"
,
server
.
getStartDateTime
());
}
}
if
(
bytes
!=
null
)
{
ServletOutputStream
out
=
resp
.
getOutputStream
();
out
.
write
(
bytes
);
}
}
private
void
trace
(
String
s
)
{
int
todo
;
System
.
out
.
println
(
"## "
+
s
);
}
protected
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
doGet
(
req
,
resp
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论