EJBコンテナはjavax.ejb.SessionContextインタフェースを実装したオブジェクトをセションBeanに与えます。このSessionContextを取得するには、EJBSessionProfileのgetEJBContextメソッドを使用します。このメソッドをビジネスクラスで呼び出す例を示します。
import com.fujitsu.uji.ejb.bean.EJBSessionProfile; import javax.ejb.SessionContext; public Object search(DispatchContext context, HashMap data) { EJBSessionProfile sp = (EJBSessionProfile)context.getSessionProfile(); SessionContext sessionContext = (SessionContext)sp.getEJBContext(); }
getEJBContextメソッドの返り値の型はSessionContextのスーパーインタフェースであるEJBContextです。これをSessionContextにキャストして使用します。
EJBSessionProfileのメソッドを利用するには、DispatchContextのgetSessionProfileでセションクラスを取得し、それをEJBSessionProfileにキャストします。