4.3.2 .NETインタフェース定義を使用したSPP.NETのコーディング例
- 〈この項の構成〉
-
(1) C#の場合のコーディング例
using System;
using Hitachi.OpenTP1;
using Hitachi.OpenTP1.Server;
namespace MyCompany
{
public class GyoumuAImpl : SPPBase, IGyoumuA
{
public GyoumuAImpl()
{
// コンストラクタの処理
// ** コンストラクタでOpenTP1のクラスは使用できません **
// ** 必要な初期化処理はInitializeSPPで行ってください **
}
~GyoumuAImpl()
{
// デストラクタの処理
// ** デストラクタでOpenTP1のクラスは使用できません **
// ** 必要な終了処理はFinalizeSPPで行ってください **
}
// SPP初期化および終了処理メソッドの実装
public override void InitializeSPP() {
// SPPの初期化処理
}
public override void FinalizeSPP() {
// SPPの終了処理
}
// サービスメソッドの実装
[TP1RpcMethod]
public void Service1(string dataId, byte[] data)
{
// Service1()の処理
}
[TP1RpcMethod]
public string[] Service2(string key)
{
// Service2()の処理
}
[TP1RpcMethod]
public int Service3(int inCount, ref string[] ids)
{
// Service3()の処理
}
[TP1RpcMethod]
public short Service4(MyStruct inStruct)
{
// Service4()の処理
}
// SPP内部メソッドの実装(自由に実装できます)
// RPCで呼び出すことはできません
public string GetUserInfo()
{
// 処理
}
private void PutErrorLog(string errorInfo, int errorCode)
{
// 処理
}
}
}
ページの先頭へ
(2) J#の場合のコーディング例
package MyCompany;
import System.*;
import Hitachi.OpenTP1.*;
import Hitachi.OpenTP1.Server.*;
public class GyoumuAImpl extends SPPBase implements IGyoumuA
{
public GyoumuAImpl()
{
// コンストラクタの処理
// ** コンストラクタでOpenTP1のクラスは使用できません **
// ** 必要な初期化処理はInitializeSPPで行ってください **
}
protected void Finalize()
{
// Finalizeメソッドの処理
// ** FinalizeメソッドでOpenTP1のクラスは使用できません **
// ** 必要な終了処理はFinalizeSPPで行ってください **
}
// SPP初期化および終了処理メソッドの実装
public void InitializeSPP() {
// SPPの初期化処理
}
public void FinalizeSPP() {
// SPPの終了処理
}
// サービスメソッドの実装
/** @attribute TP1RpcMethod() */
public void Service1(String dataId, ubyte[] data)
{
// Service1()の処理
}
/** @attribute TP1RpcMethod() */
public String[] Service2(String key)
{
// Service2()の処理
}
/** @attribute TP1RpcMethod() */
public int Service3(int inCount,
StringArrayHolder ids)
{
// Service3()の処理
}
/** @attribute TP1RpcMethod() */
public short Service4(MyStruct inStruct,
MyStructHolder outStruct)
{
// Service4()の処理
}
// SPP内部メソッドの実装(自由に実装できます)
// RPCで呼び出すことはできません
public String GetUserInfo()
{
// 処理
}
private void PutErrorLog(String errorInfo, int errorCode)
{
// 処理
}
}
ページの先頭へ
(3) Visual Basicの場合のコーディング例
Imports System
Imports Hitachi.OpenTP1
Imports Hitachi.OpenTP1.Server
Namespace MyCompany
Public Class GyoumuAImpl
Inherits SPPBase
Implements IGyoumuA
Sub GyoumuAImpl()
' コンストラクタの処理
' ** コンストラクタでOpenTP1のクラスは使用できません **
' ** 必要な初期化処理はInitializeSPPで行ってください **
End Sub
Sub Finalize()
' Finalizeメソッドの処理
' ** FinalizeメソッドでOpenTP1のクラスは使用できません **
' ** 必要な終了処理はFinalizeSPPで行ってください **
End Sub
' SPP初期化および終了処理メソッドの実装
Public Overrides Sub InitializeSPP()
' SPPの初期化処理
End Sub
Public Overrides Sub FinalizeSPP()
' SPPの終了処理
End Sub
' サービスメソッドの実装
<TP1RpcMethod()> _
Public Sub Service1(ByVal dataId As String, _
ByVal data() As Byte) _
Implements IGyoumuA.Service1
' Service1()の処理
End Sub
<TP1RpcMethod()> _
Public Function Service2(ByVal key As String) As String() _
Implements IGyoumuA.Service2
' Service2()の処理
End Function
<TP1RpcMethod()> _
Public Function Service3(ByVal inCount As Integer, _
ByRef ids() As String) _
As Integer Implements IGyoumuA.Service3
' Service3()の処理
End Function
<TP1RpcMethod()> _
Public Function Service4(ByVal inStruct As MyStruct) _
As Short _
Implements IGyoumuA.Service4
' Service4()の処理
End Function
' SPP内部メソッドの実装(自由に実装できます)
' RPCで呼び出すことはできません
Public Function GetUserInfo() As String
' 処理
End Function
Private Sub PutErrorLog(errorInfo As String, _
errorCode As Integer)
' 処理
End Sub
End Class
End Namespace
ページの先頭へ