Copyright © Oracle Corporation, 2005. All rights reserved.
37
OC4J Standalone/J2EE & Web Cache
EJB側ローカル EJB の呼び出し (OC4J 固有 )
y EJB
の論理なJNDI
名と実際のJNDI
名のマッピングy Web
モジュール:orion-web.xml
–
EJB
モジュール:orion-ejb-jar.xml
orion-web.xml
の例<orion-web-app>
...
<ejb-ref-mapping name="ejb/EmployeeMappledBean"
location="employee/EmployeeBean" />
...
</orion-web-app>
orion-ejb-jar.xml
の例<orion-ejb-jar>
...
<ejb-ref-mapping name="ejb/EmployeeMappledBean"
location="employee/EmployeeBean" />
...
</orion-ejb-jar>
OC4J Standalone/J2EE & Web Cache
EJB側ローカル EJB の呼び出し (OC4J 固有 )
y
実際のJNDI
名の定義–
orion-ejb-jar.xml
–
ejb-jar.xml
のejb-name
属性と実際のJNDI
名のマッピングorion-ejb-jar.xml
の例<orion-ejb-jar>
...
<enterprise-beans>
<session-deployment name="EmployeeBean"
location="employee/EmployeeBean" />
</enterprise-beans>
...
</orion-ejb-jar>
Copyright © Oracle Corporation, 2005. All rights reserved.
39
OC4J Standalone/J2EE & Web Cache
EJB側ローカル EJB の呼び出し (J2EE 標準 )
y Enterprise Bean
の基本的な定義–
ejb-jar.xml
–
ejb-name
要素により、Enterprise Bean
を一意に識別ejb-jar.xml
の例<enterprise-beans>
<session>
<description>Comment</description>
<display-name>EmployeeBean</display-name>
<ejb-name>EmployeeBean</ejb-name>
<local-home>employee.EmployeeLocalHome</local-home>
<local>employee.EmployeeLocal</local>
<ejb-class>employee.EmployeeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
AP サーバ固有 API
Copyright © Oracle Corporation, 2005. All rights reserved.
41
OC4J Standalone/J2EE & Web Cache
他社 AP サーバ固有 API
y
例えば:WebLogic
固有のAPI
を利用していた場合、移行時に コードの修正が必要– 起動・停止クラス
y weblogic.common.T3StartupDef y weblogic.common.T3ShutdownDef
– ログクラス
y weblogic.loggin.NonCatalogLogger
– セキュリティクラス
y weblogic.sercurity
–
XML
関連y weblogic.apache.*
– システム情報取得
y weblogic.management.configuration.*
–
HTML
関連y weblogic.html.*
–
DB
関連y weblogic.db.*
y WebLogic
での起動・停止クラス–
WebLogic
では以下のインタフェースを実装したクラスを作成し、起動・停止クラスを開発
y weblogic.common.T3StartupDef y weblogic.common.T3ShutdownDef
import weblogic.common.T3ServicesDef;
import weblogic.common.T3StartupDef;
public class AppStartup
implements T3StartupDef, CommonDefineIf { // 起動時の処理を処理を記述
・・・
}
WebLogic
固有API
での起動クラスコード例OC4J Standalone/J2EE & Web Cache
例: WebLogic 固有 API 移行
Copyright © Oracle Corporation, 2005. All rights reserved.
43
OC4J Standalone/J2EE & Web Cache
例 1 : OC4J 固有 API への移行
y
前述のOC4J(10.1.2)
の起動・停止クラスを利用し移行可能–
OC4J
では以下のインタフェースを実装したクラスを作成し、起動・停止クラスを 開発y weblogic.common.T3StartupDef
インタフェースを実装したクラスを→
com.evermind.server.OC4JStart
インタフェースを実装したクラスに移行
y weblogic.common.T3ShutdownDef
インタフェースを実装したクラスを→
com.evermind.server.OC4JShutdown
インタフェースを実装したクラスに移行OC4J Standalone/J2EE & Web Cache
例 2 : J2EE 汎用 API の移行
y Oracle Application Server10g(10.1.2)
で、J2EE
汎用的なServletContextListener
を利用 を利用した場合Oracle Application Server10g
コード例 import javax.servlet.ServletContextListener;import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContext;
public class SampleListner implements ServletContextListener { private ServletContext context = null;
public void contextInitialized(ServletContextEvent event) { context = event.getServletContext();
System.out.println("Webアプリケーション起動時に呼び出し");
}
public void contextDestroyed(ServletContextEvent event) { context = event.getServletContext();
System.out.println("Webアプリケーション停止時に呼び出し");
} }
Copyright © Oracle Corporation, 2005. All rights reserved.
45
OC4J Standalone/J2EE & Web Cache
例 2 : J2EE 汎用 API の移行
y ServletContextListener
のweb.xml
への登録– 登録した
Web
アプリケーション起動・停止時にServletContextListener
が呼び出さ れ、結果的に起動・停止クラスと同等の振る舞いになるweb.xml
の記述例<web-app>
...
<listener>
<listener-class>sample.SampleListner</listener-class>
</listener>
...
</web-app>
OC4J Standalone/J2EE & Web Cache
例 2 : J2EE 汎用 API の移行
y OC4J
起動時にWeb
アプリケーション起動–
ORACLE_HOME/j2ee/home/config/http-web-site.xml
–
load-on-startup
属性http-web-site.xml
の記述例<web-app application=“sampapp" name=“sampapp-war“
root=“sampapp“ load-on-startup="true"/>