10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SAAJ Coffee Supplier Service<br />

public ConfirmationBean placeOrder(OrderBean order) {<br />

}<br />

Date tomorrow = DateHelper.addDays(new Date(), 1);<br />

ConfirmationBean confirmation =<br />

new ConfirmationBean(order.getId(), DateHelper.dateToCalendar(tomorrow));<br />

return confirmation;<br />

<strong>The</strong> getPriceList method returns a PriceListBean object, which lists the name and price of<br />

each type of coffee that can be ordered from this service. <strong>The</strong> getPriceList method creates the<br />

PriceListBean object by invoking a private method named loadPrices. In a production<br />

application, the loadPrices method would fetch the prices from a database. However, our<br />

loadPrices method takes a shortcut by getting the prices from the<br />

SupplierPrices.properties file. Here are the getPriceList and loadPrices methods:<br />

public PriceListBean getPriceList() {<br />

}<br />

PriceListBean priceList = loadPrices();<br />

return priceList;<br />

private PriceListBean loadPrices() {<br />

}<br />

String propsName = "com.sun.cb.ws.server.SupplierPrices";<br />

Date today = new Date();<br />

Date endDate = DateHelper.addDays(today, 30);<br />

PriceItemBean[] priceItems = PriceLoader.loadItems(propsName);<br />

PriceListBean priceList =<br />

new PriceListBean(DateHelper.dateToCalendar(today),<br />

DateHelper.dateToCalendar(endDate), priceItems);<br />

return priceList;<br />

SAAJ Coffee Supplier Service<br />

1024<br />

<strong>The</strong> SAAJ supplier service implements the arrangements that the supplier and the Coffee Break<br />

have made regarding their exchange of XML documents. <strong>The</strong>se arrangements include the kinds<br />

of messages they will send, the form of those messages, and the kind of messaging they will do.<br />

<strong>The</strong>y have agreed to do request-response messaging using the SAAJ API (the javax.xml.soap<br />

package).<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!