KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > anytypeposervice > AnyTypePurchaseOrderServiceBean


1 /* Copyright 2004 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at:
2  http://developer.sun.com/berkeley_license.html
3  $Id: AnyTypePurchaseOrderServiceBean.java,v 1.12 2005/08/12 20:46:12 smitha Exp $ */

4
5 package com.sun.j2ee.blueprints.anytypeposervice;
6
7 import java.rmi.*;
8
9 import javax.ejb.*;
10 import javax.xml.soap.*;
11
12 import org.w3c.dom.*;
13 import org.w3c.dom.Node JavaDoc;
14
15 public class AnyTypePurchaseOrderServiceBean implements SessionBean {
16     
17     private SessionContext sc;
18     private POXMLUtil xmlUtil;
19     
20     public AnyTypePurchaseOrderServiceBean() {}
21     
22     public String JavaDoc submitPO(SOAPElement request) throws InvalidPOException, RemoteException {
23         String JavaDoc poID = null;
24         SOAPElement reply = null;
25         try {
26             NodeList list = ((Element)request).getElementsByTagName("poId");
27             for (int loop = 0; loop < list.getLength(); loop++) {
28                 Node JavaDoc node = list.item(loop);
29                 if (node != null) {
30                     Node JavaDoc child = node.getFirstChild();
31                     if ((child != null) && child.getNodeValue() != null){
32                         poID = child.getNodeValue();
33                     }
34                 }
35             }
36         } catch (Exception JavaDoc exe) {
37             throw new EJBException("AnyTypePOService Having Problems:"+exe.getMessage(), exe);
38         }
39         //this is done just to illustrate throwing an application specific exception
40
if(poID.equals("100"))
41             throw new InvalidPOException("Invalid ID for the purchase order!!! " +
42                     "For demo purposes, we throw " +
43                     "an application defined exception for the ID value of 100.");
44         return poID;
45     }
46     
47     //life cycle methods
48
public void ejbCreate() throws CreateException {
49         xmlUtil = new POXMLUtil();
50     }
51     
52     public void setSessionContext(SessionContext sc) {
53         this.sc = sc;
54     }
55     
56     public void ejbRemove(){}
57     
58     public void ejbActivate() {}
59     
60     public void ejbPassivate() {}
61 }
62
63
Popular Tags