001 package localControls;
002
003 /**
004 * @common:target-namespace namespace="http://workshop.bea.com/LocalControlTest"
005 */
006 public class LocalControlTest implements com.bea.jws.WebService
007 {
008 /**
009 * @common:control
010 * @jc:databaseActions checkInventory="true"
011 */
012 private localControls.tags.POVerify poVerifyControl;
013
014 /**
015 * @common:control
016 */
017 private localControls.nestedControls.VerifyFunds verifyFundsControl;
018
019 /**
020 * @common:control
021 */
022 private localControls.basics.Hello helloControl;
023
024 /**
025 * @common:control
026 */
027 private localControls.asynch.BufferJC bufferedControl;
028
029 public Callback callback;
030
031 /**
032 * Test the Hello control by clicking the testHello button. Test View
033 * will refresh to display the control's response, a "Hello, World!"
034 * greeting.
035 *
036 * @common:operation
037 */
038 public String testHello()
039 {
040 return helloControl.sayHello();
041 }
042
043 /**
044 * Test the BufferJC control by clicking the testBuffered button in Test View,
045 * then click Refresh until the control's response displays as the
046 * results of its callback.
047 *
048 * The BufferJC control demonstrates how a control
049 * can support message buffering. The BufferJC control's startRequest
050 * method is buffered, which means that requests to the method are
051 * automatically queued and fed to the control as resources allow. <br/><br/>
052 *
053 * The BufferJC control is also asynchronous, using a callback to
054 * send its response to its client (this web service). <br/><br/>
055 *
056 * @common:operation
057 * @jws:conversation phase="start"
058 */
059 public void testBuffered()
060 {
061 bufferedControl.startRequest();
062 }
063
064 /**
065 * This callback handler receives the BufferJC control's onResultsReady
066 * callback, then forwards the results to this web service's
067 * onBufferTestDone callback.
068 */
069 public void bufferedControl_onResultsReady(java.lang.String bufferResults)
070 {
071 callback.onBufferTestDone(bufferResults);
072 }
073
074 public interface Callback
075 {
076 /**
077 * Sends a response to the client of this web service when the BufferJC
078 * control's callback is received.
079 *
080 * @jws:conversation phase="finish"
081 */
082 void onBufferTestDone(String results);
083
084 /**
085 * Sends a response to the client of this web service when the VerifyFunds
086 * control's callback is received.
087 *
088 * @jws:conversation phase="finish"
089 */
090 void onVerifyFundsTestDone(String responseMessage);
091 }
092
093
094 /**
095 * Tests the VerifyFunds control, which submits purchase
096 * order information after ensuring that inventory and
097 * the customer's account support it. <br/><br/>
098 *
099 * To test the control, enter a PO number (a combination of numerals
100 * that results in a legal int value; letters are allowed, and will be
101 * removed by the POUtil control), customer ID (numerals only),
102 * item number, and item quantity. The following table lists
103 * item numbers and quantities known to the database when
104 * WebLogic Workshop is installed. The VerifyFunds control
105 * decreases quantities with successful orders. This web service
106 * gives the customer a balance of $200.00 to spend for each
107 * request. You can change this amount to test with another.<br/>
108 *
109 * <table style="font-size: 8 pt">
110 * <tr><td style="width: 100px">itemNumber</td><td style="width: 100px">quantity</td><td>price</td></tr>
111 *
112 * <tr><td>624</td><td>5</td><td>34.95</td></tr>
113 * <tr><td>625</td><td>6</td><td>39.95</td></tr>
114 * <tr><td>629</td><td>10</td><td>34.95</td></tr>
115 * <tr><td>631</td><td>15</td><td>65.95</td></tr>
116 * <tr><td>640</td><td>1</td><td>24.95</td></tr>
117 *
118 * </table>
119 *
120 * @param poNumber A number for this purchase order. May be any
121 * string whose concatenated numerals result in a legal int; non-numeric
122 * characters are allowed, and will be removed by the control.
123 * @param customerID The customer's unique ID. This may be any number.
124 * @param item The number for the item being ordered. Use a number from
125 * the range given above.
126 * @param quantity The number of the specified items to order. Note that
127 * this number must be lower than the quantities given above in order
128 * for this order to succeed. Give larger numbers to test the control's
129 * inventory checking. Also, keep in mind that a successful PO transaction
130 * will decrease the inventory quantity in the database by the amount
131 * ordered.
132 *
133 * @common:operation
134 * @jws:conversation phase="start"
135 * @jws:message-buffer enable="true"
136 */
137 public void testVerifyFunds(String poNumber,
138 String customerID, int item, int quantity)
139 {
140 /*
141 * The amount the customer can spend. Changing this amount may
142 * change the results of the control's check to verify customer
143 * funds for the purchase.
144 */
145 double balance = 200.00;
146
147 /* Call the VerifyFunds control with the details of the purchase order. */
148 verifyFundsControl.submitPO(poNumber, customerID, item, quantity, balance);
149 }
150
151 /**
152 * A handler for the VerifyFunds control's onTransactionComplete callback.
153 * The results are essentially summarized for a callback of this web service.
154 */
155 public void verifyFundsControl_onTransactionComplete(java.lang.String message,
156 boolean isBalanceAvailable, boolean isInventoryAvailable)
157 {
158 callback.onVerifyFundsTestDone(message +
159 "\n Balance available: " + isBalanceAvailable +
160 "\n Inventory available: " + isInventoryAvailable);
161 }
162
163 /**
164 * Tests the POVerify control, which submits purchase order information,
165 * and will first check inventory if its checkInventory attribute
166 * is set to "true" (as it is by default).<br/><br/>
167 *
168 * To test the control, enter any PO number (a combination of numerals
169 * that results in a legal int value; dashes are allowed, and will be
170 * removed by the POVerify control) and customer ID (numerals only), but
171 * use the item numbers and values given in the following table
172 * to test the control's inventory checking functionality. <br/><br/>
173 *
174 * <table style="font-size: 8 pt">
175 * <tr><td style="width: 100px">itemNumber</td><td style="width: 100px">quantity</td><td>price</td></tr>
176 * <tr><td>624</td><td>5</td><td>34.95</td></tr>
177 * <tr><td>625</td><td>6</td><td>39.95</td></tr>
178 * <tr><td>629</td><td>10</td><td>34.95</td></tr>
179 * <tr><td>631</td><td>15</td><td>65.95</td></tr>
180 * <tr><td>640</td><td>1</td><td>24.95</td></tr>
181 * </table>
182 * <br/>
183 *
184 * After entering the parameter values in Test View, then click the
185 * testPOVerify button. After Test View refreshes, scroll to the bottom
186 * to see whether the response is "true" (the purchase order addition
187 * succeeded) or "false" (because there isn't enough inventory to support
188 * the purchase).<br/><br/>
189 *
190 * By default, the control's checkInventory property value is set to "true".
191 * To set it to "false", use the following steps:
192 *
193 * <ol>
194 * <li>Switch to Design View for the web service.</li>
195 * <li>On the right side of the design, click the poVerifyControl.</li>
196 * <li>In the Property Editor, under databaseActions, set the checkInventory
197 * property value to "false".</li>
198 * </ol>
199 *
200 * With the value set to "false", inventory will no longer be checked and
201 * the web service will return "true" regardless of whether there are
202 * enough items.
203 *
204 * @param poNumber A number for this purchase order. May be any
205 * number that is a legal int; dashes will be removed.
206 * @param customerID The customer's unique ID. This may be any number.
207 * @param itemNum The number for the item being ordered. Use a number from
208 * the range given above.
209 * @param itemQuant The number of the specified items to order. Note that
210 * this number must be lower than the quantities given above in order
211 * for this order to succeed. Give larger numbers to test the control's
212 * inventory checking. Also, keep in mind that a successful PO transaction
213 * will decrease the inventory quantity in the database by the amount
214 * ordered.
215 *
216 * @common:operation
217 */
218 public boolean testPOVerify(String poNumber, int customerID,
219 int itemNum, int itemQuant)
220 {
221 return poVerifyControl.addPurchaseOrder(poNumber, customerID,
222 itemNum, itemQuant);
223 }
224 }
|