SessionBean?とは?

サンプルプログラム

@Local, @Remote, @Stateless, @Stateful, @Singleton

@Local, @Remote

@Stateless

@Stateful

@Singleton

インジェクション

@PersistenceContext?(unitName = "warehousePU")

@PersistenceContext(unitName = "warehousePU")
private EntityManager em;

@EJB

@EJB
private FactoryService factory;

他の Session Bean をインジェクション

@Resource

@Resource
private SessionContext context;

セッションコンテキストをインジェクション

PrincipalSessionContext?#getCallerPrincipal?()呼び出しユーザを得る
booleanSessionContext?#getRollbackOnly?()ロールバックされたか?
TimerService?SessionContext?#getTimerService?()タイマサービスを得る
UserTransaction?SessionContext?#getUserTransaction?()ユーザトランザクションを得る
booleanSessionContext?#isCallerInRole?(String roleName)呼び出しユーザは roleName か?
ObjectSessionContext?#lookup(String name)EJB管理下のオブジェクトをlookupする
voidSessionContext?#setRollbackOnly?()ロールバックする
booleanSessionContext?#wasCancelCalled?()非同期で呼び出した Session Bean の実行が cancel されたか?

非同期・タイマ

@Asynchronous

タイマ

@Stateless
public class TimerEJB {
  
  @Schedule(dayOfMonth = "1", hour = "4")
  public void task() {
    ...
  }
}

インターセプタ

@Stateless
public class SomeEJB {

  public Customer doSomething() {
    ...
  }

  public void doAnything() {
    ...
  }

  @AroundInvoke
  private Object interceptor(InvocatonContext ic) throws Exception {
    ...
    事前処理
    ...
    ic.proceeed();
    ...
    事後処理
    ...
  }
}

トランザクション

ロール


Java#Glassfish


*1 性能のチューニングが必要になったときに

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2013-04-17 (水) 23:02:45 (4020d)
Short-URL: https://at-sushi.com:443/pukiwiki/pukiwiki.php?cmd=s&k=87b865a231
ISBN10
ISBN13
9784061426061