提交 8dabf1e3 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 42e01bf9
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
javac=javac javac=javac
benchmark.drivers.dir=D\:/data/java benchmark.drivers.dir=D\:/data/java
version.name.maven=1.0.20070617 version.name.maven=1.0.20070617
path.servlet.jar=C\:/data/classpath/servlet-api-2.3.jar
jdk=1.4 jdk=1.4
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<property file="ant-build.properties" /> <property file="ant-build.properties" />
<path id="benchmark.drivers.path">
<!-- jar files required by the benchmark --> <!-- jar files required by the benchmark -->
<path id="benchmark.drivers.path">
<pathelement location="bin"/> <pathelement location="bin"/>
<pathelement path="${java.class.path}/"/> <pathelement path="${java.class.path}/"/>
<fileset dir="${benchmark.drivers.dir}"> <fileset dir="${benchmark.drivers.dir}">
...@@ -38,7 +38,7 @@ ...@@ -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> <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>
<target name="clean"> <target name="clean" depends="init">
<mkdir dir="bin"/> <mkdir dir="bin"/>
<mkdir dir="odbc"/> <mkdir dir="odbc"/>
<mkdir dir="docs"/> <mkdir dir="docs"/>
...@@ -52,11 +52,11 @@ ...@@ -52,11 +52,11 @@
<delete file="src/tools/org/h2/tools/code/CodeSwitch.class"/> <delete file="src/tools/org/h2/tools/code/CodeSwitch.class"/>
</target> </target>
<target name="codeswitch_prepare"> <target name="codeswitchPrepare">
<javac executable="${javac}" srcdir="src/tools" debug="true" includes="org/h2/tools/code/CodeSwitch.java"/> <javac executable="${javac}" srcdir="src/tools" debug="true" includes="org/h2/tools/code/CodeSwitch.java"/>
</target> </target>
<target name="codeswitch_jdk13" depends="codeswitch_prepare"> <target name="codeswitchJdk13" depends="codeswitchPrepare">
<propertyfile file="ant-build.properties"> <propertyfile file="ant-build.properties">
<entry key="jdk" value="1.3" /> <entry key="jdk" value="1.3" />
</propertyfile> </propertyfile>
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</java> </java>
</target> </target>
<target name="codeswitch_jdk14" depends="codeswitch_prepare"> <target name="codeswitchJdk14" depends="codeswitchPrepare">
<propertyfile file="ant-build.properties"> <propertyfile file="ant-build.properties">
<entry key="jdk" value="1.4" /> <entry key="jdk" value="1.4" />
</propertyfile> </propertyfile>
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</java> </java>
</target> </target>
<target name="codeswitch_jdk16" depends="codeswitch_prepare"> <target name="codeswitchJdk16" depends="codeswitchPrepare">
<propertyfile file="ant-build.properties"> <propertyfile file="ant-build.properties">
<entry key="jdk" value="1.6" /> <entry key="jdk" value="1.6" />
</propertyfile> </propertyfile>
...@@ -95,10 +95,24 @@ ...@@ -95,10 +95,24 @@
</delete> </delete>
</target> </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"> <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/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/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"/> <unzip src="src/systray/systray4j.jar" dest="bin"/>
<javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="src/systray" destdir="bin" debug="true"/> <javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="src/systray" destdir="bin" debug="true"/>
<copy todir="bin" overwrite="true"> <copy todir="bin" overwrite="true">
...@@ -138,32 +152,11 @@ ...@@ -138,32 +152,11 @@
<java classname="org.h2.tools.doc.SpellChecker" classpath="bin"/> <java classname="org.h2.tools.doc.SpellChecker" classpath="bin"/>
</target> </target>
<target name="gcj" depends="compileResources"> <target name="init">
<copy todir="bin"> <available file="${path.servlet.jar}" property="servlet.jar.present"/>
<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> </target>
<target name="jar" depends="compile"> <target name="jar" depends="compile, compileServlet">
<mkdir dir="bin/META-INF"/> <mkdir dir="bin/META-INF"/>
<manifest file="bin/META-INF/MANIFEST.MF"> <manifest file="bin/META-INF/MANIFEST.MF">
<!-- <!--
...@@ -279,6 +272,12 @@ ...@@ -279,6 +272,12 @@
</java> </java>
</target> </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"> <target name="zip">
<zip destfile="../h2.zip"> <zip destfile="../h2.zip">
<fileset dir=".." includes="h2/build.xml"/> <fileset dir=".." includes="h2/build.xml"/>
......
...@@ -93,6 +93,23 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -93,6 +93,23 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
test.printSystem(); 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 h2 console system tray: menu item to open window
Set h2.indexNew to false Set h2.indexNew to false
......
<html>
<head>
<title>H2 Console</title>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=console/">
</head>
<body>
<a href="console/">H2 Console</a>
</body>
</html>
<?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>
package org.h2.tools.servlet; package org.h2.server.web;
import javax.servlet.*; import javax.servlet.*;
import java.sql.*; import java.sql.*;
public class DbStarter implements ServletContextListener { public class DbStarter implements ServletContextListener {
private Connection conn; private Connection conn;
public void contextInitialized(ServletContextEvent servletContextEvent) { public void contextInitialized(ServletContextEvent servletContextEvent) {
......
/*
* 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论