권장하는 이주 기법은 사용자가 Stateless 세션 EJB를 SCA 컴포넌트로서 호출하게 하는 Stateless 세션 바인딩을 갖는 WebSphere® Integration Developer 가져오기를 사용하는 것입니다. 이주 중에 SCA Java™ 인터페이스 스타일에서 기존의 EJB 인터페이스 스타일로 변환하도록 Java 코드를 작성해야 합니다.
<types> <schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://migr.practice.ibm.com/" xmlns:xsd1="http://migr.practice.ibm.com/"> <complexType name="StockInfo"> <all> <element name="index" type="int"/> <element name="price" type="double"/> <element name="symbol" nillable="true" type="string"/> </all> </complexType> </schema> </types> <message name="getStockInfoRequest"> <part name="symbol" type="xsd:string"/> </message> <message name="getStockInfoResponse"> <part name="result" type="xsd1:StockInfo"/> </message> <operation name="getStockInfo" parameterOrder="symbol"> <input message="tns:getStockInfoRequest" name="getStockInfoRequest"/> <output message="tns:getStockInfoResponse" name="getStockInfoResponse"/> </operation>다음 코드는 WSDL에 해당하는 WebSphere Studio Application Developer Integration Edition 5.1 Java 메소드를 보여줍니다.
public StockInfo getStockInfo(String symbol) { return new StockInfo(); } public void setStockPrice(String symbol, float newPrice) { // set some things }다음 코드는 동일한 WSDL에 대한 WebSphere Integration Developer 6.0 Java 메소드를 표시합니다.
public DataObject getStockInfo(String aString) { //TODO Needs to be implemented. return null; } public void setStockPrice(String symbol, Float newPrice) { //TODO Needs to be implemented. }따라서 생성된 Java 구현 클래스에서 “//TODO” 태그가 표시되는 위치에 실제 코드를 채워야 합니다. 먼저 이 Java 컴포넌트에서 실제 EJB로의 참조를 작성하여 SCA 프로그래밍 모델에 따라서 EJB에 액세스할 수 있게 해야 합니다.
private YourEJBInterface ejbService = null;
private BOFactory boFactory = (BOFactory) ServiceManager.INSTANCE.locateService(“com/ibm/websphere/bo /BOFactory”);
// Locate the EJB service this.ejbService = (YourEJBInterface) ServiceManager.INSTANCE.locateService("name-of-your-ejb-reference");
/** * Method generated to support the implementing WSDL port type named * "interface.MyBean". */ public BusObjImpl getStockInfo(String aString) { BusObjImpl boImpl = null; try { // invoke the EJB method StockInfo stockInfo = this.ejbService.getStockInfo(aString); // formulate the SCA data object to return. boImpl = (BusObjImpl) this.boFactory.createByClass(StockInfo.class); // manually convert all data from the EJB return type into the // SCA data object to return boImpl.setInt("index", stockInfo.getIndex()); boImpl.setString("symbol", stockInfo.getSymbol()); boImpl.setDouble("price", stockInfo.getPrice()); } catch (RemoteException e) { e.printStackTrace(); } return boImpl; } /** * Method generated to support the implementing WSDL port type named * "interface.MyBean". */ public void setStockPrice(String symbol, Float newPrice) { try { this.ejbService.setStockPrice(symbol, newPrice.floatValue()); } catch (RemoteException e) { e.printStackTrace(); } }