星期二, 十二月 21, 2004
如何编写Jboss startup Service
编写在启动Jboss的时候就开始启动或服务的Bean.
星期五, 十二月 17, 2004
星期四, 十二月 16, 2004
星期三, 十二月 15, 2004
是XMLHTTPRequest还是XML-PRC?
http://jsolait.net/examples/xmlrpc/
目前IE和FireFox 1.0都支持XMLHTTPRequest方法来时间简单的javascript
->java之间的交换.
XML-RPC可以在Javascript中调用?
Java平台下的压力测试工具
.今天TTS上的压力测试工具看起来好像不错.
GPL的软件,可以打包在自己的工具箱里.
http://www.jcrawler.com
星期五, 十二月 10, 2004
Maven 1.2 命令行语法一览表
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2
可用的 [Plugins] / 目标
===========================
genapp ......................... 基于模板来产生应用程序
jdiff .......................... 生成两个版本之间API的不同的报告
junitdoclet .................... 生成单元测试
注意:[]之间的关键词表示maven 后跟随的目标名称,后续的名称表示子项目
比如:maven abbot editor.
[abbot] 运行修道士(abbot)测试
editor ......................... 调用修道士costello编辑器
editor-webstart ................ 调用修道士costello编辑器在一个WebStart应用里
test ........................... 运行修道士(abbot)测试
test-webstart .................. 运行测试在一个webstart引用上
[announcement] 生成发布声明
generate ....................... 生成发布声明
generate-all ................... 生成发布声明对所有的发布
mail ........................... 发送一个包含发布生命的Email
[ant] 生成ant build.xml文件
generate-build ................. 生成ant build.xml文件
[antlr] ( 没有缺省的目标 )
generate ....................... 根据antlr语法生成源代码
prepare-filesystem ............. 为altlr处理生成所有必须的字典
[appserver] ( 没有缺省的目标 )
clean .......................... 安全的删除一个已经安装的AppServer实例
cycle .......................... 强迫安装和启动一个appserver实例
init ........................... 初始化plugin必须的资源
install ........................ 安装一个appserver实例
reinstall ...................... 重安装一个appserver实例
restart ........................ 重新启动一个appserver实例
start .......................... 启动一个appserver实例
stop ........................... 停止一个appserver实例
[artifact] ( 没有缺省的目标 )
[ashkelon] ( 没有缺省的目标 )
[aspectj] Weave with AspectJ
compile ........................ Weave classes with AspectJ
test-compile ................... Weave tests with AspectJ
[aspectwerkz] ( 没有缺省的目标 )
attributec ..................... Compile AspectWerkz javadoc attributes (
xml-defined aspects)
compile ........................ Compile AspectWerkz java sources
weave .......................... Weave aspects (offline mode)
[castor] ( 没有缺省的目标 )
prepare-filesystem ............. 准备所有必须的字典为 castor 处理
[changelog] ( 没有缺省的目标 )
[changes] ( 没有缺省的目标 )
report ......................... 生成改变报告
[checkstyle] 执行 checkstyle 检查
report ......................... 执行 checkstyle 检查
[clean] 删除所有项目部件
clean .......................... 删除所有项目部件
[clover] 使用Clover生成测试覆盖率报告
html-report .................... Generate HTML test coverage reports with
Clover
off ............................ Deactivates Clover
on ............................. Activates Clover
report ......................... Generates the Clover reports
swing-report ................... Generate Swing test coverage reports with
Clover
test ........................... Compile project code with Clover and
executes the unit tests
test-single .................... Compile code with Clover and execute a
single unit test
xml-report ..................... Generate XML test coverage reports with
Clover
[console] 运行Maven控制台
help ........................... 打印帮助信息
listGoals ...................... 列出所有可用目标
[cruisecontrol] ( 没有缺省的目标 )
configure ...................... 更新Cruise 控制配置文件
run ............................ 运行Cruise控制
[dashboard] 生成仪表板报告
report ......................... 生成仪表板报告
[dist] 建立完整的配送.
build .......................... 建立完整的配送.
build-bin ...................... 建立二进制的配送.
build-setup .................... 配置建立陪送的目录
build-src ...................... 建立源代码配送.
deploy ......................... 发布一个配送
deploy-bin ..................... 发布一个二进制配送
deploy-bin-snapshot ............ 发布一个二进制配送
deploy-snapshot ................ 发布一个快照配送
deploy-src ..................... 发布一个源代码配送
deploy-src-snapshot ............ 发布一个源代码配送
prepare-bin-filesystem ......... 建立二进制的配送文件系统.
prepare-src-filesystem ......... 建立源代码的配送
[docbook] ( 没有缺省的目标 )
transform ...................... Transform any docbook-simple source into
xdocs for later use
[ear] 建立一个ear文件
deploy ......................... 发布ear 到远程知识库
deploy-snapshot ................ 发布快照版本的ear到远程知识库
ear ............................ 建立一个ear文件
generate-ear-descriptor ........ 生成 ear描述
init ........................... 初始化ear需要的文件系统和其他资源
install ........................ 在本地知识库里安装ear
install-snapshot ............... 安装快照版本的ear在本地知识库里
[eclipse] 生成Eclipse项目文件
add-maven-repo ................. 确定classpath变量MAVEN_REPO
clean .......................... 清除eclipse生成的文件
external-tools ................. 为每种目标生成一个Eclipse外部工具
external-tools-21 .............. 为每种目标生成一个Eclipse 2.1 外部工具
generate-classpath ............. 生成Eclipse .classpath 文件
generate-project ............... 生成Eclipse .project文件
[ejb] 建立一个ejb文件
deploy ......................... 发布ejb到远程知识库
deploy-client .................. 发布ejb client到远程知识库
deploy-snapshot ................ 发布快照版本的ejb到远程知识库
ejb ............................ 建立一个ejb文件
ejb-client ..................... 建立一个client ejb文件
init ........................... 为建立ejb初始文件系统和其他资源
install ........................ 在本地知识库安装ejb
install-client ................. 在本地知识库安装ejb client
install-snapshot ............... 在本地知识库安装快照版本的ejb
[faq] 从FAQ XML生成FAQ xdoc文件
[fo] This simply pre-requisites the fo:fo goal.
fo ............................. Generates an fo xml document from the ${
maven.pdf.navigationFile} file supplied as
part of the documentation.
[gump] Generate Gump descriptor from Maven
descriptor
generate-descriptor ............ Generate Gump descriptor from Maven
descriptor
[hibernate] ( 没有缺省的目标 )
aggregate-mappings ............. Aggregate multiple .hbm.xml files into one
file
schema-export .................. Export Hibernate schema
[html2xdoc] Generates XDoc documentation from normal
HTML files
transform ...................... Performs the html to xdoc transformation
[idea] Generate IDEA project files
idea ........................... Generate IDEA .ipr, .iml and .iws project
files
module ......................... Generate IDEA .iml project files
project ........................ Generate IDEA .ipr project files
workspace ...................... Generate IDEA .iws project files
[j2ee] Check that a war file is valid
validate-war ................... Check that a war file is valid
[jalopy] Format all sources with code convention
conformance
format ......................... Format all sources with code convention
conformance
taskdef ........................ Define the jalopy task to Ant and Jelly
[jar] Create the deliverable jar file.
deploy ......................... Deploy a jar to the remote repository
deploy-snapshot ................ Deploy a snapshot jar to the remote
repository
install ........................ Install the jar in the local repository
install-snapshot ............... Install a snapshot jar in the local
repository
jar ............................ Create the deliverable jar file.
snapshot ....................... Create a snapshot jar, ie '
id-YYYYMMDD.hhmmss.jar'
[java] ( 没有缺省的目标 )
compile ........................ Compile the project
jar ............................ Create the deliverable jar file.
jar-resources .................. Copy any resources that must be present in
the deployed JAR file
prepare-filesystem ............. Create the directory structure needed to
compile
[javacc] ( 没有缺省的目标 )
javacc-generate ................ Generate source from javacc grammar
[javadoc] ( 没有缺省的目标 )
deploy ......................... Deploys the jar containing javadoc to the
remote repository
deploy-snapshot ................ Deploys the snapshot version of jar
containing javadoc to remote repository
install ........................ Install the jar containing javadoc in the
local repository
install-snapshot ............... Install the snapshot version of the jar
containing javadoc in the local repository
[jboss] 生成特定的JBoss server配置文件
configure ...................... 建立特定的JBoss Server配置
deploy-ear ..................... 发布${maven.final.name}.ear
deploy-ejb ..................... 发布${maven.final.name}.jar
deploy-exploded-warfile ........ 调用'war:webapp' 目标并且发布结果
说明'maven.war.webapp.dir' 必须用.war结尾
deploy-warfile ................. 调用'war' 目标并且发布结果
dist ........................... 生成zipped JBoss配置
install ........................ 安装zip到本地知识库
package ........................ 建立制定JBoss Server的配置
start .......................... 启动JBoss 使用我们制定的Server配置
stop ........................... 停止JBoss
undeploy-ear ................... 卸载 ${maven.final.name}.ear
undeploy-ejb ................... 卸载${maven.final.name}.jar
undeploy-exploded-warfile ...... 卸载'war:webapp' 必须用.war文件结尾
undeploy-warfile ............... 卸载the result of the 'war' goal
[jbuilder] 生成JBuilder项目文件
generate-library ............... 生成JBuilder[id_project].library文件
generate-project ............... 生成JBuilder [id_project].jpx文件
[jcoverage] Generate HTML test coverage reports with
JCoverage
html-report .................... Generate HTML test coverage reports with
JCoverage
merge .......................... Merge two or more instrumentation files
into one
on ............................. perform the coverage analysis
[jdee] Generate JDEE project file
generate-project ............... Generate project file in basedir
[jdeveloper] Generate JDeveloper project files
generate-project ............... Generate jdeveloper .jpr
scanSources .................... Scans the source in order to integrate them
into JDeveloper files
[jellydoc] Generates the tag documentation
doclet ......................... A doclet which outputs all the Jelly tag
related metadata as XML
xml-doclet ..................... Creates an XML representation of the doclet
information
[jetty] Run Jetty
config ......................... Generate a Jetty configuration file
run ............................ Run Jetty
run-war ........................ Run Jetty on the current war project
[jnlp] Generate JNLP file and sign all jars
generate-jnlp .................. Generate the .jnlp file and sign all jars
generate-keystore .............. Generate a keystore file
init ........................... Initialize jnlp plugin
[junit-report] ( 没有缺省的目标 )
report ......................... Generate a report from the test results
[latex] ( 没有缺省的目标 )
generate ....................... Generate documentation from latex source
prepare-filesystem ............. Prepare the filesystem for latex processing
[latka] Run the project's latka tests
jmeter-convert ................. Convert a jmeter jmx file to a latka suite
single ......................... Execute a single test defined using the '
testcase' variable
test ........................... Run the project's latka tests
[license] Generate an XML file from the license file
transfer ....................... Generate a xml file from your license file
[maven-ashkelon-plugin] ( 没有缺省的目标 )
[maven-changelog-plugin] ( 没有缺省的目标 )
report ......................... Generate a changelog report
[maven-changes-plugin] ( 没有缺省的目标 )
[maven-checkstyle-plugin] ( 没有缺省的目标 )
[maven-clover-plugin] ( 没有缺省的目标 )
[maven-cruisecontrol-plugin] ( 没有缺省的目标 )
[maven-dashboard-plugin] ( 没有缺省的目标 )
[maven-developer-activity-plugin] ( 没有缺省的目标 )
report ......................... Generate developer and file activity reports
[maven-faq-plugin] ( 没有缺省的目标 )
report ......................... Generate FAQs
[maven-file-activity-plugin] ( 没有缺省的目标 )
report ......................... Generate developer and file activity reports
[maven-javadoc-plugin] ( 没有缺省的目标 )
report ......................... Generate API documentation
[maven-jcoverage-plugin] ( 没有缺省的目标 )
deregister ..................... Deregister the jcoverage plugin
register ....................... Register the maven-jcoverage-plugin.
report ......................... Run the default report (html).
[maven-jdepend-plugin] ( 没有缺省的目标 )
report ......................... Generate a dependency report with JDepend
[maven-jdiff-plugin] ( 没有缺省的目标 )
report ......................... Generate an api difference report between
versions
[maven-jellydoc-plugin] ( 没有缺省的目标 )
report ......................... Generates the tag documentation
[maven-jira-plugin] ( 没有缺省的目标 )
report ......................... Generate report with all entries defined in
Jira
[maven-junit-report-plugin] ( 没有缺省的目标 )
[maven-jxr-plugin] ( 没有缺省的目标 )
report ......................... Generate HTML cross reference sources
[maven-license-plugin] ( 没有缺省的目标 )
report ......................... Generate an XML file from the license.txt
[maven-linkcheck-plugin] ( 没有缺省的目标 )
clearcache ..................... Removes the cache file
report-real .................... Generate link check results and then
transform to HTML
[maven-multichanges-plugin] ( 没有缺省的目标 )
[maven-multiproject-plugin] ( 没有缺省的目标 )
[maven-pmd-plugin] ( 没有缺省的目标 )
[maven-simian-plugin] Generate Simian (Code Similarity Analyzer)
report.
[maven-tasklist-plugin] ( 没有缺省的目标 )
report ......................... Generate a list of tasks from @todo tags in
your code
[multichanges] ( 没有缺省的目标 )
[multiproject] Run the site goal of all subprojects and
generate overview page
artifact ....................... Builds all artifacts for all subproject
clean .......................... Clean all subprojects
dependency-convergence-report .. Generate report which shows how consistent
are the versions of artitfacts between
projects
deploy ......................... Run 'artifact':deploy for all subprojects
deploy-snapshot ................ Run 'artifact':deploy-snapshot for all
subprojects
goal ........................... Run a given goal on all projects
install ........................ Run 'artifact':install for all subprojects
install-snapshot ............... Run 'artifact':install-snapshot for all
subprojects
site ........................... Run the site goal of all subprojects and
generate overview page
[native] Native compiler
compile ........................ Compile the native compiler
install ........................ Install the lib in the local repository
jniheader ...................... make jniheaders for classes
[nsis] Generate NSIS Installer .exe
generate-project ............... Generate NSIS project.nsh file
generate-setup ................. Generate NSIS .nsi file
installer ...................... Generate NSIS .exe file
[pdf] This is the default goal of the plugin and
simply pre-requisites the pdf:pdf goal.
pdf ............................ Generates a PDF document containing all
project documentation. The PDF is generated
from the .fo file generated in the fo:fo
goal.
prepare ........................ Stages all files needed to generate the PDF
[plugin] Build a plugin jar
download ....................... download and install a plugin from a remote
repo
download-artifact .............. download a plugin from a remote repo
generate-docs .................. Generate navigation, goals and properties
docs
generate-goals ................. Generate goals.xml for the plugin
generate-navigation ............ Generate navigation.xml for the plugin
generate-properties ............ Generate properties.xml for the plugin
install ........................ Install the plugin jar, prepare Maven to
expand it locally and clear caches
install-now .................... Build a plugin and load it into the
currently running instance of Maven.
plugin ......................... Build a plugin jar
uninstall ...................... Uninstall all versions of the plugin
uninstall-now .................. Uninstall all versions of the plugin,
including those in the currently running
instance of Maven
[pmd] Static Code Analyzer
cpd-report ..................... Generate duplicate source code report with
CPD
report ......................... Generate source code report with PMD
[pom] Validate the Maven XML project descriptor
contentvalidate ................ Validate the content of the Maven POM
deploy ......................... Deploy POM to the central repository.
deploy-snapshot ................ Deploys the snapshot version of the POM to
remote repository
install ........................ Install POM in the local repository.
install-snapshot ............... Install the snapshot version of the POM in
the local repository
validate ....................... Validate the Maven XML project descriptor
[rar] Build a rar file
deploy ......................... Deploys the rar to the remote repository
deploy-snapshot ................ Deploys the snapshot version of the rar to
remote repository
init ........................... Initialise filesystem and other resources
for a rar
install ........................ Install the rar in the local repository
install-snapshot ............... Install the snapshot version of the rar in
the local repository
load ........................... no-op goal
rar ............................ Build a rar file
[release] ( 没有缺省的目标 )
[repository] ( 没有缺省的目标 )
audit-copy-license ............. copy the license for the specified groupId
to the repository
audit-copy-licenses ............ copy all licenses in the audit file to the
repository
audit-create-directory ......... create the directory, specified by
directoryName, for all groups in the audit
file
audit-create-licenses .......... create the license directories, for all
groups in the audit file, in the repository
audit-generate-pom ............. generate a pom for the groupId provided,
based on the audit file
audit-generate-poms ............ generate a pom for all the groupId's in the
audit file
audit-rename-licenses .......... rename/link all licenses from their
original name to ${groupId}.license
copy-artifact .................. copy an artifact, specified by groupId,
artifact and type, to the repository
copy-jar ....................... copy a jar, specified by groupId and
artifact, to the repository
copy-snapshot-jar .............. copy a snapshot jar, specified by groupId
and artifact, to the repository
create-project ................. create a project, specified by groupId, in
the repository
delete-project ................. delete a project, specified by groupId, in
the repository
[scm] ( 没有缺省的目标 )
bootstrap-project .............. Bootstrap a project from SCM
checkout-project ............... Checkout a project
perform-release ................ Perform a release from SCM
prepare-release ................ Prepare for a release in SCM
update-project ................. Update a project from SCM
[shell] Generate Zsh files
zsh ............................ Generate Zsh files
[site] Generate the web site
deploy ......................... deploy the generated site docs
ear ............................ Create an EAR File from the generated site
fsdeploy ....................... Deploy the generated site by copying to the
site directory
ftpdeploy ...................... Deploy the generated site docs using ftp
sshdeploy ...................... Deploy the generated site docs using ssh
war ............................ Create a WAR File from the generated site
[struts] Ensure a war file containing a Struts
application is valid
validate-war ................... Ensure a war file containing a Struts
application is valid
[test] Test the application
compile ........................ Compile the TestCases and TestSuites
match .......................... Execute all the tests matching the given '
testmatch' variable
match-test ..................... [deprecated] please use the test:match goal
instead
prepare-filesystem ............. Create the needed directory structure
single ......................... Execute a single test defined using the '
testcase' variable
single-test .................... [deprecated] please use the test:single
goal instead
test ........................... Test the application
test-resources ................. Copy any resources that must be present for
run tests
ui ............................. Starts the Swing TestRunner front end
[tjdo] Enhance classes for use with Triactive JDO
drop-tables .................... Drops the tables managed by Triactive JDO.
enhance ........................ Provides the enhancement of classes to use
TJDO for persistence
[uberjar] Build a uberjar file
classworlds-conf ............... Generates a classworlds conf
deploy ......................... Deploys the uberjar to the remote repository
deploy-snapshot ................ Deploys the snapshot version of the
uberjar to remote repository
install ........................ Install the uberjar in the local repository
install-snapshot ............... Install the snapshot version of the uberjar
in the local repository
uberjar ........................ Build an uberjar
[war] Build a war file
clean .......................... Remove all artifacts created by war plugin
deploy ......................... Deploys the war to the remote repository
deploy-snapshot ................ Deploys the snapshot version of the war to
remote repository
inplace ........................ Deploy a webapp into maven.war.src - in
particular setting up WEB-INF/lib and
WEB-INF/classes
install ........................ Install the war in the local repository
install-snapshot ............... Install the snapshot version of the war in
the local repository
war ............................ Build a war file
war-resources .................. Copy webapp resources to target directory
webapp ......................... Build a webapp directory
[webserver] ( 没有缺省的目标 )
clean .......................... Safely delete an installed webserver
instance
cycle .......................... Forced install and start of a webserver
instance
init ........................... Initialize resources needed for the plugin
install ........................ Install a webserver instance
reinstall ...................... Reinstall a webserver instance
restart ........................ Restart a webserver instance
start .......................... Start a webserver instance
stop ........................... Stop a webserver instance
[wizard] ( 没有缺省的目标 )
ui ............................. Run the Maven Swing Wizard
[xdoc] Generate html project documentation xdoc
sources
copy-resources ................. copy static resources for use in xdocs
generated html
copy-user-resources ............ Copy user provided resources to docs
destination
generate-from-pom .............. Generates xdocs for site based on project
descriptor
init ........................... Generates the directory structure required
for xdocs
jelly-init ..................... Set up jelly xdoc requirements
jelly-transform ................ transform xdocs using jelly/jsl rather than
dvsl
performJSL ..................... Allows the LinkCheck plugin to xdoc a
single directory
transform ...................... Generate html project documentation xdoc
sources
validate ....................... Validate xdocs match the schema
今天开始学习Maven(专家,内行) Project Management Tools.
都要看大量的文档来牢记标记的语法.
可Groovy组里大家都在热烈的讨论Maven,this is too irritating.
我只好下载了maven 1.2 开始试用.免得被"边缘化"了.:).
简单翻译并记录中间看的资料吧.
1.首先下载.
http://maven.apache.org/
2.然后看帮助:
http://maven.apache.org/start/index.html
3.然后看如何使用:
http://maven.apache.org/start/use.html
在windowsXP下运行.
maven jar 和Maven site:generate
竟然连接到网络上下载了一堆的jar包,让我印象极坏.:(.
4.然后记录如何使用Maven来同Jbuilder和Jboss如何协作工作的经验了.
Very Large Scale Integration 超大规模集成Java实现
下载了看看了.
UI方面非常丑陋.不过竟然已经到了8.0了.看来用的人很多吧.
jar包下载的地址:http://ftp.gnu.org/pub/gnu/electric/
星期三, 十二月 08, 2004
星期六, 十二月 04, 2004
如何关闭最顶级IE窗口,避免提示确认的麻烦?
问题:如果非window.open打开的窗口用window.close();或self.close()关闭,由于安全理由.
IE会提示你确认是否关闭.在B/S应用中这是非常麻烦的,因为它可能改变导航的流程.
所以必须可以用javascript直接关掉.以下代码在IE6.0SP2上测试通过.
加红色的字是关键语句
<script>
function closeself()
{
opener='"';
}
</script>
<body onload="closeself()">
<h1>Welcome</h1><a href="javascript:window.close();">close</a>
<a href="javascript:opennew();">open</a>
<script>
function opennew(){
aw=window.open("2.html","aaa");
aw.opener=this;
}
</script>
星期四, 十二月 02, 2004
在MYSQL中如何得到group by对应最大值的哪条记录呢?
SELECT article, dealer, price
FROM shop s1
WHERE price=(SELECT MAX(s2.price)
FROM shop s2
WHERE s1.article = s2.article);
在Mysql 4.1 以下的版本,不支持嵌套select的使用,所以你必须想别的的办法如下:
通过 "MAX-CONTACT 跳票"模式来实现.
SUBSTRING(MAX(CONTACT(Fileld_name_with_max_value,other FIled)),length(Fileld_name_with_max_value));
如此递归,则可以把包含最大值字段对应的记录的其他字段的值都读出来了.
一个实际的例子:
SELECT empid,substring(max(concat(effectivedate,paycatagorycode)),11) as paycatagorycode,max(effectivedate) as effectivedate,substring(max(concat(effectivedate,basicSalary)),11) as basicSalary, substring(max(concat(effectivedate,bankBranchCode)),11) as bankBranchCode, substring(max(concat(effectivedate,currencyCode)),11) as currencyCode, substring(max(concat(effectivedate,payCatagoryCode)),11) as payCatagoryCode,substring(max(concat(effectivedate,salaryPolicyType)),11) as salaryPolicyType,substring(max(concat(effectivedate,remarks)),11) as remarks FROM emp_M_SalaryBasicInfo group by empid
星期三, 十二月 01, 2004
如何制作Intel主板启动splash Screen
建立USB 启动U盘及更新Intel BIOS Splash Screen 启动画面
我的主板是Intel 865PERL,以下以此主板为例。
由于Intel BIOS Splash Screen更新目前只能在DOS下进行,所以首先建立一个可以启动的DOS盘是必备条件.但目前很多机器支持USB启动,而没有安装软驱。所以要完成BIOS启动画面的更新有几种方法可以选择:
a. 光碟启动到DOS下.访问U盘,并更新BIOS
b. U盘直接启动,完成升级BIOS任务.
以下为如何制作从U盘启动升级BIOS启动画面的过程
1. 建立可启动U盘.
目前最好用的工具当属HP公司的HP USB Disk Storage Format Tool
据说Ghost 2003也可以制作U盘启动盘,没有用过,不确定.
下载: http://h18007.www1.hp.com/support/files/hpcpqdt/us/download/20306.html
用HP的工具来制作启动U盘,需要准备好DOS的几个启动文件
io.sys,command.com和msdos.sys几个文件
MSDOS的启动文件包可以从这里下载:
http://www.nu2.nu/bootdisk/network/
将U盘插上后,启动HP Format工具,并指定MSDOS文件存放的目录,就可以格式化U盘了,HP Format会自动检测文件是否齐全.这样就可以制作可启动的U盘了.
2. Enabled USB BOOT.
必须在CMOS中允许通过USB启动.Intel主板是按下F2进入BIOS设置.
这步完成后,可以测试一下U盘确实可以启动,然后再进行下面的步骤.
c. 下载Intel(R) Integrator Toolkit
http://www.intel.com/design/motherbd/itk.htm
1. Intel Iflash BIOS Update 下载
http://www.intel.com/design/motherbd/genbios.htm 选择你对应的Intel主板类型。不要选择错了!下载Iflash版本,不要下载Express版本.
下载的.exe文件可以用winrar打开.
sw.exe 是个包文件.P19-0085.ITK是Intel(R) Integrator Toolkit需要的文件
SW.EXE 包含我们需要的主板BIO文件P19-0085.BIO和更新BIOS的主要程序IFLASH.EXE文件。如图
2. 制作定制的包含新的启动屏幕BIOS
重要提示:首先准备一份BIOS恢复盘.将SW展开的文件全部复制到软盘上,如上图.
Intel(R) Integrator Toolkit 的具体操作可以参看所带的chm帮助,进入主界面后,找到定制启动屏幕的BIOS选项,如图:
选择Edit Module后,出现图形编辑界面,你可以选择你要作为splash screen的图片;
注意:经过实验Intel 865PERL支持4位(16色),8位(256色),24位(16M颜色)的格式图片,要注意的是不能使用压缩的图片.如果用BMP必须画笔保存为16/256/24位颜色的DIB格式的BMP图片.
如果用JPG必须要采用最佳质量的图片!用PS保存的JPG质量最佳图片,如果保留了调色板信息,最好用Acesee再保存一次,去掉有关调色板的信息.
图片的大小不要超过BIOS的空间,如果超出空间,在状态栏上会出现红色的提示.容量大小会超过100%.如果出现红色提示,必须缩减图片大小
然后在File菜单中生成ini文件和BIO文件,在从Tools菜单里选择Generate Media在指定的USB启动盘或软盘上生成更新所要的ini和BIO文件及启动的autoexec.bat文件.
重新启动机器,从USB或软盘引导就开始了更新,更新完成后,机器启动,然后在黑屏下可以听到
10声喇叭的声音.然后机器会关闭。拿出软盘或USB启动盘,
重新启动后,就可以看到新的启动屏幕了。
JPG 24色的图的大小远小于DIB格式的BMP图片,所以采用JPG是最优选择.
重要提示
如果更新的时候因为掉电等原因机器不能再启动,必须首先拔掉主板上BIOS设置的三脚的跳线把模式设置为Recovery Model,启动机器会从软盘引导,插入准备好的BIOS恢复软片,就可以恢复BIOS了.
这是我的主板BIOS启动画面,24位JPG,78K,我去掉了所有网卡启动的有关BIOS.
Javascript文件操作Exception
function writeData()
{
try
{
//alert(counterValue);
var dataFileObj = fsObj.createtextfile(DataFile, true);
dataFileObj.WriteLine(status);
dataFileObj.Close();
return(true);
}
catch (err)
{
return(false);
}
}
function init()
{
try
{
this.fsObj = new ActiveXObject('Scripting.FileSystemObject');
}
catch (err) {
msg="";
for(var i in err)msg=i+":"+err[i];
alert(msg);
}
if (this.fsObj != null)
{
if (!writeData())alert('写数据时候有错误发生');
}
}
</script>
星期一, 十一月 29, 2004
Java Session setAttribute 不能传递HTML tag的问题.
1.服务器Servlet里,使用:
request.getSession().setAttribute("statusMsg",
java.net.
URLEncoder.encode(
debugMsg.toString(), "UTF-8"));
2.在JSP 里使用:
<%=java.net.URLDecoder.decode((String)request.getSession().getAttribute("statusMsg"),"UTF-8")%>
JAVA中如何计算时间差.
得到两个时间之间的所差时钟数目(MillionSecond ,nanoseconds),然后根据需要输出的结果
计算并格式化数据.
Example:
import java.util.*;
import java.text.*;
public class Timecalc2 {
public static long MS_SECOND = 1000L;
public static long MS_MINUTE = 60L * MS_SECOND;
public static long MS_HOUR = 60L * MS_MINUTE;
public static long DAY = 24L;
public static long parseDT(String s1, String s2) throws ParseException
{
DateFormat formatter = new SimpleDateFormat("MM.dd.yy HHmm");
Date d1 = formatter.parse(s1);
Date d2 = formatter.parse(s2);
long dateDiff = d2.getTime() - d1.getTime();
return dateDiff;
}
public static String formatMilli(long value)
{
//DecimalFormat is used to display at least two digits
DecimalFormat nf = new DecimalFormat( "00" );
//calculate hours, minutes
long remainder = 0;
long hours = (value / MS_HOUR);
remainder = value % MS_HOUR;
long minutes = remainder / MS_MINUTE;
//build "hh:mm:ss"
StringBuffer buffer = new StringBuffer();
buffer.append(nf.format(hours));
buffer.append( ":" );
buffer.append(nf.format(minutes));
return buffer.toString();
}
public static void main(String[] args)
{
String start = "01.14.03 1730";
String end = "01.17.03 1927";
try
{
long dateDiff = parseDT(start, end);
String answer = formatMilli(dateDiff);
System.out.println(answer);
} catch (ParseException pe)
{
System.out.println("You must use the format: MM.dd.yy HHmm");
}
}
}
星期四, 十一月 25, 2004
如何修改Intel 主板开机画面
1.下载定制工具包:Intel? Integrator Toolkit
URL:
http://www.intel.com/design/motherbd/itk.htm
2.下载对应主板的可生机BIOS.
http://developer.intel.com/design/motherbd/rl/rl_bios.htm
在DOS下执行的.exe文件里有后缀为.TLK的文件.可以用winrar打开.
我的Intel 865PERL主板对应的BIOS为:ftp://download.intel.com/design/motherbd/rl/RL86510A.86A.0085.P19.IB.EXE
3.按照操作.
星期三, 十一月 24, 2004
MySQL 常用命令(1)
1. SHOW INNODB STATUS and the InnoDB Monitors
mysql> SHOW INNODB STATUS\G (Caution:must be end with \G);
2. insert into table(column_name) select clause...
INSERT INTO Table1 (latin1_column) SELECT USER();
3.显示当前MYSQL Version
select version()
星期一, 十一月 22, 2004
书写跨平台代码的一些小技巧
使用File.separator
2.Text文件Line-carriage
Reader in=new Reader(..)
in.readLine().repace(System.getProperty("line.separator"),"&");
System.getProperty("line.separator")在window下为\n\r
Unix/Linux下为:\n
星期六, 十一月 20, 2004
MySQL 4.1 Production Level release!
看来MySQL 加强了开发力量了.真是值的祝贺的事情.
现在可以支持DBCS了通过UTF8和UCS2两种方式.
啊.想当初为了用ISO8859-1来保存DBCS的痛苦了.真是可惜啊.大量的来做ISO-8859-1->UTF8
和UTF8->ISO-8859-1的代码没用了
:(.
星期四, 十一月 11, 2004
Re: [JBoss-user] How to get messages from a remote JMS server
另外一篇文章,详细描述了如何用Jboss MDB 访问webSphere的消息bean
http://sourceforge.net/tracker/index.php?func=detail&aid=753022&group_id=22866&atid=376687
Business Process Management (BPM) Tutorial - What is BPM?
星期一, 十一月 08, 2004
如何在Javascript中得到多纬数族字符串下标
常用的数组用法:
一纬数组用法:
遍历数组:
MyObject=new Array();
MyObject=["a","b","c"];
for(var i=0;i<g;MyObject.length;i++)document.write(Myobject[i]);
多纬数组用法:
遍历数组:
MyObject = new Array();
MyObject[0]=["a","b","c"];
MyObject[10]=["a1","b1","c1"];
for(var i=0;i<g;MyObject[0].length;i++)document.write(Myobject[0][i]);
得到以定义的所有多纬数组的下标:
MyObject = new Array();
MyObject["name"]=["a","b","c"];
MyObject["high"]=["a1","b1","c1"];
用for..in 得到name,和high下标
for (var i in MyObject) {
document.write(i);
结果为:name,high
星期五, 十一月 05, 2004
Amazon Search Bar for FireFOx Enabled.
不过在中国暂时无法使用.
遗憾.
下载地址:
http://toolbar.a9.com/
星期六, 十月 30, 2004
Groovy如何返回值?
groovy将认为会把这个整数或字符串作为结果返回.
比如:test.groovy 包含:
//here is PayItem Business code.
3000;
用groovy.bat test.groovy 得到记过3000
星期三, 十月 13, 2004
如何用Java软件来开发射频身份识别自动识别方案?
原文
如何用Java软件来开发射频身份识别 自动识别方案
本文主要描述怎么使用Sun Java 系统RFID软件来开发RFID解决方案.同时帮助开发人员理解架构,设计和实现.
文章也包括的一个可以下载的应用例子,sampleRFID.同同文档一起的ReadME描述的如何同给定接口编码的细节,并且如何配置平台.
什么是RFID和Auto-ID?
射频身份识或RFID使用射频波来识别唯一对象的一种方法.RFID是对下一代条码技术的需求作出的反应.
用最简单的术语来说,RFID系统有标签(应答器)和阅读器(询问器)组成.RFID技术处理用射频通讯收集储存在标签里的远程信息.
储存在标签里的信息范围从一个表示数字到数K的数据可以被写入和读出,动态的信息比如温度的历史在标签中维护.
自动识别或Auto-ID是一个广泛的术语,包括数据数据的方法和无人工干预直接进入计算机系统.
技术传统上认为Auto-ID的部分包括条码,生物测定学,RFID,和声音识别技术.
Auto-ID 技术提供系列方法用来追踪任何物体,任何时间,任何地点.Auto-ID系统基于上面低花费的聪明标签和阅读器,及唯一的对象表示模式.Auto-ID的目标是可以替代UPC条码系统而使用不贵的RFID标签嵌入到产品包装里.或更加好的方式比如嵌入到产品里面.虽然条码不会很快消失.有许多应用如果使用RFID标签将变的更加复杂和增加成本,而使用条码就比较完美。在可见的将来,将是条码和RFID标签共存的时期.
Auto-ID网络由数个使用Auto-ID系统的贸易伙伴组用来追踪供应链上的项目.这将提供商业上空前的实时资产和任何地方的库存视图.并且能提供有重大意义的商标保护努力.Auto-ID网络提供的好处在于定位伪造,串改,恐怖主义和其他的要求的操作的有效性
标准
EPCglobal是Auto-ID的创造中心.它的标准内容基于EPCglobal网络采用的EPC技术.Epglobal 网络包括一组允许及时,自动标识和共享供应链项目信息的技术.EPCglobal网络使用射频标识(RFID)技术是供应链项目信息可见性成为可能.这个网络有5个基本元素组成:
* 电子产品代码 (EPC)
* ID系统(EPC 标签和阅读器)
* EPC 中间件
* 对象命名服务(ONS)
* 物理标记语言
EPC编号系统:
如同统一产品代码(UPC)或条码,EPC是EPC网络上的物理对象的基本标识.
EPC标识厂商,产品,版本和序列号.并且使用额外的数字组表示唯一项目.
EPC标签数据标准规范版本1.1定义了电子产品代码(EPC)在RFID芯片上的编码.也定义如何被EPC网络信息系统层使用的编码(比如RFID信息服务器).
EPC标签和阅读器和接口协议:
EPC标签是带天线的微芯片.EPC被保存在这个标签里,这是在制造过程就被应用了.
EPC标签使用射频标识(RFID)来传递他们的EPC到EPC阅读器.EPC阅读器同EPC标签通讯通过无线电波并且通过EPC中间件发送信息到本地商业信息系统.
这是Auto-ID阅读器协议规范1.0定义的关于阅读器和EPC中间件的通讯的标准协议.
阅读器管理规范扩展了阅读器协议规范,定义了在大的网络上如何管理RFID的标准.
标签可以分类为被动,主动和半被动的.被动标签没有电池及当有提示的时候简单"反射".而活跃标签自带电池并且是通讯发起者.
半被动标签有一个电池,但是也是属于"反射"通讯.它不会启动一个通讯.
可以想象被动和半被动标签作为一个用来传送光的镜子 ,当有光照在它们上面的时候.今天,EPCglobal网络集中精力在被动标签标准上.我们可以期望EPCNetwork关于积极标签的标准很快建立.
EPC中间件:
EPC 中间件过去也叫做Savant.它是关于实时事件管理,EPC数据过滤和收集规范的标准.它覆盖了新的EPCglobal规范,当前作为过滤和收集规范的参考.
EPC信息服务:
EPC信息服务允许用户同使用EPC的商业伙伴交换数据
对象命名服务(ONS):
给你能力来定位包含关于世界上特定任何地方EPC信息的服务器.商业信息系统需要一种方法匹配EPC和货物关联的信息.
ONS是提供通过指明在www上的计算机来提供自动的网络服务.它为包含产品属性及相关属性被维护的的IP地址制定了一个标准.
物理标志语言:(PML)
用做通用语言在EPCglobal网络中,用来定义物理对象的数据.PML的目标是提供一般收集,标准表达词汇和分布信息到
EPC网络可用的对象.PML 核心规范1.0定义了PML标准.
介绍Sun Java 系统RFID软件.
Sun Java系统RFID软件是Sun唯一RFID中件间平台提供提供基于广泛被接受的工业标准也包括在EPCglobal中定义的标准.
它为公司使用EPC网络提供了一个基础. 它的设计规范是提供一个高层次高可靠性和扩充能力的EPC网络同时可以简化同多个
已经存在的后台企业系统整合的任务
Sun java系统RFID软件负责在EPC阅读器和标签之间的EPC数据和事件的通讯和处理,及后台供应链系统ERP.和RFID软件包含
两个基本的部件:1).RFID事件管理 2)RFID信息服务器.两个都可以下载.这两个组件基于Jini 2.0,Rio 3.0.1,及Java Web Service Developer pack 1.3和Sun Application server 7构造.
*RFID事件管理器同EPC标签阅读器通讯来出来大量的EPC数据进入系统.事件管理器也同后台系统通讯并向RFID信息服务器记录
EPC数据和事件.RFID事件管理器是Jnin-Based的事件管理系统.它容易铺捉,过滤和保存由连接到网络上的RFID阅读器产生的EPC事件.
它的主要目标是同RFID阅读器的接口,收集EPC事件,过滤多余信息,并且产生送往迎来RFID信息服务器的相关事件或者其他
EPR软件以备处理.RFID事件管理器Jini服务通过Rio被管理,Rio是一个开源的Jini服务组件包容器.
*RFID信息服务器负责储存和聚集围绕给定的EPC事件关系的业务数据.RFID信息服务器J2EE应用用做一个接口来俘获和查询EPC
相关数据.EPC相关数据包括:来自事件管理器的检查数据也包括映射EPCS到较高级别的商业数据的信息.
RFID 信息服务器是典型的用来转换低级检查到高级商业功能.RFID信息服务器运行在Sun Java系统Application Server 7.
其他信息系统应用接口通过XML信息交换.信息系统支持HTTP和JMS信息输送.
信息系统保存所有数据到关系数据库中.
这两个组件扮演了关键的角色在EPCglobalo 定义的EPC网络中
Sun Java系统RFID软件技术描述
Sun Java 系统RFID事件管理器收集RFID阅读器的信息,过滤信息并且提供大量的信息到RFID信息服务器或第三方的ERP系统.
Figure 1 描述 RFID事件管理器和RFID信息服务器怎样适合EPC Global网络
Figure 1: Sun Java System RFID软件和EPCglobal网络
RFID事件管理器由控制工作站和一个或多个执行代理组成在图2中描述
Figure 2: Sun Java System RFID事件管理器架构
计算机系统可以运行一个或多个执行代理并且每个执行代理可以完成一个或多个工作量.每个执行代理在启动的时候向控制工作站
注册.
控制工作站保存可使用的执行代理注册,监视它们的状态,分配工作量并且帮助他们完成工作量.
一个执行代理包含一个Adapter,一个Logger和Filter组件.每个执行代理可以组成Adapter的馈给信息送到一个或多个filter或
logger,并且没个filter馈给信息给一个或多个logger.Adapter是个Java代码片同实际的RFID阅读器接口.
Sun Java系统RFID 事件管理器 来自被包装的预定义了编码的Adapter.它能理解EPC-顺从的RFID阅读器使用的指定的通讯协议.
这些阅读器 Adapter可以看做计算机系统里同周围外部设备通讯的设备驱动程序.
目前,没有标准的通讯协议可以被RFID阅读器使用来同消费它们的RFID事件的软件通讯.
RFID阅读器是独立的一片(典型的)硬件用来同RFID标签基于无线电频率通讯.
Adpater(适配器A)获得RFID标签的EPC并且产生一个事件包含时间戳和时间源(阅读器和天线发现标签).
事件被传送到处理事件的一组监听器.监听器是filter或logger.Filter可以平滑数据,扔掉先前探测信息或到其他
filter或logger的路由信息.过滤后的数据被传送作为一个事件到感兴趣的listener.Listener可以被其他有更多的数据的filter或logger作为一个连接器到第三方消费RFID信息的应用
The two tables below list the supported filters and loggers and their main functionality.
下列两个表列出了支持的filter和logger及它们主要的功能.
Table:1 Filters 由SunJava系统RFID事件管理器实现.
Filter Type Description
BandPass BandPass在阅读器EPC执行滤过器,来自阅读器的事件匹配EPC掩码被放行到listener,其他的则放弃.
Delta 报告标签进入和留下的视野
EPCFilter 同BandPass.
Smoothing Smoothing creates a union of EPC's discovered over the number of specified N cycles. If an EPC was discovered in cycle N, it is reported, if it hasn't been seen in more than the last N cycles, it is not reported. This is necessary because the RFID readers do not report tags with 100% tag accuracy.
Table 2: Loggers 由Sun Java系统RFID事件管理器实现.
名称 描述
FileLogger Logger that writes out PML Core to a file
HttpPmlLogger Logger thats write out PML Core to an HTTP connection
JMSLogger Logger that writes out PML Core to a JMS Queue or Topic
SocketLogger Creates a Socket connection and starts writing PML Core to the connection
SsocketLogger Creates a Server Socket connection and starts writing PML Core to the connection
The user configures the adapters, filters and loggers properties through an XML configuration file. The adapters, filters and loggers are tied to one another by use of a special
星期六, 十月 09, 2004
如何在Java网络程序中动态使用Proxy Server?
方法一:
设置HTTP:
System.setProperty("http.proxyHost","proxy-server-ip");//代理服务器IP
System.setProperty("http.proxyPort","proxy-server-port");//代理服务器端口
设置HTTPS:
System.setProperty("https.proxyHost","proxy-server-ip");
System.setProperty("https.proxyPort","proxy-server-port");
Java应用程序命令行
java -Dhttp.proxyHost=proxy-server-ip -Dhttp.proxyPort=proxy-server-port filename
或者:
方法二:
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "some_proxy" );
System.getProperties().put( "proxyPort", "8080" );
java -DproxySet=true -DproxyHost=some_proxy -DproxyPort=8080 SomeClass
星期五, 十月 08, 2004
IE和FireFox 1.0 对Div align 对齐方式的差异
IE 6.0 sp1和FireFox 1.0默认
IE如果不显示指定对齐方式,是右对齐。而FireFox 1.0是左对齐。
:).
所以如果有多个
通过style的float属性来指明.
如:
<div align="right" id="friendlist" style="float: right;border: 1px dotted #eeeeee;width:95%; z-index:3;overflow-y: scroll;">
这样就指明了div的边为一个象素的虚线宽度为空间的95%.
如何在IE中使用XML和XSLT来表现数据.
<HEAD>
<TITLE>sample</TITLE>
<SCRIPT language = "javascript">
function init()
{
var basicinfo = new ActiveXObject("Msxml2.DOMDocument.4.0");
var employment = new ActiveXObject("Msxml2.DOMDocument.4.0");
var paycatagory = new ActiveXObject("Msxml2.DOMDocument.4.0");
var attendence = new ActiveXObject("Msxml2.DOMDocument.4.0");
var mainpage = new ActiveXObject("Msxml2.DOMDocument.4.0");
mainpage.async=false;
mainpage.validateOnParse=true;
basicinfo.async=false;
basicinfo.validateOnParse=true;
employment.async=false;
employment.validateOnParse=true;
paycatagory.async=false;
paycatagory.validateOnParse=true;
attendence.async=false;
attendence.validateOnParse=true;
// You can substitute other XML file names here.
try
{
mainpage.load("hello.xml");
errorValid(mainpage);
basicinfo.load("emp_M_Basicinfo.xml");
errorValid(basicinfo);
employment.load("emp_M_EmploymentInfo.xml");
errorValid(employment);
attendence.load("attendence.xml");
errorValid(attendence);
paycatagory.load("pay_M_CatagoryItem.xml");
errorValid(paycatagory);
}catch(e)
{
alert("error:");
}
//Display basicinfo nodeset
// alert(basicinfo.documentElement.childNodes.item(0).xml);
var xslt = new ActiveXObject("Msxml2.XSLTemplate.4.0");
var xsltTree= new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
xsltTree.async = false;
// You can substitute other XSLT file names here.
xsltTree.load("hello.xslt");
xslt.stylesheet = xsltTree
xslProc = xslt.createProcessor();
xslProc.input = mainpage
try
{
xslProc.addParameter("basicinfo",basicinfo.documentElement);//.selectNodes("/Results")
xslProc.addParameter("employment",employment.documentElement);
xslProc.addParameter("paycatagory",paycatagory.documentElement);
xslProc.addParameter("attendence",attendence.documentElement);
xslProc.addParameter("yourname","William Wang");
}catch(e)
{
alert(e);
}
xslProc.transform();
resTree.innerHTML = xslProc.output;
// Save the result of the XSL transformation
//htmlCode = xslProc.output
//fso=new ActiveXObject("Scripting.FileSystemObject")
//htmlFile=fso.CreateTextFile("sample.html",true)
//htmlFile.WriteLine(htmlCode)
//htmlFile.Close()
}
function errorValid(errorObject)
{
if (errorObject.parseError.errorCode != 0)
{
var strErrMsg = "Problem Parsing Style Sheet:\n"
+ " Error #: " + errorObject.parseError.errorCode + "\n"
+ " Description: " + errorObject.parseError.reason + "\n"
+ " In file: " + errorObject.parseError.url + "\n"
+ " Line #: " + errorObject.parseError.line + "\n"
+ " Character # in line: " + errorObject.parseError.linepos + "\n"
+ " Character # in file: " + errorObject.parseError.filepos + "\n"
+ " Source line: " + errorObject.parseError.srcText;
alert(strErrMsg);
}
}
</SCRIPT>
</HEAD>
<BODY onload = "init()" >
<div id="resTree"></div>
</BODY>
</HTML>
IE 6.0和FireFox 1.0 Pr 关于XMLHttpRequestS 对象引用的差异
但是IE6不能保存XMLHttpRequest的引用在变量中,这是需要注意的.
如果需要多次使用,必须每次都生成XMLHttpRequest的对象引用.如下代码.
sniffer代码:
var http;
if (window.XMLHttpRequest) //FireFox系列
{
http = new XMLHttpRequest();
http.onload =processReqChange;//注意:是onload事件
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}else if (window.ActiveXObject)//IE
{
http = new ActiveXObject("Msxml2.XMLHTTP");
http.onreadystatechange = processReqChange;//注意:是onreadystatechange事件.
}
星期三, 十月 06, 2004
Sun终于决定开始整合EJB和JDO有关Persistence layer的表示逻辑了。
JDO专家组的两个专家将参加EJB 3。0的规范制定.并决定制定单一的POJO persistence Model.
如此一来,EJB和JDO起码在描述Persistence Model和操作技术粒度上保持了一致性.
很好。很大的一步.
星期五, 十月 01, 2004
如何让FireFox 右下角显示出来RSS的提示?
<link rel="alternate" type="application/xml" title="RSS" href="http://www.journalspace.com/xml/wang.xml"><title>Technology and Humanist</title>
如何就可以了。
Java的未来:从老虎(Tiger)向野马(Mustang)和海豚(Dolphin)进发
Java的未来:从老虎(Tiger)向野马(Mustang)和海豚(Dolphin)进发
英语原文
Posted By: Dion Almaer on September 30, 2004 @ 10:01 AM
目前”老虎”已经发布了,人们很想知道Java的未来计划.Sun公司的Mark Reinhode说明了Java发布模式的改变.将不会有任何维护级别的版本发布.升级的发行版本将按照大约每2-3个月频率发布.
这样可以在发布的版本里同时包含修改的内容.
新的发行计划周期
呼!我可以听到Sun公司内部和外部为了这个令人惊异的产品发出的如释重负的呼出声.
我们希望你能对这个产品有良好的感受.正如我以前所说的,我认为Tiger是自JDK 1.1以来,我们所构造的JDK里质量最高的.
这里似乎应该是向前展望的时候了,并且对我们对J2SE的发布模式修改的一些细节说明.
目前有三种类型的版本发行模式
特征发行版本用大的数目来表示(1.3,1.4,1.5 5.0),包含了成千的错误修正和众多的新特征.
这一般需要间隔24-36个月.
维护发行版本,也叫做”点-点” 发行(1.4.1,1.4.2等等),包含了许多错误修订,但是没有的性API的特征.
这些需要8-10月的间隔.
升级发行版本,也叫做”下画线” 发行(1.4.2_01,1.5.0_01 5.0 update 1),这包含了非常少量的错误修正(一般大约100左右),重要是非常仔细的从客户所遇到的比较紧急的错误.Sun 每3-4个月发布一个版本.向前来讲,我们打算简化我们发行版本的增加的速率.
尤其是:
特征发行版本将每18-24月发布.这是为了平台适合开发人员社团更加快速的演进及同.NET的竞争需要.
将不会有更多的维护版本发布.从Tiger(5.0)开始,将不会有如同1.4.1和1.4.2那里包含1500-2000错误修正的版本.如果这样,将会发布一个5.1版本,但同样包含特别特征的升级发行.
升级发行版本每2-3个月发布一次.这样将尽可能重大错误及时休正发布给用户.
改变一个发行模型对我们而言不是一件轻松的.这是数月来同我们的合作伙伴会谈及社团开发人员会谈的结果.两外两个从这些改变获得好处是:
发布将更加准时.在J2SE工程师组织内部,长期以来我们总是在困难的选择之间角斗:使当前维护发布尽可能的完美对在下一个大的新的特征上工作.这种冲突造成了很多计划超出了时间.新的发布模型解决了这种紧张:J2SE工程师一般情况下总是在为下一个特征发行版本上工作.当他们要求休正错误的时候将在一个升级发行版本中.甚至是更加珍贵的非凡工作(比如性能的提高),都将在一个升级发行版本中完成,当然可能会有异常情况超出这个规则.
发行版本的采用将会提高.已存在的中等规模的版本发行有较大的采用瘴碍.在这种程度的改变许多用户有足够的信心在他们已经限定的所有程序中采用.换句话说,对待他们更像在测试术语中的特征发行.
大多数的用户有足够的信心不做太多的测试而顺便在更新发行版本中使用他们的应用.
现在他们能有更多的时间在两个特征发行版本之间.这些不是容易的改变.
我们目前仍然在描绘出更多细节之中,也许下一个两年不是非常精确的符合我上面描述的内容。
总的来说,我们认为提高关注和增加新的发布模型的灵活性将会给平台和Java社团更大的好处.
星期四, 九月 30, 2004
Groovy 1.0 beta 7增加了embed 使用的jar库
Today 2004.9.30.groovy 1 beta 7发表
不过看了看change log.文档没有加入,修改的几个BUG.我都没碰到.
有关ClassLoader的问题,也没有修改.
只是一个小小的版本改动.
星期三, 九月 29, 2004
利用XMLHttpRequest对象来提交数据.
When using XMLHttpRequest object, there is a way to post data in the same way that an HTML Form is posted.
All you need to do is add an HTTP header, and send the data the same way you'd send it on the QueryString.
Here's a JScript example for the client side, that submits form data to another page:
var objHTTP, strResult;
objHTTP = new ActiveXObject('Microsoft.XMLHTTP');
objHTTP.Open('POST',"OtherPage.asp",false);
objHTTP.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
objHTTP.send("id=1&user="+txtUser.value+"&password="+txtPassword.value);
strResult=objHTTP.responseText;
星期一, 九月 27, 2004
欢迎你来到异次元空间!
自爱因斯坦之后,我们关于时空的最奇幻的构思.
我们处在一个最多11维的时空中.
自1995 Nova发表 Welcome to the 11th Dimension论文以来的进展有多少呢?实验室数据如何设计来证明这个理论呢?
有趣的思考.
图片来自:http://groups.msn.com/Realms-Of-Light/thedivinehologramofspirit.msnw
Nova The Elegant Universe: Welcome to the 11th Dimension "The Elegant Universe: Welcome to the 11th Dimension," shows how in 1995 Edward Witten of Princeton's Institute for Advanced Study, aided by others, revolutionized string theory by successfully uniting the five different versions into a single theory that is cryptically named "M-theory," a development which required a total of eleven dimensions. Ten...eleven...who's counting? But the new eleventh dimension is different from all the others, since it implies that strings can come in higher dimensional shapes called membranes, or " branes" for short. These have truly science-fiction-like qualities, since in principle they can be as large as the universe. A brane can even be a universe -- a parallel universe -- and we may be living on one right now. Branes might also explain why gravity is the weakest force, requiring all the matter in the Earth to produce a measly one g. According to this idea, gravity may be far more potent, but most of its strength is leaking into a parallel universe. Witten has described string theory as "a part of 21st-century physics that fell by chance into the 20th century." In fact, the theory is so far ahead of experimental technique that there is as yet no way to verify whether strings are real or a figment of some very creative imaginations. But scientists at the CERN atom-smasher on the French- Swiss border are working to test of one of the predictions of string theory. Scheduled to run later in this decade, this experiment may take an important step in showing that string theory is not just a crazy idea, but crazy reality. (CC) (D) |
如何让Google机器人搜索自己的网站呢?
http://webdesign.about.com/cs/googleoptimization/
关于SEO(Search Engine Optimized)的话题很久了.
但是我不知道Googlebot关于robots.txt和<meta name="Googlebot" content="index,follow"/>
的优先级别顺序是怎样的?
所以需要测试.不过先把<meta>标志加入网页再说其他了.:)
星期五, 九月 24, 2004
B/S开发的新里程碑(B/S application Milestone)XMLHttpRequest
动态HTML及XML:介绍XMLHttpRequest对象
(翻译:有增删:原文见:TaH Website
随着XML数据和Web服务的部署越来越普遍,你偶尔会觉的如果在HTML表现层不需要刷新页面而直接
得到XML数据来更新中间状态也是非常方便的.要感谢可爱的 XMLHttpRequest对象,可以在后台直接
提交或获得XML 数据,这扩展了Web Client的使用范围.
为了改变接受到的XML 数据并渲染成HTML内容,依赖于客户端DOM读取XML文档节点树组成用户最终
看见的HTML元素
历史和支持
Microsoft首先在IE 5 window版本用ActiveX技术实现了XMLHttpRequest对象.Mozilla 项目的工程
师们实现了兼容的本地版本Mozilla 1.0(及Netscape 7).Apple在Safari 1.2上完成了同样的工作.
包含W3C标准期望的相似的功能,DOM level 3载入及保存规范.同时随着支持XMLHttpRequest对象意味着这已经成为事实的标准.以后W3C的规范最终应该会支持它并且所有的browser都会支持的。
如何建立对象?
建立一个XMLHttpRequest对象要求根据不同的Browser用不同的方式来实例化对象.对Safari和
Mozila系列.简单调用对象的constructor功能就可以完成这个:
var req = new XMLHttpRequest();
对使用ActiveX的对象,通过传递对象名称来建立:
var req = new ActiveXObject("Microsoft.XMLHTTP");
两种构造方法都返回一个抽象对象的引用.它的方法控制所有的操作,同时他的属性从服务器返回的数据
对象方法
XMLHttpRequest对象在所有支持的环境中使用都非常简明,但是非常强大,列表所有的方法和属性
Table 1显示Safari 1.2,Mozilla及IE 5及以后的windows版本.
Table 1. 一般XMLHttpRequest对象方法
方法 | 描述 |
abort() | 停止当前请求 |
getAllResponseHeaders() | 返回一组标题头(标识及其值)字符串 |
getResponseHeader("headerLabel") | 返回指定头标识的字符串值 |
open("method", "URL"[, asyncFlag[, "userName"[, "password"]]]) | 给一个等待状态的请求制定目标URL,方法及其它可选的属性 |
send(content) | 发送请求,另外可以附加提交的字符传或DOM对象数据 |
setRequestHeader("label", "value") | 跟随请求设定指顶的标题标识及其值. |
在Table 1中显示的方法.open()和send()方法可能是你最常用的.
首先open(),用来设置一个将要用的操作场景.两个必须的参数是你将要请求的HTTP方法和连接的目
的URL.对于method参数,你可以设置"GET"接受基本数据.然后使用"POST"发送数据到服务器,尤其是数据可能大于512字节.URL可以是绝对或相对地址(不过可能引起Browser安全问题)
重要的第三个选项参数是Boolean值用来控制是否将来的事物是否异步.默认的行为是true既异步,
这表示脚本进程在调用send()后立即返回不要等待回应.如果你设置这个值为false,那么,脚本将等
到服务器返回数据为止.看起来似乎等待服务器返回数据再继续脚本进程是个好主意.但是这样做可能导致脚本因为网络或服务器问题而不能完成事务,导致脚本挂死.一个安全的主意是用send 异步操作方式,但把代码挂在onreadstatechange事件上是个好主意.
如下例:
var req;
function loadXMLDoc(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}
注意:从服务器返回的数据必须保证Content-Type是:text/xml 内容设置为text/plain或text/html
不被request对象接受.
对象属性
Table 2. 所有属性都是只读的
Table 2. 常见 XMLHttpRequest对象属性
属性 | 说明 |
onreadystatechange | 当每个状态改变时产生的事件 |
ReadyState | 对象状态整数0 = uninitialized1 = loading2 = loaded3 = interactive4 = complete |
responseText | 服务器返回结果的字符串样本 |
responseXML | DOM规范的服务器返回结果 |
status Numeric | code returned by server, such as 404 for "Not Found" or 200 for "OK" |
statusText | String message accompanying the status code |
如何使用XMLHttpRequest和DIV来动态载入内容
红色的为关键代码。
<div id=content name="content" width=80% heigth=80% >
wait
</div>
<script>
var http;
http = new XMLHttpRequest();
try
{
http.open("GET", "http://wang.journalspace.com", true);
}catch(e)
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
//弹出安全限制对话框,要用户授权。
http.open("GET", "http://wang.journalspace.com", true);
http.onreadystatechange=function() {
if (http.readyState==4) {
alert(http.responseText);
document.getElementById('content').innerHTML=http.responseText;
}
}
document.getElementById('content').innerHTML="Wait...";
http.send('');
}
</script>
Signed Scripts in Mozilla
http://www.mozilla.org/projects/security/components/signed-scripts.html
星期四, 九月 23, 2004
MySql如何增加一个新用户或改密码.
GRANT ALL PRIVILEGES ON *.* TO ehrm@"myhost" IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO ehrm@"%" IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO ehrm@localhost IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
FLUSH PRIVILEGES;
利用IE6和Javascript同服务器交互
When using XMLHttpRequest object, there is a way to post data in the same way that an HTML Form is posted.
All you need to do is add an HTTP header, and send the data the same way you'd send it on the QueryString.
Here's a JScript example for the client side, that submits form data to another page:
var objHTTP, strResult;
objHTTP = new ActiveXObject('Microsoft.XMLHTTP');
objHTTP.Open('POST',"OtherPage.asp",false);
objHTTP.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
objHTTP.send("id=1&user="+txtUser.value+"&password="+txtPassword.value);
strResult=objHTTP.responseText;
Javascript 同Regua参考资料
http://developer.netscape.com/viewsource/angus_strings.html
及通过.prototype扩展Javascript的功能.
http://www.javascriptkit.com/javatutors/proto4.shtml
星期三, 九月 22, 2004
如何避免GroovyClassLoader Defect 不足.避免动态类占用内存资源.
GroovyShell _shell=new GroovyShell(new Binding());
String text="tax=0.4; return 1000*tax;";
for(int i=0;i<3000;i++)
{
System.out.println(_shell.evaluate(text,"textScript.groovy"));
}
通过使用GroovyShell.evaluate(String script,String fileName)可以避免同一段脚本,被GroovyShell生成多个动态类保存在cache里.
如何使用JAX-RPC使用Java Object 当做Web Service
详细内容参考http://java.sun.com/developer/EJTechTips/2004/tt0824.html#1
星期二, 九月 21, 2004
如何利用Dynamic ClassLoader 来动态载入Class
import groovy.lang.GroovyShell;
import groovy.lang.Binding;
import groovy.lang.Closure;
import groovy.lang.Script;
import groovy.lang.*;
public class testGroovyMemoryLeak
{
public static void main(String[] args) throws Exception
{
String text="tax=0.4; return 1000*tax;";
ClassLoader parent = Thread.currentThread().getContextClassLoader();
GroovyObject groovyObject=null;
GroovyClassLoader loader=null;
Class groovyClass =null;
Object temp=null;
for(int i=0;i<3000;i++)
{
loader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader());
groovyClass = loader.parseClass(text);
groovyObject = (GroovyObject) groovyClass.newInstance();
temp = groovyObject.invokeMethod("run", args);
System.out.println("value="+temp);
temp=null;
loader=null;
System.gc();
}
}
}
星期一, 九月 20, 2004
Java Groovy 1.0 beta 6避免GroovyClassloader不能GC Class的问题
不能回收解析脚本动态产生的Scriptxxxx class.
原因是Groovy MetaClass使用了 static HashMap 来cache生成的class.
解决办法,模拟groovy 自己产生一个GroovyObject Arrays.
然后,把动态生成的GroovyObject放入数组,只生成一次,以后直接从数组中载入Class对象实例。
星期日, 九月 19, 2004
TTS Ask:What do you want in Next Java?
1.Better NullPointerException display(臭名远播的NPE问题)
display what name and property get Null
2.Dynamic class
通过申明生成动态类(如果Groovy加入很多问题就解决了)
3.改善ClassLoader behavior
JVM ClassLoader drive me madness.要求清晰简单的行为定义
4.Raw Socket Support
本地Socket支持。哈。这样大多数黑客(Cracker)软件就用Java development了。:)
5.XML/XSLT/XPATH支持.目前的JAXP使用太复杂了。典型的过度设计(over Designed)
6.discard setter 和getter 在Bean上的使用。
目前的沉闷的getter和setter对策略让人发疯。为什么不使用bean.propetyName直接引用呢?
7.Debug 功能要加强
包括#ifdef macro和JVM DUMP及Heap snapshot功能。Third Part module is argly.
What is Next Bigger Feature of Java?
今天看到TSS上也有人赞赏加入Closure在下一个版本中。
自从J2SE 5.0发布后,支持Closure成了一个水到渠成的步骤。
因为AutoBox,AutoUnbox和Generetor泛型的支持已经为
J2SE支持Closure的自然加入了低层支持。
在C# 2中加入了匿名代理的功能,从设计角度来说,提供了基本相识的功能。
其实JVM只要在inner class的基础上加上Autobox和Generetor的提高。
基本上可以提供Closure的功能了。不过很多Closure可以提供的比如data Pine
依然无法提供。
所以最好重新设计Closure替代inner class.
原文:
http://www.theserverside.com/news/thread.tss?thread_id=28808
星期六, 九月 18, 2004
关于Java ClassLoader和Groovy Temporary Class Load and Unload
在Java 中通过GroovyShell或GroovyClassloader来调用存放在数据库中的脚本,Groovy 编译会产生大量的Scriptxxx,xxx表示顺序好的临时class,这些class根据java classloader的规范,就存放在cache中了。
所以一个循环调用Groovy script脚本,会引起内存为了保存这些临时class产生大量的空间。
为了避免ClassLoader对这些class的引用。
需要每次执行脚本时候,必须生成一个新的ClassLoader来调用,然后释放掉。
这样就可以让JVM回收这些空间了。
代码:
星期五, 九月 17, 2004
关于Java GC(Gargabe Collection)回收的机制
The Truth About Garbage Collection
Garbage collection (GC) is probably the most widely misunderstood feature
of the Java platform. GC is typically advertised as removing all memory management
responsibility from the application developer. This just isn't the case. On the
other hand, some developers bend over backwards trying to please the collector,
and often wind up doing much more work than is required. A solid understanding
of the garbage collection model is essential to writing robust, high-performance
software for the Java platform.
This appendix provides an overview of the garbage collection mechanisms that will help you make intelligent choices about memory management issues. It also contains information to help you debug complex problems such as memory leaks.
A.1 Why Should You Care About Garbage Collection?
The cost of allocating and collecting memory can play a significant role in how
your software performs. The overall memory requirements of your software can
have a huge impact on the speed of your program when large RAM requirements
force the OS to use virtual memory. This often occurs when memory is allocated,
but not properly released. Although the JVM is responsible for freeing unused
memory, you have to make it clear what is unused. To write successful, large-scale
programs, you need to understand the basics of the GC mechanism.
A.2 The Guarantees of GC
The specification for the Java platform makes very few promises about how garbage
collection actually works. Here is what the Java Virtual Machine Specification
(JVMS) has to say about memory management.
The heap is created on virtual machine start-up. Heap storage for objects is reclaimed by an automatic storage management system (known as a garbage collector); objects are never explicitly deallocated. The Java virtual machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementor's system requirements.1
While it can seem confusing, the fact that the garbage collection model is not rigidly defined is actually important and useful-a rigidly defined garbage collection model might be impossible to implement on all platforms. Similarly, it might preclude useful optimizations and hurt the performance of the platform in the long term.
Although there is no one place that contains a full definition of required garbage collector behavior, much of the GC model is implicitly specified through a number of sections in the Java Language Specification and JVMS. While there are no guarantees about the exact process followed, all compliant virtual machines share the basic object lifecycle described in this chapter.A.3 The Object Lifecycle
In order to discuss garbage collection, it is first useful to examine the object
lifecycle. An object typically goes through most of the following states between
the time it is allocated and the time its resources are finally returned to the system
for reuse.
A.3.1 Created
When an object is created, several things occur:2
- Space is allocated for the object.
- Object construction begins.
- The superclass constructor is called.
- Instance initializers and instance variable initializers are run.
- The rest of constructor body is executed.
The exact costs of these operations depend on the implementation of the JVM, as
well as the implementation of the class being constructed. The thing to keep in
mind is that these costs exist. Once the object has been created, assuming it is
assigned to some variable, it moves directly to the in use state.A.3.2 In Use
Objects that are held by at least one strong reference are considered to be in use.
In JDK 1.1.x, all references are strong references. Java 2 introduces three other
kinds of references: weak, soft and phantom. (These reference types are discussed
in Section A.4.1.) The example shown in Listing A-1 creates an object and assigns
it to some variables.
public class CatTest {
static Vector catList = new Vector();
static void makeCat() {
Object cat = new Cat();
catList.addElement(cat);
}
public static void main(String[] arg) {
makeCat();
// do more stuff
}
}
Creating and referencing an object
Figure A-1 shows the structure of the objects inside the VM just before themakeCat
method returns. At that moment, two strong references point to theCat
object.
Object reference graph
When themakeCat
method returns, the stack frame for that method and any temporary variables it declares are removed. This leaves theCat
object with just a single reference from thecatList
static variable (indirectly via theVector
).A.3.3 Invisible
An object is in the invisible state when there are no longer any strong references
that are accessible to the program, even though there might still be references. Not
all objects go through this state, and it has been a source of confusion for some developers.
Listing A-2 shows a code fragment that creates an invisible object.public void run() {
try {
Object foo = new Object();
foo.doSomething();
} catch (Exception e) {
// whatever
}
while (true) { // do stuff } // loop forever
}
Invisible object
In this example, the objectfoo
falls out of scope when thetry
block finishes. It might seem that thefoo
temporary reference variable would be pulled off the stack at this point and the associated object would become unreachable. After all, once thetry
block finishes, there is no syntax defined that would allow the program to access the object again. However, an efficient implementation of the JVM is unlikely to zero the reference when it goes out of scope. The object referenced byfoo
continues to be strongly referenced, at least until therun
method returns. In this case, that might not happen for a long time. Because invisible objects can't be collected, this is a possible cause of memory leaks. If you run into this situation, you might have to explicitly null your references to enable garbage collection.
A.3.4 Unreachable
An object enters an unreachable state when no more strong references to it exist.
When an object is unreachable, it is a candidate for collection. Note the wording:
Just because an object is a candidate for collection doesn't mean it will be immediately
collected. The JVM is free to delay collection until there is an immediate
need for the memory being consumed by the object.
It's important to note that not just any strong reference will hold an object in memory. These must be references that chain from a garbage collection root. GC roots are a special class of variable that includes
- Temporary variables on the stack (of any thread)
- Static variables (from any class)
- Special references from JNI native code
Circular strong references don't necessarily cause memory leaks. Consider the code in Listing A-3. It creates two objects, and assigns them references to each other.public void buidDog() {
Dog newDog = new Dog();
Tail newTail = new Tail();
newDog.tail = newTail;
newTail.dog = newDog;
}
Circular reference
Figure A-2 shows the reference graph for the objects before thebuildDog
method returns. Before the method returns, there are strong references from the temporary stack variables in thebuildDog
method pointing to both theDog
and theTail
.Reference graph beforebuildDog
returns
Reference graph afterbuildDog
returns
Figure A-3 shows the graph for the objects after thebuildDog
method returns. At this point, theDog
andTail
both become unreachable from a root and are candidates for collection (although the VM might not actually collect these objects for an indefinite amount of time).A.3.5 Collected
An object is in the collected state when the garbage collector has recognized an
object as unreachable and readies it for final processing as a precursor to deallocation.
If the object has afinalize
method, then it is marked for finalization. If it
does not have a finalizer then it moves straight to the finalized state.
If a class defines a finalizer, then any instance of that class must have the finalizer called prior to deallocation. This means that deallocation is delayed by the inclusion of a finalizer.
A.3.6 Finalized
An object is in the finalized state if it is still unreachable after itsfinalize
method, if any, has been run. A finalized object is awaiting deallocation. Note that
the VM implementation controls when the finalizer is run. The only thing that can
be said for certain is that adding a finalizer will extend the lifetime of an object.
This means that adding finalizers to objects that you intend to be short-lived is a
bad idea. You are almost always better off doing your own cleanup instead of relying
on a finalizer. Using a finalizer can also leave behind critical resources that
won't be recovered for an indeterminate amount of time. If you are considering
using a finalizer to ensure that important resources are freed in a timely manner,
you might want to reconsider.
One case where afinalize
method delayed GC was discovered by the quality assurance (QA) team working on Swing. The QA team created a stress testing application that simulated user input by using a thread to send artificial events to the GUI. Running on one version of the toolkit, the application reported anOutOfMemoryError
after just a few minutes of testing. The problem was finally traced back to the fact that the thread sending the events was running at a higher priority than the finalizer thread. The program ran out of memory because about 10,000Graphics
objects were held in the finalizer queue waiting for a chance to run their finalizers. It turned out that theseGraphics
objects were holding onto fairly substantial native resources. The problem was fixed by assuring that whenever Swing is done with aGraphics
object,dispose
is called to ensure that the native resources are freed as soon as possible.
In addition to lengthening object lifetimes, finalize methods can increase object size. For example, some JVMs, such as the classic JVM implementation, add an extra hidden field to objects withfinalize
methods so that they can be held in a linked list finalization queue.A.3.7 Deallocated
The deallocated state is the final step in garbage collection. If an object is still unreachable
after all the above work has occurred, then it is a candidate for deallocation.
Again, when and how deallocation occurs is up to the JVM.A.4 Reference Objects
Prior to the introduction of the Java 2 platform, all references were strong
references. This meant that there was no way for the developer to interact with the
garbage collector, except through brute force methods such asSystem.gc
.
Thejava.lang.ref
package was introduced as part of Java 2. Figure A-4 shows the class hierarchy for the classes in this package. This package defines reference-object classes that enable a limited degree of interaction with the garbage collector.Reference
objects are used to maintain a reference to some other object in such a way that the collector can still reclaim the target object. As you might expect, the addition of these new reference objects complicates the concept of reachability as defined in the object lifecycle. Understanding this is important,
even if you don't intend to make direct use of this package. Some of the core class libraries useWeakReferences
internally, so you might encounter them while using memory profilers to track memory usage.Reference
class hierarchy
A.4.1 Types of Reference Objects
Three types of reference objects are provided, each weaker than the last: soft,
weak, and phantom. Each type corresponds to a different level of reachability:
- Soft references are for implementing memory-sensitive caches.
- Weak references are for implementing mappings that do not prevent their keys
(or values) from being reclaimed.
- Phantom references are for scheduling pre-mortem cleanup actions in a more
flexible way than is possible with the Java finalization mechanism.
Going from strongest to weakest, the different levels of reachability reflect the
lifecycle of an object:
- An object is strongly reachable if some thread can reach it without traversing
any reference objects.
- An object is softly reachable if it is not strongly reachable but can be reached
by traversing a soft reference.
- An object is weakly reachable if it is neither strongly nor softly reachable but
can be reached by traversing a weak reference. When the weak references
to a weakly reachable object are cleared, the object becomes eligible for
finalization.
- An object is phantom reachable if it is neither strongly, softly, nor weakly
reachable, it has been finalized, and some phantom reference refers to it.
- An object is unreachable, and therefore eligible for reclamation, when it is not
reachable in any of the preceding ways.
A.4.2 Example GC with WeakReference
You're likely to encounter special reference objects while using tools to look for
memory leaks. Only strong references will directly interfere with garbage collection.
If you find chains of objects linked by weak references, you should be able to
ignore them from a GC perspective. (For additional information on the use of
special reference objects, see the API documentation.)
Figure A-5 shows a graph of objects in memory for a sample program. Let's say that the problem with this program is that theDog
objects are not being collected, leading to a memory leak. By using a memory profiler, you can find all the pointers to theDog
object and follow them back to their GC roots. There are two GC roots in Figure A-5, a static variable in classKennel
and a stack frame in a live thread. In this case, theWagTask
thread is in an infinite loop, forcing the dog's tail to wag. The question is how to get rid of theDog
object.
There are two references pointing to theDog
object, but only one of them is interesting from a GC perspective. TheWeakReference
from thedogCache
is not important. The interesting reference is the reference from theTail
, which chains from a stack frame in a live thread. To free theDog
, and the associatedTail
, you need to terminate the thread that is wagging theTail
. Once this thread is gone, everything falls into place. When an object that is pointed to by aWeakReference
is collected, theWeakReference
is automatically set tonull.
Figure A-6 shows the result of terminating the wag thread.
Reference graph
When the thread dies, its stack is removed. Now the only strong reference to theDog
is via theTail
, and this becomes a simple circular reference that isn't reachable from a GC root. TheDog
, and by extension theTail
, are no longer strongly reachable through any references. They are only weakly reachable through thedogCache.
When the collector discovers this (which it does on its own schedule), it might set the weak reference tonull,
making theDog
andTail
totally unreachable. They then become candidates for collection and will be removed at the collector's discretion.
Results of garbage collection
A.5 References on Garbage Collection
Arnold, Ken, and James Gosling. The Java Programming Language, Second Edition, Addison-Wesley, Reading, MA, 1998.
Gosling, James, Bill Joy, and Guy Steele. The Java Language Specification, Second Edition, Addison-Wesley, Reading, MA, 2000.
Jones, Richard, and Rafael Lins. Garbage Collection: Algorithms for Automatic Dynamic Memory Management, John Wiley & Sons, New York, 1996.
Lindholm, Tim and Frank Yellin. The Java Virtual Machine Specification, Second Edition, Addison-Wesley, Reading, MA, 1999.
Tim Lindholm and Frank Yellin, The Java Virtual Machine Specification, Second Edition, Section 3.5.3. Addison-Wesley, 1999.
James Gosling, Bill Joy, and Guy Steele, The Java Language Specification, Second Edition. Addison-Wesley, 2000.
博客归档
-
▼
2004
(230)
-
▼
十二月
(16)
- 如何编写Jboss startup Service
- 整合Java和C++
- XML-RPC active digram
- 准备今天开始配置compiere
- ASM Java ByteCode生成软件.
- 是XMLHTTPRequest还是XML-PRC?
- Java平台下的压力测试工具
- Maven 1.2 命令行语法一览表
- 今天开始学习Maven(专家,内行) Project Management Tools.
- Very Large Scale Integration 超大规模集成Java实现
- 几天java.sun.co
- 用JConsole来监控JVM
- 如何关闭最顶级IE窗口,避免提示确认的麻烦?
- 在MYSQL中如何得到group by对应最大值的哪条记录呢?
- 如何制作Intel主板启动splash Screen
- Javascript文件操作Exception
-
►
十一月
(11)
- Java Session setAttribute 不能传递HTML tag的问题.
- JAVA中如何计算时间差.
- 如何修改Intel 主板开机画面
- MySQL 常用命令(1)
- 书写跨平台代码的一些小技巧
- MySQL 4.1 Production Level release!
- JavaRanch Big Moose Saloon: How can MDB listen a r...
- Re: [JBoss-user] How to get messages from a remote...
- Business Process Management (BPM) Tutorial - What ...
- 如何在Javascript中得到多纬数族字符串下标
- Amazon Search Bar for FireFOx Enabled.
-
►
十月
(10)
- Groovy如何返回值?
- 如何用Java软件来开发射频身份识别自动识别方案?
- 如何在Java网络程序中动态使用Proxy Server?
- Sun提供的基于Java的RSS功能包.
- IE和FireFox 1.0 对Div align 对齐方式的差异
- 如何在IE中使用XML和XSLT来表现数据.
- IE 6.0和FireFox 1.0 Pr 关于XMLHttpRequestS 对象引用的差异
- Sun终于决定开始整合EJB和JDO有关Persistence layer的表示逻辑了。
- 如何让FireFox 右下角显示出来RSS的提示?
- Java的未来:从老虎(Tiger)向野马(Mustang)和海豚(Dolphin)进发
-
►
九月
(35)
- FireFox中的XML和XSLT的使用及SOAP的引用..
- Groovy 1.0 beta 7增加了embed 使用的jar库
- Today 2004.9.30.groovy 1 beta 7发表
- 利用XMLHttpRequest对象来提交数据.
- 欢迎你来到异次元空间!
- 如何让Google机器人搜索自己的网站呢?
- B/S开发的新里程碑(B/S application Milestone)XMLHttpRequest
- 如何使用XMLHttpRequest和DIV来动态载入内容
- Signed Scripts in Mozilla
- MySql如何增加一个新用户或改密码.
- 利用IE6和Javascript同服务器交互
- Javascript 同Regua参考资料
- 如何避免GroovyClassLoader Defect 不足.避免动态类占用内存资源.
- 如何使用JAX-RPC使用Java Object 当做Web Service
- 如何利用Dynamic ClassLoader 来动态载入Class
- Java Groovy 1.0 beta 6避免GroovyClassloader不能GC Clas...
- TTS Ask:What do you want in Next Java?
- What is Next Bigger Feature of Java?
- 关于Java ClassLoader和Groovy Temporary Class Load and...
- 关于Java GC(Gargabe Collection)回收的机制
-
▼
十二月
(16)