jp.terasoluna.fw.web.jndi
クラス DefaultJndiSupport

java.lang.Object
  上位を拡張 org.springframework.jndi.JndiAccessor
      上位を拡張 org.springframework.jndi.JndiLocatorSupport
          上位を拡張 jp.terasoluna.fw.web.jndi.DefaultJndiSupport
すべての実装されたインタフェース:
JndiSupport

public class DefaultJndiSupport
extends org.springframework.jndi.JndiLocatorSupport
implements JndiSupport

TERASOLUNAが提供するJNDI関連のユーティリティデフォルト実装クラス。

WebAPコンテナのJNDIリソースを扱うユーティリティである。
JNDIの認証情報が必要な場合は、Bean定義ファイルに必要なプロパティを 以下のように設定し、initializeメソッドを実行すること。 Bean定義ファイル経由でこのクラスのインスタンスを生成する場合は init-method属性でinitializeメソッドを指定すること。

Bean定義ファイルの設定
認証情報名
説明
factory JNDIファクトリクラス名を指定する。 weblogic.jndi.WLInitialContextFactory
url JNDIプロバイダがおかれているURIを指定する。 t3://localhost:7001
username JNDIサーバのユーザ名を指定する。 weblogic
password JNDIサーバのパスワードを指定する。 password


WebLogicのようにJNDIリソース名にプリフィックス「java:comp/env/」を付けては いけない場合、プロパティ「jndiPrefix」をfalseに設定する。
デフォルトはfalseである。

WebLogicのBean定義ファイル設定例
 <bean id="jndiSupport" scope="singleton"
       class="jp.terasoluna.fw.web.jndi.DefaultJndiSupport">
       init-method="initialize">
   <!-- セッタインジェクションで認証情報設定 -->
   <property name="jndiEnvironmentMap">
     <map>
       <entry key="factory">
         <value>weblogic.jndi.WLInitialContextFactory</value>
       </entry>
       <entry key="url">
         <value>t3://localhost:7001</value>
       </entry>
       <entry key="username">
         <value>weblogic</value>
       </entry>
       <entry key="password">
         <value>password</value>
       </entry>
     </map>
   </property>
   <!-- プロパティjndiPrefixの設定 -->
   <property name="jndiPrefix"><value>false</value></property>
 </bean>
 

TomcatのBean定義ファイル設定例
 <bean id="jndiSupport" scope="singleton"
       class="jp.terasoluna.fw.web.jndi.DefaultJndiSupport" >
<!-- プロパティjndiPrefixの設定(デフォルト値はfalse) --> <property name="jndiPrefix"><value>false</value></property> </bean>

使用方法

Bean定義ファイルにサービスロジックの設定を以下のように行う。

 <bean id="jndiLogic" scope="singleton"
   class="jp.sample.JndiLogic">
   <property name="jndiSupport">
     <ref bean="jndiSupport" />
   </property>
 </bean>
<!-- JndiSupport設定 --> <bean id="jndiSupport" scope="singleton" class="jp.terasoluna.fw.web.jndi.DefaultJndiSupport" />
サービスロジックで以下のようにDefaultJndiSupportを取得する。
 public class JndiLogic {
   private JndiSupport jndiSupport = null;

   public void setJndiSupport(jndiSupport) {
     this.jndiSupport = jndiSupport;
   }

   public Object jndiLookup(String name) {
     return jndiSupport.lookup(name);
   }
 }
 


フィールドの概要
 
クラス org.springframework.jndi.JndiLocatorSupport から継承されたフィールド
CONTAINER_PREFIX
 
クラス org.springframework.jndi.JndiAccessor から継承されたフィールド
logger
 
インタフェース jp.terasoluna.fw.web.jndi.JndiSupport から継承されたフィールド
JNDI_SUPPORT_KEY
 
コンストラクタの概要
DefaultJndiSupport()
          コンストラクタ。
 
メソッドの概要
 Map<String,String> getJndiEnvironmentMap()
          jndiEnvironmentMapを取得する。
 void initialize()
          JndiTemplateの環境設定を行う。
 boolean isJndiPrefix()
          リソース名のプリフィックスのゲッター。
 Object lookup(String name)
          指定されたオブジェクトを取得する。
 void rebind(String name, Object obj)
          名前をオブジェクトにバインドして、 既存のバインディングを上書きする。
 void setJndiEnvironmentMap(Map<String,String> jndiEnvironmentMap)
          jndiEnvironmentMapを設定する。
 void setJndiPrefix(boolean jndiPrefix)
          リソース名のプリフィックスのセッター。
 void unbind(String name)
          指定されたオブジェクトをアンバインドする。
 
クラス org.springframework.jndi.JndiLocatorSupport から継承されたメソッド
convertJndiName, isResourceRef, lookup, setResourceRef
 
クラス org.springframework.jndi.JndiAccessor から継承されたメソッド
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

DefaultJndiSupport

public DefaultJndiSupport()
コンストラクタ。

メソッドの詳細

setJndiPrefix

public void setJndiPrefix(boolean jndiPrefix)
リソース名のプリフィックスのセッター。 スーパークラスのresourceRefの値を設定する。 この属性がtrueの場合、プリフィックス"java:comp/env/"をリソース名につける。

パラメータ:
jndiPrefix - リソース名のプリフィックス付加フラグ

isJndiPrefix

public boolean isJndiPrefix()
リソース名のプリフィックスのゲッター。 スーパークラスのresourceRefの値を取得する。 この属性がtrueの場合、プリフィックス"java:comp/env/"をリソース名につける。

戻り値:
jndiPrefix リソース名のプリフィックス付加フラグ

getJndiEnvironmentMap

public Map<String,String> getJndiEnvironmentMap()
jndiEnvironmentMapを取得する。

戻り値:
JNDI認証情報を格納するMap

setJndiEnvironmentMap

public void setJndiEnvironmentMap(Map<String,String> jndiEnvironmentMap)
jndiEnvironmentMapを設定する。

パラメータ:
jndiEnvironmentMap - JNDI認証情報を格納するMap

initialize

public void initialize()
JndiTemplateの環境設定を行う。


rebind

public void rebind(String name,
                   Object obj)
名前をオブジェクトにバインドして、 既存のバインディングを上書きする。

定義:
インタフェース JndiSupport 内の rebind
パラメータ:
name - オブジェクト名
obj - バインドされるオブジェクト

unbind

public void unbind(String name)
指定されたオブジェクトをアンバインドする。

定義:
インタフェース JndiSupport 内の unbind
パラメータ:
name - オブジェクト名

lookup

public Object lookup(String name)
指定されたオブジェクトを取得する。

定義:
インタフェース JndiSupport 内の lookup
オーバーライド:
クラス org.springframework.jndi.JndiLocatorSupport 内の lookup
パラメータ:
name - オブジェクト名
戻り値:
オブジェクト


Copyright © 2011. All Rights Reserved.