---
title: "EJB3 入門文件"
author: "cjc"
date: "2008-10-16T21:56:00Z"
tags: []
slug: "ejb3"
draft: false
lastmod: "2008-10-16T21:56:00Z"
id: 402852
url: "https://cjc.iteye.com/blog/402852"
---

&lt;script&gt;function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}&lt;/script&gt;先來寫幾個簡單的範例，看看 Session Bean、Message-Driven Bean 長什麼樣子，怎麼封裝 EJB-JAR、EAR 等。

- Session Bean

在 EJB3 中寫 Session，簡單的由 Annotation 就可以設定了，並可以利用容器的資源注入來簡化程式撰寫。

- - [第 一個 Session Bean（單機客戶端）](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/FirstSessionBean.html)
  - [使 用 @EJB 注入 Bean（單機客戶端）](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/InjectEJB.html)
  - [第 一個 Session Bean（Servlet 客戶端）](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/SessionBeanServlet.html)
  - [使 用 @EJB 注入 Bean（Servlet 客戶端）](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/InjectEJBServlet.html)
  - [@Remote 與 @Local](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/RemoteLocal.html)
  - [使 用 Stateful Session Bean](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/StatefulSessionBean.html)
- Message-Driven Bean

就是受容器管理的 MessageListener，所以先了解一下 Java Message Service，再來寫個簡單的 Message-Driven Bean。

- - [訊息（Message）觀念](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/MessageConcept.html)
  - [簡介 Java Message Service](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/JavaMessageService.html)
  - [第一個 Message-Driven Bean](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/MessageDrivenBean.html)
- 封裝應用程式

雖然用 IDE 很方便，但了解一下如何自行封裝 EJB-JAR、EAR 也不錯。

- - [封裝 EJB-JAR](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/EJB-JAR.html)
  - [封裝 EAR](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/EAR.html)
  - [EAR 模組及類別載入](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/LoadEARModuleClass.html)