Good-bye EJB, Hello CDI – Java EE Advent Calendar 2015

This is for the “Java EE Advent Calendar 2016” event material among Japan. Thanks for using auto translator for English. 

Java EE アドベントカレンダー2015の12月23日分です。寺田さんの記事からの続きになります。

※注: 内容がエンタープライズ開発の中核方面に寄っているので難度高かなという気がします。

今年のJavaOne 2015ではキーノート発表に日本人として超久しぶりに登壇させてもらったり去年に引き続きセッションを一枠喋ったりとなかなかのプレッシャーでしたが、なんとか無事終わりほっと一息、なんて余裕が全くないのですが、そんなことより個人的にショックなことがあったのでそれを書きます。

こういう記事が雑誌(そもそも消えてしまった)や日本語商用技術サイトに載らなくなったってのが、多分日本全体の技術力の低下&乗り遅れの証なんだろうなと思いつつ、日本語で情報発信しなくなった私も元凶の一人かもしれないですね。が、個人的に日本語で発信する意味が全くない(私はSIerでもベンダーでもない)ので、逆に来年のAdvent Calendarは多分英語で書いてる気がしています。

さよならIIOP

ショックだったのがこれ。JCPに加入しているので仕様策定の状況を見てた訳ですが、IIOPが遂にJava EE 8からオプショナル扱いになるかもしれない、という話題が急遽入ってきた訳です。で、最近使ってないからいいんじゃねパーフェクト、みたいなノリでガンガン話が進んでいくわけです。

で、Java EEを丸17年間ほぼフルで使ってる私としては、おいおいちょっと待った、と。使ってない輩が勝手に仕様を削るなよと。使ってる側の話を聞いたのかよと。とまあそんな感じをまとめて私も投稿するわけですが焼け石に水。一人で世界は変えられないのでした。

で、多分IIOP (アイアイオーピー)って何よ?とほぼ10人に9人が謎に思うと思うので改めて。ざっくり言うとIIOPはCORBA仕様の通信部分のGIOPをTCP/IP互換にしたものなんですが、それはどうでも良くて、最も重要な部分はXAに対応してるJava EE内唯一の汎用通信プロトコルなわけです。RMIとの互換性を持たせてるのでRMI-IIOP (アールエムアイ・オーバー・アイアイオーピー)という仕様になってます。WebLogicではそれを更にラップしてT3 (ティースリー)という高機能プロトコルが提供されてます

で、次にXAって何よ?の回答なんですが、JDBCにXA対応、ってのがあるのでそれで気付く人が居たら嬉しいのですが、分散トランザクションの標準プロトコル、ってのがざっくり回答でしょうか。要は、複数のシステムに跨がってACIDトランザクションを制御できるってものです(ACIDはぐぐってね)。複数システムで処理する内容があったとして、どこかでエラーが起きたら複数台丸ごとロールバックできるという素敵仕様です。金融系処理には欠かせない処理、と言えばなんとなく想像付くでしょうか。お金情報が壊れたら嫌ですよね。ある日突然増えてたりとか減ってたりとか。

このXAはTuxedoや日立のOpenTP1などで1990年代後半に一世を風靡するのですが、まあそれをWebLogicがサポートして、J2EE 1.2の標準仕様に盛り込まれ、金融系システムに2000年代前半に広まっていくというサクセスストーリーな訳です。私もだいぶお手伝いさせて頂きました。

で、IIOPをオプショナルにするとなると、アプリケーションサーバーとしては標準としてサポートしなくても良くなるわけで、三大Java EE商用アプリケーションサーバーであるWebLogic, WebSphere, JBossのどれかが将来にサポートを外してくる恐れがあるわけですね。こいつぁ困った。ということでJavaOneで直談判に行ってきました。

さよならEJB

でまあいろんな偉い人とディスカッションしていくわけですが(仔細は割愛。言えないこととかも沢山出てきた気がするので)、そこで追加で分かったのは、やっぱりEJBも将来無くなりそう、ということでした。あーやっぱり・・・時代はCDIなのです。

個人的にはEJBこそがJ2EE–>Java EEの華であり中核であり、WebLogic 3.0からEJBを使ってきた身からすると大変寂しい話ではあります。が、やはりEJBは機能がてんこもり過ぎて、必用な分だけ能動的に選択できるCDIは時代の要請でもあります。

で、Java EE 7のCDI仕様を見ると、EJBでサポートされてるけどCDIでサポートされてない機能がまあ沢山あります。どこからEJBでどこからCDIかさっぱり分からんというところもありますが、両方で使えるもの、という意味だとざっと考えて・・・

  • 既にサポートされてるもの(両方で使える)
    • 自動トランザクション制御 (@Transactional)
    • SOAP通信 (@WebServices)
    • REST通信 (@GET, @PUT)
    • JPA系制御
  • まだサポートされてないもの(EJBでしか使えない)
    • インスタンスプーリング
    • セキュリティー制御
    • 呼出のJNDI登録・参照
    • Message-Driven Bean (みたいなJMSサーバー側簡易機能)
    • Singleton Bean (みたいなSingletonパターン機能)
    • EJB Timer (みたいな時間制御)
    • IIOP通信 (EJB Remote) + XA制御 (with IIOP)

※Entity Beanは?とか聞かないで下さいね・・・もう無いです

と見ていくと、「まだサポートされてない」ものの中で落とされていくものがなんとなく色分けされていきます。どれが落とされるか分かりませんけど、少なくともIIOP+XAは当確な感じになって参りました。あーあ。

でまあ、そんなに後ろ向きだと生きるのが辛くなるし代替技術も無いので、しゃーないですなと気持ちを切り替え、XA使わないアーキテクチャーに変えていけばいいんじゃね?という方向にシフトしていく訳です。そもそもXAは完璧ではない(in-doubt windowとかあるし)ので、この方向もアリはアリです。

但し、現在動いているシステム群は一体どうするのよ?という疑問も当然あります。Webスタートアップ系の単一システムならまだしも、例えば金融系はアホみたいにシステムがある(数百から数千規模)のが普通なので、それをひとつにしていくというのも何となく無謀な感じもします。書いてると絶望感しか沸いてこない・・・で、唯一の方策というのは、製品利用企業が正しく声を上げてベンダーにIIOPをサポートさせ続けるということでしょう。プレッシャーかけていきましょう。

こんにちはCDI

さて、悩み深いリアル金融系システムはさておき、大半の利用側はCDIバンザイな気がします。配備時に実装クラスを自動生成&コンパイルして動作するEJBに対して、単純に機能がインジェクトされて動作するCDIの方が、エラー発生時も分かりやすいですし、何せテストがやりやすい。

あとは現在EJBから移行されてない機能が恐らくJava EE 8〜9で追加されていくはずなので、それを待てばEJBがこの世から消える算段ができ、初学者はCDIだけ勉強すればあとはJSFもJPAもOKな幸せな世界になると思います。そう考えてCDIに仕様を移してきているので当然です。

CDIそのものの説明は既に大量にあるので省きますが、EJB特にSession BeanからCDIに移行するために何が必用か、というところだけ補足しておきます。

Session BeanからCDIへの移行はアノテーションの一括置換で概ね行けます。ざっくりとこんな感じと考えればいいでしょうか。

EJB Session Bean CDI
Class宣言箇所 @Stateless @Named
@Dependent
@Transactional
EJB呼出し箇所 @EJB @Inject

他を言い出すとあれやこれやありますし、EJB Remoteどうすんの(=移行先が無いので削ってアーキテクチャー変更)とか沢山有りますけど、こんな感じでの基本移行パターンを考えておく必要があるかと思います。

さてそろそろ長くなってきたので結論ですが、次の世代のEJB (特にSession Bean)は以下の書き方になっていくことでしょう。ただ、現在のJava EE 7だと機能が足りなさすぎる気もするので、ご自身のソフトウェア特性に応じて使いこなしましょう。ツールに踊らされるのは本末転倒です。

@Named
@Dependent
@Transactional
@Path
public class AnBusinessLogic {

    @Inject
    private NextBusinessLogic theLogic;

    @Inject
    private ThirdBusinessLogic thirdLogic;

    @POST
    @Consumes("application/json")
    @Produces("application/json")
    public AnReturnValue theMethod(AnParam param) throws BusinessException {
        // Check param values.
        AnReturnValue result = new AnReturnValue();

        // Call other logics to operate.
        result.theResult = this.theLogic.businessMethod(param);

        result.thirdResult = this.thirdLogic.otherBusinessMethod(param);

        return result;
    }

    ....
}

明日12/24の回はhondaYoshitakaさんの番です。Merry christmas and a happy new year!

Welcome Rakuten Technology Conference 2015 (Fukuoka Location)

New seats where added and tickets registration is available. Please, register as soon as possible before is too late. 

ご盛況により当初想定よりお申し込みが多くなっていました。
新たに増席し、現在、申し込みが可能となっています。
ご興味がある方は、ぜひお早めにお申し込みください!

We are very proud to inform that this year Fukuoka Technology Conference has a lot of interesting presentations about the current trend on e-business from Rakuten Ichiba, Rakuten Travel and Rakuten Card in Fukuoka.

If you want to hear how our business are implementing the current technology, come to see our conference. We will be very happy in explain our services.

Also, come to talk with our employees in our Happy Hour. This is a place that you can enjoy food & drinks and talk with us. Please, feel free to have a nice conversation with us.

今年も福岡でやります!! 楽天テクノロジーカンファレンス2015です。

今年は、楽天市場、楽天トラベル、楽天カードなど、実際にドライブ中の最新トレンドについて、(東京からのサテライト込み込みですが) 福岡からも発信します! Web技術を中心として、主にJava EEやエンタープライズ系開発について、結構ディープにやっちゃいます。

また軽食・お飲物提供タイムも用意しました。現場で開発している社員も参加します。色々聞いてみて下さい。お気軽にご参加下さいませ。

2015110213312220151102133131

presentationBDF7C1B4-0509-407E-B8D0-5B9D49623535.jpg

FukuokaRTC

Date / 日時

Nov. 21st, 2015, Start 10:00

2015年11月21日(土)10:00〜:受付開始

Place/ 開催場所

Fukuoka Center Building 12F,
2-2-1 Hakataekimae, Hakata-ku, Fukuoka City,
Fukuoka, Japan

福岡県福岡市博多区博多駅前2丁目2番1号
福岡センタービル12F

http://tech.rakuten.co.jp/access.html#access-fukuoka

Registration / お申込み

https://www.eventbrite.com/e/rakuten-technology-conference-2015-tickets-18950765249

Procedure / お申込み手順

1. Push “REGISTER” button. / みどり色の「REGISTER」ボタンを押して・・・
2. Apply from “(Satellites) Fukuoka”. /「(Satellites) Fukuoka 福岡サテライト」からどうぞ!

20151102145410

 

Time Table /タイムテーブル

Time Location A
(Conference)
Location B
(Cafeteria)
11:00 Java EE Applications for Transaction Services by Kota Fujita [Track A]
Talk by Yutaka Matsuo by Yutaka Matsuo
12:00 [Track A]
Fun Research in Computer Vision : from robots, sports, face to medicine by Takeo Kanade
Lunch
13:00 [Track A]
Keynote by CEO by Hiroshi Mikitani
[Track A]
Keynote by CEO by Hiroshi Mikitani
14:00 Better working framework for smart device service by Shimizu Yosuke [Track B]
Rakuten Ichiba by Yoshihisa Onoue
15:00 About JavaEE and DevOPS by Nakada Hiroaki [Track E]
Rakuten Travel by Kazuhisa Naoi and Shinoda Takeshi
16:00 [Track B]
Rakuten Card by Hirofumi Iwasaki and Ameen Arshal
[Track B]
Rakuten Card by Hirofumi Iwasaki and Ameen Arshal
17:00 Closing
17:30 Lightning Talk & Happy Hour

 

Sessions in Fukuoka / 発表内容(福岡)

 

Java EE Applications for Transaction Services by Kota Fujita.

11:00〜    at Location A (Conference) in Fukuoka

Today’s e-businesses are changing very fast introducing new standards and new technologies every year. This session will explain why we selected Java EE as our platform and How we are implementing it to allow agile and safe transaction system.

 

Better working framework for smart device service by Yosuke Shimizu.

14:00〜    at Location A (Conference) in Fukuoka

We believe that promoting excellent synergy between business, development and operation; creating a working environment that support each area demands; and building multinational team; It is possible to have rapid and reliable development contributing for better user satisfaction and more revenue. Some of key concepts is to have 100% in house development on both the Client and Server side and to have high qualified engineers capable to do planning, development and operation. As a result, we could optimize our working framework providing better products with high quality and very good customer satisfaction.

 

About JavaEE and DevOPS by Hiroaki Nakada.

15:00〜    at Location A (Conference) in Fukuoka

Our system is continuing to grow and introducing new technologies is becoming our normal operation flow. This session will explain over view of our development and operation.

 

 

お申込みは、こちらから!

https://www.eventbrite.com/e/rakuten-technology-conference-2015-tickets-18950765249

My JavaOne 2015 Session “Real-World Batch Processing with Java EE” CON3339

Thanks for joining our session with @aforarshal in great 20th anniversary of Java on JavaOne 2015. Fortunately we had many attendees in big hall in Parc55, with many feedbacks and Q&A times there. Also the session room had TV streaming and recoding system, now we can see whole session scene on YouTube as above.

The session slides are also available from SlideShare here.

I was very pleased to see the strong passions of every engineer for Java EE technologies same level as the beginning of the J2EE 16 years ago there. Each technology details were already changed but the core policies were not changed from the beginning. I want to say it’s a great forecast in late 1999, and still moving forward to our future.

The session is going to replay in next Rakuten Tech Conference 2015 in Tokyo, Japan on Nov 21, 2015, more deeply.

Thanks for watching our JavaOne 2015 keynote speech

12049188_909422705793504_3388694351395045916_n

Thanks for watching today’s JavaOne 2015 keynote speech in Moscone North hall with Arshal. This was a secret project among very small team, and satisfied with the great achievement to us, for sharing our proactive working status in Fukuoka, Japan.

JavaOne 2015 Keynote Speech Full Length (see from about 1:25:00)

Fortunately the JavaOne was just started from today, I’m going to enjoy our own session on Wednesday Oct 28, 11:30 AM, as below.

Real-World Batch Processing with Java EE [CON3339]

Fortunately some sessions or keynotes are broadcasting online freely, so stay tuned to the greatest conference of programming language in the world. Happy 20th anniversary Java!

My JavaOne 2015 Session: CON3339

Screen Shot 2015-09-26 at 10.50.10 AM

Happy programming weekend! I’m going to have a speaking session in JavaOne 2015 on Oct 28, 11:30 AM, with my colleague Arshal as below. See you on SF.

Real-World Batch Processing with Java EE [CON3339]

Arshal Ameen, Team Manager, Rakuten, Inc.
Hirofumi Iwasaki, Group Manager, Rakuten, Inc.

Batch processing plays a key role in most organizations, mainly because it doesn’t need much human intervention. This session explores various ways in which batch processing can implemented with Java EE. It includes SWOT analysis of batch implementation with JSR 352 and embedded EJB containers. By the end of the session, the attendees should be able to understand when to use JSR 352 and when not to, the benefits of using an embedded EJB container for batch processing, and the best practices to follow when designing batch processes.

Conference Session
Wednesday, Oct 28, 11:30 a.m. | Parc 55—Cyril Magnin II/III

Dragon Slayer II Xanadu 30th Anniversary

CGNoasEWQAAbfpM

This picture is with “Xanadu Bible”, the 30th fan book, with five different versions of Xanadu. I believe I have three additional versions including PC-9801, PC-8801mkIISR (earliest version), and MSX2 version, but cannot find at that time.

I love the Japanese 8-bit computer games, especially with Dragon Slayer series of Falcom.

Genius Mr. Kiya Yoshio and some special members were build 8 Dragon Slayer series in Falcom, and I believe the second released “Dragon Slayer II Xanadu” (1985) was the best Japanese computer game I’ve ever played so far.

When the Xanadu released, I was a elementary school so cannot played due to no 8-bit computers.

My first playing of Xanadu was high school student. When I purchased 16-bit computer PC-9801RX, firstly I ordered Xanadu PC-9801 version to Falcom directly by telephone, because there’s no packages in local computer shop. Already 5 years passed since the release, and the latest Dragon Slayer was V “Sorcerian” at that time.

Unfortunately the PC-9801 ported version only supported BEEP sounds and I was so disappointed due to the poor environment (but 16-bit! unbelievable…).

After that, I got 8-bit computers X1F and PC-8801mkIISR from my friend, and played Xanadu in each version. So surprised the qualities and difference of musics. X1 version was the first release with PSG sound, and PC-8801mkIISR version was with FM with PSG sounds.

Xanadu was the excellent game systems as a RPG-styled but almost puzzle game (Almost all Dragon Slayer series is the RPG-styled puzzle game I believe).

Each monster was limited amount in the world, so player must construct the route for killing last dragon. The route for ending is almost infinite, and each offense item, defense item, magic, and  item has experience points for its effects.

Due to the great rule of the game, there’s many fans in Japan. And this year is the 30th anniversary. And here’s the fan book of it, written by and . This book covers tons of information for it, including version differences, developer’s interviews, and many trivia. Great information I’ve ever read. Masterpiece of Xanadu.

http://xanadu30th.blog.fc2.com/

You could purchase from this site, but unfortunately sold out. Keep waiting next announcement if you want to get it.

http://www.toranoana.jp/mailorder/article/04/0030/30/63/040030306372.html

If you have any interest for playing Xanadu in  your Windows, you can purchase porting version from EGG here (this based on PC-8801mkIISR version, with rich FM music. Best version of all).

http://bit.ly/1QhkJ9X

I have original versions and sometimes playing with my PC-8801 and X1turboZ real 8-bit machine. I believe no emulation environment is the best way to play.

Now I’m trying to take movies for playing. Here’s a test taking with Dragon Slayer (I) with real PC-8801MA2. I’m going to take Xanadu with it soon.

https://t.co/LRchVt09WQ

Repairing Apple 5.25″ Drive (A9M0107) for Apple IIGS

Arrived the Apple 5.25 inch Floppy Drive for Apple IIGS (A9M0107) from US (almost spent one month!). The seller said it tested working. Great!

But unofrtunately it was not worked correctly. No seek sound at the boot, with no lamp. No problem, start fixing.

IMG_6555

Open the screw just with two from the back of the disk, slide the top panel to the back. Easy opening.

IMG_6552

Next, remove a screw of the next of the FDD connector. Now you can open the FDD drive top shield. It hardly attached to the FDD drive basement, so open with thin driver with slowly and carefully.

 

IMG_6551

After removed the top shield, found the IC board of the FDD. Simple design, few electric parts.

IMG_6547

Found it. The connector to the IIGS was almost off, by unknown shocks among the transferring. Just connect again. Completed.

IMG_6548

The board was printed with old Apple computer logotype, on 1986, with “UNIDISK ANALOG #2”, but this drive is not the older “Unidisk 5.25 Drive” (A9M0104). It might shared the board from the last unidisk, or something. Unknown.

IMG_6550

The drive is ALPS electric, made in Japan. One inch height, bigger than latest general 1/2 height 5.25″ FDD for PC/AT.

IMG_6549

Close the top shield and cover, connect to the 3.5″ drive, and booted again. Works correctly. Easy repairing.

IMG_6553

Apple IIGS (ROM 01) Battery Replacement (Easy Version)

The internal battery of my new Apple IIGS (ROM 01) was dead completely, so it cannot hold some setting value like date time, screen color, slot configuration, RS232C value, and so force.

I decided to replace to newer one. This article shows how to replace the internal battery of IIGS ROM 01, with almost easiest working.

Open up the IIGS, remove power unit (just unlock with one notch in front sidem and pull out the power line), you’ll see the big battery just half size of AA.

Unfortunately the ROM 01’s battery was fixed to main board and cannot replace easily. I planned to replace with new battery holder for replacing in the future.

Here’s a picture of dead battery. Fixed with solder to mainboard.

IMG_6518

Cut out the lead line of the corner of “L” by nipper, leave the “I” line for attaching new battery holder. Don’t remove the whole lead line completely if you want to avoid hard work of solder operations (might be damaged to the main board).

IMG_6519

The completely dead 1/2 AA size battery was made on March, 1987. Vintage one. It might almost same birthday as my IIGS itself.

IMG_6523

I ordered new battry box with lead line, and new 1/2 AA battery for replacement. You can purchase them at some electric parts shop with cheaper, just 300JPY each (almost 3USD each).  You can also find them in ebay, but much higher price than parts shop.

If you live in Japan, you can find from here and here.

IMG_6514

To avoid solder operation for avoding big damage to the IIGS main board, I replace the lead line of the new battery case to another capped line as below. Just a easy work with solder. Well done.

IMG_6524

Just cap the new lead line to the left “I” line (from older battery) of the IIGS main board. Upside is plus, so place red line to here. The original place of the battery is little smaller than the battery case, so placed the new battery holder to the side of mainboard, with double-sided tape.

IMG_6525

Re-attached power unit and connect the power line to mainboard. Completed.

IMG_6526

Test power on, and set date time and screen color, and power down. After some second, power on again, and you’ll see the new setting screen color and date time already set.

IMG_6541

If not, check the lead line of the battery holder. Good luck.

My First Apple II, Apple IIGS

 

IMG_6511

Arrived my first Apple II, Apple IIGS ROM 01 version. Great 16-bit, good old Apple machine. Lovely big rainbow apple!!

I wanted to have my own Apple II for a long time, from my elementary school. But unfortunately, it was not common platform in Japana. I could not find any Apple II in my hometown.

After over 20 years, I decided to have my Apple IIgs as my first Apple II experience. Ordered and sent from the USA, but unfortunately some keytops were broken due to no aircap coverage. Oh, vintage GS Apple keyboard!

Fixed them with putty and glue, now the system works correctly on my desk. It contains GS AppleColor monitor, Apple Keyboard (made in Japan),  Apple Mouse (made in USA), and two Apple 3.5 Drives.

The internal battery was already dead so I’m going to replace it later. Post the replacement process soon. (Update: see here).

Seven Points for Applying Java EE 7 – Java Day Tokyo 2015

Last day I had a speaking session in “Java Day Tokyo 2015”. Here’s the session material for it.

This materials shows how to start your project with EE 7. There are many check points for starting the design of systems, and this describe some important points for it.

It seems that the Java EE engineers are increasing rapidly around the world, from the success of Java EE 6.

After six years passed from the EE 6 release, some Japanese company planned to update their older Struts-based older J2EE systems to the latest, with the EOL situation of them.

I wanted to say “start right now, with EE 7”, but there’s huge technical changes between J2EE-era and today. Start from here, with joyful EE programming.