COBOL2002 Cosminexus連携機能ガイド
「Bean生成ツール」で,「EJB対応機能を有効にする。」にチェックしない場合の生成例です(そのほかのチェックボックスはデフォルト指定です)。
なお,Windows(x64) 03-01以降では,コメント行個所の「COBOL adapter for Cosminexus Version 2」は,「COBOL adapter for Cosminexus Version 2(64)」となります。
COBOL UAPの引数にOCCURS句がない場合の例を次に示します。
01 DATAA PIC X(10). 01 DATAB. 05 DATAB1 PIC S9(9). 05 DATAB2. 10 DATAB21 USAGE COMP-1. 10 DATAB22 PIC S9(9) USAGE COMP. 77 DATAC USAGE COMP-2.
太字は条件によって生成文字列が異なります。
また,太字の変数名はウィザードで別名を指定した場合,別名になります。
package パッケージ名;
import jp.co.hitachi_sk.j2cb.*;
public class クラス名 extends CBLAccess {
/*
*Generated by COBOL adapter for Cosminexus Version 2 02-13
*DO NOT EDIT THIS FILE
*2013/09/30
*/
//インデックスを定義
private static final long serialVersionUID = 1347585438734L;
private static final int dataaIndex=0;
private static final int databIndex=1;
private static final int datacIndex=2;
private static boolean noload=true;
private static int[] mySize=null;
private static GroupAccess[] myGroupAccess=null;
private static String[] myTypeInfo=null;
private static int myLength=0;
/**
*コンストラクタ
*/
public クラス名() throws J2CBException {
super();
init();
initialData();
//データアクセスのための情報を設定
setDllName("呼び出すライブラリ名");
setFunctionName("呼び出すプログラム名");
}
/**
*初期化処理
*/
private void init( ) throws J2CBException {
//初期ロードだけ実行する
if (noload) {
init2();
}
else {
setInformation(mySize, myGroupAccess, myTypeInfo, myLength);
}
}
/**
*初期化処理2
*/
private synchronized void init2( ) throws J2CBException {
if (noload) {
String[] typeTmp={
"C(10)",
"G,CT0900,G,F,SI0900",
"D" };
String[] sizeTmp={
"10",
"17",
"8" };
setType(typeTmp, sizeTmp);
makeGroupAccess(dataaIndex,
"01",
"dataa",
"0");
makeGroupAccess(databIndex,
"01,05,05,10,10",
"datab,datab1,datab2,datab21,datab22",
"0,0,9,9,13");
makeGroupAccess(datacIndex,
"77",
"datac",
"0");
mySize=size;
myGroupAccess=groupAccess;
myTypeInfo=typeInfo;
myLength=length;
noload=false;
}
else {
setInformation(mySize, myGroupAccess, myTypeInfo, myLength);
}
}
/**
*dataa設定メソッド
*@param data Stringオブジェクト
*/
public void setDataa( Object data) throws J2CBException {
setData(dataaIndex, "dataa", data);
}
/**
*datab1設定メソッド
*@param data BigDecimalオブジェクト
*/
public void setDatab1( Object data) throws J2CBException {
setData(databIndex, "datab.datab1", data);
}
/**
*datab21設定メソッド
*@param data Floatオブジェクト
*/
public void setDatab21( Object data) throws J2CBException {
setData(databIndex, "datab.datab2.datab21", data);
}
/**
*datab22設定メソッド
*@param data Integerオブジェクト
*/
public void setDatab22( Object data) throws J2CBException {
setData(databIndex, "datab.datab2.datab22", data);
}
/**
*datac設定メソッド
*@param data Doubleオブジェクト
*/
public void setDatac( Object data) throws J2CBException {
setData(datacIndex, "datac", data);
}
/**
*dataa取得メソッド
*@return Stringオブジェクト
*/
public Object getDataa( ) throws J2CBException {
return getData(dataaIndex, "dataa");
}
/**
*datab1取得メソッド
*@return BigDecimalオブジェクト
*/
public Object getDatab1( ) throws J2CBException {
return getData(databIndex, "datab.datab1");
}
/**
*datab21取得メソッド
*@return Floatオブジェクト
*/
public Object getDatab21( ) throws J2CBException {
return getData(databIndex, "datab.datab2.datab21");
}
/**
*datab22取得メソッド
*@return Integerオブジェクト
*/
public Object getDatab22( ) throws J2CBException {
return getData(databIndex, "datab.datab2.datab22");
}
/**
*datac取得メソッド
*@return Doubleオブジェクト
*/
public Object getDatac( ) throws J2CBException {
return getData(datacIndex, "datac");
}
}
COBOL UAPの引数にOCCURS句がある場合の例を次に示します。
01 G1. 02 G2 OCCURS 10. 03 B1 PIC X(50).
OCCURSありの基本項目参照メソッド
/**
*b1設定メソッド
*@param data Stringオブジェクト
*@param dim1 int
*/
public void setB1( Object data, int dim1) throws J2CBException {
String acsstr1="g1.g2[";
String acsstr2="].b1";
StringBuffer wkbuf;
wkbuf=new StringBuffer( acsstr1 );
wkbuf.append( dim1 );
wkbuf.append( acsstr2 );
setData( g1Index, wkbuf.toString(), data );
}
/**
*b1取得メソッド
*@param dim1 int
*@return Stringオブジェクト
*/
public Object getB1( int dim1) throws J2CBException {
String acsstr1="g1.g2[";
String acsstr2="].b1";
StringBuffer wkbuf;
wkbuf=new StringBuffer( acsstr1 );
wkbuf.append( dim1 );
wkbuf.append( acsstr2 );
return getData(g1Index, wkbuf.toString());
}
「Bean生成ツール」で,「EJB対応機能を有効にする。」にチェックした場合の例を次に示します(そのほかのチェックボックスはデフォルト指定です)。
太字は条件によって生成文字列が異なります。
なお,Windows(x64) 03-01以降では,コメント行個所の「COBOL adapter for Cosminexus Version 2」は,「COBOL adapter for Cosminexus Version 2(64)」となります。
package パッケージ名;
import jp.co.hitachi_sk.j2cb.*;
public class クラス名 extends CBLEJBAccess {
/*
*Generated by COBOL adapter for Cosminexus Version 2 02-13
*DO NOT EDIT THIS FILE
*2013/09/30
*/
//インデックスを定義
private static final long serialVersionUID = 1347585448203L;
private static final int personal_dataIndex=0;
private boolean noload=true;
private int[] mySize=null;
private GroupAccess[] myGroupAccess=null;
private String[] myTypeInfo=null;
private int myLength=0;
/**
*コンストラクタ
*/
public クラス名() throws J2CBException {
super();
init();
initialData();
//データアクセスのための情報を設定
setDllName("呼び出すライブラリ名");
setFunctionName("呼び出すプログラム名");
}
/**
*初期化処理
*/
private void init( ) throws J2CBException {
//初期ロードだけ実行する
if (noload) {
String[] typeTmp={
"G,UI0900,C(50),C(100),C(50)" };
String[] sizeTmp={
"204" };
setType(typeTmp, sizeTmp);
makeGroupAccess(personal_dataIndex,
"01,05,05,05,05",
"personal_data,p_number,p_name,p_address,p_gif",
"0,0,4,54,154");
mySize=size;
myGroupAccess=groupAccess;
myTypeInfo=typeInfo;
myLength=length;
noload=false;
}
else {
setInformation(mySize, myGroupAccess, myTypeInfo, myLength);
}
}
/**
*p_number設定メソッド
*@param data Integerオブジェクト
*/
public void setP_number( Object data) throws J2CBException {
setData(personal_dataIndex, "personal_data.p_number", data);
}
/**
*p_name設定メソッド
*@param data Stringオブジェクト
*/
public void setP_name( Object data) throws J2CBException {
setData(personal_dataIndex, "personal_data.p_name", data);
}
/**
*p_address設定メソッド
*@param data Stringオブジェクト
*/
public void setP_address( Object data) throws J2CBException {
setData(personal_dataIndex, "personal_data.p_address", data);
}
/**
*p_gif設定メソッド
*@param data Stringオブジェクト
*/
public void setP_gif( Object data) throws J2CBException {
setData(personal_dataIndex, "personal_data.p_gif", data);
}
/**
*p_number取得メソッド
*@return Integerオブジェクト
*/
public Object getP_number( ) throws J2CBException {
return getData(personal_dataIndex, "personal_data.p_number");
}
/**
*p_name取得メソッド
*@return Stringオブジェクト
*/
public Object getP_name( ) throws J2CBException {
return getData(personal_dataIndex, "personal_data.p_name");
}
/**
*p_address取得メソッド
*@return Stringオブジェクト
*/
public Object getP_address( ) throws J2CBException {
return getData(personal_dataIndex, "personal_data.p_address");
}
/**
*p_gif取得メソッド
*@return Stringオブジェクト
*/
public Object getP_gif( ) throws J2CBException {
return getData(personal_dataIndex, "personal_data.p_gif");
}
}
package パッケージ名;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface クラス名EJBHome extends EJBHome {
/*
*Generated by COBOL adapter for Cosminexus Version 2 02-13
*DO NOT EDIT THIS FILE
*2013/09/30
*/
/*
*EJBのインスタンスの作成,除去のためのホームインタフェースを定義
*/
/**
*createメソッド<BR>
*ホームインタフェースは,createメソッドを一つ以上サポートし,
*EJBean内で「ejbCreate」と呼ばれるメソッドに対応していなければ
*なりません。<BR>
*この二つのメソッドのパラメタ設定は同じです。
*/
クラス名EJB create( ) throws CreateException ,RemoteException ,Exception ;
}
package パッケージ名;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface クラス名EJB extends EJBObject {
/*
*Generated by COBOL adapter for Cosminexus Version 2 02-13
*DO NOT EDIT THIS FILE
*2013/09/30
*/
/*
*EJBのビジネスメソッドのためのリモートインタフェースを定義
*/
public int callCOBOL( ) throws RemoteException,Exception;
public void setP_number( Integer val) throws
RemoteException,Exception;
public void setP_name( String val) throws
RemoteException,Exception;
public void setP_address( String val) throws
RemoteException,Exception;
public void setP_gif( String val) throws
RemoteException,Exception;
public Integer getP_number( ) throws RemoteException,Exception;
public String getP_name( ) throws RemoteException,Exception;
public String getP_address( ) throws RemoteException,Exception;
public String getP_gif( ) throws RemoteException,Exception;
}
package パッケージ名;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import jp.co.hitachi_sk.j2cb.*;
public class クラス名EJBBean implements SessionBean {
/*
*Generated by COBOL adapter for Cosminexus Version 2 02-13
*DO NOT EDIT THIS FILE
*2013/09/30
*/
/*
*EJBのビジネスメソッドを実装する
*/
//クラスの変数
private static final long serialVersionUID = 1153786720297L;
private クラス名 gEntity=null;
/**
*COBOL呼び出し
*/
public int callCOBOL( ) throws RemoteException,Exception{
int rtn=0;
try {
rtn=gEntity.callCOBOL();
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
return rtn;
}
/**
*p_number設定メソッド
*/
public void setP_number( Integer val) throws RemoteException,Exception{
try {
gEntity.setP_number(val);
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
}
/**
*p_name設定メソッド
*/
public void setP_name( String val) throws RemoteException,Exception{
try {
gEntity.setP_name(val);
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
}
/**
*p_address設定メソッド
*/
public void setP_address( String val) throws RemoteException,Exception{
try {
gEntity.setP_address(val);
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
}
/**
*p_gif設定メソッド
*/
public void setP_gif( String val) throws RemoteException,Exception{
try {
gEntity.setP_gif(val);
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
}
/**
*p_number取得メソッド
*/
public Integer getP_number( ) throws RemoteException,Exception{
Integer rtn=null;
try {
rtn=(Integer)gEntity.getP_number();
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
return rtn;
}
/**
*p_name取得メソッド
*/
public String getP_name( ) throws RemoteException,Exception{
String rtn=null;
try {
rtn=(String)gEntity.getP_name();
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
return rtn;
}
/**
*p_address取得メソッド
*/
public String getP_address( ) throws RemoteException,Exception{
String rtn=null;
try {
rtn=(String)gEntity.getP_address();
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
return rtn;
}
/**
*p_gif取得メソッド
*/
public String getP_gif( ) throws RemoteException,Exception{
String rtn=null;
try {
rtn=(String)gEntity.getP_gif();
} catch(J2CBException wkexp) {
throw new Exception(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new RemoteException(wkmsg);
}
return rtn;
}
/**
*ejbCreate()の呼び出し
*/
public void ejbCreate( ) throws CreateException,RemoteException,Exception{
try {
gEntity=new クラス名();
} catch(J2CBException wkexp) {
throw new CreateException(wkexp.getRemoteEJBMessage());
} catch(Exception ee) {
String wkmsg=null;
wkmsg=ee.getMessage();
ee.printStackTrace();
throw new CreateException(wkmsg);
}
}
/**
*関連するセッションコンテキストの設定
*/
public void setSessionContext( SessionContext ctx) {
}
/**
*終了前処理
*/
public void ejbRemove( ) {
gEntity=null;
}
/**
*活性化メソッド
*/
public void ejbActivate( ) {
}
/**
*非活性化メソッド
*/
public void ejbPassivate( ) {
}
}
<?xml version="1.0" encoding="MS932"?>
<!--
Generated by COBOL adapter for Cosminexus Version 2 02-13
DO NOT EDIT THIS FILE
2013/09/30
-->
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<display-name>クラス名EJBBean</display-name>
<enterprise-beans>
<session>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<home>パッケージ名.クラス名EJBHome</home>
<remote>パッケージ名.クラス名EJB</remote>
<ejb-class>パッケージ名.クラス名EJBBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Home</method-intf>
<method-name>create</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>callCOBOL</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setP_number</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setP_name</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setP_address</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setP_gif</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getP_number</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getP_name</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getP_address</method-name>
</method>
<method>
<ejb-name>クラス名EJB.クラス名EJBHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getP_gif</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
All Rights Reserved. Copyright (C) 2003, 2016, Hitachi, Ltd.