기술자료

DBMS, DB 구축 절차, 빅데이터 기술 칼럼, 사례연구 및 세미나 자료를 소개합니다.

Rational Application Developer와 WebSphere Application Server를 사용하여 XML 기반 SOA를 위한 JSF 개발 시간 단축하기, Part 5::nal Application Devel

기술자료
DBMS별 분류
Etc
작성자
admin
작성일
2021-02-23 14:41
조회
1127

Rational Application Developer와 WebSphere Application Server를 사용하여
XML 기반 SOA를 위한 JSF 개발 시간 단축하기, Part 5::
Rational Application Developer 버전 7.0 업데이트

연재 기사의 다섯 번째 기사에서는 IBM Rational Application Developer 버전 7.0 이상과 IBM WebSphere Application Server 버전 6.1 이상을 위한 XSD SDO Transform 기능에 대한 업데이트된 정보를 제공합니다. 이 기능은 XML 기반 SOA 애플리케이션의 프리젠테이션 개발 효율성을 높여줍니다.

업데이트된 솔루션 소개

이 연재 기사의 이전 기사들에서는 XML 기반 SOA의 프리젠테이션 개발 효율성을 높여주는 솔루션에 대해 설명했다. 이러한 연재 기사에서는 솔루션 활용을 위해 IBM Rational Application Developer 버전 6.0에 설치할 수 있는 기능도 제공했다. 그러나 이 기능은 기본 프레임워크가 변경된 Rational Application Developer V7.0과는 호환되지 않는다.이 기사에서는 Rational Application Developer V7.0 및 IBM WebSphere Application Server V6.1과 호환되는 솔루션을 제공한다. 이 업데이트된 기능에는 파일이나 클래스 경로에서 XML 리소스를 로드할 수 있는 변환 서비스 유틸리티 메소드도 추가되었다.

XSD SDO Transform V7 기능 설치

다음 단계에 따라 업데이트된 XSD SDO Transform 기능을 Rational Application Developer V7.0에 설치할 수 있다.
  1. Rational Application Developer 설치 디렉토리(예: D:\IBM\SDP70)에 xsdsdotransform-feature.zip 파일을 압축 풀기한다.
  2. Rational Application Developer를 시작한다.
  3. 그림 1과 같이Help > Software Updates > Manage Configuration을 선택한다.
그림 1. Manage Configuration 명령
090324_kck1.jpg
  1. 그림 2와 같이 XSD SDO Transform 기능이 활성화되었는지 확인한 후 Rational Application Developer를 다시 시작한다.
그림 2. 기능 설치
090324_kck2.jpg참고:-clean 명령행 인수와 함께 Rational Application Developer를 시작하면 기능의 구성 업데이트를 확인할 수 있다.

XSD SDO Transform 기능 컨텐츠

이 기능에는 XSD 스키마 및 프레임워크 구성 요소를 바탕으로 SDO 패키지를 생성하는 데 필요한 아티팩트가 있다. 이 기능을 사용하면 SDO 패키지 인스턴스와 XML 인스턴스 문서를 상호 변환할 수 있다.
  • Create SDO Package 조치:XSD 리소스에 대해 이 조치를 수행하면 XSD 스키마를 기반으로 하는 SDO 패키지가 생성된다. 또한 필수 JAR(Java™ archive) 파일도 Enterprise Application Server 프로젝트에 추가된다. 이 조치는 Java™ 2 Platform, Enterprise Edition(J2EE) 및 Java EE(Java EE 5 Platform) 모듈 종속성에 대한 웹 프로젝트의 목록을 업데이트한다. 그림 3과 같이 BrokerService.xsd를 마우스 오른쪽 단추로 클릭하고Create SDO Package를 선택한다.
그림 3. Create SDO Package
090324_kck3.jpg
  • 업데이트된 dw.ibm.etools.xsd.sdo.xmltransformservice.XMLTransformServiceFactory: 이 클래스는 SDO 패키지 인스턴스와 XML 인스턴스 문서의 상호 변환을 지원하는 API를 제공한다.
  • dw.ibm.etools.xsd.sdo.xmltransforms.util.ObjectUtil: 이 클래스는 SDO 오브젝트에 대해 작동하는 aggregate 및 helper 메소드를 제공한다.

샘플 프로젝트 컨텐츠

그림 4와 같이 프로젝트 교환 xsd_sdo_soa_xml_tutorial.zip 다운로드 파일에는 다음 프로젝트가 있다.
  • XYZInsuranceEAR:이 프로젝트는 다른 모든 프로젝트가 모듈이나 유틸리티로 포함되어 있는 엔터프라이즈 애플리케이션 프로젝트이다.
  • XYZInsuranceWeb:이 프로젝트는 애플리케이션의 동적 웹 프로젝트이며, 여기에서 모든 JSF(Java™Server Faces) JSP(Java™Server Pages) 페이지가 생성된다. 이 프로젝트의 WebContent 폴더에는 BrokerService.xsd 스키마와 샘플 데이터 파일이 포함된 Schema 폴더가 있다. 이 예제에서는 단순한 구조를 사용하기 위해 스키마와 SDO 패키지가 WebProject에 속해 있다. 여러 웹 프로젝트에서 동일한 SDO를 공유하려는 경우에는 SDO 패키지에 대한 별도의 Java 프로젝트를 만들 수 있다. SDO 패키지는 XML 스키마와 동일한 프로젝트에 생성된다.
  • XYZInsuranceService:이 프로젝트에는 브로커 서비스를 위한 Java 클래스 구현이 있다. 이 서비스는 서비스 메소드 요청에 따라 적절한 XML 응답을 로드하고 보낸다. 이 기본 구현은 서비스 동작을 구현은 이 기사의 범위에 포함되지 않는 내용이다.
  • XYZInsuranceServiceProxy:이 프로젝트에는 브로커 서비스를 호출하는 ServiceProxy의 기본 구현이 있다.
그림 4. 가져온 프로젝트 교환
090324_kck4.jpg

Create SDO Package 조치를 사용하여 SDO 생성하기

Rational Application Developer에서 샘플 프로젝트 컨텐츠를 가져온 후 BrokerService.xsd를 마우스 오른쪽 단추로 클릭하고Create SDO Package를 선택한다(그림 5).그림 5. SDO 패키지 만들기
090324_kck5.jpg결과적으로 다음과 같은 아티팩트가 생성된다.
  • xyz.brokerservice , xyz.brokerservice.impl 및 xyz.brokerservice.util Java 패키지가 생성된다. 이들 패키지에는 XSD 스키마에 정의된 유형에 대해 생성된 SDO와 관련 유틸리티가 포함되어 있다. 그림 6에서는 이들 패키지를 보여 준다.
그림 6. 생성된 SDO 패키지
090324_kck6.jpg
  • 프레임워크 JAR 파일(xsdsdotransform.jar)이 EAR 프로젝트에 추가되고 웹 프로젝트의 J2EE 모듈 종속성이 빌드 및 런타임 클래스 경로에 따라 올바르게 업데이트된다.
  • 다음과 같은 EMF JAR 파일이 EAR 프로젝트에 추가되고(그림 7 참조), 웹 프로젝트의 J2EE 모듈 종속성이 빌드 및 런타임 클래스 경로에 따라 적절하게 업데이트된다(그림 8 참조).
    • org.eclipse.emf.common_2.2.1.v200609210005.jar
    • org.eclipse.emf.commonj.sdo_2.1.0.v200609210005.jar
    • org.eclipse.emf.ecore.change_2.2.0.v200609210005.jar
    • org.eclipse.emf.ecore.sdo_2.2.0.v200609210005.jar
    • org.eclipse.emf.ecore.xmi_2.2.1.v200609210005.jar
    • org.eclipse.emf.ecore_2.2.1.v200609210005.jar
그림 7. EAR 프로젝트에 추가된 프레임워크 JAR 파일
090324_kck7.jpg그림 8. 업데이트된 J2EE 모듈 종속성
090324_kck8.jpg

Generate > Java를 사용하여 SDO 생성하기

Rational Application Developer V7.0은 XSD 스키마 문서 모델을 기초로 SDO의 Java 정의를 생성할 수 있는 기능을 제공한다.Create SDO Package조치 대신 이 기능을 사용하여 SDO Java 패키지를 생성할 수 있다.하지만Create SDO Package조치를 사용하여 생성된 SDO에는 다중 값 관계를 위한 형식화된 배열 메소드와 관련된 SDO 오브젝트를 위한 목록 리턴 유형 메소드가 있다. 이러한 추가 배열 리턴 유형 메소드는 웹 개발에 유용하게 사용할 수 있다. 콜렉션에 포함된 유형을 정의하라는 프롬프트를 표시하지 않고도 JSF 데이터테이블을 콜렉션에 쉽게 바인딩할 수 있다.또한 이 조치는 필수 프레임워크 JARS를 엔터프라이즈 애플리케이션 아카이브 프로젝트에 추가하고, 수동 설정이 필요하지 않는 J2EE 모듈 종속성을 업데이트한다.Create SDO Package조치는 웹 프로젝트 개발에서와 같이 SDO 패키지와 함께 다른 여러 가지 항목을 만들어야 하는 경우에 사용하는 것이 좋다.간단한 Java 프로젝트를 사용할 때는 XSD SDO 생성기를 사용할 수 있다. 그림 9와 같이 BrokerService.xsd를 마우스 오른쪽 단추로 클릭한다.변환 기능이 필요한 경우에는 프레임워크 JAR 파일(xsdsdotransform.jar)을 프로젝트의 클래스 경로 및 빌드 경로에 추가한다. 그러면 EMF 프레임워크 JAR이 프로젝트에 자동으로 추가된다.그림 9. Generate > Java 선택하기
090324_kck9.jpg
  1. 서비스 데이터 오브젝트 Java 패키지를 생성하기 위해 그림 10과 같이 마법사에서 SDO Generator를 선택한다.
그림 10. SDO Generate 마법사
090324_kck10.jpg
  1. 그림 11과 같이 생성된 SDO의 소스 폴더를 선택한다.
그림 11. 소스 폴더 선택하기
090324_kck11.jpg마법사 작업이 완료되면 SDO Java 패키지가 만들어지고 필수 프레임워크 JARS가 Java 프로젝트의 빌드 및 클래스 경로에 추가된다(그림 12 참조).그림 12. 생성된 패키지
090324_kck12.jpg

업데이트된 XMLTransformServiceFactory

이 기능과 함께 제공되는 XMLTransformServiceFactory에는 명시적 경로나 클래스 경로에서 파일을 로드하는 추가 메소드가 있으며, 이들 메소드는 Listing 1에굵게표시되어 있다.
Listing 1. 파일 로드하기
package dw.ibm.etools.xsd.sdo.xmltransformservice;
import java.io.InputStream;
import java.util.Map;
import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
import dw.ibm.etools.xsd.sdo.xmltransformservice.impl.XMLTransformServiceFactoryImpl;
public abstract class XMLTransformServiceFactory {
/**
* Instance of the factory
*/
static public XMLTransformServiceFactory INSTANCE
= new XMLTransformServiceFactoryImpl();
/**
* @return Returns the xmlFileService to be used for transformation.
*/
public abstract XMLTransformService getXmlFileService() throws Exception;
/**
* @param xmlFileService The xmlFileService to set to be used for transformation.
*/
public abstract void setXmlFileService(XMLTransformService xmlFileService);
/**
* load the XML input stream and return the populated dataobjects
* @param stream the input stream for the XML data
* @return the populated dataobject graph root
*/
public abstract DataObject loadStream(InputStream stream);
/**
* load the XML input stream and return the populated datagraph
* @param stream the input stream for the XML data
* @return the populated dataobject graph root
*/
public abstract DataGraph loadDataGraphStream(InputStream stream);
/**
* load the XML input stream and return the populated dataobjects
* @param String the XML file
* @return the populated dataobject graph root
*/
public abstract DataObject loadFile(String fileName);
/**
* load the XML input stream and return the populated DataGraph
* @param String the XML file
* @return the populated dataobject graph root
*/
public abstract DataGraph loadDataGraphFile(String fileName);
/**
* load the XML data and return the populated dataobjects
* @param String the XML file
* @return the populated dataobject graph root
*/
public abstract DataObject load(String xmlString);
/**
* load the XML data and return the populated DataGraph
* @param String the XML file
* @return the populated dataobject graph root
*/
public abstract DataGraph loadDataGraph(String xmlString);
/**
* Serializes the data object as a file.
* @param DataObject the dataobject to be serialized as the input file
* @param String the output file name
*/
public abstract void saveFile(DataObject dataObject, String fileName);
/**
* Serializes the data object as a file.
* @param DataGraph the DataGraph to be serialized as the input file
* @param String the output file name
*/
public abstract void saveFile(DataGraph dataGraph, String fileName);
/**
* Serializes the data object as a file.
* @param DataObject the dataobject to be serialized as the input file
* @param String the output file name
* @param unSetAllEmptyFeatures unsets all the empty features that are set,
* such that they are not written to the serialized XML
*/
public abstract void saveFile(DataObject dataObject, String fileName
, boolean unSetAllEmptyFeatures);
/**
* Serializes the data object as a string
* @param DataObject the dataobject to be serialized as a string
* @return String the serialized dataobject string
*/
public abstract String convert(DataObject dataObject);
/**
* Serializes the data object as a string
* @param DataGraph the DataGraph to be serialized as a string
* @return String the serialized dataobject string
*/
public abstract String convert(DataGraph dataGraph);
/**
* Unsets all the empty attributes and serializes the data
* object as a string.
* Call this method only when you do not need the empty tags
* for elements or attributes.
* @param DataObject the dataobject to be serialized as a string
* @param unSetAllEmptyFeatures if true, unsets all the empty
* features that are set,
* such that they are not written to the serialized XML
* @return String the serialized dataobject string
*/
public abstract String convert(DataObject dataObject
, boolean unSetAllEmptyFeatures);
/**
* load options for the parser for advanced configuration
* like XMLResource.OPTION_RECORD_UNKNOWN_FEATURE etc.
* @return Map the option map
*/
public abstract Map getOptions();
/**
* Creates a new DataGraph and root DataObject given an XSD uri.
* Returns the root DataObject
* @param targetNamespaceURI is the XSDtarget namespace
* @return DataObject Returns the root DataObject
*/
public abstract DataObject create(String targetNamespaceURI);
/**
* Creates a new DataGraph and root DataObject given an XSD uri.
* Returns the DataGraph
* @param targetNamespaceURI is the XSDtarget namespace
* @return DataGraph Returns the DataGraph
*/
public abstract DataGraph createDataGraph(String targetNamespaceURI);
/**
* load the XML input stream and return the populated dataobjects
* @param String the XML file
* @param the class that is used to get the classloader
* context to load the file
* @return the populated dataobject graph root
*/
public abstract DataObject loadFileUsingClassLoader
(String qualifiedName, Class clazz);
/**
* load the file from explicit path
* @param fileName
* @return
*/
public abstract DataObject loadFileExplicitPath(String fileName);
/**
* Serializes this data object as a string
* @param DataObject the dataobject to be serialized as a string
* @return String the serialized dataobject string
*/
public abstract String convertThis(DataObject dataObject);
}

업데이트된 XMLTransformService

이 기능과 함께 제공되는 XMLTransformService에는 데이터 오브젝트를 로드하고 저장하는 추가 메소드가 있으며, 이들 메소드는 Listing 2에굵게표시되어 있다.Listing 2. 데이터 오브젝트 로드 및 저장하기
package dw.ibm.etools.xsd.sdo.xmltransformservice;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
public interface XMLTransformService
{
/**
* Creates a new DataGraph and root DataObject given an XSD uri.
* Returns the root DataObject
* @param targetNamespaceURI is the XSDtarget namespace
* @return DataGraph the new DataGraph
*/
DataObject create(String targetNamespaceURI);
/**
* Creates a new DataGraph given an XSD uri.
* Returns the DataGraph
* @param targetNamespaceURI is the XSDtarget namespace
* @return DataGraph the new DataGraph
*/
DataGraph createDataGraph(String targetNamespaceURI);
/**
* Creates and returns a DataGraph with the data loaded from the input file.
* @param uri input file name
* @return the new root DataObject loaded
*/
DataObject load(String uri) throws IOException;
/**
* Creates and returns a DataGraph with the data loaded from the input file.
* @param uri input file name
* @return the new DataGraph loaded
*/
DataGraph loadDataGraph(String uri) throws IOException;
/**
* Creates and returns a DataGraph with the data read from the input stream.
* @param inputStream specifies the input stream to read from
* @return the new root DataObject loaded
*/
DataObject load(InputStream inputStream) throws IOException;
/**
* Creates and returns a DataGraph with the data read from the input stream.
* @param inputStream specifies the input stream to read from
* @return the new DataGraph loaded
*/
DataGraph loadDataGraph(InputStream inputStream) throws IOException;
/**
* Serializes a DataObject into the specified file
* @param dataObject specifies DataObject to be saved
* @param uri specifies the URI to be used
*/
void save(DataObject dataObject, String uri) throws IOException;
/**
* Serializes a DataGraph into the specified file
* @param DataGraph specifies DataGraph to be saved
* @param uri specifies the URI to be used
*/
void save(DataGraph dataGraph, String uri) throws IOException;
/**
* Serializes a DataObject into the specified stream
* @param dataObject specifies DataObject to be saved
* @param outputStream specifies the output stream to write to
*/
void save(DataObject dataObject, OutputStream outputStream) throws IOException;
/**
* Serializes a DataGraph into the specified stream
* @param DataGraph specifies DataObject to be saved
* @param outputStream specifies the output stream to write to
*/
void save(DataGraph dataGraph, OutputStream outputStream) throws IOException;
/**
* Serializes this DataObject into the specified stream
* @param dataObject specifies DataObject to be saved
* @param outputStream specifies the output stream to write to
*/
void saveThis(DataObject dataObject, OutputStream outputStream)
throws IOException;
/**
* load options for the parser for advanced configuration
* like XMLResource.OPTION_RECORD_UNKNOWN_FEATURE etc.
* @return Map the option map
*/
public abstract Map getOptions();
}

Java 클라이언트로 업데이트

XMLTransformService를 사용하는 Java 클라이언트의 경우 Listing 3처럼org.eclipse.xsd.util.XSDResourceFactoryImpl을 사용할 수 있도록 .xsd 확장의 등록을 업데이트해야 한다.Listing 3. .xsd 확장 등록하기
Resource.Factory.Registry.INSTANCE.
getExtensionToFactoryMap().
put("xsd", new XSDResourceFactoryImpl());

샘플 애플리케이션 실행하기

연재 기사의 Part 1 에 설명된 단계를 수행하여 튜토리얼을 완료할 수 있다. 또한 완성된 샘플 xsd_sdo_soa_xml_sample.zip 을 가져온 후 WebSphere Application Server V6.1에 전개하여 애플리케이션을 손쉽게 실행해 볼 수 있다. 패키지된 엔터프라이즈 애플리케이션 아카이브 XYZInsuranceEAR.ear 도 제공되므로 애플리케이션 서버에 전개하여 작동 중인 코드를 볼 수 있다. 그림 13에서는 보험 예제를 보여 준다.그림 13. XYZ 보험 애플리케이션
090324_kck13.jpg

결론

이 두 번째 기사에서는 Rational Application Developer V7.0 및 IBM WebSphere Application Server V6.1과 호환되는 XSD SDO Transform 기능의 업데이트된 버전을 제공했다. 또한 XMLTransformService에 추가된 서비스 API에 대해 설명하고 Rational Application Developer V7.0과 함께 제공되는 표준 SDO Generator에 대해 이 기능을 사용할 때 얻을 수 있는 장점에 대해서도 설명했다.

다운로드 하십시오

설명
이름
크기
다운로드 방식
XSD SDO transform feature xsdsdotransform-feature.zip 1.23MB HTTP
XYZInsurance complete sample xsd_sdo_soa_xml_sample.zip 7.19MB HTTP
XYZInsurance tutorial xsd_sdo_soa_xml_tutorial.zip 962KB HTTP
Deployable XYZInsuranceEAR.zip Part5Rev2.zip 20.4MB HTTP
Deployable XYZInsuranceEAR.zip XYZInsuranceEAR.zip 7.17MB HTTP

필자소개

Narinder Makin은 노스캐롤라이나의 더럼에 있는 IBM Research Triangle Park Lab에서 소프트웨어 아키텍트로 근무하고 있다. Rational Software Architect 팀에서 전개 도구 분야를 맡고 있으며, 지난 12년 동안 다양한 모델 중심 개발/전개 도구에 관한 업무를 수행했다. 여러 가지 특허를 보유하고 있고, 여러 편의 기사를 쓰기도 했다. 인도의 K.N.I.T에서 컴퓨터 공학과를 졸업하고, 코네티컷의 University Of Bridgeport에서 컴퓨터 과학 석사 학위를 받았다.출처 : 한국 IBM제공 : DB포탈사이트 DBguide.net