星期二, 三月 08, 2005

如何得到JDBC支持的连接字符串的属性?

得到一个JDBC支持的连接属性的list

import java.sql.*;

public class listAllJDBCParameters
{
public static void main(String[] args)
{
try {
// Load the driver
String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
if(args.length>0)driverName=args[0];
// Get the Driver instance
String url = "jdbc:mysql://localhost:3306/PCD55";
Driver driver = DriverManager.getDriver(url);

// Get available properties
DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
System.out.println("属性个数:"+info.length);
for (int i=0; i<info.length; i++) {
// Get name of property
String name = info[i].name;
System.out.print(name+":");
// Is property value required?
boolean isRequired = info[i].required;
System.out.print(isRequired);
// Get current value
String value = info[i].value;
System.out.print(":"+value);
// Get description of property
String desc = info[i].description;
System.out.println(":"+desc);
// Get possible choices for property; if null, value can be any string
String[] choices = info[i].choices;
}
} catch (ClassNotFoundException e)
{
// Could not find the database driver
} catch (SQLException e)
{
}
}
}

星期二, 三月 01, 2005

JSR-144 JDBC RowSet Reader give NPE(java.lang.NullPointerException),解决方法.

JSR-144 JDBC RowSet 在 JDK 1.4.2_06及以后出现错误:
代码:
com.sun.rowset.CachedRowSetImpl cacherset = new com.sun.rowset.CachedRowSetImpl();
出现以下错误

java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:80)
at java.util.Properties.load(Properties.java:266)
at java.util.PropertyResourceBundle.(PropertyResourceBundle.java:96)
at com.sun.rowset.JdbcRowSetResourceBundle.(Unknown Source)
at com.sun.rowset.JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(Unknown Source)
at com.sun.rowset.CachedRowSetImpl.(Unknown Source)


解决方法:
1.使用J2SE 5.0
2.改变用户国家.这是实现代码,绑定出错信息资源文件的时候,找不到对应语言的ResourceBundler出现的错误.
目录下:com.sun.rowset.RowSetResourceBundle.properties

这是代码没有考虑其他语言资源文件不存在的时候,应该使用en语言的资源文件.

手工改变当前语言可以解决这个问题,如下:

java -Duser.language="en" -Duser.region="US" javaProgram

JSR-144 JDBC RowSet Reader give NPE(java.lang.NullPointerException),解决方法.

JSR-144 JDBC RowSet 在 JDK 1.4.2_06及以后出现错误:
代码:
com.sun.rowset.CachedRowSetImpl cacherset = new com.sun.rowset.CachedRowSetImpl();
出现以下错误

java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:80)
at java.util.Properties.load(Properties.java:266)
at java.util.PropertyResourceBundle.(PropertyResourceBundle.java:96)
at com.sun.rowset.JdbcRowSetResourceBundle.(Unknown Source)
at com.sun.rowset.JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(Unknown Source)
at com.sun.rowset.CachedRowSetImpl.(Unknown Source)


解决方法:
1.使用J2SE 5.0
2.改变用户国家.这是实现代码,帮定出错信息的时候,找不多对应语言的ResourceBundler出现的错误.
目录下:com.sun.rowset.RowSetResourceBundle.properties
这是代码没有考虑其他语言资源文件不存在的时候,应该使用en语言的资源文件.
手工改变当前语言可以解决这个问题,如下:
java -Duser.language="en" -Duser.region="US" javaProgram

星期日, 二月 27, 2005

一个很好Reverse Engine网站

http://protools.reverse-engineering.net/decompilers.htm

星期五, 二月 25, 2005

CRM (Custom Relationship Management) 理论再现江湖.

前几天找到了一个开源的CRM.www.opencrx.com非常不错.
让Micros去搞,做为一个主力产品.

BTW:昨天在Jboss 3.2.3+Oracle 9i +openCrx 1.4成功安装了.但没有运行下.

今天看一下.非常不错的东西.

XMLHttpRequest 和encodeURIComponent及encodeURL.

通过XMLHhttpRequest向Web传送参数.用encodeURL来编码需要传送的字符串.如:script=....,但是如果包含&&符号的话,则传递到服务器期端就会在&符号处被断开.
必须使用下列方法来编码包含&&特殊符号的串.
window.encodeURIComponent

BTW:如何构造XMLHttpRequest的Post方式传递参数到服务器.

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

星期四, 二月 24, 2005

XSLT如何输入一个换行?

一般来说,下列语句可以工作:

<xsl:text> </xsl:text>
是换行的ASCII

星期一, 二月 21, 2005

如何在GroovyShell中嵌套执行脚本?

问题:在Groovy Script中,还有部分脚本来自其他媒体,比如数据库中.
需要把数据库中的代码和当前脚本一起混合执行.

解决:在当前Groovy Script中,用evaluate(String Script)来执行.
就可以了.
比如下列代码:
payitem=null;
CURRENT_CATAGORY.find(){if(it.payitemcode==Payitemcode)payitem=it}
evaluate(payitem.businessrule);

一段可以完全执行演示的代码:
import java.util.*;

mine=new ArrayList();
mine.add("123");
mine.add("3454");
script="evaluate(\"println('1sfdas')\n\");";
//keep variable self
evaluate(script);
打印出来

MySQL 如何改变一个Database的名字?

Mysql 目前还没有直接可以修改database的命令,比如Oracle的alter database .
不过Mysql的database目录对应着mysql安装目录下的data目录下的一个目录的名字.
所以最简单的方法,就是
1.shutdown Mysql Server
2.修改data目录下database对应的目录的名字就可以了.

还有常用的方法.
1.mysqldump -B database>database.sql 出要修改名字的database
2.drop database dataasename
3.修改database.sql中的建立database的命令.
4.source database.sql

星期五, 二月 18, 2005

关于规则表达(Regular Expression)RE的站点

RE 汇总站点:
http://www.wellho.net/regex/index.html
比较好的C++ RE:
http://www.boost.org/libs/regex/doc/syntax.html

星期四, 二月 17, 2005

Tomcat 5.0.28 with J2sdk 1.4.2_x毛病太多.

典型的问题(无解):
在Server.xml中定义<Context path="/jsr223samples" docBase="C:/jsr223/samples" debug="0" reloadable="true" crossContext="true"/>
访问目录下的任何一个jsp的时候出现:

package javax.servlet does not exist

这个问题是Tomcat 5.x ClassLoader算法的问题.把jsp打包在web moduler .war文件里发布没有问题.

PS:有人说要同j2sdk 5.0同Tomcat 5.x一起使用可以解决这个问题.没有试验过.

星期三, 二月 16, 2005

Java 平台里程碑的事件.JSR223草案发布

Scripting for the Java Platform
试用了一下,基本ScriptEngine同BSF类似(resemble).
不过让人惊奇的时,现在Web Tier不只有JSP可以使用了.
我们完全可以用javascript,groovy,php来直接解析和调用Servlet的API了.
这太Cool了.
换句话说,javasript可以同时在server端和Client使用同一套语法来做了.
只要符合Javascripting Engin的接口规范,其他任何语言都可以使用Java的类库了.
不知道,swing是否可以直接调用.理论上没什么问题.

方法:
1.修改配置文件.
conf/server.xml

<Context path="/jsr223samples" docBase="C:/jsr223/samples" debug="0" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_jsr223" suffix=".txt"/>
</Context>


conf/web.xml

<servlet>
<servlet-name>JSR223Script</servlet-name>
<servlet-class>com.sun.script.http.ScriptServlet</servlet-class>
<init-param>
<param-name>script-blocks</param-name>
<param-value>js,groovy</param-value>
</init-param>
</servlet>


<servlet-mapping>
<servlet-name>JSR223Script</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>JSR223Script</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>JSR223Script</servlet-name>
<url-pattern>*.groovy</url-pattern>
</servlet-mapping>


这样设置后,就可以直接调用对应的.js,php,.groovy的脚本文件在服务器端直接执行并输出结果了.

2.在Java代码中调用对应的引擎

//Initiate ScriptEngineManager
ScriptEngineManager manager = new ScriptEngineManager();

//Return Groovy engine by name
ScriptEngine jsengine = manager.getEngineByName("groovy");
//或者改为js或php

//Execute the HelloWorld script
jsengine.eval(new FileReader("./HelloWorld.groovy"));

星期三, 二月 02, 2005

如何得到Java 对象的大小Size.

Object ob = new Object();

ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream(out);
objOut.writeObject(ob);

System.out.println("Size = " + out.toByteArray().length);

星期二, 二月 01, 2005

如何格式化BigDecimal小数部分--小数点后面为两位数并且四舍五入.

/**
* 格式化数据,返回标准的Money表示结果
* @param value BigDeciam
*/
public static BigDecimal formatBigDecimal(BigDecimal value)
{
BigDecimal a=new BigDecimal("1");//必须用这个方法,才能精确得到准确的值
return value.divide(a,2,java.math.BigDecimal.ROUND_HALF_UP);
}

星期三, 一月 26, 2005

哇噻,今天dev@groovy.codehaus.org 里气氛比较激进

有个人对James .领导的JSR-99.groovy Language specification

进展缓慢非常不满.要求James改进工作方法,并寻找熟悉语言规范文档规范的助手来做.
并对Groovy语言目前竟然没有完全的语言手册大大不满.

Re: [groovy-dev] Pragmatic Groovy Development and Project

老外也是整天喜欢搞政治的.

星期二, 一月 25, 2005

JBOSS JAAS 403错误解决问题.

问题描述:
当使用JAAS Login成功后,访问任何页面出现:
HTTP Status 403 - Access to the requested resource has been denied
错误

分析:
当使用JAAS login的时候.在login jsp里包括如下Form:

用户名

密码:




在conf/login-config.xml包含如下:
<application-policy name = "Demo">
<authentication>
<login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag = "required">
<module-option name = "dsJndiName">java:/MySqlDS</module-option>
<module-option name = "principalsQuery">
Select userpassword from sys_L_UserLogin where userid = ?
</module-option>
<module-option name = "rolesQuery">
Select roleid,roleid as Role from sys_L_UserRole where userid =?
</module-option>

</login-module>
</authentication>
</application-policy>

在web.xml包含如下:
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>

<url-pattern>*.jsp</url-pattern>

<url-pattern>/Demo/*.jsp</url-pattern>
<url-pattern>*.*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>

</web-resource-collection>

<auth-constraint>
<role-name>*</role-name>
</auth-constraint>

<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>

</security-constraint>
<login-config>
<auth-method>FORM</auth-method>

<realm-name>Demo</realm-name>

<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error_error.jsp</form-error-page>
</form-login-config>

</login-config>
注意红色部分.
出现403 错误:
jboss-web.xml 包含:
<同jboss-web.xml中的 <security-domain>java:/jaas/Demo</security-domain>相同>

星期一, 一月 24, 2005

JBOSS如何启动Mbean在EJB EAR包部属完成之后?

在Jboss-Services.xml中加入:

jboss.j2ee:module=myapp-ejb-jar.jar,service=EjbModule

现在需要一个Solution:在建立EJB的时候在注册MBean.

Jboss关于JMX有关FAQ连接.

http://www.jboss.org/wiki/Wiki.jsp?page=FAQJBossJMX

很多问题都解答了.

星期五, 一月 21, 2005

Java 控制台得到用户输入字符串最完美演示代码.

按照OnkeyUP或OnKeyDown来写Java方法算法真是希奇古怪.
竟然用了近半个小时,My,God.
晕.


import java.io.*;

public class test
{
public static void main(String[] args) throws Exception
{
//OnEvent事件,知道回车才得到结果.
String input = "" ;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)) ;
input = in.readLine() ;
System.out.println(input);

//Onkey事件,这个算法算是最完美的了。真麻烦
String password="";
while (true)
{
char c = (char)System.in.read();
if (c == '\r') {
c = (char)System.in.read();
if (c == '\n') {
break;
} else {
continue;
}
} else if (c == '\n') {
break;
} else {
password += c;
}
}
System.out.println("Password:"+password);
}
}

星期四, 一月 20, 2005

MySQL的常用方便命令之一

把符合查询条件的记录保存到一个文件中.
比如:
SELECT * into outfile "outdata.txt" FIELDS TERMINATED BY ',' FROM emp_M_EmploymentInfo

FIELDS TERMINATED 表示字段之间隔离的符号.

JBOSS JMX FAQ 1

1.Q:如何给我写的Servlet添加一个JMX的监控组件呢?
A: 在Servlet init() 方法中调用MBeanServer.registerMBean(...)
来注册你的servlet
Code Example:
List srvrlist = MBeanServerFactory.findMBeanServer(null);
MBeanServer server = (MBeanServer)srvrlist.iterator().next();

ObjectName name = new ObjectName("com.wxk:service=mybean");
Mybean emb = new Mybean();
server.registerMBean(emb, name);

2.Q:为什么我发布的sar总是扔出:Class does not expose a management interface :错误:
A:JBoss规则或JMX规范:一个Class的JMX Management Interfact必须是添加后缀MBean
比如你的Class为 x.y那么对应的JMX管理接口的class名字必须为x.yMBean

3.Q:如何得到当前系统的默认MBeanServer?
A:使用MBeanServerFactory.findMBeanServer(null).iterator().next();
要注意必须使用同一个VM/ClassLoader.

Jboss建立JMX组件(1)



ToDo.

星期三, 一月 19, 2005

WindowSXP 批文件新增强大功能.

SET 变量字符串替换:
/P 命令行开关允许将变量数值设成用户输入的一行输入。读取输入
行之前,显示指定的 promptString。promptString 可以是空的。

环境变量替换已如下增强:

%PATH:str1=str2%

会扩展 PATH 环境变量,用 "str2" 代替扩展结果中的每个 "str1"。
要有效地从扩展结果中删除所有的 "str1","str2" 可以是空的。
"str1" 可以以星号打头;在这种情况下,"str1" 会从扩展结果的
开始到 str1 剩余部分第一次出现的地方,都一直保持相配。

也可以为扩展名指定子字符串。

%PATH:~10,5%

会扩展 PATH 环境变量,然后只使用在扩展结果中从第 11 个(偏
移量 10)字符开始的五个字符。如果没有指定长度,则采用默认
值,即变量数值的余数。如果两个数字(偏移量和长度)都是负数,
使用的数字则是环境变量数值长度加上指定的偏移量或长度。

%PATH:~-10%

会提取 PATH 变量的最后十个字符。

%PATH:~0,-2%

会提取 PATH 变量的所有字符,除了最后两个。

举例


set DT=%DATE%_%TIME%
echo %DT%
set DT=%DT: =%
echo %DT%
set DT=%DT:/=-%
echo %DT%
set DT=%DT::=-%
echo %DT%
set DT=%DT:~4%
echo %DT%
set DT=%DT:~0,-3%
echo %DT%

Groovy Beta 9 依然没有进步!

Sign.要大叹一口气.
我已经报告了内存泄露的问题,并且在fix list已经列出了被修复了.可是依然是没有修复.

我真的很遗憾.对Groovy的质量问题.

Linux shell 命令编程

删除了.

星期二, 一月 18, 2005

Firefox 单一文档保存.

http://maf.mozdev.org/index.html
类似IE.的单一打包文档mht.

如何在Java 5.0里面最简洁的得到系统环境变量的?

Just on statement:
for(String key:System.getenv().keySet())
{
System.out.println(key+" = "+System.getenv(key));
}

MySQLD Tuning 参数配置.

/etc/my.cnf 配置

skip-locking
key_buffer = 384M
max_allowed_packet = 1M
table_cache = 1024
sort_buffer_size = 8M
read_buffer_size = 2M
myisam_sort_buffer_size = 64M
thread_cache = 8
query_cache_size = 32M
set-variable = max_connections=500
thread_concurrency = 8

星期一, 一月 17, 2005

J2SE 5.0 New Features.

J2SE 5.0新操作符含义
1. Generics(泛型)
,读做:” of Type”,比如Collection c读做”Collectioin of String c
2. for-loop:
Colon( : ) 冒号,读做: for each typeObject t in c.”
比如:
for (TimerTask t : c) 读做: for each TimerTask t in c
3. varargs(变元),声明参数个数不确定的方法或接口.
三个点(…);
public static String format(String pattern,Object... arguments);
public static String format(String pattern,Object... arguments)
{
String temp="";
for(Object t:arguments)temp+=t;
return pattern+":"+temp;
}
4. enum 枚举声明
简单enum:
enum Season { WINTER, SPRING, SUMMER, FALL }
Examples:
//Test for enum simple
for (Season rank : Season.values())System.out.println("Enum:"+rank);
复杂enum:
可以包含数据,行为
public enum Planet {
MERCURY (3.303e+23, 2.4397e6),
VENUS (4.869e+24, 6.0518e6),
EARTH (5.976e+24, 6.37814e6),
MARS (6.421e+23, 3.3972e6),
JUPITER (1.9e+27, 7.1492e7),
SATURN (5.688e+26, 6.0268e7),
URANUS (8.686e+25, 2.5559e7),
NEPTUNE (1.024e+26, 2.4746e7),
PLUTO (1.27e+22, 1.137e6);

private final double mass; // in kilograms
private final double radius; // in meters
Planet(double mass, double radius) {
this.mass = mass;
this.radius = radius;
}
private double mass() { return mass; }
private double radius() { return radius; }

// universal gravitational constant (m3 kg-1 s-2)
public static final double G = 6.67300E-11;

double surfaceGravity() {
return G * mass / (radius * radius);
}
double surfaceWeight(double otherMass) {
return otherMass * surfaceGravity();
}
}
Example:
//Test for complex enum Planet
for (Planet p : Planet.values())
System.out.printf("Your weight on %s is %f%n",
p, p.surfaceWeight(8));

5. 注解(Annotations)
目的:很多API要求提供一些模板代码,以供方便使用.

ERM BOM

物料清单(BOM),又称为产品结构表或产品结构树;在某些工业领域,可能称为“配方”、“要素表”或其它名称。在ERP系统中,物料一词有着广泛的含义,它是所有产品、半成品、在制品、原材料、配套件、协作件、易耗品等等与生产有关的物料的统称。BOM作用于计算机识别物料、接受客户定单、编制计划、配套(装配)和领料、加工过程跟踪、采购和外协、成本计算、报价参考、物料追溯、改进产品设计等等。系统可以采用多种方法描述物料清单,如单层法、缩进法、模块法、暂停法、矩阵法以及成本法等等。


BOM(Bill of material )物料清单;
PP(Production Planning)生产计划大纲;
MPS(Master Production Scheduling)主生产计划;
RCCP( Rough Cut Capacity Planning)粗能力需求计划;
MRP(Materiel Requirements Planning) 物料需求计划;
CRP(Capacity Requirements Planning) 能力需求计划;
PAC(Production Activity Control) 车间作业管理;
IM(Inventory Management) 库存管理;
CO(Controlling) 管理会计(Management Accounting);
FI(Financial Accounting) 财务会计(GL总帐、AR应收、AP应付);
COE(Customer order Entry) 客户订单输入;
HR(Human Resources) 人力资源计划;
SD(Sales and Distribution) 分销管理。

星期六, 一月 15, 2005

如何用Linux下Sendmail把所有的近来的Email全部转发到另外一个Sendmail Server上呢?

这种模式叫做:smart Host模式.
在/etc/sendmail.cf里,找到DS关键词.
在后面加入你要转发到的Senmail server的名字

必须是名字,如果用IP可能不能成功.同sendmail版本有关.
1.在/etc/hosts加入一行
10.2.5.1 MailGW

2.在/etc/sendmail.cf里加入
# "Smart" relay host (may be null)
DSMailGW

就可以了.然后可以用.
mail -v 来跟踪一下发送过程


问题:为什么Linux启动的时候在Sendmail就停在那里,非常慢?

原因:可能的原因是修改了网卡IP.
你必须在/etc/hosts
把localhost加在IP不是127.0.0.1的那行

如下:
10.2.5.240 localhost SZSE199

星期二, 一月 11, 2005

JBOSS如何在Web加如虚拟目录

I made the following changes. Not all of them may be required. You can try one at a time.
1. jboss/server/default/conf/jboss-service.xml
Code:


<server>
<!-- Load all jars from the JBOSS_DIST/server/<config>/lib directory. This
can be restricted to specific jars by specifying them in the archives
attribute.
-->
<classpath codebase="lib" archives="*"/>

<!-- Set the virtual directory to be used by the application
Ref: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=48300 -->
<attribute name="Config">
<Server>
<Service name="JBoss-Tomcat">
<Engine name="MainEngine" defaultHost="localhost">
<Host name="localhost">
<!-- Default context parameters -->
<DefaultContext cookies="true" crossContext="true" override="true"/>
<!-- Add a static context /Storage using directory /tmp/images -->
<Context docBase="C:/images" appBase="/cmpe275" path="/images"/>
</Host>
</Engine>
</Service>
</Server>
</attribute>
<!-- Virtual directory setting - END -->




one more place
Code:

<!-- ==================================================================== -->
<!-- Deployment Scanning -->
<!-- ==================================================================== -->
<!-- An mbean for hot deployment/undeployment of archives.
-->
<mbean code="org.jboss.deployment.scanner.URLDeploymentScanner" name="jboss.deployment:type=DeploymentScanner,flavor=URL">

<attribute name="URLs">
deploy/cmpe275, file:///C:/images/
</attribute>





2. jboss/server/default/deploy/jbossweb-tomcat50.sar/META-INF/jboss-service.xml
Code:

<server>
<mbean code="org.jboss.web.tomcat.tc5.Tomcat5" name="jboss.web:service=WebServer">
<!-- Get the flag indicating if the normal Java2 parent first class
loading model should be used over the servlet 2.3 web container first
model.
-->
<attribute name="Java2ClassLoadingCompliance">true</attribute>
<attribute name="LenientEjbLink">true</attribute>
<!-- A flag indicating if the JBoss Loader should be used. This loader
uses a unified class loader as the class loader rather than the tomcat
specific class loader.
-->

<!-- Set the virtual directory to be used by the application
Ref: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=48300 -->
<attribute name="Config">
<Server>
<Service name="JBoss-Tomcat">
<Engine name="MainEngine" defaultHost="localhost">
<Host name="localhost">
<!-- Default context parameters -->
<DefaultContext cookies="true" crossContext="true" override="true"/>
<!-- Add a static context /Storage using directory /tmp/images -->
<Context docBase="C:/images" appBase="/cmpe275" path="/images"/>
</Host>
</Engine>
</Service>
</Server>
</attribute>
<!-- Virtual directory setting - END -->
<attribute name="UseJBossWebLoader">true</attribute>





3. jboss/server/default/deploy/jbossweb-tomcat50.sar/server.xml
Code:

<Host name="localhost" autoDeploy="false" deployOnStartup="false" deployXML="false">
<!-- Default context parameters -->

<DefaultContext cookies="true" crossContext="true" override="true"/>
<!-- Add a static context /Storage using directory /tmp/images -->
<Context docBase="C:/images" path="/cmpe275/images"/>





4. copy web.xml to
jboss/server/default/conf

This has worked for me. Hope this helps you.
There has to be easier way to solve this.

星期一, 一月 10, 2005

JbuilderX如何把任意类型的文件都打包到War或Jar里?

以Jbuildx为列
1.选择Tools/Prefefences/Browser..File Types


2,选则Module的老鼠右键选择properties..
入图:


3.还有一种最简洁的方法,假如Filters
加入Include型的Filter,Module的老鼠右键选择properties/Content/Filter,加入*.*类型的过滤.



星期五, 一月 07, 2005

JAVA JMX Programming Rapid ..

http://java.sun.com/developer/technicalArticles/J2SE/jmx.html
很好.

星期三, 一月 05, 2005

如何用XML-RPC来传递汉字参数.

我这里使用的是xml.apache.org的实现.
关键的一点:改变字符集合可以使用:org.apache.xmlrpc.XmlRpc.setEncoding("UTF-8");

这会影响对传递的数据的encode.
下面用一个简单的Client/Server/Handler来说明XML-RPC的实现:

Client的实现


package home.wxk;

import org.apache.xmlrpc.*;
import java.util.Vector;

public class RpcClient {
public RpcClient() {
}
public static void main(String[] args) throws Exception
{
//org.apache.xmlrpc.XmlRpc.setEncoding("UTF-8");
XmlRpcClient xmlrpc = new XmlRpcClient ("http://localhost:8080");
Vector params = new Vector ();
// params.addElement (new String(" 123".getBytes(),"UTF-8"));
params.addElement(new String("这时候汉字的未来xmlrpc123".getBytes(),"ISO-8859-1"));
// this method returns a string
String a="";
// try
// {
a=(String)xmlrpc.execute("hello.sayHello", params);
System.out.println("........"+a);
// }catch(Exception e)
// {
// System.out.println("异常:......."+a);
// }
}
}

服务器端的实现


package home.wxk;
import org.apache.xmlrpc.*;

public class RpcServer {

public static void initServer() {
// XmlRpc.setDriver("org.apache.xerces.parsers.SAXParser");
//start the server
System.out.println("Starting XML-RPC Server......");
org.apache.xmlrpc.XmlRpc.setEncoding("ISO-8859-1");
WebServer server = new WebServer(8080);
//register our handler class

server.addHandler("hello", new HelloHandler());
server.start();

System.out.println("Now accepting requests......");
}

public static void main(String[] args){
initServer();
}

}

Handler的实现


package home.wxk;

public class HelloHandler {
public String sayHello(String name) throws Exception
{
System.out.println("I am come ing..."+name+new String(name.getBytes("UTF-8")+new String(name.getBytes("ISO-8859-1")+new String(name.getBytes()))));
String echo="Hello 你好";
//String returnstr=new String(name.getBytes(),"ISO-8859-1");
return new String(name.getBytes(),"iso-8859-1");
}
}

Groovy Beta 8 的一个bug

Beta 8修改了GroovyClassLoader在反复运行大量小脚本的情况下会泄露内存的问题.但是又把GroovyShell.execute的默认行为给修改了.
execute在beta 7中,会首先判定才cache中是否有同名的scriptText,如果有,则运行Cached的脚本.但Beta 8却扔出了一个:duplicate class definition:

Guillaume Laforge
回复到:
"Hello William,

In CVS Head, there should be a fix that solved your problem.
When beta-9 is released, could you please check if this issue is still
present? Thanks in advance."

当然,我在Beta 9 released的时候,会检查这个问题是否纠正了.
我的Payroll系统Groovy这可是核心的技术了.

星期二, 十二月 21, 2004

如何编写Jboss startup Service

http://www.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService

编写在启动Jboss的时候就开始启动或服务的Bean.

星期五, 十二月 17, 2004

整合Java和C++

让你更加容易使用JNI

http://www.javaworld.com/javaworld/jw-05-2002/jw-0510-integrate.html
准备翻译下.

星期四, 十二月 16, 2004

XML-RPC active digram

准备今天开始配置compiere

http://www.compiere.org/

ASM Java ByteCode生成软件.

http://asm.objectweb.org/

主要用来生成java bytecode代码.是Groovy的核心.

需要多了解

星期三, 十二月 15, 2004

是XMLHTTPRequest还是XML-PRC?

这里有些学习的例子:
http://jsolait.net/examples/xmlrpc/
目前IE和FireFox 1.0都支持XMLHTTPRequest方法来时间简单的javascript
->java之间的交换.

XML-RPC可以在Javascript中调用?

Java平台下的压力测试工具

Web Stress test Tool
.今天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.

我现在挺厌烦用OpenSource的管理方面的工具的.包括CVS/ant等等,非常难用.基本上都不是 Ready for out Box.开箱即用的.
都要看大量的文档来牢记标记的语法.

可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实现

今天Sun公司网站上给出了一个用Java编写的电子CAD设计工具.
下载了看看了.

UI方面非常丑陋.不过竟然已经到了8.0了.看来用的人很多吧.
jar包下载的地址:http://ftp.gnu.org/pub/gnu/electric/

几天java.sun.co

星期三, 十二月 08, 2004

用JConsole来监控JVM

http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

星期六, 十二月 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对应最大值的哪条记录呢?

In ANSI SQL, I'd do it with a subquery like this:

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

Keyword:USB Memory stick bootable,Bios Recovery,Intel 865PERL


建立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

<script>
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
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 主板开机画面

Modify Intel Bios MainBoard boot splash .
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)

MySQL 4.1.7 Tune Performance Common Command
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

书写跨平台代码的一些小技巧

1.目录分隔符号.
使用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 4.1 从Development-->Production,时间如此之短.
看来MySQL 加强了开发力量了.真是值的祝贺的事情.
现在可以支持DBCS了通过UTF8和UCS2两种方式.

啊.想当初为了用ISO8859-1来保存DBCS的痛苦了.真是可惜啊.大量的来做ISO-8859-1->UTF8
和UTF8->ISO-8859-1的代码没用了

:(.

星期四, 十一月 11, 2004

JavaRanch Big Moose Saloon: How can MDB listen a remote queue ?

JavaRanch Big Moose Saloon: How can MDB listen a remote queue ?

Re: [JBoss-user] How to get messages from a remote JMS server

Re: [JBoss-user] How to get messages from a remote JMS server: "> Hello all, > I am trying to set up deployment descriptors for some MDB in jboss. I need to > subscribe to topics from a remote JMS server. I have added the remote JMS MBean > into jboss.jcml as was described in the documentation : > > name=':service=JMSProviderLoader,name=RemoteJMSProvider'> > RemoteJMSProvider > org.jboss.jms.jndi.JBossMQProvider > remote.com:1099 > > > and I got the server to start. The only thing I have left to do is to actually > write the deployment descriptor to look up the topics in the remote server. > I know that the syntax for doing so for topics in jboss.xml is : > > > topic/MyTopicj > > is this the same syntax for all such servers?"
另外一篇文章,详细描述了如何用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?

Business Process Management (BPM) Tutorial - What is BPM?: "What is Business Process Management (BPM)?"

星期一, 十一月 08, 2004

如何在Javascript中得到多纬数族字符串下标

在Javascript中所有Object都是Hashtable对象的包装.
常用的数组用法:
一纬数组用法:
遍历数组:
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.

AmaZon的搜索条为FireFox的定做已经发布了,很好看.
不过在中国暂时无法使用.

遗憾.

下载地址:
http://toolbar.a9.com/

星期六, 十月 30, 2004

Groovy如何返回值?

在数据库或.groovy脚本程序文件中,只写入一个整数或其他字符串.
groovy将认为会把这个整数或字符串作为结果返回.

比如:test.groovy 包含:
//here is PayItem Business code.
3000;

用groovy.bat test.groovy 得到记过3000

星期三, 十月 13, 2004

如何用Java软件来开发射频身份识别自动识别方案?

Oct 12, 2004
原文

如何用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 tag in the configuration file. Figure 3 below illustrates the design and syntax of the XML configuration file. The dotted lines imply that the associated elements or components are optional. Zero or more of each can be present.


Figure 3: Illustration of Sun Java System RFID Event Manager Configuration File

The following attributes define the Adapters of the RFID Event Manager:

1. name: The unique name for the component.
2. classname: The name of the Java class that implements the component.
3. LogLevel: The LogLevel parameter specifies the detail of logging information to be generated by the Adapter. The settings follow java.util.logging conventions established in the J2SE release of the Java VM.
4. properties: A sequence of name value pairs.
5. outputs: a sequence of component names that will be registered as event listeners to this adapter. The outputs normally designate one or more filters, or loggers.

Some of the common properties include:

1. Reader Hostname
2. Reader EPC identifier
3. Log Level


Anatomy of an EPC
EPC can be represented as a URI (Uniform Resource Identifier) to enable the data exchange between software systems. EPC URI are based on the EPC Tag Data Standards defined by EPCglobal. These standards define completely that portion of EPC tag data that is standardized, including how that data is encoded on the EPC tag itself (that is, the EPC Tag Encodings), as well as how it is encoded for use in the information systems layers of the EPC Systems Network (the EPC URI or Uniform Resource Identifier Encodings). The EPC Tag Encodings include a Header field followed by one or more Value Fields. The Header field defines the overall length and format of the Values Fields. The Value Fields contain a unique EPC Identifier and optional Filter Value when the latter is judged to be important to enable effective and efficient reading of the EPC tags.

The EPC encoded in an RFID tag can identify the manufacturer, product, version and serial number, and also provides an extra set of digits to identify unique items.

For various industries, the EPC identifier specifies various coding schemes:

* General Identifier (GID)
* Serialized version of the EAN.UCC Global Trade Item Number (GTIN)
* EAN.UCC Serial Shipping Container Code (SSCC)
* EAN.UCC Global Location Number (GLN)
* EAN.UCC Global Returnable Asset Identifier (GRAI)
* EAN.UCC Global Individual Asset Identifier (GIAI)

Given EPC data, its header field indicates which coding scheme can be applied. The standard URI representation of EPCs has 4 categories:

1. URIs for pure identities (also called canonical forms) which contains only the EPC fields to identify a physical object. For example, a pure identity URI for GID can be "urn:epc:id:gid:10.1002.2" and a URI for GRAI can be "urn:epc:id:grai:0652642.12345.1234."
2. URIs for EPC Tags which represents the tag encodings. These URIs can be used by application software to write a tag. An example for a Serialized GTIN 64-bit encoding is "urn:epc:tag:sgtin-64:3.0652642.800031.400."
3. URIs for Raw Bit Strings which represent invalid bit-level patterns as a single decimal number. For example: "urn:epc:raw:64.20018283527919."
4. URIs for EPC Patterns. Each pattern URI refers to a set a EPCs for the EPC filtering purpose. For example: a pattern "urn:epc:pat:sgtin-64:3.0652642.[1024-2047].*" refers to any SGTIN Identifier 64-bit tag with Filter value as 3, Company Prefix as 0652642, Item Reference in the range from 1024 to 2047 and any Serial Number.

For further details, EPC TagData Standards Specification.

Anatomy of a PML message

The RFID Event Manager loggers output PMLCore XML messages, conformant to version 1.0 of the specification published by the Auto-ID Center. The specifications can be located here. The snippet below is a PML message sent by the Event Manager corresponding to a TagsIn event, ie, when a tagged item comes in view of an antenna. A similar event with a command TagsOut is sent when a tagged item goes out of view of an antenna.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- The root element of PML Core -->
<Sensor xmlns="urn:autoid:specification:interchange:PMLCore:xml:schema:1">
<!--The EPC of the reader specified in the RFID Event Manager configuration file for the Reader adapter -->
<ns1:ID xmlns:ns1="urn:autoid:specification:universal:Identifier:xml:schema:1">urn:epc:id:gid:1.1.3</ns1:ID>
<!-- The root element for an observation -->
<Observation>
<ns2:ID xmlns:ns2="urn:autoid:specification:universal:Identifier:xml:schema:1">4</ns2:ID>
<!-- The time when the observation was recorded by the RFID Event Manager -->
<DateTime>2004-05-27T15:36:25.758-07:00</DateTime>
<!--If the PML is generated from a Delta Event, the value of Command is either TagsIn or TagsOut -->
<Command>TagsIn</Command>
<!-- A tag observation -->
<Tag>
<!-- The EPC of the observed tag -->
<ns3:ID xmlns:ns3="urn:autoid:specification:universal:Identifier:xml:schema:1">urn:epc:id:gid:1.1.209</ns3:ID>
</Tag>
</Observation>
</Sensor>

The Sensor element is the main interchange element for PML Core messaging. This element is a composite element comprised of the following subordinate elements:

* ID element
* one or more Observation elements

The Sensor element captures sensor information. A sensor is considered any device that makes measurements and observations. Sensors in the EPC Network are identified by an identifier code. The default identification scheme should be the EPC.

The ID element follows EPC as the default identification scheme to uniquely identify sensors and tags. The use of other identification scheme is supported, but is not encouraged. The EPC is represented as a URI as specified in [EPC] or later versions of this specification.

Each Observation element contains data that are the result of a measurement by a particular sensor. Each observation must be labeled with date and time. It can also be equipped with a unique ID, and a reference to the kind of command that was issued to make the observation. The Observation element consists of the following:

* an optional ID element
* an optional Command element
* DateTime element
* zero or more Data elements
* zero or more Tag elements

The DateTime element captures the date and time when the observation was made. It is based on the [XSD] data type. The Command element can be used to specify the command that was issued to trigger the observation. The Tag element is a special kind of observed value introduced with recognition of the importance of automatic identifications in the EPC network. The tag entity represents any device that can be detected by a sensor. The Tag element consists of the following elements:

* ID element
* optional Data element
* zero or more Sensor elements

All ID elements follow the EPC as the default identification scheme to uniquely identify sensors and tags.

urn:epc:id:gid:1.1.3 is the unique ID of the Reader and Antenna encoded in the GID EPC scheme. A reader can have a unique EPC for each associated antennae, or if the EPC for each antennae is not specified, all antennae will inherit the reader EPC. If the unique EPC for each Reader-antenna is mapped to the location of the antenna, it can be used to track the location of the tagged item as it is scanned by the antenna. urn:epc:id:gid:1.1.209 is the unique EPC number of the tagged item read by the RFID reader represented in GID URI format.

RFID Implementation Hurdles

Theoretically, automating product scanning should make RFID simpler to operate than bar-code technology. However, in many ways, the technology's increased capabilities make it more challenging.

The most basic challenge is managing data. Unlike bar-code technology, where information is scanned only when someone passes a printed label in front of a reader, RF scanning is always on. Consequently, RFID systems must filter data that is constantly streaming in. Additionally, these systems must contend with physical factors that may interfere with RFID's use of radio waves. Warehouses and plants that have electric motors and metal obstructions can have electromagnetic interference. Product materials?liquids or metals?may absorb or reflect RF signals.

As with supply chain integration, RFID technology has the potential to allow suppliers, customers, and other firms in the industry access to critical competitive information. However, with RFID it could be used to gather the information clandestinely because it is so anonymous.

The IDs on passive RFID cards can easily be stolen using a sniffer and a power source without the knowledge or consent of the ID's owner. One major problem with passive RFID systems is that the power source comes from the receiver, not from within the RFID tag itself. This makes the tags cheaper and more robust, but it also makes them vastly less secure. Unless the encryption is very good, the RFID unique identifiers can be duplicated.

Future
To date, only the EPC Tag Data Standards Version 1.1 is finalized. The term Savant is deprecated. Savant standards 1.0 are in the process of being replaced by specifications and standards focused on Event Manager, Reader Management, Reader Protocol, Filtering and Collection, and EPCIS.

References

[XSD] XML Schema Part 2: Datatypes W3C Recommendation, 02 May 2001 http://www.w3.org/TR/xmlschema-2/

[EPC] Michael Mealling and Ken Traub, The URI Representation of the Electronic Product Code and Related Types , Working Draft Version, 12 August 2003 EPC Global http://www.epcglobalinc.com

EPC Tag Data Standards Version 1.1 http://www.epcglobalinc.com/standards_technology/EPCTagDataSpecification11rev124.pdf

PML Core specification 1.0 http://www.epcglobalinc.com/standards_technology/Secure/v1.0/PML_Core_Specification_v1.0.pdf

Auto-ID Savant Specification 1.0 http://www.epcglobalinc.com/standards_technology/specifications.html

Auto-ID Reader Protocol Specification 1.0 http://www.epcglobalinc.com/standards_technology/specifications.html

Sun Java System RFID Software Product Documentation http://docs.sun.com/db/coll/RFID_04q3

EPC and RFID: Enabling the Next Level of Business Efficiencies http://wwws.sun.com/software/solutions/rfid/index.html

The Sun RFID Test Center http://wwws.sun.com/software/solutions/rfid/testcenter/index.html

The Sun" EPC Network Architecture http://wwws.sun.com/software/solutions/rfid/EPCNetArch_wp021304a.pdf

The RFID Journal http://www.rfidjournal.com/

Acknowledgements
The author would like to thank Ricardo Labiaga of the RFID engineering team at Sun for his input, help and guidance in writing this paper.

About the Authors

Alka Gupta is a member of the Technical Staff at Sun Microsystems. She's responsible for working with Sun's ISV's and partners to help them adopt the emerging Sun technologies and platforms quickly and efficiently. Alka has been in this industry for nearly 10 years. Alka graduated from the Indian Institute of Technology (IIT), India.

Mayank Srivastava is a Software Engineering Manager in Market Development Engineering, at Sun Microsystems. In this capacity, Mayank's group responsibilities include providing help to ISVs to adopt Sun's technology and systems.

星期六, 十月 09, 2004

如何在Java网络程序中动态使用Proxy Server?

如何在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

Sun提供的基于Java的RSS功能包.

http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/

星期五, 十月 08, 2004

IE和FireFox 1.0 对Div align 对齐方式的差异

KeyWords:div,align.FireFox,Iexporer
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来表现数据.

<HTML>
<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 对象引用的差异

XMLHttpRequest一个有价值的用途,就是在后台反复使用XMLHttpRequest的对象引用来从服务器获取数据.叫做round-trip模式.
但是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的表示逻辑了。

原文:Sun对Java社区的公开信
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)进发

“Tiger one of the most ambitious Java revisions to date”---TTS

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社团更大的好处.