Monday Mar 30, 2009

There already have lots for page flipping components for flash. Seemed there is no for JavaFX. I take some times and create a prototype. You can take a try if you already installed jdk1.6.0 u12 or above on your machine to view this demo:

- Wait for program loading for a while

- Move mouse to one corner of slides, drag it to flip to another page till it's on end or beginning page.

Please let me know if you have more comments. I will put your suggestion into update version.

FlipPage Demo

Here is java web start way to run it as desktop: FlipPage Demo

Tuesday Mar 17, 2009

As bug 6416177 exist, Java didn't official support SuSe10 for CCKJ. In case you need run some java application show in CCKJ, do there have any workaround? Here is a step about how to config font support for JDK:

  • Check what types of font SuSe support for your language

Go to '/usr/X11R6/lib/X11/fonts/truetype and view file 'fonts.dir', you will see map between true type font file and it's supported font like this:

FZSongTi.ttf -founder-songti-medium-i-normal-0-0-0-0-c-0-gb18030-0

Try to pick up fonts from that list for JDK's 5 logical font families:

  1. serif: plain, bold, italic, bolditalic
  2. sansserif: plain, bold, italic, bolditalic
  3. monospaced: plain, bold, italic, bolditalic
  4. dialog: plain, bold, italic, bolditalic
  5. dialoginput: plain, bold, italic, bolditalic

Abviously, you can use one font represent all of those logical fonts. It's you prefer.

  • Make change in fontconfig file 

Go to directory <JDK HOME>/jre/lib/, view file 'fontconfig.SuSE.properties.src'. You will see it only support charset 'iso8859-1'. We need put our language's support into it.

For example, we want use '-founder-songti-medium-i-normal-0-0-0-0-c-0-gb18030-0' for logical font 'serif.plain'. We need put following into that fontconfig file:

serif.plain.zh-1=-founder-songti-medium-i-normal-*-%d-*-*-c-*-gb18030-0

Please map all logical fonts to our phyical font alias following about way. After that, we need change the 'Search Sequences' to 'sequence.allfonts=latin-1,zh-1' and put font file names we used into file:

filename.-founder-fangsong-medium-r-normal-*-%d-*-*-c-*-gb18030-0=/usr/X11R6/lib/X11/fonts/truetype/FZFangSong.ttf

Also, we need put following line in file:

awtfontpath.zh-1=/usr/X11R6/lib/X11/fonts/truetype

Here is fully sample on my test machine. Restart application, and enjoys!

Wednesday Feb 18, 2009

GlassFish 中启用压缩功能提升网站性能

GlassFish 中可以启用 HTTP 压缩功能来提升网站性能。HTTP 压缩其实就是将网页内容压缩,减少HTML代码网络传输的代价,来提高Web性能。这里有四个属性可供配置:

  • compression
  • compressionMinSize (in OCTET)
  • compressableMimeType
  • noCompressionUserAgents

你可以用通过命令行启动:

%asadmin set server.http-service.http-listener.http-listener-1.property.compression=force

许可的值是:
    off –  取消压缩
    on –   启用压缩
    force –在任何情况下都压缩
    正数 – 采用压缩应满足的最小输出数据

如果 content-length 未知, 只有在 compression 设为 force h时才会压缩。

详细可参考

Enabling HTTP Compression in GlassFish
compression and compressionMinSize in GlassFish v3
http-listener in GlassFish v3

Wednesday Aug 06, 2008

从 GlassFish V3 TP2 开始要采用 OSGi 模型,我开始了解 OSGi 的一些基本概念。OSGi是一种服务运行平台。通过实现能够提供服务的符合OSGi规范的组件,用户可以将其组件发布到OSGi运行平台,供用户和其他组件使用。可以在 OSGi 的官方网站得到详细的信息。

我从 Apache 的网站下了 Felix - 一个 OSGi 的开源实现,要运行起来还是比较容易的:

  • 下载 Felix
  • 在机器上解开该包,到其解压目录运行 java -jar bin/felix.jar 就能得到其 shell 接口
注意不要到 bin 目录执行 java -jar felix.jar。因为其初始要加载的三个服务使用了相对路径。更多资源可见 Felix 项目主页

Tuesday Aug 05, 2008

如果你也在使用 app client 调用 EJB,那么下面两个问题的解决方法可能对你有用:

  • 如果你在 Netbeans 中产生一个 EJB 模块,编译部署到应用服务器上。然后又产生一个 app 客户端项目并在其中通过注射 EJB 方法调用 EJB 模块。运行该 app 客户端会出现如下异常:

com.sun.enterprise.appclient.MainWithModuleSupport <init>
warning: ACC003:application exception threw.
java.lang.NullPointerException

如果你在调试模式下又不会出现此问题。此问题是 Netbeans 的一个 bug, 请见该 bug 的描述。解决的办法是再产生一个企业应用程序,将上述两模块添加到该应用中。从该应用中运行该 app 客户端即可。如果部署时支持了 Java Web Start, 则应通过浏览器访问 http://<machine name>:8080/<j2ee context>/<app client context> 来通过 Java Web Start 的方式运行该 app 客户端。

  • 如果你通过Java Web Start 的方式运行该 app 客户端出现下面的异常:

Error launching or running the application
java.lang.ClassNotFoundException: com.sun.enterprise.appclient.MainWithModuleSupport
java.lang.ClassNotFoundException: com.sun.enterprise.appclient.MainWithModuleSupport
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)

此为 jdk1.6.0 u7 特有的问题。解决办法是在 Java Console 修改 "临时 Internet 文件" 的设置,如下图一样禁用该缓存:



Monday Aug 04, 2008

Sun 刚发布了 JavaFX SDK 的预览版,于是从网站上下载了该版来试用。该版给人全新的感觉:

  • 可视化的 drag & drop 功能:开发人员可以直接从左面拖拉组件到中间的脚本编辑器来直接生成脚本。该功能与 Netbeans 的 JSF 的可视化功能相似。
  • 在脚本编辑器中,提供了包,类及其成员的上下文提示。
  • 比较 JavaOne 时提供的版本,大量的类都被归到了不同的包下
总的来说,现在使用 JavaFX 已经方便多了,对 RIA 提供了更丰富的支持。如果感兴趣,可以从 http://java.sun.com/javafx  下载。

Tuesday Jul 22, 2008

ALT DESCR 很高兴的在 http://blogs.sun.com/  上看到 GlassFish 中文博客今天访问量接近 2000。相对于 GlassFish 英文博客 的每天 20000 的访问量还有很大的差距。但也是一个不错的结果的了。谢谢大家的支持和关注。希望有一天我们中文的用户能超过英文,那我们博客的访问量也能超过英文了。

Monday Jul 14, 2008

从上周开始,GlassFish 的 Blog 重新开业了。我们将会尽可能的与英文版的保持同步。同时,会有越来越多的原创作品在上面发布。希望大家到水族馆来坐坐,并多提意见。

Monday Jul 30, 2007

我实际上加入了DocWeb社区是去年的事了。现在才有一些心思来写点东西。实际上DocWeb是一个开源的项目,主要的目的是要围绕Java API做出一个社区。在这个社区内,开发人员可以分享自己对某一API的使用心得,可以提供一些示例给其他开发者。在这个社区内,开发人员也可以翻译API的文档,分享大家翻译后的劳动成果。如果你感兴趣,可以到这个网站看看:http://doc.java.sun.com/DocWeb/. 整个项目的源代码是开源的,可以在java.net上找到。你如果对整个开发项目有兴趣,可以到https://docweb.dev.java.net/上申请加入。

Tuesday Jan 09, 2007

我在2006年9月在Sun的Netbeans技术日上做了"如何'掌'控你的企业应用'的讲座. 过后基本上就没在想这事了. 直到不久前我的同事又发封信,发现组织者考虑周到,还录了音. 所以其他如果想了解这方面内容的开发人员可以下载讲座和录音:

英文幻灯
中文幻灯
录音
如果想听更多的关于 Netbeans 的其他功能,可在Netbeans Day查找.

Thursday Jul 20, 2006

最近, Sun Portal Server 提供了一个在后面的版本中将要加入的 Ajax 的一些应用:

. 用户可以直接拖拉用户界面上的通道(Channel)来可视化调整布局
. 一个通道的变化如最小化,恢复,刷新等,不用刷新整个界面
. 通道的编辑被内嵌到通道显示的页面中而不是象以前那样要切换到一个新的编辑页面中
. 用户产生新的通道时可以预览该通道


等等.
在以后的版本,Portal Server 的管理也应该更多的应用 Ajax. 这样,管理员在部署用户的 Web 界面时也可以象构建传统的 GUI 界面那样做到"所见即所得" .
详细情况,请看 Sun Portal Server 的演示

Sunday Jul 09, 2006

Application Server 9.0 中提供了"管理规则"的新功能. 在"管理规则"中,可以定义一些事件,当这些事件发生时,执行特定的动作.

事件包括:
. monitor
. notification
. lifecycle
. log
. timer
. trace
详见配置管理规则

如何用这个功能来提供执行另一种定时任务的方法呢?方法就是写自己的Custom MBean:

Custom MBean 接口 TimerMBean:

package com.example.mbeans;

public interface TimerMBean {}

然后写该接口的实现,关键是要实现 NotificationListener 接口. 当某一特定时间到来时,方法 handleNotification 会被系统自动调用,用户要定时执行的任务就应该写在本方法中:

package com.example.mbeans;

import javax.management.*;
import java.util.*;

public class Timer implements TimerMBean, NotificationListener{

public Timer() {}

public void handleNotification(Notification notification, Object handback) {
String message = notification.getMessage();
System.out.println("Get notification: " + "message: " + message);
}
}

这里的实现仅仅是记录下收的通知的消息内容.
编译完后打成 jar 包,通过Application Server 的管理界面部署该自定义 MBean. 部署自定义 MBean时,实现类名称为"com.example.mbeans.Timer"

下一步是在Application Server 的管理界面中点"配置"->"管理规则",点"新建", 在"事件类型"中选 "timer" 后点"下一步". 在"日期字符串"中输入要定时的时间(缺省格式为"MM/dd/yyyy HH:mm:ss"). 在"操作"中选取前面部署上去的自定义 MBean. 如图所示:

保存配置并重启 Application Server.到设定的时间后, Application Server 的日志中存有前面部署上去的自定义 MBean的输出信息.表明该定时任务按时执行.

Friday Jun 23, 2006

Sun 在服务器软件上集成了许多大型的应用软件形成 JavaES 套件. 由于里面的大型软件很多,象 Application Server, Web Server, Mail Server, Access Manager 和 Portal Server 等等.s所以对内存的要求就比较高,一般要使其中的软件都安装运行正常,要 4G 左右的. 这对要部署 JavaES 到生产环境而言,是必须的. 但很多用户可能是要评估 JavaES 或要在上面做开发的用户,内存的要求可能就会有点高. 我们如何在一个配置较低, 如 1G 的内存的系统上安装 JavaES 呢, 我们可以扩大交换区来解决这个问题.

在 Solaris sparc 上, 确保 /export 所在文件系统分区上有 4G 以上的剩余磁盘空间:

1.产生交换文件
mkfile 4096m /export/swap1
2.使交换文件马上生效
/usr/sbin/swap -a /export/swap1
3.将配置存入配置,使操作系统下次启动后该交换文件仍然生效
echo '/export/swap1 - - swap - no -' >> /etc/vfstab

在 Solaris x86 上, 确保 /export 所在文件系统分区上有 4G 以上的剩余磁盘空间:

mkfile 2000m /export/swap1
/usr/sbin/swap -a /export/swap1
echo '/export/swap1 - - swap - no -' >> /etc/vfstab

mkfile 2000m /export/swap2
/usr/sbin/swap -a /export/swap2
echo '/export/swap2 - - swap - no -' >> /etc/vfstab

在 Linux 上, 确保 /export 所在文件系统分区上有 4G 以上的剩余磁盘空间:

dd if=/dev/zero of=/export/swap1 bs=1024 count=1966080
mkswap /export/swap1
swapon /export/swap1
echo '/export/swap1 swap swap defaults 0 0' >> /etc/fstab

dd if=/dev/zero of=/export/swap2 bs=1024 count=1966080
mkswap /export/swap2
swapon /export/swap2
echo '/export/swap2 swap swap defaults 0 0' >> /etc/fstab

Wednesday Jun 14, 2006

最近有客户问我在j2se中,所有的异常提供了getLocalizedMessage()方法.她认为在程序中调用它就能得到所有j2se异常的中文信息了.但最后她发现还是得到英文的异常.

实际上,从设计的角度, 接口 Throwable 已经考虑了国际化的要求, 定义了方法 getLocalizedMessage(). 下面的具体子类实现如果要提供本地化方法,就应该重载该方法,并根据 locale 的信息返回相应语言的异常.

为什么在 j2se 中还未提供本地化的异常呢?

实际上有两个原因:

1. 经费和优先级的考虑 - 一般而言,异常只有管理员能见到而用户很少看到. 所以翻译它的优先级比较低.

2. j2se 的大小 - j2se 软件的大小需要严格控制. 因为现在还是有很多用户靠拨号来下载 j2se. 所以 j2se 的大小应该尽可能小. 如果翻译所有异常, 将增大 j2se 本身的尺寸. (这也是为什么 j2se 要提供两个版本: 英文版和国际化版, 而不是仅提供国际化版的原因. 因为英文版的尺寸就足够小,便于许多用户快速下载和安装)

Monday Oct 31, 2005

These days, AJAX become more and more popular. So I take a look on it and find it's very interesting. Basically, AJAX is Asynchronous JavaScript + XML. So totally, no new tech in it, the reasons it become popular I think are mature tech and customer's requirement.

Talking About the customer's requirment, I still remember one of consultant told me something when I took a Java conference in Beijing.

His company do lots of integration projects for the customers, such as call center system etc, and his customer alway prefer the static web page just like tradition C/S program. As usually the web page refresh too much when the system worked, this thing heavily hurt the operators' eyes and effect the work efficiency.

Back the tech, the new mozilla version support XMLHttpRequest tech make AJAX's popularity become possible. But one thing we still need deal, that many old browser didn't support it, so the system developer may need provide another version to support these system users. For example, gmail still provide another version to support the user who still use the old browse which didn't support the XMLHttpRequest.

So, in my view, the framework who can let the developer easily develop web UI just like C/S UI will be very popular in the presentation layer.
If you are interested in this new tech. please refer following url: https://bpcatalog.dev.java.net/nonav/ajax/index.html http://java.sun.com/developer/technicalArticles/J2EE/AJAX/ http://ajaxanywhere.sourceforge.net/quickStart.html

This blog copyright 2009 by leonfan