database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
ㆍCache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Cache Q&A 346 게시물 읽기
No. 346
[Ensemble]DB Independent 어플리케이션 만들기 예제 Production
작성자
앙상블
작성일
2008-12-01 14:52ⓒ
2009-02-11 21:29ⓜ
조회수
4,530

DB 독립적인 어플리케이션을 만드는 것은 DB를 사용하는 모든 어플리케이션 개발 회사의 바램일 것이다. 

Ensemble은 이럴 위해 비즈니스 오퍼레이션을 추가하여 쉽게 이런 문제를 해결할 수 있다. 


Files 게시판에 예제를 첨부한다.(첨부가 안돼 아래에 정리함)


1. Web Services 클래스에서 Ensemble Business Service 호출예제:


 Method CallDBProcess(Action As %String, ColumnName As %String) As %String [ WebMethod ]

{

set tReq=##class(SearchReq).%New()

set tReq.Action=Action

set tReq.Columns=ColumnName

set tSC=##class(Ens.Director).CreateBusinessService("DummySvc",.bs)

if 'tSC quit "Error to find BS"

set tSC=bs.OnProcessInput(tReq, .tRes)

set a=tRes.ResultText


quit a

}


2. Ens Business Service는 Synchronoous 호출을 한다. 


 Class DummySvc Extends Ens.BusinessService [ ProcedureBlock ]

{

Method OnProcessInput(pInput As SearchReq, pOutput As SearchRes) As %Status

{

set tApplication = pInput

Set tSC = ..SendRequestSync("DataProcess",tApplication,.res) Quit:$$$ISERR(tSC) tSC

Set pOutput = res

Quit tSC

}

}


3. Ensemble Business Process 예제- DBMode의 값에 따라 알맞은 비즈니스 오퍼레이션을 호출한다. 

 Class DataProcess Extends Ens.BusinessProcessBPL [ ClassType = persistent ]

{


/// BPL Definition

XData BPL [ XMLNamespace = "http://www.intersystems.com/bpl" ]

{

<process language='objectscript' request='SearchReq' response='SearchRes' height='2000' width='2000' >

<sequence xend='550' yend='550' >

<switch name='Check the DBMode' xpos='550' ypos='200' xend='550' yend='450' >

<case condition='^DBMode="INTERSYSTEMS"' >

<call name='Ens Call' target='EnsDBOperation' async='0' timeout='5' xpos='685' ypos='350' >

<request type='SearchReq>

<assign property='callrequestvalue='requestaction='set' />

request>

<response type='SearchRes>

<assign property='responsevalue='callresponseaction='set' />

response>

call>

case>

<case condition='^DBMode="ORACLE"' >

<call name='Ora Call' target='OraDBOperation' async='0' timeout='5' xpos='955' ypos='350' >

<request type='SearchReq>

<assign property='callrequestvalue='requestaction='set' />

request>

<response type='SearchRes>

<assign property='responsevalue='callresponseaction='set' />

response>

call>

case>

<default/>

switch>

sequence>

process>

}


}


4. Ens DB Operation 의 예제 (Ensemble DB의 경우)

 Class EnsDBOperation Extends Ens.BusinessOperation [ ProcedureBlock ]

{


Parameter ADAPTER = "EnsLib.SQL.OutboundAdapter";


Parameter INVOCATION = "Queue";


Method Search(pRequest As SearchReq, Output pResponse As SearchRes) As %Status

{

// parse Action

set pResponse=##class(SearchRes).%New()

if (pRequest.Action="Study") {

set sql="select top 2 * from sample.person" //"select top 50 key from Study"

set tSC= ..Adapter.ExecuteQuery(.rs,sql)

while (rs.Next()) {

set pResponse.ResultText=pResponse.ResultText_","_rs.GetData(1)_" "_rs.Get($P(pRequest.Columns,","))

}

}

else {

set pResponse.ResultText="No Study"

}

Quit $$$OK

}


XData MessageMap

{

<MapItems>

<MapItem MessageType="SearchReq">

<Method>SearchMethod>

MapItem>

MapItems>

}


}


5. Production의 예제

 Class MainProduction Extends Ens.Production

{


XData ProductionDefinition

{

<Production Name="MainProduction" TestingEnabled="true" LogGeneralTraceEvents="false">

  <Description>DB Independant ProductionDescription>

  <ActorPoolSize>2ActorPoolSize>

  <Setting Target="Production" Name="ShutdownTimeout">120Setting>

  <Setting Target="Production" Name="UpdateTimeout">10Setting>

  <Item Name="EnsDBOperation" Category="InterSystems" ClassName="EnsDBOperation" PoolSize="1" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="CacheDB" LogTraceEvents="true" Schedule="">

    <Setting Target="Host" Name="AlertRetryGracePeriod">0Setting>

    <Setting Target="Host" Name="RetryInterval">5Setting>

    <Setting Target="Host" Name="FailureTimeout">15Setting>

    <Setting Target="Host" Name="AlertOnError">0Setting>

    <Setting Target="Host" Name="ArchiveIO">0Setting>

    <Setting Target="Adapter" Name="DSN">ENSEMBLE SamplesSetting>

    <Setting Target="Adapter" Name="Credentials">SYSTEMSetting>

    <Setting Target="Adapter" Name="StayConnected">-1Setting>

    <Setting Target="Adapter" Name="ConnectTimeout">5Setting>

  Item>

  <Item Name="OraDBOperation" Category="Oracle" ClassName="EnsDBOperation" PoolSize="1" Enabled="false" Foreground="false" InactivityTimeout="0" Comment="Oracle DB " LogTraceEvents="false" Schedule="">

    <Setting Target="Host" Name="AlertRetryGracePeriod">0Setting>

    <Setting Target="Host" Name="RetryInterval">5Setting>

    <Setting Target="Host" Name="FailureTimeout">15Setting>

    <Setting Target="Host" Name="AlertOnError">0Setting>

    <Setting Target="Host" Name="ArchiveIO">0Setting>

    <Setting Target="Adapter" Name="DSN">OracleSetting>

    <Setting Target="Adapter" Name="Credentials">ORAUSERSetting>

    <Setting Target="Adapter" Name="StayConnected">-1Setting>

    <Setting Target="Adapter" Name="ConnectTimeout">5Setting>

  Item>

  <Item Name="TestOp" Category="Test" ClassName="EnsDBOperation" PoolSize="1" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="Test" LogTraceEvents="false" Schedule="">

  Item>

  <Item Name="DataProcess" Category="" ClassName="DataProcess" PoolSize="0" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">

  Item>

  <Item Name="DummySvc" Category="" ClassName="DummySvc" PoolSize="0" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">

  Item>

Production>

}


}







[Top]
No.
제목
작성자
작성일
조회
352공식 지원되는 웹 서버..
공식지원
2009-01-07
4107
350[CSP]2008.2 개발자 매뉴얼 올렸습니다!
CSP마스터
2008-12-12
4265
349CSP Cache쪽 로그 보기
CSP짱
2008-12-08
4868
346[Ensemble]DB Independent 어플리케이션 만들기 예제 Production
앙상블
2008-12-01
4530
344긴급히 Cache를 셧다운 해야하는 경우
긴급종료
2008-11-18
4280
343쓸만한 Cache DB 보안 기능모음
Security
2008-11-11
6259
342Cache DB를 3.xx를 쓰고 있는데요... [1]
잘하고파
2008-11-07
4414
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2019 DSN, All rights reserved.
작업시간: 0.286초, 이곳 서비스는
	PostgreSQL v11.5로 자료를 관리합니다