본문 바로가기
백엔드/WAS

JBoss 로의 마이그레이션 전략 - Migration From WebLogic To JBoss Part4

by david100gom 2008. 12. 4.

4. Migration 

이번장에서는 전에 말했던 XSLT stylesheet 를 이용한 DD (Deployment Descriptor) 파일 마이그레이션 자동화에 관해서 얘기하려 합니다.

XSLT (Extensible Style Language Transformation) - XML 문서 형식을 다른 형식의 문서로 변환하는 방법을 기술한 표준방법

Deployment Descriptor File Migration  자동화 단계

1단계
Eclipse + Ant + XSLT stylesheet 를 이용 DD File Migration

2단계
추가 사항은 DTD 파일을 참고하여 XSLT 파일을 Modify 후 1 단계 다시 실행
http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd
http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd

3단계
 JBoss 로 deploy 테스트

Ant - 샘플 Build.xml 파일

<project name="JBoss" default="webdocs" basedir="./">
 <target name="webdocs">
 <xslt basedir="in" destdir="out" includes="weblogic-ejb-jar.xml" extension=".xmls" style="xslt/jboss.xslt"/>
  <move file="out/weblogic-ejb-jar.xmls" tofile="out/jboss.xml"/>
 
 <xslt basedir="in" destdir="out" includes="weblogic-cmp-rdbms-jar.xml" extension=".xmls"  style="xslt/jbosscmp-jdbc.xslt"/>
  <move file="out/weblogic-cmp-rdbms-jar.xmls" tofile="out/jbosscmp-jdbc.xml"/> 
 </target>
</project>

XSLT 샘플 파일 - jboss.xslt

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output  method="xml" doctype-public="-//JBoss//DTD JBOSS 4.0//EN"  doctype-system="http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd"/>

<xsl:template match="/weblogic-ejb-jar">
<jboss>
    <enterprise-beans><xsl:apply-templates select="weblogic-enterprise-bean"/></enterprise-beans>
</jboss>
</xsl:template>

<xsl:template match="weblogic-enterprise-bean">
<xsl:if test="entity-descriptor">
<entity>
   <xsl:copy-of select="ejb-name"/>
   <xsl:copy-of select="jndi-name"/>
   <xsl:copy-of select="local-jndi-name"/>
   </entity>
</xsl:if>

<xsl:if test="stateful-session-descriptor">
<session>
   <xsl:copy-of select="ejb-name"/>
   <xsl:copy-of select="jndi-name"/>
   <xsl:copy-of select="local-jndi-name"/>
</session>
</xsl:if>

<xsl:if test="stateless-session-descriptor">
<session>
    <xsl:copy-of select="ejb-name"/>
    <xsl:copy-of select="jndi-name"/>
    <xsl:copy-of select="local-jndi-name"/>
</session>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

XSLT 샘플 파일 - jbosscmp-jdbc.xslt

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output  method="xml" doctype-public="-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"  doctype-system="http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd"/>
<xsl:template match="/weblogic-rdbms-jar">

<jbosscmp-jdbc>
<defaults>
       <datasource><xsl:value-of select="weblogic-rdbms-bean/data-source-name"/></datasource>
       <datasource-mapping>mySQL</datasource-mapping>
</defaults>

<enterprise-beans>
  <xsl:apply-templates select="weblogic-rdbms-bean"/>
</enterprise-beans>

</jbosscmp-jdbc>
</xsl:template>

 <xsl:template match="weblogic-rdbms-bean">
 <entity>
  <xsl:copy-of select="ejb-name"/>
   <create-table>true</create-table>
  <xsl:copy-of select="table-map/table-name"/>
  <xsl:apply-templates select="table-map/field-map"/>
 </entity>
</xsl:template>

<xsl:template match="field-map">
<cmp-field>
    <field-name><xsl:value-of select="cmp-field"/></field-name>
     <column-name><xsl:value-of select="dbms-column"/></column-name>
</cmp-field>
</xsl:template>
</xsl:stylesheet>

위에 나열한 샘플 파일(build.xml, jboss.xslt, jbosscmp-jdbc.xslt) 들을 가지고 이클립스에서 weblogic-ejb-jar.xml 을 jboss.xml 로 weblogic-cmp-rdbms-jar.xml 를 jbosscmp-jdbc.xml 파일로의 마이그레이션을 자동화 할수 있습니다. 

이해를 돕기 위해 데모 동영상 파일과 예제 소스를 올려놓았으니 참고 하세요 

데모동영상 

Migration_Demo.zip
다운로드


예제소스

Migration_Sample_File.zip
다운로드


지금까지 간단하게 Weblogic에서 JBoss로의 마이그레이션 방법에 관하여 적어보았습니다. ^^

댓글