Upload
ngokiet
View
218
Download
3
Embed Size (px)
Citation preview
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
JBoss & Spring
임형준 ([email protected])
충남대학교 컴퓨터공학과
데이터베이스시스템연구실
2008년 7월 24일 목요일
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
JBoss Overview
2
Operating SystemWindows, Unix, Other Linux
Java Virtual Machine
JBoss Microkernel
Application Platform Other Application Server
JBoss Rules
JBoss jBPM
JBoss Hibernate
JBoss Seam
SOAPlatform
Application Platform
for Portals
Enterprise Platforms Enterprise Frameworks
JBoss Enterprise Middleware System (JEMS)
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
JBoss Enterprise Middleware System (JEMS)
Open source middleware platform for SOA-based enterprise applications and services
Plug-and-play architecture enables standardizing on JEMS products at your own pace
Focused on simplifying development
3
JBoss Microkernel
JBossApp
Server
ApacheTomcat
HibernateJBossCache
JBossjBPM
…JBossRules
Your Applications and Services
JBossPortal
Your Platform Services
JBossEclipse
IDE
#1 #1 #1
Multivendor Java VM, Operating System, Hardware
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
JEMS Architecture
4
Operating System (Windows, Unix = Linux, Solaris, AIX, etc.)
Hardware (CPU + Storage + Memory)
Java Virtual Machine (Sun JVM, BEA JRockit, IBM VM, etc.)
JBoss Application Server 4.x (JMX Microkernel : JBossMX)
Cus
tom
Mbe
ans
Services beyond J2EE
Per
sist
ence
(Hib
erna
te*)
Clu
ster
ing
Cac
hing
(JB
ossC
ache
*)
Wor
kflo
w (J
Bos
s jB
PM
**)
JBos
s A
OP
*
Java Applications (EARs, WARs, JARs, JSPs, Servlets)
JBos
s E
clip
se ID
E
JBoss Portal
--- J2EE 1.4 Services implemented as JMX Mbeans ---
JSP
/Ser
vlet
(Tom
cat*
)
JND
I (JB
ossN
S)
WS
4EE
(JB
ossW
S)
JDBC
JMS
(JB
oss
MQ
)E
JB (J
Bos
s C
MP
)
JTA
(JB
ossJ
TA)
SAAJ
JAC
C
JCA
(JB
ossJ
CA
)JA
AS
(JB
ossS
X)
RM
I-IIO
P (ja
cOR
B)
JAX
-RP
C
Dep
loym
ent A
PI
JAXR
Man
agem
ent A
PI
* Product can run inside JBoss AS or stand-alone** Integration as MBean under development
JAXP
JBos
s R
emot
ing*
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Spring Framework의 구성
5
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Spring Architecture – Simple Example
6
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Drools
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
What is a Drools?
Drools 3 Released
■ Thursday, June 1, 2006
■ Drools.NET now supports .NET Framework v1.1
JBoss는 가트너가 제시한 Simple Application를 위해서 DBMS를 제외한 모든 패키지 (BPM, BRE, SOA)를 포함
A Java Rules Engine implementation
An object-oriented interface allows for more natural expression of business rules with regards to business objects
8
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Drools Features
Drools is designed to allow pluggeable language implementations
■ Currently rules can be written in Java, Python and Groovy
Drools is written in Java, but able to run on Java and .Net.
Drools provides for Declarative Programming and is flexible enough to match the semantics of your problem domain
■ With Domain Specific Languages (DSL) via XML using a Schema defined for your problem domain
Graphical editing tools, web based tools and developer productivity tools
9
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Why Choose Drools?
Open Source
Declarative Programming
■ Allow you to say “What to do” not “How to do it”
Accessible business rules
Logic and Data Separation
Speed and Scalability
Eclipse IDE
Web based BRMS
■ BRMS: Business rule management system
10
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Drools Modules
11
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Drools Layers
12
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Drools Semantic Modules
13
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Drools Flow view with GWT Diagram
14
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Drools 설치
Drools 엔진 다운로드 및 설치
■ http://www.drools.org/Project+Downloads
■ drools-all-jdk5-2.5-final.jar
■ antlr-2.7.5.jar
■ janino-2.3.15.jar
■ xml-apis-2.0.2.jar
■ xercesImpl-2.7.1.jar
■ Python이나 Groovy로 룰 파일을 작성하려면 Classpath 설정 변경
– 배포파일의 Readme.txt 참고
설치 후 Eclipse에 Plug-in
15
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Rule File 작성
Ex) hello.drl
16
<?xml version="1.0" encoding="euc-kr" ?><rule-set name="Hello"
xmlns="http://drools.org/rules"xmlns:java="http://drools.org/semantics/java"xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"xs:schemaLocation="http://drools.org/rules rules.xsd
http://drools.org/semantics/java java.xsd"><import>java.lang.Object</import><import>java.lang.String</import><java:functions>
public static void helloWorld(java.lang.String hello) {System.out.println(hello + " World");
}public static void goodbyeWorld(String goodbye) {
System.out.println(goodbye + " Cruel World");}
</java:functions>
<rule name="Hello World"><parameter identifier="hello">
<class>String</class></parameter><java:condition>hello.equals("Hello")</java:condition><java:consequence>
helloWorld( hello );</java:consequence>
</rule><rule name="Goodbye Cruel World">
<parameter identifier="goodbye"><class>String</class>
</parameter>
<java:condition>goodbye.equals("Goodbye")</java:condition><java:consequence>
goodbyeWorld( goodbye );</java:consequence>
</rule></rule-set>
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Rule File Tag
Import
■ 자바의 import와 동일하게 룰 파일 내에서 사용할 클래스를 명시
java:functions
■ 룰 파일에서 사용될 함수. 자바의 메소드와 동일
Rule
■ 하나의 규칙을 표현. 룰을 실행할 때 필요한 파라미터, 실행 조건 그리고조건 충족 시 실행될 코드로 구성
17
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Rule Tag
Parameter
■ 룰을 실행하는 데 필요한 파라미터 값
■ identifier 속성을 사용해서 룰에서 사용할 파라미터의 이름을 지정
java:condition
■ 룰을 실행하기 위한 조건
java:consequence
■ 조건이 충족될 경우 실행될 코드
18
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
Execute Java File using Rule File
Ex) HelloExample.java
19
package javacan.drools.test;
import java.io.IOException;
import org.drools.FactException;import org.drools.IntegrationException;import org.drools.RuleBase;import org.drools.WorkingMemory;import org.drools.io.RuleBaseLoader;import org.xml.sax.SAXException;
public class HelloExample {public static void main(String[] args) throws IntegrationException, SAXException, IOException, FactException {
RuleBase ruleBase = RuleBaseLoader.loadFromUrl(HelloExample.class.getResource("hello.drl") );
WorkingMemory workingMemory = ruleBase.newWorkingMemory();workingMemory.assertObject("Hello");workingMemory.fireAllRules(); // 첫번째 실행
workingMemory = ruleBase.newWorkingMemory();workingMemory.assertObject("Goodbye");workingMemory.fireAllRules(); // 두번째 실행
}}
Result ValueHello WorldGoodbye Cruel World
Chungnam National UniversityComputer Science and EngineeringDatabase System Laboratory
DRL File 작성법
Agenda Group로 룰 파일 작성하기
■ 예를 들어 가족수당을 룰로 만들 경우에 가족수당 룰도 여러 가지 경우의수가 나올 수 있으므로 agenda 그룹으로 만들어야 함
20
rule "family-wifCn-pay"agenda-group "family“no-loopwhen
e : Employee (marry =="Y")then
e.setBasicpay(e.getBasicpay() + 10);String log ="가족수당-배우자" + e.getBasicpay();e.message.add(log);
endrule "family-supCn-pay"
agenda-group "family“no-loopwhen
e : Employee (children > 0, children <=4)then
e.setBasicpay(e.getBasicpay() + (e.getChildren() *5));
String log ="가족수당-부양가족" + e.getBasicpay();e.message.add(log);
end