org.seasar.kuina.dao.internal.builder
クラス AbstractCommandBuilder

java.lang.Object
  上位を拡張 org.seasar.kuina.dao.internal.builder.AbstractCommandBuilder
すべての実装されたインタフェース:
CommandBuilder
直系の既知のサブクラス:
AbstractQueryCommandBuilder, ContainsCommandBuilder, FindCommandBuilder, GetReferenceCommandBuilder, MergeCommandBuilder, NamedQueryUpdateCommandBuilder, PersistCommandBuilder, ReadLockCommandBuilder, RefreshCommandBuilder, RemoveCommandBuilder, SqlUpdateCommandBuilder, WriteLockCommandBuilder

public abstract class AbstractCommandBuilder
extends Object
implements CommandBuilder

コマンドを作成するビルダの抽象クラスです.

作成者:
koichik

フィールドの概要
protected  NamingConvention convention
          命名規約
protected  DaoHelper daoHelper
          Daoヘルパー
protected  EntityManagerProvider entityManagerProvider
          エンティティ・マネージャ・プロバイダ
protected  Pattern methodNamePattern
          メソッド名の正規表現パターン
 
コンストラクタの概要
AbstractCommandBuilder()
          インスタンスを構築します。
 
メソッドの概要
protected  ParameterBinder getBinderForNamedParameter(Class<?> type, String name, Annotation[] annotations)
          Named ParameterをバインドするParameterBinderを作成して返します.
protected  ParameterBinder getBinderForPositionalParameter(Class<?> type, int position, Annotation[] annotations)
          Positional ParameterをバインドするParameterBinderを作成して返します.
protected  ParameterBinder[] getBinders(Method method, BeanDesc beanDesc)
          パラメータをバインドするParameterBinderの配列を作成して返します.
protected  ParameterBinder[] getBindersForNamedParameter(Method method, String[] parameterNames)
          Named ParameterをバインドするParameterBinderの配列を作成して返します.
protected  ParameterBinder[] getBindersForPositionalParameter(Method method)
          Positional ParameterをバインドするParameterBinderの配列を作成して返します.
protected  String[] getQueryNames(Class<?> daoClass, Method method)
          Named Queryの名前の候補を配列で返します.
protected  Class<?> getTargetClass(Class<?> daoClass, Method method)
          操作対象のエンティティクラスを返します.
protected  Class<?> getTargetClassFromDaoName(Class<?> daoClass)
          Daoのクラス名から操作対象となるエンティティクラスを求めて返します.
protected  TemporalType getTemporalType(Annotation[] annotations)
          アノテーションで指定された時制を返します.
 boolean isExists(Class<?> daoClass, String queryName)
          指定された名前のNamed Queryが存在すればtrueを返します.
protected  boolean isMatched(Method method)
          テスト対象のメソッドの名前が正規表現パターンとマッチする場合にtrueを返します.
 void setMethodNamePattern(String methodNamePattern)
          メソッド名の正規表現パターンを文字列で設定します.
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
インタフェース org.seasar.kuina.dao.internal.CommandBuilder から継承されたメソッド
build
 

フィールドの詳細

convention

protected NamingConvention convention
命名規約


daoHelper

protected DaoHelper daoHelper
Daoヘルパー


entityManagerProvider

protected EntityManagerProvider entityManagerProvider
エンティティ・マネージャ・プロバイダ


methodNamePattern

protected Pattern methodNamePattern
メソッド名の正規表現パターン

コンストラクタの詳細

AbstractCommandBuilder

public AbstractCommandBuilder()
インスタンスを構築します。

メソッドの詳細

setMethodNamePattern

public void setMethodNamePattern(String methodNamePattern)
メソッド名の正規表現パターンを文字列で設定します.

パラメータ:
methodNamePattern - メソッド名の正規表現パターン文字列

isMatched

protected boolean isMatched(Method method)
テスト対象のメソッドの名前が正規表現パターンとマッチする場合にtrueを返します.

パラメータ:
method - テスト対象のメソッド
戻り値:
テスト対象のメソッドの名前が正規表現パターンとマッチする場合にtrue

getTargetClass

protected Class<?> getTargetClass(Class<?> daoClass,
                                  Method method)
操作対象のエンティティクラスを返します.

操作対象のエンティティクラスは次の順で検索します.

  1. DaoのメソッドにTargetEntityアノテーションが付けられていればそのvalue要素の値
  2. DaoクラスにTargetEntityアノテーションが付けられていればそのvalue要素の値
  3. Daoのクラス名から操作対象となるエンティティクラスを求めることができればそのクラス

操作対象となるエンティティクラスが見つからない場合はnullを返します.

パラメータ:
daoClass - Daoクラス
method - Daoのメソッド
戻り値:
操作対象のエンティティクラス

getTargetClassFromDaoName

protected Class<?> getTargetClassFromDaoName(Class<?> daoClass)
Daoのクラス名から操作対象となるエンティティクラスを求めて返します.

操作対象のエンティティは,Daoのクラス名からDaoのサフィックスを取り除いてエンティティのサフィックスを付加したものをエンティティクラスの単純名とし,
ルートパッケージ.Daoのサブパッケージ名.エンティティの単純名
という名前のクラスが見つかればそれを操作対象のエンティティクラスとして返します.

操作対象となるエンティティクラスが見つからない場合はnullを返します.

パラメータ:
daoClass - Daoクラス
戻り値:
操作対象となるエンティティクラス

getBinders

protected ParameterBinder[] getBinders(Method method,
                                       BeanDesc beanDesc)
パラメータをバインドするParameterBinderの配列を作成して返します.

パラメータ:
method - Daoのメソッド
beanDesc - DaoクラスのBeanDesc
戻り値:
パラメータをバインドするParameterBinderの配列

getBindersForNamedParameter

protected ParameterBinder[] getBindersForNamedParameter(Method method,
                                                        String[] parameterNames)
Named ParameterをバインドするParameterBinderの配列を作成して返します.

パラメータ:
method - Daoのメソッド
parameterNames - Daoメソッドの引数名の配列
戻り値:
パラメータをバインドするParameterBinderの配列

getBinderForNamedParameter

protected ParameterBinder getBinderForNamedParameter(Class<?> type,
                                                     String name,
                                                     Annotation[] annotations)
Named ParameterをバインドするParameterBinderを作成して返します.

パラメータ:
type - 引数の型
name - 引数の名前
annotations - 引数に付けられたアノテーションの配列
戻り値:
パラメータをバインドするParameterBinder

getBindersForPositionalParameter

protected ParameterBinder[] getBindersForPositionalParameter(Method method)
Positional ParameterをバインドするParameterBinderの配列を作成して返します.

パラメータ:
method - Daoのメソッド
戻り値:
パラメータをバインドするParameterBinderの配列

getBinderForPositionalParameter

protected ParameterBinder getBinderForPositionalParameter(Class<?> type,
                                                          int position,
                                                          Annotation[] annotations)
Positional ParameterをバインドするParameterBinderを作成して返します.

パラメータ:
type - 引数の型
position - 引数の位置
annotations - 引数に付けられたアノテーションの配列
戻り値:
パラメータをバインドするParameterBinder

getTemporalType

protected TemporalType getTemporalType(Annotation[] annotations)
アノテーションで指定された時制を返します.

annotationsの中にTemporalSpecアノテーションが含まれていれば, そのvalue要素の値を返します.
annotationsの中にTemporalSpecアノテーションが含まれていなければTemporalType.DATEを返します.

パラメータ:
annotations - アノテーションの配列
戻り値:
時制

getQueryNames

protected String[] getQueryNames(Class<?> daoClass,
                                 Method method)
Named Queryの名前の候補を配列で返します.

次の順でNamed Queryの候補を作成します.

  1. QueryNameアノテーションが指定されていれば,そのvalue要素で指定された名前
  2. DaoのFQN.Daoのメソッド名
  3. Daoの単純名.Daoのメソッド名
  4. 対象のエンティティを求めることができれば,エンティティ名.Daoのメソッド名

パラメータ:
daoClass - Daoクラス
method - Daoのメソッド
戻り値:
Named Queryの名前の配列

isExists

public boolean isExists(Class<?> daoClass,
                        String queryName)
指定された名前のNamed Queryが存在すればtrueを返します.

Named Queryが存在するかチェックするためにEntityManager.createNamedQuery(String)を呼び出します. Named Queryが存在しない場合,EntityManagerは例外をスローし,JPA実装によってはトランザクションを ロールバックしてしまうため,トランザクション特性をREQUIRES_NEWにしています.

パラメータ:
daoClass - Daoクラス
queryName - Named Queryの名前
戻り値:
指定された名前のNamed Queryが存在すればtrue


Copyright © 2006-2007 The Seasar Foundation. All Rights Reserved.