KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > objectposervice > SchemaDefinedPurchaseOrderServiceBean


1 /* Copyright 2005 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: SchemaDefinedPurchaseOrderServiceBean.java,v 1.10 2005/12/01 20:54:04 yutayoshida Exp $ */

4
5 package com.sun.j2ee.blueprints.objectposervice;
6
7 import java.rmi.*;
8 import javax.ejb.*;
9
10 /**
11  * A simple endpoint that receives PO objects
12  * and returns the po ID
13  */

14
15 public class SchemaDefinedPurchaseOrderServiceBean implements SessionBean {
16     
17     private SessionContext sc;
18     public SchemaDefinedPurchaseOrderServiceBean(){}
19     
20     public String JavaDoc submitPO(PurchaseOrder po) throws InvalidPOException, RemoteException {
21         //this is done just to illustrate throwing an application specific exception
22
if(po.getPoId().equals("100"))
23             throw new InvalidPOException("Invalid ID for the purchase order!!! " +
24                     "For demo purposes, we throw " +
25                     "an application defined exception for the ID value of 100.");
26         
27         //extract the PO ID and return to the client
28
return po.getPoId();
29     }
30     
31     //life cycle methods
32
public void ejbCreate() throws CreateException {}
33     
34     public void setSessionContext(SessionContext sc) {
35         this.sc = sc;
36     }
37     
38     public void ejbRemove(){}
39     
40     public void ejbActivate() {}
41     
42     public void ejbPassivate() {}
43 }
44
45
Popular Tags