IBM®
메인 컨텐츠로 가기
    Korea [국가변경]    이용약관
 
 
   
        제품    서비스 & 솔루션    고객지원 & 다운로드    회원 서비스    
메인 컨텐츠로 가기

한국 developerWorks  >  Rational  >

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

developerWorks
문서 옵션
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
772KB (22 pages)

Get Adobe® Reader®

JavaScript가 필요한 문서 옵션은 디스플레이되지 않습니다.

샘플 코드

영어원문

영어원문


제안 및 의견
피드백

난이도 : 중급

Narinder Makin, Software Architect, IBM Rational SOA tools, IBM

원문 게재일 : 2009 년 1 월 13 일
번역 게재일 : 2009 년 3 월 24 일

연재 기사의 다섯 번째 기사에서는 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 명령
menu command
  1. 그림 2와 같이 XSD SDO Transform 기능이 활성화되었는지 확인한 후 Rational Application Developer를 다시 시작한다.

그림 2. 기능 설치
menu command

참고: -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
menu command
  • 업데이트된 dw.ibm.etools.xsd.sdo.xmltransformservice.XMLTransformServiceFactory: 이 클래스는 SDO 패키지 인스턴스와 XML 인스턴스 문서의 상호 변환을 지원하는 API를 제공한다.
  • dw.ibm.etools.xsd.sdo.xmltransforms.util.ObjectUtil: 이 클래스는 SDO 오브젝트에 대해 작동하는 aggregatehelper 메소드를 제공한다.



위로


샘플 프로젝트 컨텐츠

그림 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. 가져온 프로젝트 교환
projects listed in the Project Explorer



위로


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

Rational Application Developer에서 샘플 프로젝트 컨텐츠를 가져온 후 BrokerService.xsd를 마우스 오른쪽 단추로 클릭하고 Create SDO Package를 선택한다(그림 5).


그림 5. SDO 패키지 만들기
menu command

결과적으로 다음과 같은 아티팩트가 생성된다.

  • xyz.brokerservice, xyz.brokerservice.implxyz.brokerservice.util Java 패키지가 생성된다. 이들 패키지에는 XSD 스키마에 정의된 유형에 대해 생성된 SDO와 관련 유틸리티가 포함되어 있다. 그림 6에서는 이들 패키지를 보여 준다.

그림 6. 생성된 SDO 패키지
referenced artifacts selected in Project Explorer
  • 프레임워크 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 파일
JAR files in the META-INF folder

그림 8. 업데이트된 J2EE 모듈 종속성
tree view on left, details on right



위로


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 선택하기
menu command
  1. 서비스 데이터 오브젝트 Java 패키지를 생성하기 위해 그림 10과 같이 마법사에서 SDO Generator를 선택한다.

그림 10. SDO Generate 마법사
Generator drop-down above, Description below
  1. 그림 11과 같이 생성된 SDO의 소스 폴더를 선택한다.

그림 11. 소스 폴더 선택하기
enter or Browse to select the Container

마법사 작업이 완료되면 SDO Java 패키지가 만들어지고 필수 프레임워크 JARS가 Java 프로젝트의 빌드 및 클래스 경로에 추가된다(그림 12 참조).


그림 12. 생성된 패키지
referenced files selected in explorer



위로


업데이트된 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 보험 애플리케이션
screen with client details



위로


결론

이 두 번째 기사에서는 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 featurexsdsdotransform-feature.zip1.23MBHTTP
XYZInsurance complete samplexsd_sdo_soa_xml_sample.zip7.19MBHTTP
XYZInsurance tutorialxsd_sdo_soa_xml_tutorial.zip962KBHTTP
Deployable XYZInsuranceEAR.zipPart5Rev2.zip20.4MBHTTP
Deployable XYZInsuranceEAR.zipXYZInsuranceEAR.zip7.17MBHTTP
다운로드 방식에 대한 정보


참고자료

교육

제품 및 기술 얻기

토론


필자소개

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




기사에 대한 평가


보다 나은 서비스를 제공하기 위함이오니 잠시 짬을 내어 이 양식을 제출하여 주십시오.



 


 


 


이 문서 북마킹 하기

mar.gar.in mar.gar.in naver naver eolin eolin del.icio.us del.icio.us





위로


developerWorks 콘텐트를 다른 사이트에 전재하기:
developerWorks 콘텐트에 대한 저작권은 IBM에 있습니다. IBM의 서면 허가나 원본 저자의 허락이 없이는 전재를 금합니다. 저희 콘텐트를 전재하시려면 IBM developerWorks 담당자 에게 문의하십시오.
    IBM 소개 개인정보 보호정책 문의