---
title: "EJB3 入門文件（二）"
author: "cjc"
date: "2008-11-04T17:39:00Z"
tags: []
slug: "ejb3"
draft: false
lastmod: "2008-11-04T17:39:00Z"
id: 402851
url: "https://cjc.iteye.com/blog/402851"
---

&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 撰寫方式，接下來看一些生命週期、攔截器、Timer 等服務。

- 生命週期

來看看 Session Bean 與 Message-Driven Bean 的生命週期與回呼方法。

- - [Stateless Session Bean 生命週期](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/StatelessSessionBeanLifeCycle.html)
  - [Stateful Session Bean 生命週期](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/StatefulSessionBeanLifeCycle.html)
  - [Message-Driven Bean 生命週期](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/MessageDrivenBeanLifeCycle.html)
- 攔截器（Interceptor）

攔截器可以介入方 法呼叫前後，或是作生命週期回呼，可作一些與商務邏輯無關的額外服務。

- - [Bean 中的攔截器](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/InterceptorInBean.html)
  - [攔 截器類別](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/InterceptorClass.html)
  - [生 命週期回呼攔截器](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/LifeCycleInterceptor.html)
  - [InvocationContext](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/InvocationContext.html)
- 編寫規則

一些瑣瑣碎碎的編 寫規則。

- - [Session Bean編寫規則](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/SessionBeanCodingRule.html)
  - [Message-Driven Bean編寫規則](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/MessageDrivenBeanCodeRule.html)
  - [攔截器編寫規則](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/InterceptorCodeRule.html)
- 使用 Timer 服務

Timer 服務是由容器所提供的服務，適用於Stateless Session Bean 與 Message-Driven Bean。

- - [簡介 Timer 服務](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/TimerServiceABC.html)
  - [TimerService 與 Timer 回呼](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/TimerServiceTimer.html)
- 交易（Transaction）

看是要使用 CMT 或 BMT 都可以。。XD

- - [簡介交易](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/TransactionABC.html)
  - [簡介交易區間（Transaction Demarcation）](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/TransactionDemarcation.html)
  - [使用 CMT（Container-Managed Transaction）](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/ContainerManagedTransaction.html)
  - [使用 BMT（Bean-Managed Transaction）](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/Bean-ManagedTransaction.html)
- 安全

驗證（Authentication）交給容器，授權（Authorization）可以用宣告式（Declarative）或編程式（Programmatic）。

- - [簡介 Java EE 安全](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/JavaEESecurityABC.html)
  - [宣告式安全](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/DeclarativeSecurity.html)
  - [編程式安全](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/ProgrammaticSecurity.html)
- 例外處理
  
  - [簡介 Java EE 例外處理](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/JavaEEException.html)
  - [Java EE 例外路徑](http://caterpillar.onlyfun.net/Gossip/EJB3Gossip/JavaEEExceptionPath.html)