Sep 12, 2006
[Misc] ADCan
知り合いが ADCan というアフィリエイトサービスを開始したので、ちょっと紹介。
始まったばかりなので登録者数はマダマダの様だけれど、機能的には他のアフィリエイトサービスと遜色ない。
というか、ぱっと見た限りでは後発な分だけ積極的に +α を狙っているだけに面白いサービスだと思う。
アフィリエイトサイトを専門家の視点からどう映るのかは分からないけれど、
個人的には面白いと思うので時間のあるときにでも登録してみてくださいませ m(_ _)m
ちなみに、JavaScript が有効になっていないと動作しない機能もあると思うので要注意。
- ADCan
- http://adcan.jp/index.jsp
- ADCan - はじめての方へ
- http://adcan.jp/info/service.jsp
- ADCan - よくある質問
- http://adcan.jp/info/qa.jsp
ADCan への参加方法
ブログを持っている人であれば簡単に参加できる。
|
![]() |
コンテンツマッチへの参加
ちなみに、コンテンツマッチは↓の様な感じになる。
アフィリエイトへの参加
ちなみに、アフィリエイトは↓の様な感じになる。
Jun 28, 2006
[dotNet] WinFS の終焉
なんと本日付で WinFS の開発終了がアナウンスされた。
These changes do mean that we are not pursuing a separate delivery of WinFS, including the previously planned Beta 2 release. With most of our effort now working towards productizing mature aspects of the WinFS project into SQL and ADO.NET, we do not need to deliver a separate WinFS offering.
元々は Longhorn (現在の名称は Windows Vista) の目玉機能として宣伝されていたものなのだが、「開発遅延」→「Windows Vistaには搭載されない」と次第に声が小さくなっていた。 そして、ついに開発打ち切り・・・。 何と言うことだ。 WinFS がもたらしてくれるはずだった利便性には期待していただけに残念だ。 WinFS が搭載される可能性が無いのであれば、無駄に重くなるだけの Windows Vista には全く魅力を感じないのだが、私だけだろうか??
- 元麻布春男の週刊PCホットライン - Microsoft、WinFSの開発中止を表明
- http://pc.watch.impress.co.jp/docs/2006/0628/hot434.htm
- WinFS Overview
- http://www.ntfs.com/winfs_basics.htm
Jun 26, 2006
[Misc] Live-F1 にチャレンジ
Live-F1 とは
F1 の公式サイトにグランプリの情報をリアルタイムに提供してくれるサービスがある。 デフォルトでは Java のクライアントが必要なのだけれど、Terminal 版のクライアントもあるらしいということを知った。 公式サイトによると、
Live F1 is a native Linux client for viewing the information feed of the official Formula-1 Web site without the need of a Java-enabled browser. It displays the live timing information from the track side during races, qualifying, and practice sessions. An account on formula1.com is still required.というツールらしい。
- Live F1
- http://freshmeat.net/projects/live-f1/
- The Official Formula 1 Website
- http://formula1.com/
- 2006 British Grand Prix Live Timing
- http://www.formula1.com/race/livetiming/758.html
- CLIマジック:フォーミュラ1ファンに新しいツール
- http://opentechpress.jp/developer/06/06/21/0236254.shtml
Live-F1 deb パッケージ
更に嬉しいことに、有志の方が Live-F1 を deb パッケージ化してくれている。 何とも素晴らしい!!
ということで、deb化してみました。もともと構成がautoconf化されてて単純だし、cdbsを使えば5分足らずでパッケージを作れます。manがないとかいうのはさておき。
snip...
パッケージ名live-f1。
- KeN's GNU/Linux Diary - live-f1パッケージ
- http://kmuto.jp/d/index.cgi/debian/live-f1.htm
Live-F1 を試してみる
というわけで、早速 Live-F1 をインストールして遊んでみた。
- F1 公式サイトのアカウントを持っていない場合は Live Timing Registration で登録(無料)を行う。
- KeN's GNU/Linux Diary さんのこちらから deb パッケージをダウンロードする。ここでは live-f1_0.2.5-2_i386.deb を前提とする。
-
Live-F1 をインストールする。
# dpkg -i ./live-f1_0.2.5-2_i386.deb Selecting previously deselected package live-f1. (Reading database ... 15390 files and directories currently installed.) Unpacking live-f1 (from ./live-f1_0.2.5-2_i386.deb) ... Setting up live-f1 (0.2.5-2) ...
-
とりあえずバージョンなどを確認してみた。
# which live-f1 /usr/bin/live-f1 # live-f1 --version live-f1 0.2.5 Copyright (C) 2006 Scott James Remnant
. This is free software, covered by the GNU General Public License; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -
起動してみた。
# live-f1 live-f1 0.2.5 Copyright (C) 2006 Scott James Remnant
. This is free software, covered by the GNU General Public License; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In order to connect to the Live Timing stream, you need to be registered; if you've not yet done so, do so now by filling in the form at the URL: http://www.formula1.com/livetiming_registration/ Enter your registered e-mail address: me@example.com Enter your registered password: P Name Gap Int Time Sector 1 Sector 2 Sector 3 Ps Lap 70 1 1 F. ALONSO LAP 70 1:18.061 21.6 24.7 31.6 2 2 5 M. SCHUMACHER 2.1 2.1 1:16.605 21.2 24.2 31.0 2 3 3 K. RAIKKONEN 8.8 6.7 1:20.463 21.8 25.1 33.4 2 4 2 G. FISICHELLA 15.6 6.8 1:19.077 21.9 24.8 32.2 3 5 6 F. MASSA 25.1 9.4 1:20.819 22.5 25.4 32.7 1 6 8 J. TRULLI 1L 1L 1:18.299 21.7 24.9 31.5 2 7 16 N. HEIDFELD 1L 1.4 1:18.364 21.7 24.7 31.9 2 8 14 D. COULTHARD 1L 5.8 1:18.298 21.8 24.8 31.5 2 9 12 J. BUTTON 1L 2.1 1:18.976 22.2 24.7 32.0 2 10 21 S. SPEED 1L 0.4 1:18.925 22.2 24.9 31.6 2 11 15 C. KLIEN 1L 4.2 1:20.455 22.3 25.4 32.6 2 12 9 M. WEBBER 1L 5.8 1:23.858 24.4 26.7 32.6 2 13 20 V. LIUZZI 2L 1L 1:20.887 22.5 25.8 32.4 3 14 18 T. MONTEIRO 4L 2L 1:23.602 23.4 27.6 32.4 3 15 22 T. SATO 6L 2L 23.0 STOP 3 17 J. VILLENEUVE 12L 6L 22.2 STOP 2 7 R. SCHUMACHER 12L RETIRED 24.6 L51 25.7 L57 6 4 J. MONTOYA 57L 45L STOP 1 11 R. BARRICHELLO 59L 2L RETIRED 1 23 F. MONTAGNY 68L 9L 26.0 59.7 STOP 1 10 N. ROSBERG 69L 1L STOP 19 C. ALBERS 27.1 STOP 0
Live-F1 + ttyrec
今日のなんでやねんさんのところで ttyrec というツールが紹介されていた。 公式サイトによると、以下の様なものらしい。
ttyrec は tty を録画します。録画したデータは付属の ttyplayコ マンドで再生できます。ttyrec は script コマンドにマイクロ秒 単位で時間情報を埋め込む機能を追加しただけの代物です。emacs -nw でも vi でも lynx でも tty 上で動くプログラムなら何でも 録画できます。で、ttyrec と Live-F1 でレースの状況を録画しておくことができるそうだ。 live-f1パッケージ によると、
今気付いたんだが,コレをttyrecで録画しとけばlive timingの録画で出来るんじゃないの? ということで,今晩のカナダを録画してみよう.とのこと。楽しそう。 今週末(2006/07/02)のアメリカグランプリで試してみよう。
snip...
追記4: おぉ,ちゃんとttyplayで再生できる!
Jun 25, 2006
[WebService] Weather Hacks 発見!!
以前から天気予報を Web サービスで提供してくれるサイトが無いものかと思っていた。 しばらく前に調べたときには下記の様な情報に行き当たって結局諦めたのだが、現在では少し状況が変わっている様だ。
- Web屋のネタ帳 - 天気予報をXMLで提供すると気象庁が発表してから半年が経った
- http://neta.ywcafe.net/000484.html
- Web屋のネタ帳 - 天気予報のXMLはFTPでGETできる。ただし月額10万円超
- http://neta.ywcafe.net/000497.html
- Web屋のネタ帳 - もしも天気予報がXMLだったら − その1 XMLとは?
- http://neta.ywcafe.net/000338.html
- Web屋のネタ帳 - もしも天気予報がXMLだったら − その2 できない理由
- http://neta.ywcafe.net/000339.html
Jun 24, 2006
[Misc] オープンソースの SNS
オープンソースの SNS を調べてみた。
色々探してみたが、結局 2 つしか引っかからなかった。
他にもいくつか情報は存在するのだが、既に消滅していたり、そもそも一度もリリースされた形跡がなかったり。
SNS は人を集めてナンボのシステムなのでオープンソースには不向きなのかもしれない。
| プロダクト名 | サイト | ライセンス | 動作環境 | DBMS |
| OpenPNE | http://docs.openpne.jp/ | GPL 2.0 / Commercial License | PHP(4.3.*/5.0以降) | MySQL(4.0/4.1以降) |
| Affelio | http://open.affelio.jp/ | GPL 2.0 / Commercial License | Perl(5.6以降) | SQLite / MySQL(4.1以降) |
Jun 23, 2006
[Misc] コメントスパムが酷い(2)
とりあえず、スパマーの IP アドレスからの接続を拒否することにした。 httpd.conf を編集して接続を拒否する。
これでしばらく経過観察にしよう。Order allow,deny allow from all deny from 195.225.176.73 deny from 195.225.176.77 deny from 195.225.177.90 deny from 85.255.117.250
Jun 22, 2006
[Misc] コメントスパムが酷い
ここ 1 ヶ月ほど、コメントスパムが極端に酷くなった。 何パターンが存在しているのだけれど、その中でも特にたちの悪いものを調べてみた。
スパマーA - 195.225.176.73
最もたちの悪いのがこれ。 195.225.176.73、195.225.176.77、195.225.177.90 という 3 つの IP アドレスを使用してコメントスパムを送りつけてくる。 通数がやたらと多く、コメントのサイズも巨大なので非常に迷惑。 whois によると
というネットワークを使用している。inetnum: 195.225.176.0 - 195.225.179.255 netname: NETCATHOST descr: NetcatHosting country: UA admin-c: VS1142-RIPE tech-c: VS1142-RIPE status: ASSIGNED PI mnt-by: RIPE-NCC-HM-PI-MNT mnt-lower: RIPE-NCC-HM-PI-MNT mnt-by: NETCATHOST-MNT mnt-routes: NETCATHOST-MNT source: RIPE # Filtered remarks: **************************************** remarks: * Abuse contacts: abuse@netcathost.com * remarks: **************************************** person: Vsevolod Stetsinsky address: 01110, Ukraine, Kiev, 20チ, Solomenskaya street. room 206. phone: +38 050 6226676 e-mail: vs@netcathost.com nic-hdl: VS1142-RIPE source: RIPE # Filtered
スパマーB - 85.255.117.250
次にたちの悪いのがこれ。 85.255.117.250 という IP アドレスを使用している。
inetnum: 85.255.112.0 - 85.255.127.255 netname: inhoster descr: Inhoster hosting company descr: OOO Inhoster, Poltavskij Shliax 24, Kharkiv, 61000, Ukraine remarks: ----------------------------------- remarks: Abuse notifications to: abuse@inhoster.com remarks: Network problems to: noc@inhoster.com remarks: Peering requests to: peering@inhoster.com remarks: ----------------------------------- country: UA org: ORG-EST1-RIPE admin-c: AK4026-RIPE tech-c: AK4026-RIPE tech-c: FWHS1-RIPE status: ASSIGNED PI mnt-by: RIPE-NCC-HM-PI-MNT mnt-lower: RIPE-NCC-HM-PI-MNT mnt-by: RECIT-MNT mnt-routes: RECIT-MNT mnt-domains: RECIT-MNT mnt-by: DAV-MNT mnt-routes: DAV-MNT mnt-domains: DAV-MNT source: RIPE # Filtered organisation: ORG-EST1-RIPE org-name: INHOSTER org-type: NON-REGISTRY remarks: ************************************* remarks: * Abuse contacts: abuse@inhoster.com * remarks: ************************************* address: OOO Inhoster address: Poltavskij Shliax 24, Xarkov, address: 61000, Ukraine phone: +38 066 4633621 e-mail: support@inhoster.com admin-c: AK4026-RIPE tech-c: AK4026-RIPE mnt-ref: DAV-MNT mnt-by: DAV-MNT source: RIPE # Filtered person: Andrei Kislizin address: OOO Inhoster, address: ul.Antonova 5, Kiev, address: 03186, Ukraine phone: +38 044 2404332 nic-hdl: AK4026-RIPE source: RIPE # Filtered person: Fast Web Hosting Support address: 01110, Ukraine, Kiev, 20チ, Solomenskaya street. room 201. address: UA phone: +357 99 117759 e-mail: support@fwebhost.com nic-hdl: FWHS1-RIPE source: RIPE # Filtered
気づいたこと
スパマーA、スパマーB 共に
01110, Ukraine, Kiev, 20チ, Solomenskaya street.が関係している。 ワルモノはここに在住??
Jun 21, 2006
[Maven] pom.xml の pom / organization / name は折り返してはいけない。
唐突に Maven2 でよく分からないエラーが発生するようになってしまった。 Maven2 の依存解決時に JAR ファイルのヘッダがおかしいと言われてビルドに失敗してしまうというもの。
[INFO] [compiler:compile] Compiling 50 source files to C:\myproject\myapp\target\classes [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure Failure executing javac, but could not parse the error: エラー: C:\Documents and Settings\me\.m2\repository\myproject\1.0.0\myapp-1.0.0 .jar の読み込みエラーです。invalid header field エラー 1 個 [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4 seconds [INFO] Finished at: Wed Jun 21 16:57:35 JST 2006 [INFO] Final Memory: 6M/15M [INFO] ------------------------------------------------------------------------
結局、原因は pom.xml の pom / organization / name のコンテンツが折り返されていたことだった。 Eclipse WST の XML エディタで無意識にオートフォーマットをかけてしまっていたらしい。 なんだかものすごく deja vu を感じたので昔のエントリを見返してみると・・・「Maven2 で API Document を生成する方法」にメモしてあった orz 2 度も同じミスでハマってしまった。 今回は忘れないようにちゃんとエラー内容もメモしておく。
Jun 20, 2006
[Mustang] Derby in Mustang にチャレンジ
色々なところで話題になっているようだが、Derby が Mustang に同梱されるらしい。 公式には Java DB という DBMS が搭載されるということだが、Java DB のサイトには
What's Java DB?と記述されているので、Java DB == Derby ということだろう。
Java DB is Sun's supported distribution of the open source Apache Derby 100% Java technology database. It is fully transactional, secure, easy-to-use, standards-based -- SQL, JDBC API, and Java EE -- yet small, only 2MB. The Apache Derby project has a strong and growing community that includes developers from large companies such as Sun Microsystems and IBM as well as individual contributors.
ユニットテストやプロトタイプ開発時など「とりあえず何でもいいから DBMS が欲しい」というときに Derby を結構使うので同梱してくれるのは多少嬉しい。 ・・・ Maven2 使っていれば別に同梱してくれなくてもすぐ使えるけれど。
- Java DB is bundled in Mustang
- http://weblogs.java.net/blog/davidvc/archive/2006/06/java_db_is_bund.html
- Java DB
- http://developers.sun.com/prodtech/javadb
Derby in Mustang のインストール
早速 Java Platform, Standard Edition 6 Binary Snapshot Releases から jdk-6-rc-bin-b88-windows-i586-15_jun_2006.exe をダウンロードしてインストールしてみた。 インストールされた J2SE SDK を見てみると、%JAVA_HOME%\db に Derby がそのまま同梱されていることが分かる。
>tree /f C:\_java\jdk\1.6.0_15_jun_2006\db
C:\_JAVA\JDK\1.6.0_15_JUN_2006\DB
│ 3RDPARTY
│ CHANGES
│ COPYRIGHT
│ LICENSE
│ NOTICE
├─demo
│ ├─databases ... snip
│ └─programs ... snip
├─frameworks
│ │ readme.html
│ ├─embedded
│ │ │ readme.html
│ │ └─bin
│ │ dblook.bat
│ │ dblook.ksh
│ │ ij.bat
│ │ ij.ksh
│ │ setEmbeddedCP.bat
│ │ setEmbeddedCP.ksh
│ │ sysinfo.bat
│ │ sysinfo.ksh
│ └─NetworkServer
│ │ readme.html
│ └─bin
│ dblook.bat
│ dblook.ksh
│ ij.bat
│ ij.ksh
│ NetworkServerControl.bat
│ NetworkServerControl.ksh
│ setNetworkClientCP.bat
│ setNetworkClientCP.ksh
│ setNetworkServerCP.bat
│ setNetworkServerCP.ksh
│ startNetworkServer.bat
│ startNetworkServer.ksh
│ stopNetworkServer.bat
│ stopNetworkServer.ksh
│ sysinfo.bat
│ sysinfo.ksh
└─lib
derby.jar
derby.war
derbyclient.jar
derbyLocale_de_DE.jar
derbyLocale_es.jar
derbyLocale_fr.jar
derbyLocale_it.jar
derbyLocale_ja_JP.jar
derbyLocale_ko_KR.jar
derbyLocale_pt_BR.jar
derbyLocale_zh_CN.jar
derbyLocale_zh_TW.jar
derbynet.jar
derbyrun.jar
derbytools.jar
Derby in Mustang を使ってみる
環境設定
Mustang 内の Derby を実行するには、JAVA_HOME、DERBY_HOME という環境変数を指定する必要がある。 これら環境変数を指定した後で、DERBY_HOME の中にある環境設定用バッチファイルを実行する。 今回は Embedded モードを使用した。
> set JAVA_HOME=c:\_java\jdk\1.6.0_15_jun_2006 > set DERBY_HOME=%JAVA_HOME%\db > set PATH=%JAVA_HOME%\bin;%PATH% > %DERBY_HOME%\frameworks\embedded\bin\setEmbeddedCp.bat SET DERBY_HOME=c:\_java\jdk\161730~1.0_1\db set CLASSPATH=c:\_java\jdk\161730~1.0_1\db\lib \derby.jar;c:\_java\jdk\161730~1.0_1\db\lib\derbytools.jar;.;C:\Program Files\Ja va\jre1.5.0_06\lib\ext\QTJava.zip
環境確認
Derby の情報を確認するための sysinfo.bat というバッチファイルが用意されているので実行してみた。
> java -version
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b88)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b88, mixed mode, sharing)
> %DERBY_HOME%\frameworks\embedded\bin\sysinfo.bat
------------------ Java 情報 ------------------
Java バージョン: 1.6.0-rc
Java ベンダー: Sun Microsystems Inc.
Java ホーム: c:\_java\jdk\1.6.0_15_jun_2006\jre
Java クラスパス: c:\_java\jdk\161730~1.0_1\db\lib\derby.jar;c:\_java\jdk\1
61730~1.0_1\db\lib\derbytools.jar;.;C:\Program Files\Java\jre1.5.0_06\lib\ext\QT
Java.zip
OS 名: Windows XP
OS アーキテクチャー: x86
OS バージョン: 5.1
Java ユーザー名: me
Java ユーザー・ホーム: C:\Documents and Settings\me
Java ユーザー dir: C:\Hoge
java.specification.name: Java Platform API Specification
java.specification.version: 1.6
--------- Derby 情報 --------
JRE - JDBC: ?-?
[C:\_java\jdk\1.6.0_15_jun_2006\db\lib\derby.jar] 10.2.0.3 alpha - (412448:41244
9)
[C:\_java\jdk\1.6.0_15_jun_2006\db\lib\derbytools.jar] 10.2.0.3 alpha - (412448:
412449)
------------------------------------------------------
----------------- ロケール情報 ----------------
現行ロケール : [日本語/日本 [ja_JP]]
ロケールのサポートが見つかりました: [de_DE]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [es]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [fr]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [it]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [ja_JP]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [ko_KR]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [pt_BR]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [zh_CN]
バージョン: 10.2.0.3 alpha - (412448:412449)
ロケールのサポートが見つかりました: [zh_TW]
バージョン: 10.2.0.3 alpha - (412448:412449)
------------------------------------------------------
サンプルコード実行
以前作成した Embedded モード Derby 用のサンプルコードを実行してみた。
> java jp.in_vitro.codelets.mustang.javadb.Codelet field01=100, field02=dummy data field01=888, field02=hogehoge Derby システムがシャットダウンされました。 : 50000
Jun 19, 2006
[WebService] YouTube API にチャレンジ
YouTube とは
YouTube はビデオ共有サービスらしい。 しばらく前から話題になっていて気にはなっていたのだが、なかなか使ってみる機会がなかった。 調べてみたら API が公開されているということだったので、とりあえず API だけ遊んでみることにした。
- YouTube
- http://www.youtube.com/
- Developer APIs
- http://www.youtube.com/dev
試してみる
YouTube API を使用するには、YouTube のアカウントが必要。 まずは YouTube アカウント作成から行ってみた。
- YouTube SignUp から YouTube のアカウントを作成。
- developer profile で Developer ID を取得。
User Profile の取得
YouTube API は REST を採用している。
User Profile は下記の URL にアクセスすることで取得できる。
http://www.youtube.com/api2_rest?method=youtube.users.get_profile&dev_id=[Developer ID]&user=[プロファイルを取得したいユーザID]
<?xml version="1.0" encoding="utf-8"?>
<ut_response status="ok">
<user_profile>
<first_name />
<last_name />
<about_me />
<age>55</age>
<video_upload_count>0</video_upload_count>
<video_watch_count>0</video_watch_count>
<homepage />
<hometown />
<gender>m</gender>
<occupations />
<companies />
<city />
<country>JP</country>
<books />
<hobbies />
<movies />
<relationship />
<friend_count>0</friend_count>
<favorite_video_count>0</favorite_video_count>
<currently_on>true</currently_on>
</user_profile>
</ut_response>
Vide リストを取得
YouTube では Video にタグ付けができるらしい。
現在(2006/06/19) の YouTube API では Video リストはタグ単位、ユーザ単位で取得できる。
とりあえず "cat" というタグのついた Video リストを取得してみた。
URL は下記の通り。
http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=[Developer ID]&tag=cat
<?xml version="1.0" encoding="utf-8"?>
<ut_response status="ok">
<video_list>
<video>
<author />
<id>HsNYrJDwguo</id>
<title>cat</title>
<length_seconds>183</length_seconds>
<rating_avg>3.46</rating_avg>
<rating_count>54</rating_count>
<description>cat</description>
<view_count>51380</view_count>
<upload_time>1145383314</upload_time>
<comment_count>33</comment_count>
<tags>cat</tags>
<url>http://www.youtube.com/?v=HsNYrJDwguo</url>
<thumbnail_url>http://sjl-static6.sjl.youtube.com/vi/HsNYrJDwguo/2.jpg</thumbnail_url>
</video>
snip...
</video_list>
</ut_response>
Jun 18, 2006
[Library] JChart2D にチャレンジ
JChart2D とは
JChart2D はチャートを生成してくれる Java 用のライブラリ。 LGPL で提供されている。
実行環境準備
- こちら から JChart2D をダウンロードする。ここでは jchart2d-2.0.0.jar を前提とする。
- jchart2d-2.0.0.jar をクラスパスに追加する。
サンプルコード
JChart2D を使用して JPEG のチャートを生成するサンプルを作成してみた。 残念なことに、ウィンドウを表示しない状態での動作は実現できなかった。 というわけで、X Window System がインストールされていない等でウィンドウ描画ができない環境では実行できない。 何か方法があるのだろうか・・・。
package jp.in_vitro.codelets.jchart2d;
import info.monitorenter.gui.chart.Chart2D;
import info.monitorenter.gui.chart.ITrace2D;
import info.monitorenter.gui.chart.traces.Trace2DSimple;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class Codelet {
public Codelet() {
super();
}
protected void execute() throws IOException {
Chart2D chart = new Chart2D();
ITrace2D trace = new Trace2DSimple();
Random random = new Random();
for (int i = 100; i >= 0; i--) {
trace.addPoint(i, random.nextDouble() * 10.0 + i);
}
chart.addTrace(trace);
chart.setSize(640, 480);
chart.setPaintLabels(true);
JFrame frame = new JFrame();
frame.setSize(640, 480);
frame.add(chart);
frame.setVisible(true);
BufferedImage image = chart.snapShot();
frame.setVisible(false);
frame.dispose();
ImageIO.write(image, "JPEG", new File("c:\\chart.jpg"));
}
public static void main(String[] args) throws IOException {
Codelet me = new Codelet();
me.execute();
}
}
Jun 17, 2006
[Misc] プロジェクト jdk-api-ja に参加してみる
jdk-api-ja プロジェクトで Mustang の日本語ドキュメントの精度を高めよう、という活動を行っているらしいということを知った。 日本語ドキュメントは当然日本人のためのものだから、やはり日本人が貢献すべきだろう。 どこまで貢献できるか分からないがとりあえず参加はしておくことに。
- プロジェクト jdk-api-ja
- https://jdk-api-ja.dev.java.net/ja/index.html
プロジェクト jdk-api-ja へようこそ! このプロジェクトは JDK ドキュメントの日本語翻訳の品質向上を目指します。現在、 java.sun.com において、API 仕様を含め JDK ユーザードキュメントの日本語翻訳が提供されています。一方で、Sun はこれらのドキュメントについてユーザ様からバグ報告や、改善のご提案を頂いており、それらを基に定期的に修正を行っています。本プロジェクトではこのプロセスをよりオープンなものにし、リリース前の翻訳に関しても皆様からのフィードバックを取り入れるなど、さらなる日本語翻訳の品質向上を目指します。日本語ドキュメントユーザの皆様、是非ご参加下さい。
なお、プロジェクトの性質上基本的には日本語で運営させて頂きます。
Jun 15, 2006
[Misc] 日本標準 NTP スタート!!
かねてからの願いであった日本標準 NTP がスタートしたらしい。 管理してくれるのは独立行政法人・情報通信研究機構(NICT)。 独立行政法人がこういうサービスをしてくれるのは本当に有り難い。 SourceForgeやApacheのミラーサーバなんかももっと国内でやって欲しいな。
- 世界最高性能のインターネット用時刻同期サーバによる日本標準時配信の開始
- http://www2.nict.go.jp/pub/whatsnew/press/h18/060612-1/060612-1.html
- 世界最高性能のNTPサーバ、NICTが新設
- http://www.itmedia.co.jp/news/articles/0606/12/news068.html
NTP サーバの情報
NTP サーバの情報を見てみた。 IPv6 のアドレスも持っている様だ。
# nslookup > server ns1.nict.jp Default Server: ns1.nict.jp Address: 133.243.3.1 > set type=A > ntp.nict.jp Server: ns1.nict.jp Address: 133.243.3.1 Name: ntp.nict.jp Addresses: 133.243.238.163, 133.243.238.164, 133.243.238.243, 133.243.238.244 > set type=AAAA > ntp.nict.jp Server: ns1.nict.jp Address: 133.243.3.1 ntp.nict.jp AAAA IPv6 address = 2001:2f8:29::fff3 ntp.nict.jp AAAA IPv6 address = 2001:2f8:29::fff4 nict.jp nameserver = ns1.nict.jp nict.jp nameserver = ns2.nict.jp ns1.nict.jp internet address = 133.243.3.1 ns2.nict.jp internet address = 133.243.3.2 >
NTP サーバに接続してみる
とりあえず試しに接続してみた。 ntpdate で同期してみただけなのだけれど。
# /etc/init.d/ntp-server stop Stopping NTP server: ntpd. # ntpdate 133.243.238.163 14 Jun 16:21:53 ntpdate[32251]: adjust time server 133.243.238.163 offset -0.078740 sec
自動的に時刻同期をする場合、/etc/ntp.conf を編集する。
# vi /etc/ntp.conf server ntp.nict.jp server ntp.nict.jp server ntp.nict.jp
Jun 14, 2006
[Trac] Trac にチャレンジ(5)
カスタムレポートの作成
Trac はバグや TODO、その他 issue などを Ticket として管理する。 レポート機能を使用することで Ticket の一覧画面を簡単にカスタマイズできる。 例えば、「バージョンが 1.0.0 の Ticket 全て」「マイルストーン MS_001 の Ticket の内クローズされていないもの」といった画面を作成できる。 レポートは非常に便利な機能なので、自前の Report 作成にチャレンジしてみた。
カスタムレポートの作成方法
カスタムレポートの作成方法は Trac のヘルプに記述されている。
- Trac Reports
- https://www.in-vitro.jp/projects/wiki/TracReports
- Trac Permissions
- https://www.in-vitro.jp/projects/wiki/TracPermissions
アカウントにレポート生成権限を付与
デフォルト状態のアカウントはレポート生成権限を持っていない。 そのため、trac-admin コマンドを使用してレポート生成権限を与える。
ちなみに、レポート関連の権限には REPORT_VIEW, REPORT_CREATE, REPORT_MODIFY, REPORT_DELETE, REPORT_ADMIN, REPORT_SQL_VIEW がある。 REPORT_CREATE を付与するついでに REPORT_MODIFY を付与しておくと、デフォルトで用意されているレポートの定義情報を見られるようになる。# trac-admin /tmp/trac/myprojects permission add me REPORT_CREATE
レポートの作成
REPORT_CREATE 権限を所有しているアカウントでログインすると、"View Tickets" 画面に "New Report" というリンクが表示される。 "New Report" からレポート生成画面に移動し、Report Title、Description、SQL Query for Report を入力するとレポートが生成される。 今回は特定のコンポーネント用の Ticket を表示するレポートを作成してみた。 作成した、とは言ってもほとんどデフォルトで用意されているレポートの Copy & Paste。
Active Tickets by Component [MyComponent]
SELECT p.value AS __color__,
t.milestone AS __group__,
(CASE status
WHEN 'closed' THEN 'color: #777; background: #ddd; border-color: #ccc;'
ELSE
(CASE owner WHEN '$USER' THEN 'font-weight: bold' END)
END) AS __style__,
id AS ticket, summary, component, status,
resolution,version, severity, priority, owner,
changetime AS modified,
time AS _time,reporter AS _reporter
FROM ticket t,enum p
WHERE status IN ('new', 'assigned', 'reopened') AND
p.name=t.priority AND p.type='priority' AND
component='MyComponent'
ORDER BY (milestone IS NULL), milestone DESC, (status = 'closed'),
(CASE status WHEN 'closed' THEN modified ELSE -p.value END) DESC
All Tickets By Component[MyComponent] (Including closed)
SELECT p.value AS __color__,
t.milestone AS __group__,
(CASE status
WHEN 'closed' THEN 'color: #777; background: #ddd; border-color: #ccc;'
ELSE
(CASE owner WHEN '$USER' THEN 'font-weight: bold' END)
END) AS __style__,
id AS ticket, summary, component, status,
resolution,version, severity, priority, owner,
changetime AS modified,
time AS _time,reporter AS _reporter
FROM ticket t,enum p
WHERE p.name=t.priority AND p.type='priority' AND
component='MyComponent'
ORDER BY (milestone IS NULL), milestone DESC, (status = 'closed'),
(CASE status WHEN 'closed' THEN modified ELSE -p.value END) DESC
Jun 13, 2006
[Book] Java EE 5.0 本(少しだけ)続々
先日 EJB3 の書籍を調べてみたので、Java EE 5.0 関連書籍も調べてみた。 こちらは EJB3 程出版されない様だ。 J2EE(Java EE) も枯れてきたということなのか。 少し寂しい。
EJB 3.0 関連書籍
2005/10 発売
![]()
Beginning Java EE 5 From Novice to Professional
2006/05 発売
![]()
Pro Java EE 5 Performance Management and Optimization
2006/10 発売
Jun 12, 2006
[WebService] Flickr API にチャレンジ
Flickr API とは
Flickr は写真を共有するサービスを提供しているサイト。 API 経由で写真の検索などができる。
- Flickr
- http://www.flickr.com/
- Flickr Services
- http://www.flickr.com/services/api/
試してみる
- こちらから Flickr のアカウントを取得する。
- こちらから API application key を取得する。
- http://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=[Your API application key]&text=[Query] にアクセスする。
実行結果
http://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=[My API application key]&text=dr+strangelove にアクセスした結果がこちら↓
上記の XML には URL が含まれていないのでそのままでは写真を取得することができない。 ID から URL へのマッピングルールは以下に記述されている。<?xml version="1.0" encoding="utf-8" ?> <rsp stat="ok"> <photos page="1" pages="2" perpage="100" total="167"> <photo id="159653118" owner="14441184@N00" secret="4137e632d9" server="51" title="Dr_Strangelove" ispublic="1" isfriend="0" isfamily="0" /> <photo id="157381443" owner="84949728@N00" secret="6dd9524b53" server="48" title="Riding the Fire Hydrant" ispublic="1" isfriend="0" isfamily="0" /> <photo id="152649730" owner="91264084@N00" secret="e8a2ad03da" server="54" title="dr_strangelove" ispublic="1" isfriend="0" isfamily="0" /> ...略 </photos> </rsp>
API Explorer
Flickr は Web インターフェースから API をコールできる API Explorer というアプリケーションを提供している。 ちょっと試してみるには非常に便利。
- 写真検索用 API をコールする API Explorer
- http://www.flickr.com/services/api/explore/?method=flickr.photos.search
Jun 11, 2006
[WebService] Technorati API にチャレンジ
Technorati API とは
Technorati は Blog 検索サービスを提供しているサイト。 Search や Browse といった照会系の API を提供してくれているので、試してみた。
- Technorati
- http://www.technorati.com/
- Developer Center
- http://www.technorati.com/developers/
- Technorati API Documentation
- http://www.technorati.com/developers/api/
試してみる
- こちらで Technorati のアカウントを取得する。
- 生成したアカウントでサインインする。
- こちらに ApiKey が表示されるのでメモ。
- http://api.technorati.com/search?key=[Your ApiKey]&query=[Query] にアクセスして検索を行ってみる。
実行結果
http://api.technorati.com/search?key=[My ApiKey]&query=star+wars にアクセスした結果がこちら↓
<?xml version="1.0" encoding="utf-8"?>
<!-- generator="Technorati API version 1.0 /search" -->
<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml">
<tapi version="1.0">
<document>
<result>
<query>star wars</query>
<querycount>647413</querycount>
<rankingstart>0</rankingstart>
</result>
<item>
<weblog>
<name>The Truth Shall Make Ye Fret</name>
<url>http://kingandy.livejournal.com</url>
<rssurl></rssurl>
<atomurl>http://kingandy.livejournal.com/data/atom</atomurl>
<inboundblogs>1</inboundblogs>
<inboundlinks>2</inboundlinks>
<lastupdate>2006-06-06 12:20:43 GMT</lastupdate>
</weblog>
<title>The Truth Shall Make Ye Fret</title>
<excerpt>So I've found the link at the bottom of the Penny Arcade front page that permalinks to the most recent comic. You are no longer safe from my linkage. Why the new Star Wars original trilogy DVDs are a crappy rip</excerpt>
<created>2006-06-08 08:49:22 GMT</created>
<permalink>http://kingandy.livejournal.com/388241.html</permalink>
</item>
...略
</document>
</tapi>
現在提供されている API
2006/06/11 現在、以下の API が提供されている。
- Search
-
- cosmos ・・・ Blogs linking to a given URL.
- search ・・・ Blog posts featuring a given keyword or phrase.
- tag ・・・ Blog posts tagged with a specific topic.
- Browse
-
- toptags ・・・ Top tags indexed by Technorati.
- Blog information
-
- bloginfo ・・・ Information about a specific blog URL such as link counts, rank, and available feeds.
- blogposttags ・・・ The top tags used by a specific blog.
- Member Information
-
- getinfo ・・・ Information about a Technorati member such as full name and other blogs by the same author.
Jun 10, 2006
[Trac] Trac にチャレンジ(4)
Ticket のフィールドをカスタマイズする
Ticket にはデフォルトで Summary、Component、Version などいくつかのフィールドが用意されている。 また、デフォルトのフィールドでは不足の際はカスタムフィールドを追加することができる。 ということで、カスタムフィールドの追加にチャレンジ。
- Custom Ticket Fields
- http://projects.edgewall.com/trac/wiki/TracTicketsCustomFields
[ticket-custom] ticket_type = select ticket_type.label = Type ticket_type.options = Memo|Bug|Todo ticket_type.value = 0
Jun 09, 2006
[Misc] GanttProject にチャレンジ
GanttProject とは
GanttProject は、名前の通りプロジェクトをガントチャートで管理するツール。 フリーの Microsoft Project といったところか。 機能的には Microsoft Project の方が高機能だけれど、個人的にはこれで十分な気がする。 Java で開発されているのでプラットフォームを選ばず実行できる、Java Web Start で実行することができる(但し、その場合は PDF によるエクスポートができない)、多言語対応で日本語にも対応しているなど嬉しい点が結構ある。
- GanttProject
- http://ganttproject.sourceforge.net/index.php
- Demo
- http://ganttproject.sf.net/demo/demo.html
- Run (Java Web Start)
- http://ganttproject.sf.net/jws/ganttproject.jnlp
- Weekbuild の Hack 倉庫 - ガントチャートとマイルストーン
- http://weekbuild.sakura.ne.jp/trac/ticket/49
GanttProject を Java Web Start から起動してみた。
デフォルトの Locale を見てくれているらしく、起動直後から日本語で表示された。
![[Role View]](/blog/entries/Misc/20060609_01/gantt_02.png)
ちなみに、担当者を作成する前に 編集 > 設定 > 担当者の役割 でロールを設定する必要がある。
ロールを指定せずに担当者を生成すると担当者タブを選択できなくなる(バグ??)。
Jun 08, 2006
[Misc] \\?\ の効用
Windows では \\?\ を使用すると通常許されない名前のディレクトリやファイルを作成できるということを教えてもらった。 \\?\ に続けてフルパスを指定すると、半角ドット(.)で終わるファイルやディレクトリを作成できるらしい。 というわけで、早速チャレンジ。
C:\tmp>dir C:\tmp のディレクトリ 2006/06/04 01:58 <DIR> . 2006/06/04 01:58 <DIR> .. C:\tmp>md dummy C:\tmp>dir C:\tmp のディレクトリ 2006/06/04 01:58 <DIR> . 2006/06/04 01:58 <DIR> .. 2006/06/04 01:58 <DIR> dummy C:\tmp>rd dummy C:\tmp>dir C:\tmp のディレクトリ 2006/06/04 01:59 <DIR> . 2006/06/04 01:59 <DIR> .. C:\tmp>md dummy. C:\tmp>dir C:\tmp のディレクトリ 2006/06/04 01:59 <DIR> . 2006/06/04 01:59 <DIR> .. 2006/06/04 01:59 <DIR> dummy C:\tmp>rd dummy. C:\tmp>dir C:\tmp のディレクトリ 2006/06/04 01:59 <DIR> . 2006/06/04 01:59 <DIR> .. C:\tmp>md \\?\c:\tmp\dummy. C:\tmp>dir C:\tmp のディレクトリ 2006/06/04 01:59 <DIR> . 2006/06/04 01:59 <DIR> .. 2006/06/04 01:59 <DIR> dummy. C:\tmp>dir dummy. C:\tmp のディレクトリ ファイルが見つかりません C:\tmp>dir \\?\c:\tmp\dummy. \\?\c:\tmp\dummy のディレクトリ ファイルが見つかりません C:\tmp>rd dummy. 指定されたファイルが見つかりません。 C:\tmp>rd c:\tmp\dummy. 指定されたファイルが見つかりません。 C:\tmp>rd \\?\c:\tmp\dummy. C:\tmp>dir C:\tmp のディレクトリ 2006/06/04 02:01 <DIR> . 2006/06/04 02:01 <DIR> .. C:\tmp>
Jun 07, 2006
[Misc] Eclipse Update Site のミラーサイトを作成する
Eclipse 3.x では Software Update 機能が提供され、プラグインのインストールが楽になった。 ただし、この機能、当然作業の度に Update Site に接続する必要がある。 大人数で一度に環境を整えたり、ネットワークの帯域が不足していたり、サーバが落ちていたりするとプラグインのインストールが延々終わらなかったりする。 プロジェクトの開始時にプラグインのインストールが出来ないと困るので、プロジェクトローカルの Update Site を準備してみた。
Subclipse Update Site の構築
Subversion Client Plugin である Subclipse の Update Site を用意する。 Subclipse は、Update Site をそのままアーカイビングしたファイルを提供してくれている。 そのため、Update Site の構築は非常に楽。
- こちらから Update Site のアーカイブをダウンロードする。(ここでは site-1.0.1.zip を前提とする)
-
Apache 経由でアクセスできる位置にアーカイブを展開する。
# mkdir /var/www/eclipse-plugins/subclipse # cd /var/www/eclipse-plugins/subclipse # unzip ./site-1.0.1.zip Archive: ./site-1.0.1.zip creating: features/ inflating: features/org.tigris.subversion.subclipse_1.0.1.jar creating: plugins/ inflating: plugins/org.tigris.subversion.javahl.win32_1.0.0.jar inflating: plugins/org.tigris.subversion.subclipse.core_1.0.1.jar inflating: plugins/org.tigris.subversion.subclipse.ui_1.0.1.jar inflating: plugins/org.tigris.subversion.subclipse_1.0.1.jar inflating: site.xml # ls features plugins site-1.0.1.zip site.xml # chown -R www-data:www-data .
- Eclipse の Software Update で http://www.example.com/eclipse-plugins/subclipse/ (URL はアーカイブの展開先に合わせる) を指定してみる。プラグインが見えれば OK。
Maven 2.0 integration plugin Update Site の構築
Maven2 用の Eclipse Plugin の Update Site を用意する。 Maven2.0 integration plugin は残念ながら Update Site 用ファイルのアーカイブは提供されていない。 そのため、必要となるファイルを集めて Update Site を作成する。
- こちらから site.xml をダウンロードする。
- こちらから Plugin の jar ファイルをダウンロードする。(ここでは org.maven.ide.eclipse.feature_0.0.9.jar を前提とする)
-
site.xml を編集する。
全バージョンをミラーリングするのであれば編集は不要。
今回はプロジェクトで使用するバージョンだけをミラーリングするので、その他バージョンに関する記述を削除する。
<?xml version="1.0" encoding="UTF-8"?> <site> <feature url="features/org.maven.ide.eclipse.feature_0.0.9.jar" id="org.maven.ide.eclipse.feature" version="0.0.9"> <category name="Maven 2.0 integration"/> </feature> <category-def name="Maven 2.0 integration" label="org.maven.ide.eclipse"/> </site> -
Update Site 用にディレクトリ構成を作成し、ファイルを設置する。
/var/www/eclipse-plugins/maven2/ ├ features/ │ └ org.maven.ide.eclipse.feature_0.0.9.jar └ site.xml
- Eclipse の Software Update で http://www.example.com/eclipse-plugins/maven2/ (URL は上記で作成したディレクトリに合わせる) を指定してみる。プラグインが見えれば OK。
本格的に Eclipse Update Site のミラーサイトを構築する
ネットワークやマシンの問題で私には無理ではあるけれど、公開用 Eclipse Update Site のミラーサイトを構築することもできる。
- Re: [eclipse-mirrors] Eclipse update site mirror
- http://dev.eclipse.org/mhonarc/lists/eclipse-mirrors/msg00151.html
Simply add this RSYNC line to your script:
rsync -rtlv --delete download.eclipse.org::eclipseMirror/eclipse/updates/ /path/to/eclipse.org mirror/eclipse/updates/
I will be looking for your Update content at this URL:
http://eclipse.gabriel.co.hu/eclipse/updates/3.1/site.xml
When you are synced, please let me know and I'll add you to the Updates list.
自作 Plugin 用 Update Site の構築
当然ながら、自作 Plugin 用 Update Site を構築することもできる。
- FAQ How do I create an update site (site.xml)?
- http://wiki.eclipse.org/index.php/FAQ_How_do_I_create_an_update_site_(site.xml)%3F
Jun 06, 2006
[Book] EJB 3.0 本続々
2006/05/11 に EJB 3.0 Specification の Final Release が公開された。 書籍の方も続々と出版されてきている。 そろそろ書籍を買い揃える時期か。
- Enterprise JavaBeans Technology
- http://java.sun.com/products/ejb/
- JSR-000220 Enterprise JavaBeans 3.0 (Final Release)
- http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html
EJB 3.0 関連書籍
2006/05 発売
![]()
Ejb 3.0 in a Nutshell A Desktop Quick Reference for Ejb 3.0
![]()
Pro EJB 3 Java Persistence API (Pro)
![]()
Enterprise Javabeans 3.0
2006/07 発売
![]()
Mastering Enterprise Javabeans 3.0
![]()
Beginning Ejb 3 (Beginning from Novice to Professional)
2006/09 発売
Jun 05, 2006
[Library] JDiff にチャレンジ
JDiff とは
JDiff はプロジェクトのバージョン間で API の diff を取るツール。 カスタム Doclet として提供され、新旧 API Document の比較を行い、比較結果の API Document を生成する。 ソースコードではなく、API の比較というのは目新しいので試してみた。
サンプルの実行
サンプルは Ant から実行できる。 JDK、Ant にパスを通して Ant を実行する。 ↓の例では JDiff のバージョンを確認するために JDiff にもパスを通している。
Ant プロセス終了後、file:///C:/_java/tool/jdiff/1.0.10/examples/sample_output/newdocs/changes.html にアクセスする。>set JAVA_HOME=c:\_java\jdk\1.5.0_06 >set PATH=%JAVA_HOME%\bin;%PATH% >set ANT_HOME=c:\_java\tool\ant\1.6.4 >set PATH=%ANT_HOME%\bin;%PATH% >set JDIFF_HOME=c:\_java\tool\jdiff\1.0.10 >set PATH=%JDIFF_HOME%\bin;%PATH% >java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing) >ant -version Apache Ant version 1.6.4 compiled on May 19 2005 >jdiff -version JDiff version: 1.0.10 >cd c:\_java\tool\jdiff\1.0.10\examples >ant Buildfile: build.xml init: create_javadoc_dirs: javadoc_old: [javadoc] Generating Javadoc [javadoc] Javadoc execution [javadoc] パッケージ com.acme.sp のソースファイルを読み込んでいます... [javadoc] パッケージ com.acme.util のソースファイルを読み込んでいます... [javadoc] Javadoc 情報を構築しています... [javadoc] 標準 Doclet バージョン 1.5.0_06 ...略 javadoc_new: [javadoc] Generating Javadoc [javadoc] Javadoc execution [javadoc] パッケージ com.acme.sp のソースファイルを読み込んでいます... [javadoc] パッケージ com.acme.spextra のソースファイルを読み込んでいます... [javadoc] Javadoc 情報を構築しています... [javadoc] 標準 Doclet バージョン 1.5.0_06 ...略 jdiff_old_api: [javadoc] Generating Javadoc [javadoc] Javadoc execution [javadoc] パッケージ com.acme.sp のソースファイルを読み込んでいます... [javadoc] パッケージ com.acme.util のソースファイルを読み込んでいます... [javadoc] Javadoc 情報を構築しています... [javadoc] JDiff: doclet started ... [javadoc] JDiff: writing the API to file 'SuperProduct_1.0.xml'... [javadoc] JDiff: finished (took 0s, not including scanning the source files). jdiff_new_api: [javadoc] Generating Javadoc [javadoc] Javadoc execution [javadoc] パッケージ com.acme.sp のソースファイルを読み込んでいます... [javadoc] パッケージ com.acme.spextra のソースファイルを読み込んでいます... [javadoc] Javadoc 情報を構築しています... [javadoc] JDiff: doclet started ... [javadoc] JDiff: writing the API to file 'SuperProduct_2.0.xml'... [javadoc] JDiff: finished (took 0s, not including scanning the source files). jdiff_compare_apis: [javadoc] Generating Javadoc [javadoc] Javadoc execution [javadoc] ソースファイル C:\_java\tool\jdiff\1.0.10\lib\Null.java を読み込んで います... [javadoc] Javadoc 情報を構築しています... [javadoc] JDiff: doclet started ... [javadoc] JDiff: reading the old API in from file 'SuperProduct_1.0.xml'... fi nished [javadoc] JDiff: reading the new API in from file 'SuperProduct_2.0.xml'... fi nished [javadoc] JDiff: comparing the old and new APIs ... [javadoc] Approximately 64% difference between the APIs [javadoc] JDiff: reading the comments in from file 'C:\_java\tool\jdiff\1.0.10 \examples\sample_output\newdocs\user_comments_for_SuperProduct_1.0_to_SuperProdu ct_2.0.xml'... [javadoc] JDiff: generating HTML report into the file 'C:\_java\tool\jdiff\1.0 .10\examples\sample_output\newdocs\changes.html' and the subdirectory 'C:\_java\ tool\jdiff\1.0.10\examples\sample_output\newdocs\changes' [javadoc] JDiff: writing the comments out to file 'C:\_java\tool\jdiff\1.0.10\ examples\sample_output\newdocs\user_comments_for_SuperProduct_1.0_to_SuperProduc t_2.0.xml'... [javadoc] JDiff: finished (took 0s). jdiff: BUILD SUCCESSFUL Total time: 14 seconds >
Jun 04, 2006
[Blosxom] SimpleAPI その1. にチャレンジ(2)
SimpleAPI その1. 用の Blosxom プラグインを作成してみた。 %BLOSXOM_HOME%/plugins/siteimg に保存して、Story 内で [[siteimg:<URL>]] と記述するだけ。
SimpleAPI その1. 用 Blosxom プラグイン
プラグインのソースは下記の通り。
ZIP アーカイブでダウンロードする場合は
こちら。
# Blosxom Plugin: siteimg
# Author: in-vitro.jp
# Version: 1.0.0
# License: GPL
# Autoattach
#
# Usage Examples:
# [[siteimg:http://www.in-vitro.jp]]
package siteimg;
###############################################################
# Configuration Section
$simpleapi1_url = "http://img.simpleapi.net/small/";
###############################################################
sub start {
1;
}
sub story {
my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
$$body_ref =~ s/\[\[siteimg:(.+)\]\]/ <a href="$1\"><img src="$simpleapi1_url$1" width="128" height="128" border="0"><br>$1<\/a>/gs;
1;
}
1;
こんな感じで表示される。
http://www.in-vitro.jp/blog/index.cgi
Jun 03, 2006
[WebService] SimpleAPI その1. にチャレンジ
SimpleAPI その1. ウェブサイトサムネイル作成API β版 というサービスを見つけた。 URL を渡すとページのサムネイル画像を返してくれる。 なかなか面白そうなので試してみた。
- SimpleAPI
- http://img.simpleapi.net/
このサイトのサムネイル画像
<a href="http://www.in-vitro.jp/blog/index.cgi"> <img src="http://img.simpleapi.net/small/http://www.in-vitro.jp/blog/index.cgi" alt="" width="128" height="128" hspace="4" vspace="4" border="0"> </a>Blosxom 用の plugin でも作ってみようかな。
Jun 02, 2006
[Trac] Trac にチャレンジ(3)
マクロの追加
Trac built-in Wiki 用のマクロを追加してみた。 マクロは以下で公開されている。
- MacroBazaar
- http://projects.edgewall.com/trac/wiki/MacroBazaar
- TracHacks - plugin
- http://trac-hacks.org/wiki/plugin
- Javadoc
- http://projects.edgewall.com/trac/wiki/MacroBazaar#Javadoc
- AddComment
- http://trac-hacks.org/wiki/AddCommentMacro
- TOC
- http://trac-hacks.org/wiki/TocMacro
Milestone を Google Calendar に表示する
Trac は Roadmap を iCalendar 用データファイルとしてエクスポートする機能を持っている。 このデータファイルには、Milestone やチケットの情報が含まれている。 都合の良いことに、Google Calendar は iCalendar のデータファイルをインポートする機能を持っている。 というわけで、Trac の Roadmap 情報を Google Calendar にインポートできるか試してみた。
Milestone の作成
まず Milestone を作成する。 先日試した様に trac-admin を使用する。 Milestone を作成する際には、必ず完了期日を指定する。 Google Calendar では完了期日の指定されていない Milestone は表示されない。
ちなみに、完了期日の設定されていない Milestone に完了期日を設定する場合は# trac-admin /tmp/trac/myprojects milestone add MyMilestone "Jun 18, 2006"
という様に、"add" コマンドの代わりに "time" コマンドを使用する。# trac-admin /tmp/trac/myprojects milestone time MyMilestone "Jun 18, 2006"
Roadmap のエクスポート
Roadmap ページに行くと、"Download in other formats: iCalendar" というリンクがある。 ここをクリックすると Roadmap の情報がエクスポートされる。
Google Calendar にインポート
Google Calendar の "settings" から "Import Calendar" タブを選択する。
先ほどエクスポートしたデータファイルを選択し、インポート先のカレンダーを指定。
"Import" ボタンを押下するとデータがインポートされる。
Jun 01, 2006
[Book] フリーで公開されている Java 関連書籍リスト
何となく集めていたフリーで公開されている Java 関連書籍を整理してみた。 古いものが大半だけれど、まだ情報源にできる書籍もそこそこある。 今となってはどこから集めたのか分からないので出典は掲載しない(というか、できない)。
May 31, 2006
[Misc] 攻撃?? 研究?? 調査??
ありがちな脆弱性をねらったアクセスが来ていた。 Perl などで発生しやすい OS コマンドインジェクションを狙ったもの。
- HotFix Report - OSコマンド・インジェクション(OS command injection)
- http://www.hotfix.jp/archives/word/2004/word04-18.html
- セキュリティガイドライン - 4. OSコマンドインジェクション
- http://www.e-3lab.com/security_guideline/index.html#os
********************** - - [30/May/2006:10:56:18 +0900] "GET /blog/index.cgi/Web
Service/20051218_01.htm|ls%20-la| HTTP/1.1" 200 5857 "-" "Mozilla/4.0 (compatibl
e; MSIE 6.0; Windows NT 5.1)"
アクセス元が某国内有名研究所関連の組織なので、さすがにクラックするつもりではないと思うけれど。
調査・研究目的であっても、外部サーバに対して脆弱性を突く(可能性のある) URL を流すなら事前に教えて欲しい。
攻撃なのか調査・研究なのかはアクセスされた方では判断できないから。
・・・と個人的には思うが、人によって判断の分かれるところだろう。 面倒で一々連絡していられるか、ということかもしれない(^^;
とりあえず、怖いので攻撃は勘弁してくださいませ m(_ _)m > ALL
May 30, 2006
[Trac] Trac にチャレンジ(2)
Trac の動作環境が整ったので、実際に使用できるようにプロジェクトの初期設定を行う。 プロジェクトにはコンポーネントやマイルストーンなどの初期値が設定されている。 初期値をそのまま使うことはないので、初期値を削除して実際に使用する値をセットする。 この作業はコマンドラインから trac-admin コマンドを実行して行う。
component の設定
コンポーネントの初期値は component1, component2 となっている。 さすがに component1 という名前のコンポーネントを作成することはないだろう。 ということで、これを削除して新しいコンポーネントを追加する。
# trac-admin /tmp/trac/myprojects component list Name Owner -------------------- component1 somebody component2 somebody # trac-admin /tmp/trac/myprojects component remove component1 # trac-admin /tmp/trac/myprojects component remove component2 # trac-admin /tmp/trac/myprojects component list Name Owner ----------- # trac-admin /tmp/trac/myprojects component add MyComponent me # trac-admin /tmp/trac/myprojects component list Name Owner --------------------- MyComponent me #
version の設定
# trac-admin /tmp/trac/myprojects version list Name Time ---------- 1.0 2.0 # trac-admin /tmp/trac/myprojects version remove 1.0 # trac-admin /tmp/trac/myprojects version remove 2.0 # trac-admin /tmp/trac/myprojects version list Name Time ---------- # trac-admin /tmp/trac/myprojects version add 1.0.0 # trac-admin /tmp/trac/myprojects version list Name Time ----------- 1.0.0 #
milestone の設定
# trac-admin /tmp/trac/myprojects milestone list Name Time ---------------- milestone1 milestone2 milestone3 milestone4 # trac-admin /tmp/trac/myprojects milestone remove milestone1 # trac-admin /tmp/trac/myprojects milestone remove milestone2 # trac-admin /tmp/trac/myprojects milestone remove milestone3 # trac-admin /tmp/trac/myprojects milestone remove milestone4 # trac-admin /tmp/trac/myprojects milestone list Name Time ---------- #
May 29, 2006
[Trac] Trac にチャレンジ
Trac とは
Trac は Web インターフェースの Wiki + BugTracker + Subversion Viewer。 聞くところによると結構便利らしい。 WebSVN をインストールしようかと思っていたのだけれど、どうせなら BugTracker も一緒に欲しいということで Trac にしてみた。
- Trac
- http://www.edgewall.com/trac/
- The Trac Configuration File
- http://projects.edgewall.com/trac/wiki/TracIni
Trac のインストールや設定は以下のサイトを参考にさせていただいた。多謝。 (参考というより、指示通りに作業しただけ・・・)
- 鷹の島 - Trac をインストールしてみたよ
- http://espion.just-size.jp/archives/05/297225719.html
- [trac] default_charset
- http://zippo.taiyo.co.jp/~gotoh/diary/?200502a&to=200502023#200502023
Trac のインストール
Trac を Debian Sarge にインストールしたときのメモ。 Debian では apt で Trac をインストールできる。便利。 Trac 本体と Python でマルチバイトを扱うライブラリをインストールする。
# apt-get install trac Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: libsqlite0 python python-clearsilver python-sqlite python2.3 python2.3-clearsilver python2.3-sqlite python2.3-subversion Suggested packages: python-doc python-tk python-profiler python2.3-doc python2.3-profiler enscript python-docutils Recommended packages: python2.3-iconvcodec python2.3-cjkcodecs python2.3-japanese-codecs python-egenix-mxdatetime The following NEW packages will be installed: libsqlite0 python python-clearsilver python-sqlite python2.3 python2.3-clearsilver python2.3-sqlite python2.3-subversion trac 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 4654kB of archives. After unpacking 15.7MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://www.jp.debian.org sarge/main libsqlite0 2.8.16-1 [176kB] Get:2 http://www.jp.debian.org sarge/main python2.3 2.3.5-3sarge1 [2906kB] Get:3 http://www.jp.debian.org sarge/main python 2.3.5-2 [127kB] Get:4 http://www.jp.debian.org sarge/main python2.3-clearsilver 0.9.13-3.2 [81.0kB] Get:5 http://www.jp.debian.org sarge/main python-clearsilver 0.9.13-3.2 [4820B] Get:6 http://www.jp.debian.org sarge/main python2.3-sqlite 1.0.1-2 [29.1kB] Get:7 http://www.jp.debian.org sarge/main python-sqlite 1.0.1-2 [2608B] Get:8 http://www.jp.debian.org sarge/main python2.3-subversion 1.1.4-2 [1130kB] Get:9 http://www.jp.debian.org sarge/main trac 0.8.1-3sarge4 [199kB] Fetched 4654kB in 22s (209kB/s) Preconfiguring packages ... ...略 # apt-get install python2.3-japanese-codecs Reading Package Lists... Done Building Dependency Tree... Done The following NEW packages will be installed: python2.3-japanese-codecs 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 273kB of archives. After unpacking 1237kB of additional disk space will be used. Get:1 http://www.jp.debian.org sarge/main python2.3-japanese-codecs 1.4.9-3 [273kB] Fetched 273kB in 1s (241kB/s) Selecting previously deselected package python2.3-japanese-codecs. (Reading database ... 15287 files and directories currently installed.) Unpacking python2.3-japanese-codecs (from .../python2.3-japanese-codecs_1.4.9-3_i386.deb) ... Setting up python2.3-japanese-codecs (1.4.9-3) ... #
Trac の設定
Trac プロジェクトの作成
# mkdir /tmp/trac # cd /tmp/trac # trac-admin myprojects initenv Creating a new Trac environment at /tmp/trac/myprojects Trac will first ask a few questions about your environment in order to initalize and prepare the project database. Please enter the name of your project. This name will be used in page titles and descriptions. Project Name [My Project]> my projects Please specify the absolute path to the project Subversion repository. Repository must be local, and trac-admin requires read+write permission to initialize the Trac database. Path to repository [/var/svn/test]> /var/svn/svndb Please enter location of Trac page templates. Default is the location of the site-wide templates installed with Trac. Templates directory [/usr/share/trac/templates]> Creating and Initializing Project Inserting default data Configuring Project trac.repository_dir ...略 Congratulations! # chown -R www-data:www-data /tmp/trac
Trac と Apache2 の連携
私の環境では、Trac のメインの用途は Subversion に対する Web インターフェースとなる。 そのため、Trac も Subversion と同一のユーザを使用することにした。 また、アクセス元制限もついでにかけておくことに。
# cat /etc/apache2/sites-available/trac Alias /trac "/usr/share/trac/htdocs/" ScriptAlias /proj "/usr/share/trac/cgi-bin/trac.cgi" <Location "/proj"> SetEnv TRAC_ENV "/tmp/trac/myprojects" SSLRequireSSL AuthType Basic AuthName "please login" AuthUserFile /var/svn/svndb/.svnpasswd Require valid-user order allow,deny allow from 192.168.1. </Location> <Location "/trac"> SSLRequireSSL AuthType Basic AuthName "please login" AuthUserFile /var/svn/svndb/.svnpasswd Require valid-user order allow,deny allow from 192.168.1. </Location> # a2ensite trac Site trac installed; run /etc/init.d/apache2 reload to enable. # /etc/init.d/apache2 reload Reloading web server config...done.cts" #
Trac の設定
Trac 画面のヘッダ、フッタを設定する。 Subversion 内のファイルの文字エンコーディングも設定する。
# cat /tmp/trac/myprojects/conf/trac.ini [header_logo] src = trac_banner.png alt = my projects height = 73 link = https://www.example.com/proj width = 236 [trac] default_charset = japanese.shift_jis ...略 #
May 28, 2006
[Library] JasperReports にチャレンジ
JasperReports とは
JasperReports はオープンソースの帳票ソリューション。 帳票印刷、PDF 生成はもちろんのこと、HTML、XLS、CSV、XML の生成が可能。 帳票のデザイナもオープンソースで提供されている、なかなかの優れもの。
- JasperReports
- http://jasperreports.sourceforge.net/index.html
- Tutorial
- http://jasperreports.sourceforge.net/tutorial/index.html
- GUI Tools
- http://jasperreports.sourceforge.net/tools.html
- License
- http://jasperreports.sourceforge.net/license.html
サンプル実行
実行環境準備
サンプルの実行には JDK、Ant が必要。
>set JAVA_HOME=c:\_java\jdk\1.5.0_06 >set ANT_HOME=c:\_java\tool\ant\1.6.4 >set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH% >java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing) >ant -version Apache Ant version 1.6.4 compiled on May 19 2005 >cd .\jasperreports-1.2.2\demo\samples\csvdatasource
csvdatasource サンプルの実行
>ant clean javac compile fill pdf
Buildfile: build.xml
clean:
javac:
[javac] Compiling 1 source file to C:\jasperreports-1.2.2\demo\samples\csvda
tasource
[javac] 注: C:\jasperreports-1.2.2\demo\samples\csvdatasource\CsvDataSourceA
pp.java の操作は、未チェ
ックまたは安全ではありません。
[javac] 注: 詳細については、-Xlint:unchecked オプションを指定して再コンパイ
ルしてください。
compile:
[jrc] Compiling 1 report design files.
[jrc] File : C:\jasperreports-1.2.2\demo\samples\csvdatasource\CsvDataSourc
eReport.jrxml ... OK.
fill:
[java] Filling time : 1641
pdf:
[java] PDF creation time : 1312
BUILD SUCCESSFUL
Total time: 8 seconds
fonts サンプルの実行
>ant clean javac compile fill pdf
Buildfile: build.xml
clean:
javac:
[javac] Compiling 1 source file to C:\jasperreports-1.2.2\demo\samples\fonts
[javac] 注: C:\jasperreports-1.2.2\demo\samples\fonts\FontsApp.java の操作は
、未チェックまたは安全ではありません。
[javac] 注: 詳細については、-Xlint:unchecked オプションを指定して再コンパイ
ルしてください。
compile:
[jrc] Compiling 1 report design files.
[jrc] File : C:\jasperreports-1.2.2\demo\samples\fonts\FontsReport.jrxml .
.. OK.
fill:
[java] Filling time : 2187
pdf:
[java] PDF creation time : 2250
BUILD SUCCESSFUL
Total time: 10 seconds
May 27, 2006
[Maven] pom.xml で entity reference が使えない理由
pom.xml では entity reference が使用できない。 使えないのは実際に試した結果から知っていたが、理由が分からなかった。 ようやく使えない理由が書かれたドキュメントを見つけたのでメモ。 Maven 1.x の FAQ なのだけれど、Maven 2.x でも同様の理由で使えなくなっているのだろう。 使えると非常に便利なのだけれど、機構的に仕方がないといったところか。
- Apache Maven 1.x Frequently Asked Questions
- http://maven.apache.org/maven-1.x/faq.html#using-entities
Q. What's the problem with entities in project.xml?
A. As of Maven 1.1, external entities will not be enabled by default in project.xml, and their use is discouraged in Maven 1.0.x as well. There will still be the ability to use them, but it will have to be enabled.
There are several reasons for this, but the main reason is that the content of project.xml needs to be completely self-contained and and able to be reproduced from a history at any point in time.
For this reason, using Jelly expressions other than ${pom.*} references is also not recommended and likely to be unsupported in future.
The most common use of this technique is to manage dependencies across multiple projects. You should strongly consider using inheritence for this purpose.
Note: special character entities will always be supported and should not have any current issues.
May 26, 2006
[Maven] Maven2 のバージョンを自動チェックする方法
Maven2 の実行時に Maven2 のバージョンを自動チェックすることができる。 例えば、2.0.3 以前の Maven2 が使用された場合はビルドを強制的に失敗させる、といったことが可能。 ビルドプロセスが Maven2 のバージョンに依存することは少ないと思うけれど、大規模プロジェクトではこの機能を使っておくと安心できそう。
設定方法
pom.xml の project/prerequisites/maven でバージョンを指定する。
詳細な設定方法は以下を参照のこと。<project> <prerequisites> <maven>2.0.4</maven> </prerequisites> </project>
- Project Descriptor - Prerequisites
- http://maven.apache.org/ref/current/maven-model/maven.html#class_prerequisites
動作例
project/prerequisites/maven に 2.0.5 を指定した状態で、2.0.4 を使用してビルドすると下記の様にビルドに失敗する。
>mvn --version Maven version: 2.0.4 >mvn clean [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Unable to build project 'C:\MyProject\pom.xml; it requires Maven version 2.0.5 [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: < 1 second [INFO] Finished at: Thu May 25 19:09:36 JST 2006 [INFO] Final Memory: 1M/2M [INFO] ------------------------------------------------------------------------
May 25, 2006
[Misc] 公開サーバに用意すべきメールアドレス
公開サーバで用意すべきメールアドレスが RFC2142 で規定されている。
- RFC2142 - MAILBOX NAMES FOR COMMON SERVICES, ROLES AND FUNCTIONS
- http://www.ietf.org/rfc/rfc2142.txt
- RFC2142 - 一般的なサービス、役割、機能に対するメールボックス名
- http://rfc-jp.nic.ad.jp/rfc-jp/RFC2142-JP.txt
RFC 2142 で規定されているメールアドレス
RFC 2142 ではビジネス関連、ネットワーク運用関連、インターネットサービス関連の 3 種類のメールアドレスが規定されている。
BUSINESS-RELATED MAILBOX NAMES
MAILBOX AREA USAGE
----------- ---------------- ---------------------------
INFO Marketing Packaged information about the
organization, products, and/or
services, as appropriate
MARKETING Marketing Product marketing and
marketing communications
SALES Sales Product purchase information
SUPPORT Customer Service Problems with product or
service
NETWORK OPERATIONS MAILBOX NAMES MAILBOX AREA USAGE ----------- ---------------- --------------------------- ABUSE Customer Relations Inappropriate public behaviour NOC Network Operations Network infrastructure SECURITY Network Security Security bulletins or queries
SUPPORT MAILBOX NAMES FOR SPECIFIC INTERNET SERVICES MAILBOX SERVICE SPECIFICATIONS ----------- ---------------- --------------------------- POSTMASTER SMTP [RFC821], [RFC822] HOSTMASTER DNS [RFC1033-RFC1035] USENET NNTP [RFC977] NEWS NNTP Synonym for USENET WEBMASTER HTTP [RFC 2068] WWW HTTP Synonym for WEBMASTER UUCP UUCP [RFC976] FTP FTP [RFC959]
要するに
自宅サーバの様な小規模公開サイトの場合、POSTMASTER、HOSTMASTER、WEBMASTER、WWW を用意すればよさそう。 ビジネス関連のサービスを提供する場合は更に INFO、MARKETING、SALES、SUPPORT も必要か。
May 24, 2006
[Misc] 開発環境における環境変数の設定
Windows における環境変数にはスコープの違いによりシステム環境変数、ユーザ環境変数、一時的な環境変数の 3 種類の環境変数がある。
- システム環境変数
- システムのすべてのユーザーに適用される環境変数
- ユーザ環境変数
- それぞれのユーザーごとに異なる環境変数
- 一時的な環境変数
- 特定の CMD プロセス内でのみ有効な環境変数
環境変数の設定指針
チームメンバへの説明をするときのために設定指針をまとめておく。
1. システム環境変数を変更しない
特にパスやパスに類する環境変数(JAVA_HOMEなど)はシステム環境変数として設定すべきではない。 システム環境変数は新規にソフトウェアをインストールする際に、インストーラに変更されてしまうことがあることを考慮しないといけない。 例えば、Oracle Database Server をインストールするとシステム環境変数の PATH の先頭に Oracle 内の JDK が追加されてしまう。
2. ユーザ環境変数を変更しない
こちらもシステム環境変数と同様。
3. 環境変数はバッチファイルで設定する
別に CMD 起動後に毎回手で打っても良いのだけれど、バッチファイルの方が間違いがないのと面倒がないのでオススメ。
4. パスを追加する際は既存のパスの先頭に追加する
言わずもがな。 既存のパスの後ろに追加する人にはさすがに出会ったことはないが、念のため。
> set JAVA_HOME=c:\_java\jdk\1.6.0 > set ANT_HOME=c:\_java\tool\ant\1.6.5 > set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%
5. パスを追加する際は、追加後に必ずバージョンを確認する
パスを変更したら、必ず使用する前にバージョンを確認すること。 先頭に追加すればまず間違いは無いが、設定をミスしていると予期しないバージョンのものを使用してしまっている可能性がある。 プロジェクトでは通常使用するソフトウェアのバージョンが規定されている。 自分が使用しているソフトウェアのバージョンくらいはきちんと把握しておいて欲しい。 少なくとも JDK、JRE のバージョンくらいは・・・。
> set JAVA_HOME=c:\_java\jdk\1.6.0 > set PATH=%JAVA_HOME%\bin;%PATH% > java -version java version "1.6.0-beta" Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59g) Java HotSpot(TM) Client VM (build 1.6.0-beta-b59g, mixed mode, sharing)
May 23, 2006
[Misc] DOS Command に関する参考資料をメモ
私より下の世代の人は DOS に関する知識を余り持っていないことが多い。 本番環境として Windows を使用することは少ないにしても、開発は Windows でやることが多いのだから最低限は知っておいて欲しいところ。 今更 config.sys を書けとは言わないが、バッチファイルは書けないと困る。 というわけで、DOS Command に関する参考資料をメモ。
- New ways to do familiar tasks
- http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/dos_diffs.mspx
- New command-line tools
- http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_new_tools.mspx
- Command-line reference A-Z
- http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx
- Batch Commands
- http://www.microsoft.com/technet/archive/msdos/07_refer.mspx
May 22, 2006
[Misc] JMX の参考資料をメモ
JBoss AS のソースコードを読み始めて、Microkernel で苦しんでいる。 JMX の詳細を把握していないのが原因。 ということで、JMX の参考資料をメモ。
- JMX
- http://java.sun.com/products/JavaManagement/index.jsp
- JMX Downloads
- http://java.sun.com/products/JavaManagement/download.html
- Sun Community Source Licensing (SCSL) - Java(TM) Management Extensions (JMX) - Download
- http://www.sun.com/software/communitysource/jmx/download.xml
- JSR 255: JavaTM Management Extensions (JMXTM) Specification, version 2.0
- http://jcp.org/en/jsr/detail?id=255
- JSR-000003 Java Management Extensions (JMX) (Maintenance Release 2)
- http://jcp.org/aboutJava/communityprocess/final/jsr003/index3.html
- Wikipedia - Java Management Extensions
- http://en.wikipedia.org/wiki/Java_Management_Extensions
- JBoss Architecture Overview
- http://jboss.com/products/jbossas/architecture
- Apache Geronimo Architecture
- http://wiki.apache.org/geronimo/Architecture
May 21, 2006
[Subversion] CentOS 4.x に Subversion をインストールする方法
CentOS 4.x に Subversion をインストールしたときのメモ。 apt の代わりに yum を使用するだけで、基本的には Debian と同じ。
Subversion のインストール手順
インストール先 CentOS のバージョンは以下の通り。
インストール作業自体は yum を使用するだけで完了する。# cat /etc/redhat-release CentOS release 4.2 (Final)
Apache2 と連携するために mod_dav_svn もインストールしておく。# yum install subversion ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: subversion i386 1.1.4-2.ent base 1.6 M Installing for dependencies: neon i386 0.24.7-4 base 86 k
後は Subversion の設定ファイルを適当にいじれば OK。 設定ファイルは Debian とは異なり /etc/httpd/conf.d/subversion.conf にある。# yum install mod_dav_svn ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: mod_dav_svn i386 1.1.4-2.ent base 50 k
May 20, 2006
[Misc] MySQL の文字エンコーディング関連設定
Windows で開発して Linux で稼働させる、といった状況だと文字エンコーディングは UCS2 や UTF-8 にしておくと楽。 MySQL を UTF-8 で動作させるための設定方法をメモしておく。
- 4.1.2. my.cnf オプション設定ファイル
- http://dev.mysql.com/doc/refman/4.1/ja/option-files.html
- 付録 F. 環境変数
- http://dev.mysql.com/doc/refman/4.1/ja/environment-variables.html
- 9.3.6. 接続のキャラクタセットおよび照合順序
- http://dev.mysql.com/doc/refman/4.1/ja/charset-connection.html
- ぱんぴーまっしぐら - PHPとMySQLの個人的まとめ
- http://puchiko.lowtech.ne.jp/?itemid=349&catid=27
設定方法
環境変数を毎回指定しても良いが、/etc/my.cnf を編集すると毎回毎回の手間を省くことができる。
現在の文字エンコーディング関連設定がどうなっているのかを調べる方法は以下の通り。# cat /etc/my.cnf [mysql] default-character-set=utf8 [mysqld] default-character-set=utf8 character_set_server=utf8
使用した環境は以下の通り。# mysql -u mysqlaccount -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 141 to server version: 4.1.12 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SHOW VARIABLES LIKE 'character\_set\_%'; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | +--------------------------+-------+ 6 rows in set (0.00 sec)
# mysqladmin -u mysqlaccount -p version Enter password: mysqladmin Ver 8.41 Distrib 4.1.12, for redhat-linux-gnu on i686 Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version 4.1.12 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 1 hour 31 min 52 sec Threads: 2 Questions: 2227 Slow queries: 0 Opens: 97 Flush tables: 1 Open tables: 64 Queries per second avg: 0.404
May 18, 2006
[Library] Java Plugin Framework(JPF) にチャレンジ(2)
Plugin の構成
Plugin のディレクトリ構成は以下の通り。 このディレクトリ構成を ZIP、JAR でアーカイブ化すると Plugin になる。
PLUGIN_HOME ├classes/ ├docs/ │ └api/ ├icons/ ├lib/ └plugin.xml
plugin.xml の DTD は以下にある。
- Plug-in DTD
- http://jpf.sourceforge.net/dtd.html
May 17, 2006
[Library] Java Plugin Framework(JPF) にチャレンジ
Java Plugin Framework(JPF) とは
JPF は、Plugin アーキテクチャをサポートするためのライブラリ。 ZIP や JAR 形式で Plugin を作成し、アプリケーションからその Plugin を読み込み利用する。
- Java Plugin Framework(JPF)
- http://jpf.sourceforge.net/
- Tutorial
- http://jpf.sourceforge.net/tutorial.html
デモアプリケーションの起動
JPF にはデモアプリケーションが用意されている。 デモアプリケーションは簡単に起動し、Plugin のロードを試すことができる。
jpf-demo-bin-0.8> set JAVA_HOME=c:\_java\jdk\1.5.0_06 jpf-demo-bin-0.8> set PATH=%JAVA_HOME%\bin;%PATH% jpf-demo-bin-0.8> run.bat
サンプルコード
PluginManager を初期化し、Plugin をロードするサンプルコード。
package jp.in_vitro.codelets.jpf;
import java.io.InputStream;
import java.util.Collection;
import org.java.plugin.ObjectFactory;
import org.java.plugin.PluginManager;
import org.java.plugin.PluginManager.PluginLocation;
import org.java.plugin.boot.DefaultPluginsCollector;
import org.java.plugin.boot.PluginsCollector;
import org.java.plugin.registry.ExtensionPoint;
import org.java.plugin.registry.PluginDescriptor;
import org.java.plugin.util.ExtendedProperties;
public class Codelet {
public Codelet() {
super();
}
protected void execute() throws Exception {
ExtendedProperties config = new ExtendedProperties(System
.getProperties());
InputStream is = null;
try {
String configFile = "/"
+ this.getClass().getPackage().getName().replaceAll("\\.",
"/") + "/" + "config.properties";
is = this.getClass().getResourceAsStream(configFile);
config.load(is);
} finally {
if (is != null) {
is.close();
}
}
PluginManager pluginManager = ObjectFactory.newInstance(config)
.createManager();
PluginsCollector collector = new DefaultPluginsCollector();
collector.configure(config);
Collection pluginLocations = collector.collectPluginLocations();
pluginManager.publishPlugins((PluginLocation[]) pluginLocations
.toArray(new PluginLocation[pluginLocations.size()]));
for (Object pdObj : pluginManager.getRegistry().getPluginDescriptors()) {
PluginDescriptor pd = (PluginDescriptor) pdObj;
System.out.println("" + pd);
for (Object epObj : pd.getExtensionPoints()) {
ExtensionPoint ep = (ExtensionPoint) epObj;
System.out.println(" " + ep);
}
}
}
public static void main(String[] args) throws Exception {
Codelet me = new Codelet();
me.execute();
}
}
config.properties
org.java.plugin.PathResolver=org.java.plugin.standard.ShadingPathResolver
org.java.plugin.standard.ShadingPathResolver.shadowFolder=${applicationRoot}/temp/.jpf-shadow
org.java.plugin.standard.ShadingPathResolver.unpackMode=smart
org.java.plugin.boot.pluginsRepositories=./plugins/
サンプルコードの実行結果
plugins ディレクトリにデモアプリケーションの Plugin をいくつか登録して読み込ませてみた。
2006/05/16 23:58:37 org.java.plugin.registry.xml.ManifestParser情報: got SAX parser factory - com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl@16a55fa 2006/05/16 23:58:37 org.java.plugin.registry.xml.PluginRegistryImpl configure 情報: configured, stopOnError=false, isValidating=true 2006/05/16 23:58:37 org.java.plugin.standard.ShadingPathResolver configure 情報: configured, shadow folder is C:\Codelets\${applicationRoot}\temp\.jpf-shadow 2006/05/16 23:58:37 org.java.plugin.registry.xml.PluginRegistryImpl register 情報: plug-in and fragment descriptors registered - 2 {PluginDescriptor: uid=org.jpf.demo.toolbox.pluginbrowser@0.0.4} {PluginDescriptor: uid=org.jpf.demo.toolbox.core@0.0.4} {ExtensionPoint: uid=org.jpf.demo.toolbox.core@Tool}
May 15, 2006
[Misc] ClassLoader に関する参考資料をメモ
未だに ClassLoader を実装するとハマることがある。 何年実装やっているんだ・・・orz というわけで、ClassLoader に関する再勉強の必要性を強く感じて参考資料を集めてみた。
- JSR 924: Java Virtual Machine Specification
- http://www.jcp.org/en/jsr/detail?id=924
- The Java Virtual Machine Specification Second Edition
- http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html
- Java2 Platform SE 5.0 API Document - java.lang.ClassLoader
- http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/lang/ClassLoader.html
- The Apache Tomcat 5.5 Servlet/JSP Container Class Loader HOW-TO
- http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
- developerWorks - クラス・ローディングとデバッグ・ツール
- http://www-06.ibm.com/jp/developerworks/java/060113/j_j-dclp1.shtml
- developerWorks - クラス・ローディングに関する基本的な例外
- http://www-06.ibm.com/jp/developerworks/java/060127/j_j-dclp2.shtml
ちなみに、今回ハマった状況はこういうもの。
「class A extends B」というクラスをロードする。
B をシステム ClassLoader がロード、A を自作 ClassLoader がロード。
特定環境下で 「A.class.getSuperclass」 が何故か java.lang.Object を返してくるという問題が発生。
結局のところ、ClassLoader の階層構造にミスがあったのだけれど、発生する環境としない環境があって結構手こずった。
教訓 - ClassLoader の階層構造はきちんと把握しよう。
May 14, 2006
[Misc] JSTL に関する参考資料をメモ
JSTL に関するサイトをメモ。
- JSTL 1.1 API Document
- http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html
- JavaServer Pages Standard Tag Library
- http://java.sun.com/products/jsp/jstl/index.jsp
- JSR 052 JavaServer Pages Standard Tag Library Specification
- http://jcp.org/aboutJava/communityprocess/final/jsr052/
- developerWorks - JSTL入門: 式言語
- http://www-06.ibm.com/jp/developerworks/java/030411/j_j-jstl0211.html
- developerWorks - JSTL入門: 核心(core)に触れる
- http://www-06.ibm.com/jp/developerworks/java/030516/j_j-jstl0318.html
May 13, 2006
[Misc] 日本固有のバリデーションに関わる資料をメモ。
日本固有のバリデーションに関する資料をメモ。 海外製ライブラリは当然の様にこの辺りは未サポート。 自前のライブラリを「正確に」作成する場合に参照すると良いページ。
- ゆうびんホームページ - 郵便番号検索
- http://www.post.japanpost.jp/zipcode/
- 全国地方公共団体コード
- http://ja.wikipedia.org/wiki/%E5%85%A8%E5%9B%BD%E5%9C%B0%E6%96%B9%E5%85%AC%E5%85%B1%E5%9B%A3%E4%BD%93%E3%82%B3%E3%83%BC%E3%83%89
- JIS X 0401 都道府県コード
- http://www.webstore.jsa.or.jp/webstore/Com/FlowControl.jsp?lang=jp&bunsyoId=JIS+X+0401%3A1973&dantaiCd=JIS&status=1&pageNo=0
- JIS X 0402 市区町村コード
- http://www.webstore.jsa.or.jp/webstore/Com/FlowControl.jsp?lang=jp&bunsyoId=JIS+X+0402%3A2003&dantaiCd=JIS&status=1&pageNo=0
- 市外局番の一覧
- http://www.soumu.go.jp/joho_tsusin/top/tel_number/shigai_list.html
May 12, 2006
[Library] Eclipse 3.1 で JUnit 4 のテストケースを一括実行する
JUnit 4 は JUnit 3 よりも楽にテストケースを作成できる。 最近はめっきり JUnit 4 に染まってしまった。 ただ、ツールのサポートが追いついていないところだけが玉に瑕。 Eclipse 3.1 の環境下で、JUnit 4 のテストケースを一括実行したいので簡単なコードを書いてみた。
JUnit 4 のテストケース一括実行用クラス
↓のコード (AllTests) をプロジェクトのルートパッケージに置いて実行する。 AllTests が置いてあるパッケージ以下の全テストケース("**/*Test.class") が実行される。 JVM は 5.0 以降が必要。
package jp.in_vitro.test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTests {
public static Test suite() throws URISyntaxException,
ClassNotFoundException {
return AllTests.createTestSuite();
}
protected static TestSuite createTestSuite() throws URISyntaxException,
ClassNotFoundException {
TestSuite suite = new TestSuite();
URL codeSourceUrl = AllTests.class.getProtectionDomain()
.getCodeSource().getLocation();
File codeSourceFile = new File(codeSourceUrl.toURI());
String codeSourceName = codeSourceFile.getAbsolutePath().replaceAll(
"\\\\", "\\\\\\\\");
List<File> testCaseFiles = new ArrayList<File>();
AllTests.listTestCase(testCaseFiles, codeSourceFile);
for (File testCaseFile : testCaseFiles) {
String fileName = testCaseFile.getAbsolutePath();
String className = fileName.replaceAll(codeSourceName + "\\\\", "")
.replaceAll(".class", "").replaceAll("\\\\", ".");
suite.addTest(new JUnit4TestAdapter(Class.forName(className)));
}
return suite;
}
protected static void listTestCase(final List<File> testCaseFiles,
final File file) {
for (File child : file.listFiles()) {
if (child.isFile()) {
if (child.getAbsolutePath().endsWith("Test.class")) {
testCaseFiles.add(child);
}
} else if (child.isDirectory()) {
AllTests.listTestCase(testCaseFiles, child);
}
}
}
}
Eclipse 3.2 では JUnit 4 はサポートされているだろうか??
May 11, 2006
[Misc] Google Trends で遊ぶ
Google Trends というサービスが新規公開された。 How does Google Trends work? によると、
Google Trends analyzes a portion of Google web searches to compute how many searches have been done for the terms you enter relative to the total number of searches done on Google over time.というサービスらしい。 試してみると、これが意外と面白い。
Google Trends の使い方
Google Trends のクエリフォーマットは How many terms can I compare? What other functionality is available? で解説されている。
You can compare up to five terms by separating each term with a comma. To compare trend info for "mittens" and "bathing suits," for example, you'd simply enter [ mittens, bathing suits ] and click on "Search Trends."要するに、
To see how many searches contained either of two terms, just separate those terms with a vertical bar: "|". For example, to determine how many searches contained the terms "mittens" or "gloves," you'd enter [ mittens | gloves ]. To compare multi-word terms, use parentheses. To see how many searches were done for either "winter mittens" or "gloves," for instance, enter [ (winter mittens) | gloves ]; otherwise, your query will be interpreted to mean all searches for "winter mittens" or "winter gloves."
You can also exclude terms from your search by using the minus sign. To see how many searches contained the term "maps" but not "google," for instance, just enter [ maps -google ].
To restrict your results to only those searches that contain your terms in the specific order you've entered them, put your terms in quotation marks. (By default, Google Trends will show you all searches that contain the terms you entered in any order.)
Note: when you use any of these advanced features -- quotation marks, minus signs, or vertical bars -- Google Trends will only display the search-volume graph. The news portion of the product doesn't support advanced functionality at this time.
- 比較したいキーワードはカンマ区切りで入力 (例、"apple,orange")
- キーワードを OR で連結する場合は '|' を使用 (例、"Revolution|Wii,PS3|(Play Station 3)")
- 特定の語彙を除外したい場合は '-' を使用 (例、"java - coffee,.Net")
Web 開発のトレンド
面白いので、Java による Web 開発関連のトレンドを調べてみた。 Application Server や IDE はなかなか面白い結果だった。
↑のボックスをクリックするとグラフが切り替わる。
May 10, 2006
[Linux] Linux で起動してからの時間を調べる方法
Linux が起動してから経過した時間を調べる方法をメモ。 起動後の経過時間は /proc/uptime から取得することができる。
一つめの値が起動後の経過時間を秒数で表した数値となる。 後は電卓を叩いて日数や時間数に換算すれば良い。 電卓を起動するのが面倒な場合は AWK で計算しても良い。# cat /proc/uptime 2700777.74 2676642.02
# cat /proc/uptime | awk '{print $1 / 60 /60 /24 "days (" $1 "sec)"}'
31.2591days (2700784.86sec)
ただしこの値、32bit でカウントされているために 500 日程度でリセットされてしまうらしい。
(ともちゃ日記さんの [Linux] uptime より)
- Manpage of PROC
- http://www.linux.or.jp/JM/html/LDP_man-pages/man5/proc.5.html
May 09, 2006
[WebService] Wikipedia API にチャレンジ
Wikipedia の API が無いものかと調べてみた。 「クローラのアクセスは止めて」と書いてあるものの普通に公開されていた。
- Wikipedia:Database download
- http://en.wikipedia.org/wiki/Wikipedia:Download#XML_schema
- XML access
- http://en.wikipedia.org/wiki/Special:Export/Title_of_the_article
- RSS access
- http://www.blinkbits.com/en_wikifeeds_rss/Title_of_the_article
XML フォーマットで記事を取得
AIBO に関する記事を XML フォーマットで取得してみた。 http://en.wikipedia.org/wiki/Special:Export/AIBO にアクセスするだけで良い。
<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/
http://www.mediawiki.org/xml/export-0.3.xsd"
version="0.3"
xml:lang="en">
<siteinfo>
<sitename>Wikipedia</sitename>
<base>http://en.wikipedia.org/wiki/Main_Page</base>
<generator>MediaWiki 1.7alpha</generator>
<case>first-letter</case>
<namespaces>
<namespace key="-2">Media</namespace>
<namespace key="-1">Special</namespace>
<namespace key="0" />
<namespace key="1">Talk</namespace>
<namespace key="2">User</namespace>
<namespace key="3">User talk</namespace>
<namespace key="4">Wikipedia</namespace>
<namespace key="5">Wikipedia talk</namespace>
<namespace key="6">Image</namespace>
<namespace key="7">Image talk</namespace>
<namespace key="8">MediaWiki</namespace>
<namespace key="9">MediaWiki talk</namespace>
<namespace key="10">Template</namespace>
<namespace key="11">Template talk</namespace>
<namespace key="12">Help</namespace>
<namespace key="13">Help talk</namespace>
<namespace key="14">Category</namespace>
<namespace key="15">Category talk</namespace>
<namespace key="100">Portal</namespace>
<namespace key="101">Portal talk</namespace>
</namespaces>
</siteinfo>
<page>
<title>AIBO</title>
<id>47087</id>
<revision>
<id>51895470</id>
<timestamp>2006-05-06T22:55:18Z</timestamp>
<contributor>
<ip>68.121.102.200</ip>
</contributor>
<comment>/* External links */</comment>
<text xml:space="preserve">[[Image:AIBO.JPG|thumb|right|The AIBO ERS-7 re
sembles a small dog]] '''AIBO''' is one of several types of [[robot|robotic]] [
[pet]]s designed and manufactured by [[Sony]]; there have been sever
中略
</text>
</revision>
</page>
</mediawiki>
RSS フォーマットで記事を取得
同じく、AIBO に関する記事を RSS フォーマットで取得してみた。 http://www.blinkbits.com/en_wikifeeds_rss/AIBO にアクセスするだけで良い。
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:annotate="http://purl.org/rss/1.0/modules/annotate/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<channel>
<title>AIBO RSS Feed for Wikipedia powered by BlinkBits.com</title>
<link>http://www.blinkbits.com/en_wikifeeds/AIBO</link>
<description>Imagine the Collective Wisdom of All Mankind Available in the
Blink of An Eye... That's BlinkBits!</description>
<managingEditor>lcotter@blinkbits.com</managingEditor>
<docs>http://www.blinkbits.com</docs>
<generator>RSS Feed 2.1.4</generator>
<language>en</language>
<lastBuildDate>Wed, 12 Apr 2006 08:09:19 -0400</lastBuildDate>
<image>
<url>http://www.blinkbits.com/images/icon_6040.gif</url>
<title>AIBO RSS Feed from Wikipedia Powered by BlinkBits.com</title>
<link>http://www.blinkbits.com</link>
<width>60</width>
<height>40</height>
</image>
<item>
<title>AIBO Wikipedia RSS Feed</title>
<link>http://www.blinkbits.com/en_wikifeeds/AIBO</link>
<pubDate>Wed, 12 Apr 2006 08:09:19 -0400</pubDate>
<guid isPermaLink="true">http://www.blinkbits.com/en_wikifeeds/AIBO</guid>
<description>
<![CDATA[ [b]AIBO[/b] is one of several types of robotic pets designed and ma
nufactured by Sony; there have been several different models since their introdu
中略
]]>
The Wikipedia article is licensed under http://www.gnu.org/copyleft/fdl.html and
uses material from http://en.wikipedia.org/wiki/AIBO. A preview of this article
is available at http://www.blinkbits.com/en_wikifeeds/AIBO.
</description>
<dc:subject>Biography</dc:subject>
<comments>http://www.blinkbits.com/en_wikifeeds/AIBO</comments>
</item>
</channel>
</rss>
May 08, 2006
[Library] JUnit 4.1 リリース
JUnit 4.1 がリリースされた。 README.html によると、4.0 からの変更点は
だそうだ。 特に大きな変更は無い模様。
- Bug fix: listeners now get a correct test running time, rather than always being told 0 secs.
- The @RunWith annotation is now inherited by subclasses: all subclasses of an abstract test class will be run by the same runner.
- The build script fails if the JUnit unit tests fail
- The faq has been updated
- Javadoc has been improved, with more internal links, and package descriptions added (Thanks, Matthias Schmidt!)
- An acknowledgements.txt file has been created to credit outside contributions
- The Enclosed runner, which runs all of the static inner classes of a given class, has been added to org.junit.runners.
ついでに JUnit4 の素敵な紹介記事を発見したのでメモ。
- developerWorks - JUnit 4の現状を紹介する
- http://www-06.ibm.com/jp/developerworks/java/051007/j_j-junit4.shtml
May 07, 2006
[Maven] Maven2 でアーカイブのファイル名を指定する
Maven2 でアーカイブを生成すると、デフォルトでは artifactId と version からファイル名が決定される。 WAR だとアーカイブファイル名がコンテキスト名として使用されるので、任意のファイル名を指定したい。 いつも設定方法を忘れるので、メモしておく。
アーカイブファイル名の指定方法
アーカイブファイル名は project/build/finalName で指定する。 ↓の例では my-war-file.war という WAR ファイルが生成される。
<?xml version="1.0"?>
<project>
<artifactId>my-artifact</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<build>
<finalName>my-war-file</finalName>
</build>
</project>
Apr 30, 2006
[Misc] Java で Scheme
JVM 上の Scheme 実行環境で遊んでみた。 どうやら SISC と Kawa という環境があるらしい。
- SISC
- http://sisc.sourceforge.net/
- Kawa
- http://www.gnu.org/software/kawa/
- オレンジニュース - JavaベースのScheme処理系「Kawa」と「SISC」の違い
- http://secure.ddo.jp/~kaku/tdiary/20060412.html
- ひWeb / ひ日誌 - JavaベースのScheme処理系
- http://www.fobj.com/hisa/diary/20060412.html#p02
Kawa にチャレンジ
Kawa は jar 1 つで動作できる非常に軽い環境。
>set JAVA_HOME=c:\_java\jdk\1.5.0_06 >set PATH=%JAVA_HOME%\bin;%PATH% >java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing) >java -jar .\kawa-1.8.jar #|kawa:1|# (display (+ 12 4))(newline) 16 #|kawa:2|#
SISC にチャレンジ
Kawa よりは jar が多いけれど、Kawa 同様簡単に起動できた。
>java -classpath .\sisc.jar;.\sisc-lib.jar;.\sisc-opt.jar sisc.REPL -h .\sisc.shp SISC (1.13.6) #;> (display (+ 12 4)) 16#;>
Apr 29, 2006
[AS] JBoss AS のコードを読む (3)
Server 実行編
今回は Server の実行周り。
- org.jboss.Main
- 起動用クラス。main メソッドを持つ。起動時引数の解析はここで行われている。
- org.jboss.system.server.Server
- Server 機能を表すインタフェース。主に Server のライフサイクルを制御するメソッドが定義されている。
- org.jboss.system.server.ServerImpl
- Server インタフェースのデフォルト実装。
Apr 27, 2006
[AS] JBoss AS のコードを読む (2)
Server 初期化編
今回は Server の初期化処理周り。
- org.jboss.Main
- 起動用クラス。main メソッドを持つ。起動時引数の解析はここで行われている。
- org.jboss.system.server.Server
- Server 機能を表すインタフェース。主に Server のライフサイクルを制御するメソッドが定義されている。
- org.jboss.system.server.ServerImpl
- Server インタフェースのデフォルト実装。
- org.jboss.system.server.ServerConfig
- Server の設定項目を表すインタフェース。
- org.jboss.system.server.ServerConfigImpl
- ServerConfig インタフェースのデフォルト実装。
Apr 26, 2006
[AS] JBoss AS のコードを読む (1)
以前から JBoss のコードを読んでみたいと思っていた。 ただ Application Server という規模の大きなコードを読む面倒さから、なかなか着手する気にならなかった。 今回、とりあえずどこまで続くか分からないが、着手だけはしてみることに。 読みやすい順番で少しずつ、のんびりと読んで行きたいと思う。
起動編
まずは main メソッド実行から Server#start が呼ばれるところ辺りまで。
- org.jboss.Main
- 起動用クラス。main メソッドを持つ。起動時引数の解析はここで行われている。
- org.jboss.system.server.ServerLoader
- Server インスタンスを生成するファクトリクラス。
- org.jboss.system.server.Server
- Server 機能を表すインタフェース。主に Server のライフサイクルを制御するメソッドが定義されている。
- org.jboss.system.server.ServerImpl
- Server インタフェースのデフォルト実装。
- org.jboss.system.server.NoAnnotationURLClassLoader
- URLClassLoader の拡張。何故拡張が必要かは知らない。
Apr 25, 2006
[WebService] Google Calendar API にチャレンジ
Google Calendar も API が公開されていたのでサワリだけ試してみた。
- Using the Google Calendar Data API
- http://code.google.com/apis/gdata/calendar.html
API 経由で Google Calendar にアクセス
Google Calendar に API 経由でアクセスするためには、まずアクセスしたいカレンダーの URL を調べなければならない。
- Google Calendar に Web ブラウザでアクセス
- Calendars > My Calendars > アクセスしたいカレンダー > Calendar settings を選択
- Private Address の "XML" アイコンのリンク先 URL をコピーする
http://www.google.com/calendar/feeds/in-vitro.example@gmail.com/private-1234567890abcdef1234567890abcdef/basicにアクセスすると
という感じの XML を取得できる。 尚、上記のリクエスト、レスポンス共にダミーなのでそのままコピペしても当然無効。<?xml version='1.0' encoding='UTF-8'?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gd='http://schemas.google.com/g/2005'> <id> http://www.google.com/calendar/feeds/in-vitro-example%40gmail.com/private-1234567890abcdef1234567890abcdef/basic </id> <updated>2006-04-24T01:05:34.000Z</updated> <title type='text'>private</title> <subtitle type='text'>private</subtitle> <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.google.com/calendar/feeds/in-vitro-example%40gmail.com/private-1234567890abcdef1234567890abcdef/basic'> </link> <link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/in-vitro-example%40gmail.com/private-1234567890abcdef1234567890abcdef/basic?max-results=25'> </link> <link rel='next' type='application/atom+xml' href='http://www.google.com/calendar/feeds/in-vitro-example%40gmail.com/private-1234567890abcdef1234567890abcdef/basic?start-index=26&max-results=25'> </link> <author> <name>in-vitro-example</name> <email>in-vitro-example@gmail.com</email> </author> <generator version='1.0' uri='http://www.google.com/calendar'> Google Calendar </generator> <openSearch:itemsPerPage>25</openSearch:itemsPerPage> <entry> <id> http://www.google.com/calendar/feeds/in-vitro-example%40gmail.com/private-1234567890abcdef1234567890abcdef/basic/1357913579abcdefabcdef2468 </id> <published>2006-04-15T04:30:00.000Z</published> <updated>2006-04-15T14:43:51.000Z</updated> <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'> </category> <title type='text'>○○さん、××さんと昼食</title> <summary type='html'> When: 2006-04-14 21:30:00 to 00:00:00 America/Los_Angeles<br> </summary> <content type='text'> When: 2006-04-14 21:30:00 to 00:00:00 America/Los_Angeles<br><br>Event Description:null </content> <link rel='alternate' type='text/html' href='http://www.google.com/calendar/event?eid=fedcba0987654321fedcba0987654321fedbca0987654321fedbca098765' title='alternate'> </link> <link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/in-vitro-example%40gmail.com/private-1234567890abcdef1234567890abcdef/basic/1357913570abcdefabcdef2468'> </link> <author> <name>in-vitro-example</name> <email>in-vitro-example@gmail.com</email> </author> </entry> </feed>
Google Calendar API のリクエスト URL フォーマット
Google Calendar API に対するリクエスト URL は
http://www.google.com/calendar/feeds/<userID>/<visibility>/<projection>という形式になっている。 visibility、projection に指定可能な値は
- Visibility values
- http://code.google.com/apis/gdata/calendar.html#Visibility
- Projection values
- http://code.google.com/apis/gdata/calendar.html#Projection
Apr 24, 2006
[Library] JExcelAPI にチャレンジ(6)
チマチマと動作確認のために作成していたコードを貼っておく。 ここ数日の内容をまとめたもの。
package jp.in_vitro.codelets.jexcelapi;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import jxl.HeaderFooter;
import jxl.SheetSettings;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.PageOrientation;
import jxl.format.PaperSize;
import jxl.write.Formula;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableCellFeatures;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class Codelet2 {
public Codelet2() {
super();
}
protected void execute() throws IOException, RowsExceededException,
WriteException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WorkbookSettings settings = new WorkbookSettings();
settings.setGCDisabled(true);
WritableWorkbook book = Workbook.createWorkbook(baos, settings);
WritableSheet sheet = book.createSheet("my sheet", 0);
this.configureSheet(sheet);
this.adjustColumnWidth(sheet);
this.writeHeader(sheet, 1);
this.writeBookmark(sheet, 2, 1, "Google", "http://www.google.com/",
"サーチエンジン");
this.writeBookmark(sheet, 3, 2, "CNN", "http://www.cnn.com/", "ニュース");
this.writeBookmark(sheet, 4, 3, "Amazon", "http://www.amazon.co.jp/",
"ショッピング");
book.write();
book.close();
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File("c:\\tmp.xls"));
fos.write(baos.toByteArray());
fos.flush();
} finally {
if (fos != null) {
fos.close();
}
}
}
protected void configureSheet(final WritableSheet sheet) {
SheetSettings settings = sheet.getSettings();
HeaderFooter header = new HeaderFooter();
header.getCentre().append("My Bookmarks");
settings.setHeader(header);
HeaderFooter footer = new HeaderFooter();
footer.getCentre().appendPageNumber();
footer.getCentre().append(" / ");
footer.getCentre().appendTotalPages();
settings.setFooter(footer);
settings.setProtected(true);
settings.setPassword("mypassword");
settings.setFitHeight(2);
settings.setFitWidth(0);
settings.setFitToPages(true);
settings.setHorizontalFreeze(1);
settings.setVerticalFreeze(2);
settings.setZoomFactor(75);
sheet.setPageSetup(PageOrientation.LANDSCAPE, PaperSize.B5, 10, 10);
}
protected void adjustColumnWidth(final WritableSheet sheet) {
int[] widths = new int[] { 10, 30, 50, 50 };
for (int i = 0; i < widths.length; i++) {
sheet.setColumnView(i, widths[i]);
}
}
protected void writeHeader(final WritableSheet sheet, final int y)
throws WriteException {
String[] headers = new String[] { "No.", "Title", "URL", "Description" };
String[] comments = new String[] { "番号", "タイトル", "", "備考" };
WritableCellFormat format = new WritableCellFormat();
format.setBorder(Border.ALL, BorderLineStyle.THIN);
format.setBackground(Colour.LIGHT_ORANGE);
format.setAlignment(Alignment.CENTRE);
WritableFont font = new WritableFont(format.getFont());
font.setBoldStyle(WritableFont.BOLD);
format.setFont(font);
for (int i = 0; i < headers.length; i++) {
WritableCellFeatures feature = new WritableCellFeatures();
if (!"".equals(comments[i])) {
feature.setComment(comments[i]);
}
Label label = new Label(i, y, headers[i]);
label.setCellFeatures(feature);
label.setCellFormat(format);
sheet.addCell(label);
}
}
protected void writeBookmark(final WritableSheet sheet, final int y,
final int no, final String title, final String url,
final String description) throws RowsExceededException,
WriteException {
WritableCellFormat format = new WritableCellFormat();
format.setBorder(Border.ALL, BorderLineStyle.THIN);
Number noNumber = new Number(0, y, no);
noNumber.setCellFormat(format);
Label titleLabel = new Label(1, y, title);
titleLabel.setCellFormat(format);
Formula urlLabel = new Formula(2, y, "HYPERLINK(\"" + url + "\",\""
+ url + "\")");
urlLabel.setCellFormat(format);
Label descriptionLabel = new Label(3, y, description);
descriptionLabel.setCellFormat(format);
sheet.addCell(noNumber);
sheet.addCell(titleLabel);
sheet.addCell(urlLabel);
sheet.addCell(descriptionLabel);
}
public static void main(String[] args) throws IOException,
RowsExceededException, WriteException {
Codelet2 me = new Codelet2();
me.execute();
}
}
Apr 23, 2006
[Library] JExcelAPI にチャレンジ(5)
JExcelAPI 実行時の GC を抑制する
どうやら JExcelAPI はガベージコレクションを強制的に実行するらしい。 ガベージコレクションにより CPU に負荷がかかりすぎる様であれば、下記の方法で抑制する。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WorkbookSettings settings = new WorkbookSettings();
settings.setGCDisabled(true);
WritableWorkbook book = Workbook.createWorkbook(baos, settings);
ガベージコレクションの状況
実際に WorkbookSettings#setGCDisabled でどの程度ガベージコレクションの頻度が変わるのかチェックしてみた。 適当なブックを作成するサンプルコードを -verbose:gc 付きで実行してみた結果。 ガベージコレクションを抑制しないとかなり FULL GC が実行されていることが分かる。 サーバなどで JVM に大量のメモリを割り当てている環境では注意が必要になりそう。
-verbose:gc
| setGCDisabled(true) | setGCDisabled(false) |
[GC 512K->219K(1984K), 0.0037125 secs] [GC 731K->213K(1984K), 0.0013843 secs] [GC 725K->355K(1984K), 0.0025442 secs] [GC 485K->355K(1984K), 0.0008825 secs] [Full GC 355K->355K(1984K), 0.0185440 secs] [GC 5987K->5482K(7108K), 0.0007786 secs] [GC 5994K->5489K(7108K), 0.0010468 secs] [GC 6001K->5494K(7108K), 0.0008387 secs] [GC 6006K->5510K(7108K), 0.0014418 secs] [GC 5819K->5602K(7108K), 0.0015913 secs] [GC 5940K->5604K(7108K), 0.0007699 secs] [GC 6116K->5607K(7108K), 0.0007481 secs] [GC 6118K->5644K(7108K), 0.0021126 secs] [GC 5870K->5654K(7108K), 0.0005934 secs] [Full GC 5654K->460K(7108K), 0.0228395 secs] [GC 5946K->5605K(7108K), 0.0003456 secs] [GC 5946K->5606K(7108K), 0.0003162 secs] [GC 6116K->5649K(7108K), 0.0006051 secs] [GC 5685K->5653K(7108K), 0.0005341 secs] [Full GC 5653K->460K(7108K), 0.0227604 secs] [GC 5946K->5605K(6612K), 0.0003417 secs] [GC 5941K->5607K(6612K), 0.0002489 secs] [GC 6117K->5649K(6612K), 0.0004610 secs] [GC 5685K->5653K(6612K), 0.0005034 secs] [Full GC 5653K->454K(6612K), 0.0246984 secs] [GC 5940K->5600K(9932K), 0.0007546 secs] [GC 5939K->5601K(9932K), 0.0002735 secs] [GC 6111K->5644K(9932K), 0.0005029 secs] [GC 5682K->5647K(9932K), 0.0005302 secs] [Full GC 5647K->454K(9932K), 0.0233284 secs] [GC 5940K->5600K(7220K), 0.0003615 secs] [GC 5936K->5601K(7220K), 0.0002601 secs] [GC 6111K->5644K(7220K), 0.0007819 secs] [GC 5682K->5647K(7220K), 0.0005554 secs] [Full GC 5647K->454K(7220K), 0.0346614 secs] [GC 5939K->5600K(7220K), 0.0003635 secs] [GC 5938K->5601K(7220K), 0.0002766 secs] [GC 6111K->5644K(7220K), 0.0004685 secs] [GC 5682K->5647K(7220K), 0.0005615 secs] [Full GC 5647K->454K(7220K), 0.0334269 secs] [GC 5939K->5600K(7220K), 0.0003344 secs] [GC 5938K->5601K(7220K), 0.0002590 secs] [GC 6108K->5638K(7220K), 0.0005610 secs] [GC 5687K->5648K(7220K), 0.0005389 secs] [Full GC 5648K->455K(7220K), 0.0241341 secs] [GC 5941K->5601K(7220K), 0.0003498 secs] [GC 5938K->5602K(7220K), 0.0003266 secs] [GC 6109K->5638K(7220K), 0.0004643 secs] [GC 5688K->5649K(7220K), 0.0005397 secs] [Full GC 5649K->456K(7220K), 0.0234329 secs] [GC 5942K->5602K(7224K), 0.0008445 secs] [GC 5940K->5603K(7224K), 0.0002972 secs] [GC 6114K->5646K(7224K), 0.0004772 secs] [GC 5684K->5649K(7224K), 0.0005274 secs] [Full GC 5649K->457K(7224K), 0.0240489 secs] [GC 5942K->5602K(7228K), 0.0003386 secs] [GC 5938K->5604K(7228K), 0.0002643 secs] [GC 6113K->5646K(7228K), 0.0004836 secs] [GC 5684K->5650K(7228K), 0.0005246 secs] [Full GC 5650K->457K(7228K), 0.0248289 secs] [GC 5941K->5602K(7228K), 0.0003587 secs] [GC 5940K->5604K(7228K), 0.0002548 secs] [GC 6114K->5646K(7228K), 0.0004914 secs] [GC 5684K->5650K(7228K), 0.0005420 secs] [Full GC 5650K->456K(7228K), 0.0240072 secs] [GC 5940K->5602K(7224K), 0.0003609 secs] [GC 5939K->5603K(7224K), 0.0002562 secs] [GC 6113K->5645K(7224K), 0.0004696 secs] [GC 5683K->5649K(7224K), 0.0005280 secs] [Full GC 5649K->456K(7224K), 0.0239544 secs] [GC 5940K->5602K(7224K), 0.0003447 secs] [GC 5939K->5603K(7224K), 0.0002523 secs] [GC 6113K->5645K(7224K), 0.0004699 secs] [GC 5683K->5649K(7224K), 0.0005327 secs] [Full GC 5649K->456K(7224K), 0.0233776 secs] [GC 5940K->5602K(7224K), 0.0004629 secs] [GC 5939K->5603K(7224K), 0.0002674 secs] [GC 6113K->5645K(7224K), 0.0004660 secs] [GC 5683K->5649K(7224K), 0.0005395 secs] [Full GC 5649K->456K(7224K), 0.0236684 secs] [GC 5940K->5602K(7224K), 0.0003498 secs] [GC 5939K->5603K(7224K), 0.0002699 secs] [GC 6113K->5645K(7224K), 0.0004730 secs] |
[GC 512K->219K(1984K), 0.0030713 secs] [GC 731K->213K(1984K), 0.0013647 secs] [GC 725K->355K(1984K), 0.0024732 secs] [GC 485K->355K(1984K), 0.0009328 secs] [Full GC 355K->355K(1984K), 0.0186873 secs] [GC 5987K->5482K(7108K), 0.0014714 secs] [GC 5994K->5489K(7108K), 0.0010350 secs] [GC 6001K->5494K(7108K), 0.0008428 secs] [GC 6006K->5510K(7108K), 0.0013708 secs] [GC 5819K->5602K(7108K), 0.0016069 secs] [GC 5940K->5604K(7108K), 0.0007275 secs] [GC 6116K->5607K(7108K), 0.0007294 secs] [GC 6118K->5644K(7108K), 0.0020734 secs] [Full GC 5850K->5654K(7108K), 0.0233583 secs] [GC 5676K->5654K(10196K), 0.0002358 secs] [Full GC 5654K->460K(10196K), 0.0228359 secs] [GC 6284K->5606K(10196K), 0.0003883 secs] [Full GC 6142K->5619K(10196K), 0.0328980 secs] [GC 5639K->5620K(10196K), 0.0002173 secs] [Full GC 5620K->454K(10196K), 0.0228797 secs] [GC 6279K->5601K(10196K), 0.0004512 secs] [Full GC 6135K->5648K(10196K), 0.0234963 secs] [GC 5666K->5648K(10196K), 0.0002104 secs] [Full GC 5648K->454K(10196K), 0.0328841 secs] [GC 6274K->5601K(10196K), 0.0003517 secs] [Full GC 6135K->5619K(10196K), 0.0401814 secs] [GC 5637K->5620K(10196K), 0.0002282 secs] [Full GC 5620K->454K(10196K), 0.0338029 secs] [GC 6276K->5601K(10196K), 0.0003730 secs] [Full GC 6134K->5648K(10196K), 0.0235197 secs] [GC 5665K->5648K(10196K), 0.0002112 secs] [Full GC 5648K->454K(10196K), 0.0232991 secs] [GC 6275K->5601K(10196K), 0.0006495 secs] [Full GC 6135K->5619K(10196K), 0.0410946 secs] [GC 5637K->5620K(10196K), 0.0002313 secs] [Full GC 5620K->454K(10196K), 0.0235823 secs] [GC 6276K->5601K(10196K), 0.0003721 secs] [Full GC 6143K->5648K(10196K), 0.0371251 secs] [GC 5666K->5649K(10196K), 0.0002836 secs] [Full GC 5649K->455K(10196K), 0.0232323 secs] [GC 6278K->5602K(10196K), 0.0003699 secs] [Full GC 6142K->5621K(10196K), 0.0310796 secs] [GC 5638K->5621K(10196K), 0.0002299 secs] [Full GC 5621K->456K(10196K), 0.0236888 secs] [GC 6277K->5603K(10196K), 0.0005277 secs] [Full GC 6137K->5649K(10196K), 0.0237972 secs] [GC 5667K->5650K(10196K), 0.0002115 secs] [Full GC 5650K->456K(10196K), 0.0231585 secs] [GC 6276K->5603K(10196K), 0.0003615 secs] [Full GC 6135K->5621K(10196K), 0.0310106 secs] [GC 5638K->5621K(10196K), 0.0002330 secs] [Full GC 5621K->456K(10196K), 0.0243056 secs] [GC 6277K->5603K(10196K), 0.0003727 secs] [Full GC 6137K->5649K(10196K), 0.0243352 secs] [GC 5667K->5650K(10196K), 0.0002106 secs] [Full GC 5650K->456K(10196K), 0.0239634 secs] [GC 6276K->5603K(10196K), 0.0006238 secs] [Full GC 6135K->5621K(10196K), 0.0313233 secs] [GC 5638K->5621K(10196K), 0.0002310 secs] [Full GC 5621K->456K(10196K), 0.0241263 secs] [GC 6277K->5603K(10196K), 0.0003755 secs] [Full GC 6136K->5649K(10196K), 0.0241584 secs] [GC 5667K->5650K(10196K), 0.0002148 secs] [Full GC 5650K->456K(10196K), 0.0233303 secs] [GC 6276K->5603K(10196K), 0.0003743 secs] [Full GC 6136K->5621K(10196K), 0.0304924 secs] [GC 5638K->5621K(10196K), 0.0002355 secs] [Full GC 5621K->456K(10196K), 0.0235848 secs] [GC 6276K->5603K(10196K), 0.0005327 secs] [Full GC 6136K->5649K(10196K), 0.0246543 secs] |
-verbose:gc -Xmn16m
| setGCDisabled(true) | setGCDisabled(false) |
[GC 10740K->455K(16192K), 0.0067553 secs] [GC 13198K->455K(16192K), 0.0033887 secs] [GC 13310K->455K(16192K), 0.0031920 secs] [GC 13194K->455K(16192K), 0.0032965 secs] [GC 13188K->456K(16192K), 0.0032487 secs] [GC 13231K->456K(16192K), 0.0032934 secs] [GC 13218K->456K(16192K), 0.0033169 secs] |
[Full GC 10740K->5620K(16192K), 0.0376690 secs] [Full GC 12104K->5625K(16192K), 0.0320728 secs] [Full GC 12050K->5651K(16192K), 0.0320968 secs] [Full GC 12031K->5619K(16192K), 0.0346910 secs] [Full GC 11985K->5630K(16192K), 0.0324041 secs] [Full GC 12034K->5639K(16192K), 0.0324170 secs] [Full GC 12040K->5649K(16192K), 0.0326779 secs] [Full GC 12043K->5621K(16192K), 0.0340462 secs] [Full GC 11999K->5630K(16192K), 0.0329092 secs] [Full GC 11992K->5635K(16192K), 0.0330936 secs] [Full GC 12009K->5636K(16192K), 0.0325304 secs] [Full GC 11999K->5621K(16192K), 0.0325377 secs] [Full GC 11992K->5630K(16192K), 0.0431563 secs] [Full GC 12000K->5638K(16192K), 0.0337579 secs] [Full GC 12001K->5646K(16192K), 0.0353190 secs] |
Apr 22, 2006
[Library] JExcelAPI にチャレンジ(4)
シートの印刷サイズをセットする
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
sheet.setPageSetup(PageOrientation.LANDSCAPE, PaperSize.B5, 10, 10);
シート印刷時のページ数を指定する
シートを印刷するときに指定したページ枚数にフィットするように拡大縮小させることができる。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
SheetSettings settings = sheet.getSettings();
settings.setFitHeight(1);
settings.setFitWidth(1);
settings.setFitToPages(true);
シートを保護する
以下の方法でシート編集時にパスワードを問い合わせるようにすることができる。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
SheetSettings settings = sheet.getSettings();
settings.setProtected(true);
settings.setPassword("mypassword");
ウィンドウ枠を固定する
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
SheetSettings settings = sheet.getSettings();
settings.setHorizontalFreeze(1);
settings.setVerticalFreeze(2);
シート表示のズームをセットする
SheetSettings#setZoomFactor でズームを指定できる。 パラメータとして渡す数値はズームの %。 例えば、50 を指定すると 50% で表示される。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
SheetSettings settings = sheet.getSettings();
settings.setZoomFactor(75);
Apr 21, 2006
[Library] JExcelAPI にチャレンジ(3)
文字を BOLD にする
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
WritableCellFormat format = new WritableCellFormat();
WritableFont font = new WritableFont(format.getFont());
font.setBoldStyle(WritableFont.BOLD);
format.setFont(font);
Label label = new Label(0, 0, "hoge");
label.setCellFormat(format);
sheet.addCell(label);
文字をセンタリングする
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
WritableCellFormat format = new WritableCellFormat();
format.setAlignment(Alignment.CENTRE);
Label label = new Label(0, 0, "hoge");
label.setCellFormat(format);
sheet.addCell(label);
罫線を引く
セル単位で罫線を引くことができる。 使用できる線種は以下の通り。
- DASH_DOT
- DASH_DOT_DOT
- DASHED
- DOTTED
- DOUBLE
- HAIR
- MEDIUM
- MEDIUM_DASH_DOT
- MEDIUM_DASH_DOT_DOT
- MEDIUM_DASHED
- NONE
- SLANTED_DASH_DOT
- THICK
- THIN
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
WritableCellFormat format = new WritableCellFormat();
format.setBorder(Border.ALL, BorderLineStyle.THIN);
Label label = new Label(0, 0, "hoge");
label.setCellFormat(format);
sheet.addCell(label);
セルの背景色をセットする
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
WritableCellFormat format = new WritableCellFormat();
format.setBackground(Colour.LIGHT_ORANGE);
Label label = new Label(0, 0, "hoge");
label.setCellFormat(format);
sheet.addCell(label);
シートにヘッダをセットする
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
SheetSettings settings = sheet.getSettings();
HeaderFooter header = new HeaderFooter();
header.getCentre().append("My Bookmarks");
settings.setHeader(header);
シートにフッタをセットする
フッタもヘッダと同じ方法でセットできる。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
SheetSettings settings = sheet.getSettings();
HeaderFooter footer = new HeaderFooter();
footer.getCentre().appendPageNumber();
footer.getCentre().append(" / ");
footer.getCentre().appendTotalPages();
settings.setFooter(footer);
Apr 20, 2006
[Library] JExcelAPI にチャレンジ(2)
JExcelAPI を実際に使用する可能性が出てきた。 というわけで、JExcelAPI で出来ることを簡単に調べてメモしておく。 JExcelAPI のバージョンは 2.5.9 を前提とする。
- JExcelAPI にチャレンジ
- http://www.in-vitro.jp/blog/index.cgi/Library/20051105_01.html
- JExcelAPI のクラス図
- http://www.in-vitro.jp/blog/index.cgi/Library/20051106_01.html
ブックを生成する
ブックは Workbook#createWorkbook(File) で簡単に生成できる。 Servlet から Stream で Web ブラウザに流すといった用途の場合は下記の様に一度オンメモリで生成する。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
// ここで book を編集する。
book.write();
book.close();
OutputStream fos = null;
try {
fos = new FileOutputStream(new File("c:\\mybook.xls"));
fos.write(baos.toByteArray());
fos.flush();
} finally {
if (fos != null) {
fos.close();
}
}
シートを生成する
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
カラムの幅を変更する
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
sheet.setColumnView(0, 100);
セルに数値を書く
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
Number number = new Number(0, 0, 999);
sheet.addCell(number);
セルに文字列を書く
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
Label label = new Label(0, 0, "hoge");
sheet.addCell(label);
セルに式を書く
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
Formula formula = new Formula(0, 0, "10 * 10");
sheet.addCell(formula);
セルにリンクを書く
WritableHyperlink を使用するとリンクを作成できる。 ただ、WritableHiperlink を使用したセルにフォーマット(罫線等)を指定する方法が見つからなかった。 仕方が無いので、関数を使用してリンクを作成してみた。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableWorkbook book = Workbook.createWorkbook(baos);
WritableSheet sheet = book.createSheet("my sheet", 0);
Formula formula = new Formula(0, 0, "HYPERLINK(\"http://www.google.com/\", \"Google\")");
sheet.addCell(formula);
Apr 19, 2006
[Misc] ジェノグラフィック・プロジェクトその後
以前、自分のご先祖様を調べてくれるジェノグラフィック・プロジェクトに参加した。
自分の DNA サンプルを送ると、DNA の情報を基にルーツを調べてくれる。
DNA の分析に時間がかかっていたが、ついに結果が分かった。
ジェノグラフィック・プロジェクトに関してはこちら→ ジェノグラフィック・プロジェクトに参加
というわけで、私の父方のご先祖様は "Eurasian Adam" だということが分かった。
アフリカから、インド、東南アジアを経由して日本にたどり着いたらしい。
日本人の 40% が私と同じルーツを持つそうなので、「ごくありふれた日本人」ということか。
M174 の皆様、遠い親戚になるそうですのでよろしくお願いしますm(_ _)m
![[ルーツ]](/blog/entries/Misc/20060419_01/genographic_01.png)
ルーツ
![[Genetic Sequence]](/blog/entries/Misc/20060419_01/genographic_02.png)
Genetic Sequence
![[Genetic History]](/blog/entries/Misc/20060419_01/genographic_03.png)
Genetic History
Apr 18, 2006
[Library] JBoss jBPM Process Designer にチャレンジ(2)
JBoss jBPM Process Designer でプロセスを記述してみた。
Process Project の作成、設定など
まずはプロジェクト作成ウィザードを使用して "Process Project" を作成する。
"Process Project" を作成したら、次に "Process" を作成する。
作成された XML をエディタで開くと、プロセス定義をすることができる。
![]() Process Project の作成 |
![]() 作成された Process Project |
![]() jBPM の設定 |
![]() Process の作成 |
プロセスの記述
<?xml version="1.0" encoding="UTF-8"?>
<process-definition
xmlns="http://jbpm.org/3/jpdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jbpm.org/3/jpdl http://jbpm.org/xsd/jpdl-3.0.xsd"
name="sample-process">
<start-state name="start">
<transition name="tr1" to="state1"></transition>
</start-state>
<end-state name="end1"></end-state>
<state name="state1">
<transition name="tr1" to="decision1"></transition>
</state>
<decision name="decision1">
<transition name="tr1" to="state2"></transition>
<transition name="tr2" to="state3"></transition>
</decision>
<state name="state2">
<transition name="tr1" to="end1"></transition>
</state>
<state name="state3">
<transition name="tr1" to="end1"></transition>
</state>
</process-definition>
Apr 17, 2006
[Library] JBoss jBPM Process Designer にチャレンジ
JBoss jBPM Process Designer とは
JBoss jBPM Process Designer は、JBoss jBPM 用のプロセス定義ツール。 GUI でプロセスを定義することができるので便利。 JBoss 謹製で、Eclipse Plugin として提供されている。
- JBoss jBPM Process Designer ドキュメント
- http://docs.jboss.com/jbpm/v3/gpd/
JBoss jBPM Process Designer の実行環境構築
JBoss jBPM Process Designer は Eclipse Plugin なので、まず Eclipse を用意する。 ドキュメントによると
This release should work with all Eclipse 3.1 releases starting from M7.ということなので、現時点(2006/04/17) で最新のプロダクトリリースである 3.1.2 を使用することにする。 JBoss jBPM Process Designer は最新の 3.0.4 を使用する。
- Eclipse 3.1.2 をここからダウンロードする
- Eclipse をインストールする。以降、インストール先ディレクトリを %ECLIPSE_HOME% と記述する。
- JBoss jBPM Process Designer Plugin 3.0.4 をここからダウンロードする
- JBoss jBPM Process Designer をインストールする。JBoss jBPM Process Designer のアーカイブ内の plugins, features をそれぞれ%ECLIPSE_HOME%/plugins, %ECLIPSE_HOME%/features にコピーする
- Eclipse 3.1.2 の起動確認を行う。
Apr 16, 2006
[Library] JBoss jBPM + Hibernate + Derby 連携方法をメモ
JBoss jBPM は DBMS に情報を格納することができる。 この機能をお手軽に試すために Derby と連携させてみた。
jbpm.properties
クラスパスルートに jbpm.properties を作成する。
jbpm.hibernate.cfg.xml=hibernate.cfg.xml
hibernate.cfg.xml
クラスパスルートに hibernate.cfg.xml を作成する。
<?xml version="1.0" ?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd" >
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">
org.apache.derby.jdbc.EmbeddedDriver
</property>
<property name="connection.url">jdbc:derby:derbyDB</property>
<property name="dialect">
org.hibernate.dialect.DerbyDialect
</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<mapping resource="DummyEntity.hbm.xml" />
</session-factory>
</hibernate-configuration>
Apr 15, 2006
[Library] JBoss jBPM にチャレンジ
先日調べたワークフローエンジンの中から JBoss jBPM を試してみた。
JBoss jBPM の環境構築
JBoss jBPM 3.0.1 の実行環境構築方法は以下の通り。
-
クラスパスのルートに jbpm.properties を設置する。
- antlr-2.7.5H3.jar
- asm-attrs.jar
- asm.jar
- bsh-2.0b2.jar
- cglib-2.1.jar
- commons-collections-2.1.1.jar
- commons-logging-1.0.4.jar
- converter.jar
- dom4j-1.6.jar
- ehcache-1.1.jar
- hibernate3.jar
- jaxen-1.1-beta-4.jar
- jbpm-3.0.1.jar
- jbpm-identity-3.0.1.jar
- jdbc2_0-stdext.jar
- jta.jar
- クラスパスに以下の jar を追加する。
jbpm.properties は JbpmConfiguration が自動的に読み込む。 jbpmConfiguration が jbpm.properties を探すサーチパスは
- クラスパス内の /jbpm.properties
- クラスパス内の /org/jbpm/jbpm.properties
とっかかり
とりあえずこの辺りを読めばとりあえず使えるというドキュメントをメモ。
- チュートリアル
- http://docs.jboss.com/jbpm/v3/userguide/tutorial.html
- Graph Oriented Programming
- http://docs.jboss.com/jbpm/v3/userguide/graphorientedprogramming.html
- jPDL xml schema
- http://docs.jboss.com/jbpm/v3/userguide/jpdl.html#d0e4520
- Expressions
- http://docs.jboss.com/jbpm/v3/userguide/jpdl.html#expressions
- Expression Language
- http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html
- Script
- http://docs.jboss.com/jbpm/v3/userguide/processmodelling.html#script
- beanshell
- http://www.beanshell.org/
Apr 14, 2006
[WebService] Google Calendar で遊ぶ
Google Calendar が公開された。 面白そうなので早速遊んでみることに。 インタフェースは Mac に付属の iCal にそっくり。 かなり使いやすい。 まだカレンダの新規作成などでバグが散見されるが、バグが減って安定してくれば結構使えそう。
![]() |
![]() |
![]() |
![]() |
![]() |
Apr 13, 2006
[Library] Java で利用可能なワークフローエンジンをメモ
Google 先生に教えてもらったワークフローエンジンをメモ。 Java 用の API が存在する(と思われる)もののみ。
オープンソース製品
- ActiveBPEL (ActiveBPEL, LLC., GPL/Commercial License)
- http://www.activebpel.org/
- Bonita (ECOO Team., LGPL)
- http://bonita.objectweb.org/
- con:cern
- http://con-cern.org/
- Dalma
- https://dalma.dev.java.net/nonav/maven/index.html
- Enhydra Workflow Platform (Together Teamlösungen, LGPL 2.1)
- http://www.enhydra.org/workflow/
- Enhydra JaWE
- http://www.enhydra.org/workflow/jawe/index.html
- Enhydra Shark
- http://www.enhydra.org/workflow/shark/index.html
- Freefluo
- http://freefluo.sourceforge.net/
- JBoss jBPM
- http://labs.jboss.com/portal/index.html?ctrl:id=page.default.info&project=jbossjbpm
- JFlower (?, GPL)
- http://sourceforge.net/projects/jflower/
- Nautica Worklfow (アルゴ21 研究開発センター, LGPL 2.1)
- http://nautica.sourceforge.jp/main.html
- OpenWFE (?, BSD License)
- http://web.openwfe.org/display/openwfe/Home
- OSWorkflow (OpenSymphony, The OpenSymphony Software License, Version 1.1)
- http://www.opensymphony.com/osworkflow/
- S2Buri (まこたん, ASL 2.0)
- http://s2buri.sandbox.seasar.org/
- Taverna (?, LGPL)
- http://taverna.sourceforge.net/
- Twister (?, LGPL)
- http://www.smartcomps.org/twister/
- XFLOW (Rob Tan, ?)
- http://xflow.sourceforge.net/
- werkflow
- http://sourceforge.net/projects/werkflow/
商用製品
- j-Flow (関西日本電気)
- http://www.scs.co.jp/product/gaiyo/jflow.html
- Flux Workflow (Flux Corporation.)
- http://www.fluxcorp.com/workflow/
- Global Flow (Panasonic Solution Technologies Co.)
- http://panasonic.co.jp/pss/pstc/products/gf/flow/index.html
- Green Office Workflow (京セラコミュニケーションシステム株式会社)
- http://www.kccs.co.jp/products/workflow/index.html
- Groupmax (日立)
- http://www.hitachi.co.jp/Prod/comp/soft1/groupmax/
- MajorFlow (松下ネットソリューションズ株式会社)
- http://www.mnes.co.jp/Home/products.nsf/ContentsByKey/MajorFlow_Top
- MELDandy (三菱電機情報ネットワーク株式会社)
- http://www.mind.co.jp/service/application/appli_package/meldandy/index.html
- OptimalFlow (株式会社NTTデータビジネスブレインズ)
- http://www.nttd-bb.com/solution/total/solution4/index.html
- WebLogic Integration (BEA Systems, Inc.)
- http://www.beasys.co.jp/products/weblogic/integration/index.html
Apr 12, 2006
[AS] Apache Web Server 2、lighttpd、JBossWeb のパフォーマンス比較
JBossWeb のパフォーマンス感が知りたくて、大雑把なパフォーマンス比較をしてみた。 それぞれインストールしただけの Apache Web Server 2、JBossWeb に JMeter で負荷をかけてみた。 また、ついでに lighttpd も試してみた。
テスト環境
- Debian Sarge on VMWare Player
- Kernel 2.6.8-2-386
テスト方法
-
各サーバのドキュメントルートに以下の "index.html" を作成する。
<html> <head> <title>dummy page</title> </head> <body> This is a dummy page. </body> </html>
- JMeter で 1000 回程度 "/index.html" を GET する。(このときの結果は無視)
- JMeter でスレッド数 10、20、30、40、50 の状態で "/index.html" を 1000 回 GET し、パフォーマンスを計測する。
テスト結果
Apache Web Server 2
# /usr/sbin/apache2 -v Server version: Apache/2.0.54 Server built: Sep 5 2005 11:11:08
| スレッド数 | Samples | Average | Median | 90% Line | Min | Max | Error % | Throughput | KB/sec |
|---|---|---|---|---|---|---|---|---|---|
| 10 | 10000 | 9 | 0 | 16 | 0 | 1734 | 0.00% | 824.7/sec | 78.93 |
| 20 | 20000 | 18 | 15 | 31 | 0 | 3562 | 0.00% | 859.7/sec | 82.27 |
| 30 | 30000 | 28 | 16 | 32 | 0 | 3609 | 0.00% | 913.0/sec | 87.38 |
| 40 | 40000 | 35 | 15 | 47 | 0 | 11078 | 0.00% | 815.0/sec | 78.00 |
| 50 | 50000 | 48 | 16 | 78 | 0 | 12218 | 0.00% | 810.3/sec | 77.55 |
lighttpd
# /usr/sbin/lighttpd -v lighttpd-1.4.11 (ssl) - a light and fast webserver Build-Date: Mar 27 2006 09:56:59
| スレッド数 | Samples | Average | Median | 90% Line | Min | Max | Error % | Throughput | KB/sec |
|---|---|---|---|---|---|---|---|---|---|
| 10 | 10000 | 5 | 0 | 16 | 0 | 485 | 0.00% | 1406.7/sec | 134.62 |
| 20 | 20000 | 15 | 16 | 31 | 0 | 235 | 0.00% | 1175.4/sec | 112.49 |
| 30 | 30000 | 23 | 16 | 47 | 0 | 313 | 0.00% | 1209.1/sec | 115.71 |
| 40 | 40000 | 32 | 31 | 62 | 0 | 204 | 0.01% | 1151.6/sec | 110.32 |
| 50 | 50000 | 41 | 47 | 63 | 0 | 297 | 0.01% | 1140.8/sec | 109.27 |
Apache Web Server 2
# ./run.sh --version ========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /opt/jbossweb JAVA: /opt/jdk15/bin/java JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh CLASSPATH: /opt/jbossweb/bin/run.jar:/opt/jdk15/lib/tools.jar ========================================================================= JBoss 4.0.4RC1 (build: CVSTag=JBoss_4_0_4_RC1 date=200602071519) Distributable under LGPL license. See terms of license at gnu.org.
| スレッド数 | Samples | Average | Median | 90% Line | Min | Max | Error % | Throughput | KB/sec |
|---|---|---|---|---|---|---|---|---|---|
| 10 | 10000 | 10 | 0 | 16 | 0 | 625 | 0.00% | 856.8/sec | 81.99 |
| 20 | 20000 | 21 | 0 | 16 | 0 | 12984 | 0.00% | 817.9/sec | 78.27 |
| 30 | 30000 | 32 | 15 | 31 | 0 | 13750 | 0.00% | 763.7/sec | 73.09 |
| 40 | 40000 | 48 | 15 | 62 | 0 | 6703 | 0.00% | 739.0/sec | 70.73 |
| 50 | 50000 | 59 | 16 | 94 | 0 | 12922 | 0.00% | 750.1/sec | 71.79 |
Apache Tomcat 5.5
Apache Tomcat 5.5.16 の計測結果を以下に示す。
| スレッド数 | Samples | Average | Median | 90% Line | Min | Max | Error % | Throughput | KB/sec |
|---|---|---|---|---|---|---|---|---|---|
| 10 | 10000 | 8 | 0 | 16 | 0 | 562 | 0.00% | 959.5/sec | 91.83 |
| 20 | 20000 | 19 | 0 | 16 | 0 | 10844 | 0.00% | 888.9/sec | 85.07 |
| 30 | 30000 | 28 | 0 | 16 | 0 | 20766 | 0.00% | 901.0/sec | 86.23 |
| 40 | 40000 | 36 | 0 | 16 | 0 | 8953 | 0.00% | 886.4/sec | 84.83 |
| 50 | 50000 | 51 | 0 | 16 | 0 | 12844 | 0.00% | 866.7/sec | 82.95 |
まとめ
未チューニング状態では、JBossWeb のパフォーマンスは Apache Web Server 2 より多少遅いレベルの様だ。
当然ながら Apache Tomcat とも大差ない結果となっている。
それにしても、lighttpd は light と銘打つだけあって流石に速い。
それにしても、Apache Web Server 2 が JBossWeb や Apache Tomcat と同等だったのが意外だった。
もう少し速いイメージがあったのだけれど。
Apr 11, 2006
[AS] JBossWeb にチャレンジ
JBossWeb とは
JBossWeb は、JBoss AS をシンプルにして Web サーバ機能のみを残したもの。 要するに「ほぼ」Apache Tomcat ということだろう。 当然 Servlet や JSP の動作環境も提供される。
- JBossWeb
- http://labs.jboss.com/portal/index.html?ctrl:id=page.default.info&project=jbossweb
- JBossWeb Download
- http://labs.jboss.com/portal/index.html?ctrl:id=page.default.downloads&project=jbossweb
JBossWeb のインストール
Debian Sarge 上に JBossWeb をインストールしたときのメモ。
- こちらから JBossWeb のバイナリをダウンロードする。ここでは jbossweb-4.0.4RC1-linux-i686.tar.gz を前提とする。
-
アーカイブを解凍して、適当な位置に配置する。
# tar zxvf ./jbossweb-4.0.4RC1-linux-i686.tar.gz # mv ./jbossweb-4.0.4RC1-linux-i686 /opt # ln -s /opt/jbossweb-4.0.4RC1-linux-i686 /opt/jbossweb
-
シェルスクリプトのパーミッションを変更する。
# chmod 755 /opt/jbossweb/bin/*.sh
-
Java の動作環境を設定する。
# export JAVA_HOME=/opt/jdk15 # export PATH=$JAVA_HOME/bin:$PATH # java -version java version "1.5.0_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05) Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
- 必要に応じてサーバの設定を変更する。 例えば、HTTP のポートを変更する場合は /opt/jbossweb/server/default/deploy/jbossweb.sar/server.xml を変更する。
-
起動する。
# cd /opt/jbossweb/bin # ./run.sh
Apr 10, 2006
[Misc] Jabberd のインストールにチャレンジ
Jabberd を Debian Sarge にインストールしてみた。 Jabberd は APT で簡単にインストールできる。
- jabberd 1.4
- http://jabberd.jabberstudio.org/1.4/
- jabberdの動かし方
- http://nantoka.kicks-ass.net/wiki/index.php?%5B%5Bjabberd%A4%CE%C6%B0%A4%AB%A4%B7%CA%FD%5D%5D
インストールされた Jabberd のバージョンを確認してみる。# apt-get install jabber jabber-aim jabber-common jabber-dev jabber-jit jabber-jud jabber-msn jabber-muc jabber-yahoo パッケージリストを読みこんでいます... 完了 依存関係ツリーを作成しています... 完了 以下の特別パッケージがインストールされます: libcurl3 libexpat1-dev libglib1.2 libglib2.0-0 libpth-dev libpth2 libssl-dev 提案パッケージ: libcurl3-gssapi ca-certificates libpth-dbg libpth-prof 推奨パッケージ: libglib2.0-data 以下のパッケージが新たにインストールされます: jabber jabber-aim jabber-common jabber-dev jabber-jit jabber-jud jabber-msn jabber-muc jabber-yahoo libcurl3 libexpat1-dev libglib1.2 libglib2.0-0 libpth-dev libpth2 libssl-dev アップグレード: 0 個、新規インストール: 16 個、削除: 0 個、保留: 9 個。 4532kB のアーカイブを取得する必要があります。 展開後に追加で 13.1MB のディスク容量が消費されます。 続行しますか? [Y/n] Y 取得:1 http://http1.debian.or.jp sarge/main jabber-common 0.4 [3848B] 取得:2 http://http1.debian.or.jp sarge/main libpth2 2.0.1-2 [73.5kB]
インストールが終了すると Jabberd は自動的に起動される。# /usr/sbin/jabberd -v Jabberd Version 1.4.3
# ps -ef | grep jabber jabber 1104 1 0 12:00 ? 00:00:00 /usr/sbin/jabberd jabber 1106 1104 0 12:00 ? 00:00:00 /usr/sbin/jabberd root 1145 872 0 12:01 pts/0 00:00:00 grep jabber
Apr 09, 2006
[Misc] Java における慣習的命名
Manager というクラスの命名に関連して、Java における慣習的な命名を調べてみた。 調査方法は以下の通り。
- 調査対象は公開されているオープンソースライブラリ。
- Maven2 の公開リポジトリ(http://repo1.maven.org/maven2) に登録されているライブラリから適当に Jar アーカイブを選択
- Jar アーカイブ内の全クラス、全メソッドを抽出
- クラス名、メソッド名をキャメルノーてーションを前提として単語に分割
- 単語毎に出現回数をカウント
- Jar アーカイブ ・・・ 1179
- クラス ・・・ 129152
- メソッド ・・・ 943841
慣習的クラス名
クラス名として使用されている単語の TOP 30 は以下の通り。 件の Manager も 27 位にランクインしている。
| 順位 | 単語 | カウント数 |
|---|---|---|
| 01 | Impl | 7817 |
| 02 | Factory | 6171 |
| 03 | Type | 4676 |
| 04 | Exception | 4596 |
| 05 | Element | 3170 |
| 06 | Map | 2928 |
| 07 | Key | 2723 |
| 08 | Document | 2622 |
| 09 | Context | 2361 |
| 10 | Abstract | 2328 |
| 11 | Handler | 2221 |
| 12 | Bean | 2215 |
| 13 | Class | 2196 |
| 14 | Set | 2110 |
| 15 | Xml | 2106 |
| 16 | Hash | 2073 |
| 17 | Object | 2026 |
| 18 | Info | 2010 |
| 19 | Helper | 1915 |
| 20 | Resource | 1900 |
| 21 | Holder | 1757 |
| 22 | List | 1756 |
| 23 | Property | 1731 |
| 24 | Message | 1671 |
| 25 | Tag | 1671 |
| 26 | Default | 1655 |
| 27 | Manager | 1655 |
| 28 | Event | 1622 |
| 29 | Name | 1600 |
| 30 | Attribute | 1575 |
慣習的メソッド名
メソッド名として使用されている単語の TOP 30 は以下の通り。
| 順位 | 単語 | カウント数 |
|---|---|---|
| 01 | get | 240349 |
| 02 | set | 107927 |
| 03 | Name | 33048 |
| 04 | is | 32509 |
| 05 | Value | 25894 |
| 06 | Type | 23199 |
| 07 | add | 22824 |
| 08 | String | 18564 |
| 09 | create | 18113 |
| 10 | new | 16511 |
| 11 | to | 14490 |
| 12 | Class | 13125 |
| 13 | Instance | 12121 |
| 14 | Element | 11662 |
| 15 | Id | 11543 |
| 16 | Set | 10390 |
| 17 | Object | 9427 |
| 18 | Attribute | 9413 |
| 19 | remove | 9336 |
| 20 | Array | 9113 |
| 21 | To | 9084 |
| 22 | Stream | 7733 |
| 23 | Property | 7654 |
| 24 | Message | 6936 |
| 25 | Key | 6931 |
| 26 | Node | 6794 |
| 27 | XML | 6726 |
| 28 | write | 6190 |
| 29 | Data | 6150 |
| 30 | New | 6102 |
Apr 08, 2006
[Misc] Manager というクラスの命名
Radium Software DevelopmentさんのSomethingManagerというエントリを読んで。
クラス名に "Manager" という接尾語を用いていることは,そのクラスの設計に不備があることを暗に告げていると考えることができる。このような,クラス名から伝わってくる「兆候」 ― いわゆる "code smell" [Wikipedia] は,他にも幾つか見つけることができる。例えば "Object", "Handler", "Data" などがこれに含まれる [C2Wiki] 。これらの接尾語をクラス名に見つけたならば,そのクラスの設計を見直すことを考えた方が良いかもしれない。
確かに言われてみると、"Manager" という命名は責務が曖昧になりがちだ。 ただ、"Manager" という命名のクラスが即クラス設計のミスだとは思えない。 逆に "Manager" クラスの責務を規定しても良いのではないだろうか??
Code smell
Manager という命名など、コードのきな臭さのことを Code smell というらしい。 Code smell によると
code smell is a jargon term used among programmers to refer to a symptom that indicates something may be wrong.ということらしい。
Apr 07, 2006
[Misc] Jabber Server にチャレンジ
複数の IM を使用しなければならない状況が次第に増えてきた。 主に Google Talk と MSN Messenger。 使い分けが面倒になってきたので、IM クライアントを一つに統一したい。 というわけで、Jabber クライアントに乗り換えることに。 ついでなので、Jabber Server も少し調べてみることに。 Jabber Server が簡単に立てられるようなら、自分専用で用意してみようと思う。
- IM Federation - Software
- http://imfederation.com/software.html
- Jabber :: Software :: Servers
- http://www.jabber.org/software/servers.shtml
Jabbered
リストアップされていた Jabber Server の中から Jabberd を調べてみることに。 Jabberd を選択したのは、Debian Sarge の場合 apt でインストールできるため。 当然設定も Debian に合わせてカスタマイズしてあるはず。
- jabberd 1.4
- http://jabberd.jabberstudio.org/1.4/
- jabberdの動かし方
- http://nantoka.kicks-ass.net/wiki/index.php?%5B%5Bjabberd%A4%CE%C6%B0%A4%AB%A4%B7%CA%FD%5D%5D
# apt-cache search jabber jabber - Daemon for the jabber.org Open Source Instant Messenger jabber-aim - Provides AIM messenger transport for Jabber IM server jabber-common - Jabber server and transport (common files) jabber-dev - Daemon for the jabber.org Open Source Instant Messenger jabber-jit - Jabber ICQ Transport jabber-jud - Provides User Directory support for the Jabber IM server jabber-msn - Provides the MSN transport for the Jabber IM server jabber-muc - Multi User Chat module for the Jabber IM Server jabber-yahoo - Provides Yahoo messenger transport for Jabber IM server
Apr 06, 2006
[Tiger] Java の Unicode 4 サポート
Java が Java 5.0 で Unicode 4 にバージョンアップしてたことを最近知った。 Unicode 4 は 1 文字 16bit では表現できないコード体系になっているらしい。 Java は 1 文字 16bit を前提としている言語になっている。 char は 16bit で確保されているし。 Unicode 4 のサポートは結構オオゴトな気がするのだが、どうなっているのだろう。 というわけで、少々調べてみることにした。
- JSR-000204 Unicode Supplementary Character Support (Final Release)
- http://jcp.org/aboutJava/communityprocess/final/jsr204/index.html
- The Java Language Specification
- http://java.sun.com/docs/books/jls/index.html
- JSR-000204 Unicode Supplementary Character Support (Proposed Final Draft)
- http://jcp.org/aboutJava/communityprocess/first/jsr204/index.html
- Java プラットフォームにおける補助文字のサポート
- http://java.sun.com/developer/technicalArticles/Intl/Supplementary/index_ja.html
- Unicode 4.0 の補助文字のサポート Supplementary Char
- http://www.javainthebox.net/laboratory/J2SE1.5/MiscAPI/SupplementaryChar/SupplementaryChar.html
Unicode 4 のコード体系
Unicode 3 までの Unicode は 1 文字 16bit で固定されていた。 Unicode 4 では、コード体系が下記の様に拡張されている。
- 0x0000 - 0xFFFF ・・・ BMP(Basic Multilingual Plane, 基本多言語面)
-
0x10000 - 0x1FFFFF ・・・ SMP(Supplementary Multilingual Plane, 補助的多言語面)
- 0x10000 - 0x1FFFF ・・・ Plane 1
- 0x20000 - 0x2FFFF ・・・ Plane 2
- 0x30000 - 0x3FFFF ・・・ Plane 3
- 0x40000 - 0x4FFFF ・・・ Plane 4
- 0x50000 - 0x5FFFF ・・・ Plane 5
- 0x60000 - 0x6FFFF ・・・ Plane 6
- 0x70000 - 0x7FFFF ・・・ Plane 7
- 0x80000 - 0x8FFFF ・・・ Plane 8
- 0x90000 - 0x9FFFF ・・・ Plane 9
- 0xA0000 - 0xAFFFF ・・・ Plane 10
- 0xB0000 - 0xBFFFF ・・・ Plane 11
- 0xC0000 - 0xCFFFF ・・・ Plane 12
- 0xD0000 - 0xDFFFF ・・・ Plane 13
- 0xE0000 - 0xEFFFF ・・・ Plane 14
- 0xF0000 - 0xFFFFF ・・・ Plane 15
- 0x100000 - 0x10FFFF ・・・ Plane 16
の辺りは覚えておいた方がよさそうか。
- Supplementary Character
- A Unicode encoded character having a supplementary code point.
- Supplementary Code Point
- A Unicode code point between U+10000 and U+10FFFF.
- Supplementary Planes
- Planes 1 through 16, consisting of the supplementary code points.
- Surrogate Character
- A misnomer. It would be an encoded character having a surrogate code point, which is impossible. Do not use this term.
- Surrogate Code Point
- A Unicode code point in the range U+D800 through U+DFFF. Reserved for use by UTF-16, where a pair of surrogate code units (a high surrogate followed by a low surrogate) “stand in” for a supplementary code point.
- Surrogate Pair
- A representation for a single abstract character that consists of a sequence of two 16-bit code units, where the first value of the pair is a high-surrogate code unit, and the second is a low-surrogate code unit. (See definition D27 in Section 3.8, Surrogates.)
Apr 05, 2006
[VMWare] Virtual Server 2005 にチャレンジ
Virtual Server とは
Virtual Server は Microsoft 製の仮想化ソフト。 VMWare と同種のソフトウェア。 今は Microsoft 製品だけれど Virtual PC 同様 Microsoft に買収された Connectix が開発したもの。 VMWare で特に困ったことはないが、最近フリーで公開されたので試してみることに。
- Download or Order Virtual Server 2005 R2 Enterprise Edition for Free
- http://www.microsoft.com/windowsserversystem/virtualserver/software/default.mspx
- Virtual Server 2005 R2 Software Download Registration
- http://www.microsoft.com/windowsserversystem/virtualserver/software/privacy.mspx
Virtual Server のインストール
- ダウンロードページへ行く。
- "Change Language" で言語を日本語に変更する。
- "32 ビット X86 実行可能ファイル" というリンクからバイナリ("setup.exe")をダウンロードする。
- "setup.exe" を実行するとインストーラが起動する。
Virtual Machine の作成
Virtual Server は入ったが、Virtual Machine の作成方法が分からない。 ファーストステップガイドを読んでみたところ「バーチャル マシンを作成するには、管理 Web サイトを開きます。」と書かれていた。 どうやら「Virtual Server Web アプリケーション」が無ければ Virtual Machine を作成できないらしい。 色々調べてみたが他の Virtual Machine 作成方法は見つからなかった。 IIS はインストールしたくないので、ここで断念。 CUI のツールを用意して欲しいな。
Apr 04, 2006
[DocBook] DocBook Doclet にチャレンジ
DocBook Doclet
DocBook Doclet は Javadoc のカスタム doclet。 API Document を PDF や Docbook 形式など様々な形式で出力することができるスグレモノ。 API Document を Docbook 形式で出力できると便利なので早速試してみた。
DocBook Doclet のインストール
DocBook Doclet は、Javadoc へ組み込んで使用する jar と単体で動作する GUI アプリケーションの 2 種類のバイナリが提供されている。 とりあえず時間もないので GUI アプリケーションを試してみることに。
- こちらから Windows 用のバイナリをダウンロードする。ここでは dbdoclet-0_70_1.exe を使用。
-
ダウンロードしたバイナリを実行するとインストーラが起動するので、後はインストーラの指示通りにインストールする。
但し、インストール先ディレクトリはスペースが含まれないパスに変更した。念のためだけれど。 - デスクトップ上に作成されるショートカットを削除(使用できなかったので)
-
起動用のバッチファイルを作成
set JAVA_HOME=c:\_java\jdk\1.5.0_06 set PATH=%JAVA_HOME%\bin;%PATH% set DOCLET_HOME=C:\_java\tool\DocBookDoclet set DOCLET_JAR=%DOCLET_HOME%\jars\tidbit.jar java.exe -Xmx512m -Dhome=%DOCLET_HOME% -jar %DOCLET_JAR%
DocBook Doclet で DocBook 形式の API Document 作成
- 上で作成した起動用バッチファイルを使用して DocBook Doclet を起動する。
- プロジェクトを新規作成する
- "Project" タブで "Project name"、"Destination directory" を設定
- "Sources" タブで "Sourcepath" を設定して "Add" ボタンを押下
- "Classpath" タブで "Classpath" を設定して "Add" ボタンを押下
- 必要に応じて "Javadoc"、"DocBook XML"、"PDF layout"、"Trafo" も設定
- "DocBook" ボタンを押下
- "Destination directory" で指定したディレクトリの中に docbook/Reference.xml が生成される
Apr 03, 2006
[Library] NGramJ にチャレンジ
NGramJ とは
NGramJ は、Natural Language Processing(NLP)用のライブラリ。 与えられたバイト配列の言語、文字エンコーディングを判別してくれる。 たとえば、"竹やぶに竹立てかけた。"という文字列を Shift_JIS のバイト配列で NGramJ に引き渡すと、「Shift_JIS の日本語」であることを判断してくれる。
- NGramJ
- http://ngramj.sourceforge.net/index.html
- API Document
- http://ngramj.sourceforge.net/javadoc/index.html
NGramJ の実行環境構築
- こちらから NGramJ をダウンロードする。ここでは ver.1.0-0.060327 を前提とする。
- アーカイブの中にある以下の ngramj.jar をクラスパスに追加する。
サンプルコード
とりあえず日本語と英語の判別を試してみた。
package jp.in_vitro.codelets.ngramj;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;
import de.spieleck.app.ngramj.Categorizer;
import de.spieleck.app.ngramj.EntryProfile;
import de.spieleck.app.ngramj.Profile;
import de.spieleck.app.ngramj.lm.CategorizerImpl;
public class Codelet {
public Codelet() {
super();
}
public static void main(final String[] args) throws IOException {
Codelet me = new Codelet();
me.execute01();
me.execute02();
me.execute03();
me.execute04();
}
protected void execute01() throws IOException {
String target = "竹やぶに竹立てかけた。";
InputStream is = new ByteArrayInputStream(target
.getBytes("Shift_JIS"));
Profile profile = this.match(is);
Logger.global.info("" + target + " -> " + profile);
}
protected void execute02() throws IOException {
String target = "竹やぶに竹立てかけた。";
InputStream is = new ByteArrayInputStream(target
.getBytes("EUC-JP"));
Profile profile = this.match(is);
Logger.global.info("" + target + " -> " + profile);
}
protected void execute03() throws IOException {
String target = "竹やぶに竹立てかけた。";
InputStream is = new ByteArrayInputStream(target
.getBytes("UTF-8"));
Profile profile = this.match(is);
Logger.global.info("" + target + " -> " + profile);
}
protected void execute04() throws IOException {
String target = "This is a pen. Who cares?";
InputStream is = new ByteArrayInputStream(target
.getBytes("ISO-8859-1"));
Profile profile = this.match(is);
Logger.global.info("" + target + " -> " + profile);
}
protected Profile match(final InputStream is) throws IOException {
Categorizer categorizer = new CategorizerImpl();
EntryProfile entryProfile = new EntryProfile(is);
Profile profile = categorizer.match(entryProfile);
return profile;
}
}
実行結果
日本語の UTF-8 は判別できなかった。調べてみると標準で用意されている日本語プロファイルは Shift_JIS と EUC-JP だけだった。 Shift_JIS、EUC-JP 以外の文字エンコーディングを使用する場合は、自分でプロファイルを作成する必要がある。
2006/04/03 2:05:59 jp.in_vitro.codelets.ngramj.Codelet execute01 情報: 竹やぶに竹立てかけた。 -> japanese-shift_jis.lm 2006/04/03 2:05:59 jp.in_vitro.codelets.ngramj.Codelet execute02 情報: 竹やぶに竹立てかけた。 -> japanese-euc_jp.lm 2006/04/03 2:06:00 jp.in_vitro.codelets.ngramj.Codelet execute03 情報: 竹やぶに竹立てかけた。 -> armenian.lm 2006/04/03 2:06:00 jp.in_vitro.codelets.ngramj.Codelet execute04 情報: This is a pen. Who cares? -> english.lm
標準提供されるプロファイル
今回使用したバージョンでは下記のプロファイルが添付されていた。 実際に使用するのであれば、日本語関連で文字エンコーディングをいくつか追加する必要がありそう。
afrikaans.lm albanian.lm amharic-utf.lm arabic-iso8859_6.lm arabic-windows1256.lm armenian.lm basque.lm belarus-windows1251.lm bosnian.lm breton.lm bulgarian-iso8859_5.lm catalan.lm chinese-big5.lm chinese-gb2312.lm croatian-ascii.lm czech-iso8859_2.lm danish.lm dutch.lm english.lm esperanto.lm estonian.lm finnish.lm french.lm frisian.lm georgian.lm german.lm greek-iso8859-7.lm hawaian.lm hebrew-iso8859_8.lm hindi.lm hungarian.lm icelandic.lm indonesian.lm irish.lm italian.lm japanese-euc_jp.lm japanese-shift_jis.lm korean.lm latin.lm latvian.lm lithuanian.lm malay.lm manx.lm marathi.lm middle_frisian.lm mingo.lm nepali.lm norwegian.lm persian.lm polish.lm portuguese.lm quechua.lm romanian.lm rumantsch.lm russian-iso8859_5.lm russian-koi8_r.lm russian-windows1251.lm sanskrit.lm scots.lm scots_gaelic.lm serbian-ascii.lm slovak-ascii.lm slovak-windows1250.lm slovenian-ascii.lm slovenian-iso8859_2.lm spanish.lm swahili.lm swedish.lm tagalog.lm tamil.lm thai.lm turkish.lm ukrainian-koi8_r.lm vietnamese.lm welsh.lm yiddish-utf.lm
Apr 02, 2006
[dotNet] .Net 関連の仕様をメモ
.Net 関連の言語使用をメモ。
- Standard ECMA-334 C# Language Specification
- http://www.ecma-international.org/publications/standards/Ecma-334.htm
- Standard ECMA-335 Common Language Infrastructure (CLI)
- http://www.ecma-international.org/publications/standards/Ecma-335.htm
- Visual Basic .NET Language Specification
- http://www.microsoft.com/downloads/details.aspx?familyid=bf32527d-187c-49fa-8c67-9e9105535550&displaylang=en
- Visual Basic .NET Code Samples: Master Set of 101 Samples
- http://www.microsoft.com/downloads/details.aspx?familyid=87951CB9-5AEB-4F46-9BF0-2B3E3664BE77&displaylang=en
Apr 01, 2006
[WebService] Yahoo!オークション API にチャレンジ
Yahoo!オークションも遂に API 公開ということで少し遊んでみた。
- Yahoo!デベロッパーネットワーク - Yahoo!オークション
- http://developer.yahoo.co.jp/auctions/
- カテゴリ情報
- http://developer.yahoo.co.jp/auctions/categorytree/V1/rest/categorytree.html
- 商品リスト
- http://developer.yahoo.co.jp/auctions/categoryleaf/V1/rest/categoryleaf.html
- 出品リスト
- http://developer.yahoo.co.jp/auctions/sellinglist/V1/rest/sellinglist.html
Yahoo!オークション API を使用したサンプルアプリケーション
Ajax を利用した Yahoo!オークション API サンプルアプリケーション。
"+" をクリックするとツリーが展開される。
リーフノードに表示される"[OPEN]"をクリックすると、出品されているアイテムの 1 ページ目を表示する。
ただそれだけ。
ちなみに、Web ブラウザは IE のみ対応。
Ajax なので当然要 JavaScript。
-
+ オークション
Mar 31, 2006
[Mustang] JapaneseImperialCalendar にチャレンジ
Mustang では遂に和暦がサポートされるらしい!!
![]()
JavaWorld 2006/05 を貰ったので何となく眺めていたら、とある記事で紹介されていた。
java.util.Calendar の実装クラスがパッケージプライベートなので API Document を眺めていても全く気付いていなかった。
Calendar の和暦サポートは Mustang でも流れたとばかり思っていた。
JavaWorld は久しぶりに開いたけれど、軽くでも毎月目を通すべきかもしれないな。
JavaWorld の記事中でも紹介されていた JapaneseImperialCalendar の紹介ページは↓
- Java SE 6 Mustang じゃじゃ馬ならし 官公庁向けでも大丈夫 - 和暦
- http://www.javainthebox.net/laboratory/JavaSE6/imperialcalendar/imperialcalendar.html
サンプルコード
package jp.in_vitro.codelets.util;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class Codelet {
private Date date = new Date(System.currentTimeMillis());
public Codelet() {
super();
}
public static void main(final String[] args) {
Codelet me = new Codelet();
me.execute00();
me.execute01();
me.execute02();
me.execute03();
}
protected void execute00() {
Locale locale = new Locale("ja", "JP");
Calendar cal = Calendar.getInstance(locale);
System.out
.println("0*************************************************************");
System.out.println("Default Locale : " + Locale.getDefault());
System.out.println("Calendar#getInstance : " + locale);
System.out.println();
System.out.println("" + cal);
DateFormat format0 = new SimpleDateFormat("GGGGyy年MMMMdd日");
System.out.println("GGGGyy年MMMMdd日 : " + format0.format(this.date));
DateFormat format1 = new SimpleDateFormat("GGGyy年MMMMdd日");
System.out.println("GGGyy年MMMMdd日 : " + format1.format(this.date));
DateFormat format2 = new SimpleDateFormat("GGGyy/MM/dd");
System.out.println("GGGGyy/MM/dd : " + format2.format(this.date));
DateFormat format3 = new SimpleDateFormat("GGGyy/MM/dd");
System.out.println("GGGyy/MM/dd : " + format3.format(this.date));
System.out.println();
}
protected void execute01() {
Locale locale = new Locale("ja", "JP", "JP");
Calendar cal = Calendar.getInstance(locale);
System.out
.println("1*************************************************************");
System.out.println("Default Locale : " + Locale.getDefault());
System.out.println("Calendar#getInstance : " + locale);
System.out.println();
System.out.println("" + cal);
DateFormat format0 = new SimpleDateFormat("GGGGyy年MMMMdd日");
System.out.println("GGGGyy年MMMMdd日 : " + format0.format(this.date));
DateFormat format1 = new SimpleDateFormat("GGGyy年MMMMdd日");
System.out.println("GGGyy年MMMMdd日 : " + format1.format(this.date));
DateFormat format2 = new SimpleDateFormat("GGGyy/MM/dd");
System.out.println("GGGGyy/MM/dd : " + format2.format(this.date));
DateFormat format3 = new SimpleDateFormat("GGGyy/MM/dd");
System.out.println("GGGyy/MM/dd : " + format3.format(this.date));
System.out.println();
}
protected void execute02() {
Locale.setDefault(new Locale("ja", "JP"));
Calendar cal = Calendar.getInstance();
System.out
.println("2*************************************************************");
System.out.println("Default Locale : " + Locale.getDefault());
System.out.println("Calendar#getInstance : null");
System.out.println();
System.out.println("" + cal);
DateFormat format0 = new SimpleDateFormat("GGGGyy年MMMMdd日");
System.out.println("GGGGyy年MMMMdd日 : " + format0.format(this.date));
DateFormat format1 = new SimpleDateFormat("GGGyy年MMMMdd日");
System.out.println("GGGyy年MMMMdd日 : " + format1.format(this.date));
DateFormat format2 = new SimpleDateFormat("GGGyy/MM/dd");
System.out.println("GGGGyy/MM/dd : " + format2.format(this.date));
DateFormat format3 = new SimpleDateFormat("GGGyy/MM/dd");
System.out.println("GGGyy/MM/dd : " + format3.format(this.date));
System.out.println();
}
protected void execute03() {
Locale.setDefault(new Locale("ja", "JP", "JP"));
Calendar cal = Calendar.getInstance();
System.out
.println("3*************************************************************");
System.out.println("Default Locale : " + Locale.getDefault());
System.out.println("Calendar#getInstance : null");
System.out.println();
System.out.println("" + cal);
DateFormat format0 = new SimpleDateFormat("GGGGyy年MMMMdd日");
System.out.println("GGGGyy年MMMMdd日 : " + format0.format(this.date));
DateFormat format1 = new SimpleDateFormat("GGGyy年MMMMdd日");
System.out.println("GGGyy年MMMMdd日 : " + format1.format(this.date));
DateFormat format2 = new SimpleDateFormat("GGGGyy/MM/dd");
System.out.println("GGGGyy/MM/dd : " + format2.format(this.date));
DateFormat format3 = new SimpleDateFormat("GGGyy/MM/dd");
System.out.println("GGGyy/MM/dd : " + format3.format(this.date));
System.out.println();
}
}
実行結果
0, 2, 3 の結果は理解できる。 1 は何故こうなるのだろう?? バグなのか仕様なのか・・・。 Mustang が正式にリリースされたら試してみるか。
0************************************************************* Default Locale : ja_JP Calendar#getInstance : ja_JP java.util.GregorianCalendar[time=1143914626604,areFieldsSet=true,areAllFieldsSet =true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Tokyo",offset=324000 00,dstSavings=0,useDaylight=false,transitions=10,lastRule=null],firstDayOfWeek=1 ,minimalDaysInFirstWeek=1,ERA=1,YEAR=2006,MONTH=3,WEEK_OF_YEAR=14,WEEK_OF_MONTH= 2,DAY_OF_MONTH=2,DAY_OF_YEAR=92,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOU R=3,HOUR_OF_DAY=3,MINUTE=3,SECOND=46,MILLISECOND=604,ZONE_OFFSET=32400000,DST_OF FSET=0] GGGGyy年MMMMdd日 : 西暦06年4月02日 GGGyy年MMMMdd日 : 西暦06年4月02日 GGGGyy/MM/dd : 西暦06/04/02 GGGyy/MM/dd : 西暦06/04/02 1************************************************************* Default Locale : ja_JP Calendar#getInstance : ja_JP_JP java.util.JapaneseImperialCalendar[time=1143914626664,areFieldsSet=true,areAllFi eldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Tokyo",offset =32400000,dstSavings=0,useDaylight=false,transitions=10,lastRule=null],firstDayO fWeek=1,minimalDaysInFirstWeek=1,ERA=4,YEAR=18,MONTH=3,WEEK_OF_YEAR=14,WEEK_OF_M ONTH=2,DAY_OF_MONTH=2,DAY_OF_YEAR=92,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=1,AM_PM= 0,HOUR=3,HOUR_OF_DAY=3,MINUTE=3,SECOND=46,MILLISECOND=664,ZONE_OFFSET=32400000,D ST_OFFSET=0] GGGGyy年MMMMdd日 : 西暦06年4月02日 GGGyy年MMMMdd日 : 西暦06年4月02日 GGGGyy/MM/dd : 西暦06/04/02 GGGyy/MM/dd : 西暦06/04/02 2************************************************************* Default Locale : ja_JP Calendar#getInstance : null java.util.GregorianCalendar[time=1143914626664,areFieldsSet=true,areAllFieldsSet =true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Tokyo",offset=324000 00,dstSavings=0,useDaylight=false,transitions=10,lastRule=null],firstDayOfWeek=1 ,minimalDaysInFirstWeek=1,ERA=1,YEAR=2006,MONTH=3,WEEK_OF_YEAR=14,WEEK_OF_MONTH= 2,DAY_OF_MONTH=2,DAY_OF_YEAR=92,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOU R=3,HOUR_OF_DAY=3,MINUTE=3,SECOND=46,MILLISECOND=664,ZONE_OFFSET=32400000,DST_OF FSET=0] GGGGyy年MMMMdd日 : 西暦06年4月02日 GGGyy年MMMMdd日 : 西暦06年4月02日 GGGGyy/MM/dd : 西暦06/04/02 GGGyy/MM/dd : 西暦06/04/02 3************************************************************* Default Locale : ja_JP_JP Calendar#getInstance : null java.util.JapaneseImperialCalendar[time=1143914626664,areFieldsSet=true,areAllFi eldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Tokyo",offset =32400000,dstSavings=0,useDaylight=false,transitions=10,lastRule=null],firstDayO fWeek=1,minimalDaysInFirstWeek=1,ERA=4,YEAR=18,MONTH=3,WEEK_OF_YEAR=14,WEEK_OF_M ONTH=2,DAY_OF_MONTH=2,DAY_OF_YEAR=92,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=1,AM_PM= 0,HOUR=3,HOUR_OF_DAY=3,MINUTE=3,SECOND=46,MILLISECOND=664,ZONE_OFFSET=32400000,D ST_OFFSET=0] GGGGyy年MMMMdd日 : 平成18年4月02日 GGGyy年MMMMdd日 : H18年4月02日 GGGGyy/MM/dd : 平成18/04/02 GGGyy/MM/dd : H18/04/02
Mar 30, 2006
[Maven] Maven2 の Report 用プラグイン一覧
Maven2 が提供している Report 用プラグインをリストアップしてみた。
- checkstyle
- http://maven.apache.org/plugins/maven-checkstyle-plugin
- clover
- http://maven.apache.org/plugins/maven-clover-plugin
- PMD
- http://maven.apache.org/plugins/maven-pmd-plugin
- project-info-reports
- http://maven.apache.org/plugins/maven-project-info-reports-plugin
- changes
- http://mojo.codehaus.org/changes-maven-plugin
- jdepend
- http://mojo.codehaus.org/jdepend-maven-plugin
- surefire-report
- http://mojo.codehaus.org/surefire-report-maven-plugin
Mar 29, 2006
[Maven] Maven2 で API Document を生成する方法
Maven2 では maven-javadoc-plugin というプラグインが提供されており、このプラグインを使用することで簡単に API Document を生成できる。 但し、デフォルトの設定ではお約束のように 2 バイト文字が文字化けするので、多少設定が必要。
maven-javadoc-plugin の設定方法
<pom>
<organization>
<name>in-vitro.jp</name> ←改行コードが入るとエラー
<url>http://www.in-vitro.jp/</url>
</organization>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<charset>Shift_JIS</charset>
</configuration>
</plugin>
</plugins>
</reporting>
</pom>
maven-javadoc-plugin の実行方法
JDK と Maven2 にパスを通したコンソールから、下記のコマンドを実行する。 生成された API Document は target/site に出力される。
> mvn site
Mar 27, 2006
[Misc] Named Capture メモ
最速インターフェース研究会さんのNamedCapture for JavaScriptでNamed Captureというものを知った。 日本語では「名前付きキャプチャ」と言うらしい。 Named Capture は正規表現の Syntax で、(?P<name>regexp) と言うように名前を指定することで今までマッチした順序を数値で指定していたところが名前でアクセスできるようになるらしい。 細かい改良だけれど、意外と便利そう。
- .NET での正規表現の使用
- http://japan.internet.com/developer/20050822/28.html
- グループ化構成体
- http://msdn.microsoft.com/library/ja/cpgenref/html/cpcongroupingconstructs.asp?frame=true
- Named Capture Groups
- http://regular-expressions.info/named.html
The regular expression classes of the .NET framework also support named capture. Unfortunately, the Microsoft developers decided to invent their own syntax, rather than follow the one pioneered by Python.
Python で Named Capture にチャレンジ
$ python
Python 1.5.2 (#1, Jan 31 2003, 11:01:49) [GCC 2.96 20000731 (Red Hat Linux 7.2 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import re
>>> search = re.compile("(?P[a-zA-Z]+)")
>>> line = "123abc456"
>>> result = search.search(line)
>>> print result.group('alphabet')
abc
>>> print result.group(0)
abc
>>>
Mar 26, 2006
[Library] MockObjects
MockObjects とは
MockObjects は、Javaのテスト用ライブラリで様々なモックの詰め合わせ。 単体テストを真面目に行おうとすると、とかくモックだの何だのが必要になるのでこれがあると便利。 類似のライブラリには SpringFramework の Package org.springframework.mock.web や Package org.springframework.mock.jndi がある。
- MockObjects
-
http://www.mockobjects.com/FrontPage.html
http://www.mockobjects.com/ (2007.05.23 変更) - API Document
- http://mockobjects.sourceforge.net/javadoc/1.4/
- Using Mock Objects in Java
- http://javaboutique.internet.com/tutorials/mock_objects/
- MockObjects ってなに?
- http://genjo9.lit.let.hokudai.ac.jp/keita/read.cgi?MockObjects
MockObjects が提供するモック
-
com.mockobjects.beans
- MockPropertyChangeListener
-
com.mockobjects.io
- MockFile
- MockFileInputStream
- MockIOFactory
- MockOutputStream
- MockPrintStream
- MockPrintWriter
- MockWriter
-
com.mockobjects.jms
- MockConnection
- MockMapMessage
- MockMessage
- MockMessageConsumer
- MockMessageProducer
- MockMessagePublisher
- MockObjectMessage
- MockQueue
- MockQueueConnection
- MockQueueConnectionFactory
- MockQueueReceiver
- MockQueueSender
- MockQueueSession
- MockSession
- MockTemporaryQueue
- MockTextMessage
- MockTopic
- MockTopicConnection
- MockTopicConnectionFactory
- MockTopicPublisher
- MockTopicSession
- MockTopicSubscriber
-
com.mockobjects.mail
- MockMessage
- MockService
- MockSession
- MockTransport
-
com.mockobjects.mail.internet
- MockMimeMessage
- MockMimeMessageFactory
-
com.mockobjects.naming
- MockContext
-
com.mockobjects.naming.directory
- MockAttribute
- MockAttributes
- MockDirContext
- MockNamingEnumeration
-
com.mockobjects.net
- MockSocket
- MockSocketFactory
-
com.mockobjects.rmi
- MockNaming
-
com.mockobjects.servlet
- MockBodyContent
- MockFilterChain
- MockFilterConfig
- MockHttpServletRequest
- MockHttpServletResponse
- MockHttpSession
- MockJspWriter
- MockPageContext
- MockRequestDispatcher
- MockServletConfig
- MockServletContext
- MockServletInputStream
- MockServletOutputStream
-
com.mockobjects.sql
- MockArray
- MockConnection
- MockConnection2
- MockDatabaseMetaData
- MockDataSource
- MockDriver
- MockMultiRowResultSet
- MockPreparedStatement
- MockResultSetMetaData
- MockSingleRowResultSet
- MockStatement


![[adcan01]](/blog/entries/Misc/20060912_01/adcan01.jpg)
![[adcan02]](/blog/entries/Misc/20060912_01/adcan02.jpg)
![[adcan03]](/blog/entries/Misc/20060912_01/adcan03.jpg)
![[adcan04]](/blog/entries/Misc/20060912_01/adcan04.jpg)
![[Server Server 実行に関係するクラス]](/blog/entries/AS/20060429_01/jboss_invocation_01.png)
![[Server Server 実行時のシーケンス]](/blog/entries/AS/20060429_01/jboss_invocation_02.png)
![[Server 初期化に関係するクラス]](/blog/entries/AS/20060427_01/jboss_initserver_01.png)
![[Server 初期化時のシーケンス]](/blog/entries/AS/20060427_01/jboss_initserver_02.png)
![[起動時処理に関係するクラス]](/blog/entries/AS/20060426_01/jboss_boot_01.png)
![[起動時のシーケンス]](/blog/entries/AS/20060426_01/jboss_boot_02.png)
![[Process Designer 01]](/blog/entries/Library/20060418_01/gpd_01.png)
![[Process Designer 02]](/blog/entries/Library/20060418_01/gpd_02.png)
![[Process Designer 03]](/blog/entries/Library/20060418_01/gpd_03.png)
![[Process Designer 04]](/blog/entries/Library/20060418_01/gpd_04.png)
![[Process Designer 05]](/blog/entries/Library/20060418_01/gpd_05.png)
![[Google Calendar 01]](/blog/entries/WebService/20060414_01/calendar_01.png)
![[Google Calendar 02]](/blog/entries/WebService/20060414_01/calendar_02.png)
![[Google Calendar 03]](/blog/entries/WebService/20060414_01/calendar_03.png)
![[Google Calendar 04]](/blog/entries/WebService/20060414_01/calendar_04.png)
![[Google Calendar 05]](/blog/entries/WebService/20060414_01/calendar_05.png)