Download - Scala in our BRMS
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 1
~BRMS開発でのScala利用事例~
三菱UFJインフォメーションテクノロジー株式会社
ITプロデュース部
土佐鉄平
Mitsubishi UFJ Information Technology, Ltd.IT Production Dept.
Teppei Tosa
Scala in our BRMSBRMS: Business Rule Management System
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 2
Agenda
1. About MUFG, MUIT
2. About BRMS
3. About our original BRMS, “BIWARD”
4. How we have used Scala’s features in BIWARD� Using the Recursive Call function
� Using DSL
5. Our thoughts on Scala in developing Enterprise Applications
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 3
About MUFG 出典:MUFG Corporate Reviewhttp://www.mufg.jp/english/ir/annualreport/2012mufg/pdf/mar/cr1202.pdf
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 4
About MUIT(Mitsubishi UFJ Information Technology, Ltd.)
� Started on July 1st, 2009 when these three companies merged
� Tokyo Mitsubishi Information Technology, Ltd.
� UFJ Hitachi Systems, Ltd.
� UFJIS, Ltd.
� Amount of Capital: 181 million yen
� Capital from Bank of Tokyo Mitsubishi UFJ: 85%
� Capital from MUFG: 15%
� Currently over 1500 employees
For Bank Systems
For Credit Cards
For MUFG’s Members
For outside financial institutions
For Lease Systems
For Securities’ system
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 5
About BRMS(Business Rule Management System)
アプリケーションから、ビジネスルール(業務判断ロジック)を切出して実行・設計・管理を行うためのフレームワーク
BRMS is a framework that separates business logic from software applications and executes, designs and manages that logic.
WEB/AP Server
DBServer
ClientWEB/AP Server (ex. Cosminexus、Websphere、GlassFish)
Business Application
Framework (ex. JavaEE)
OS (ex. RedhatLinux、AIX)
Rule Engine
Rule Base
ExecutesExecutes
DesignsDesignsManagesManages
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 6
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 7
The Reason for Creating an Original BRMS
Back-office TypeInput operations are fixed.
Rule Engine
Papers
The system calculates how payments need to be made based on accident and contract information.
金融関連のBRMS事例は保険のバックオフィス業務への適用が多いが、銀行では対面型業務での適用ニーズがあり、市場製品では「前進判断」機能のみのため、これに応えることができない。
In the financial industry, there are some back-offices at insurance companies that use BRMSs. However, all banks have to use BRMS for their teller-window type operations. Other BRMS products cannot fulfill our needs because they have only “forward execution” functions.
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 8
The Reason for Creating an Original BRMS
Back-office Type Teller-window TypeInput operations are fixed.
Rule Engine
Papers
The system calculates how payments need to be made based on accident and contract information.
At teller-windows, we interact directly with customers, so we require a BRMS with not only “forward execution” but also “backward execution”.
Sorry, we can’t authenticate you with this kind of ID.
【【【【forward execution】】】】
So, what should I do?
If you have a driver’s license or a health insurance ID card…
【【【【backward execution】】】】
I have a health insurance ID card.
金融関連のBRMS事例は保険のバックオフィス業務への適用が多いが、銀行では対面型業務での適用ニーズがあり、市場製品では「前進判断」機能のみのため、これに応えることができない。
In the financial industry, there are some back-offices at insurance companies that use BRMSs. However, all banks have to use BRMS for their teller-window type operations. Other BRMS products cannot fulfill our needs because they have only “forward execution” functions.
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 9
Algorithm for BIWARD
Logic operating in a TREE form
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 10
Algorithm for BIWARD
Logic operating in a TREE formForward Execution
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 11
Algorithm for BIWARD
Logic operating in a TREE form Logic operating as a NETWORKForward Execution
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 12
Algorithm for BIWARD
Logic operating in a TREE form Logic operating as a NETWORKForward Execution Forward Exec.
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 13
Algorithm for BIWARD
Logic operating in a TREE form Logic operating as a NETWORKForward Execution Forward Exec. Backward Exec.
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 14
Algorithm for BIWARD
Logic operating in a TREE form Logic operating as a NETWORKForward Execution Forward Exec. Backward Exec. Biward Exec.
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 15
Example: Logic for Authentication
ResultConditions
NONO
NONO
YESNO
YESYES
YES
YES
Can authenticateBring a
resident card
Have a
home loan
Bring a
driver’s license
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 16
Internal Structure of Logic
ResultConditions
Can authenticateBring a
resident card
Have a
home loan
Bring a
driver’s license
Y
N
Y
N
Y
NY
N
Root :Node
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 17
BIWARD walks on nodes recursively.
� BIWARDはRootNodeからスタートして、RootNodeまでを辿る� 辿ったNodeを記録しながら、「walk」関数を再帰的に処理していき、最終的に記録したNodeを結果として応答
� Scalaによって、こういった処理を非常にシンプルに構築
� BIWARD can “walk” on the network in both directions from the Root Node and back to the Root Node.
� The nodes use the “walk” function to call one another recursively. BIWARD records the nodes that have been “walked” through, then returns the results by displaying the recorded nodes.
� Thanks to Scala, we were able to create this program very elegantly.
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 18
Steps of Creating Rules
XML Scala JARregisterregisterCompilesand
packages
Compilesand
packages
Exported from WEB-UIor input by the user
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 19
Using Scala’s Parser
BIWARD parses these conditional expressions with Scala’s DSL function.
<rule id=“rule1” … >
<parameters>
<booleanParameter id=“hasDriversLicence” label=“運転免許証持参有無運転免許証持参有無運転免許証持参有無運転免許証持参有無” … />
…
</parameters>
<results>
<booleanResult id=“canAuthenticate” label=“本人確認可否本人確認可否本人確認可否本人確認可否”/>
</results>
<patterns>
<pattern>
<conditions>
<condition … ><![CDATA[ param(“hasDriversLicense”)==true ]]></condition>
</conditions>
<results>
<booleanResult id=“canAuthenticate”>true</booleanResult>
</results>
</pattern>
…
</patterns>
</rule>
Not only boolean, but also strings, numbers and date types in conditional expressions.
Exported Scala CodeCondition(Equal(
BooleanParameter(“”“9”“”, “”“bringDriversLicense”“”,
List(BooleanValue(true, """Yes"""), BooleanValue(false, """No"""))),
BooleanValue(true, """Yes""")
)),
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 20
Thoughts on Scala
� 高生産性を確かに実感
� Javaとの親和性メリットは大きいScalaプログラムがJavaリソースを利用するという観点はもちろん、Javaに対してScalaリソースを提供するという観点でもメリット大きい。
� 言語仕様が強力で、標準言語とするにはまだまだハードル高い
� Javaの置き換えではなく、ポイントを抑えた部分的な活用が有効
� Achieve a higher level of productivity
� Compatibility with Java is a strong meritScala can use Java as a library, and Java can use Scala the same way.
� As a result of its elaborate syntax, it will still be difficult to adopt Scala as the standard.
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 21
Our Goal for Scala
DSLやJavaAPIを通した機能提供を前提に、より汎用的な機能の開発にScalaを活用
To develop universal features with Scala and supply them using DSL or Java API
Universal featuresSpecific features for business
Common Parts (Java)
Business Application(Java)
Common Parts (Scala)
Java API
DSL
All Rights Reserved,Copyright © 2013 Mitsubishi UFJ Information Tecnology,Ltd. 22
御静聴ありがとうございましたThank you for listening