01: // MessageTakerMD.java
02:
03: package ersatz.resourceadapter;
04:
05: import javax.ejb.MessageDrivenBean;
06: import javax.ejb.MessageDrivenContext;
07:
08: /**
09: *
10: */
11: public class MessageTakerMD implements MessageDrivenBean,
12: MsgListenerInterface {
13: private transient MessageDrivenContext mdbContext;
14: String cName = "MessageTakerMD";
15:
16: // constructor for the container
17: public MessageTakerMD() {
18: }
19:
20: // ------------------------------------------------------------------
21: // MessageDrivenBean implementation
22: // ------------------------------------------------------------------
23:
24: /**
25: * Set the associated context. The container calls this method
26: * after the instance creation.
27: * The enterprise Bean instance should store the reference to the context
28: * object in an instance variable.
29: * This method is called with no transaction context.
30: *
31: * @param MessageDrivenContext A MessageDrivenContext interface for the instance.
32: * @throws EJBException Thrown by the method to indicate a failure caused by
33: * a system-level error.
34: */
35:
36: public void setMessageDrivenContext(MessageDrivenContext ctxt) {
37: mdbContext = ctxt;
38: /*tmp*/System.out.println(cName + ".setMessageDrivenContext");
39: Utility.log(cName + ".setMessageDrivenContext");
40: }
41:
42: /**
43: * A container invokes this method before it ends the life of the message-driven object.
44: * This happens when a container decides to terminate the message-driven object.
45: *
46: * This method is called with no transaction context.
47: *
48: * @throws EJBException Thrown by the method to indicate a failure caused by
49: * a system-level error.
50: */
51: public void ejbRemove() {
52: Utility.log(cName + ".ejbRemove");
53: }
54:
55: /**
56: * The Message driven bean must define an ejbCreate methods with no args.
57: *
58: */
59: public void ejbCreate() {
60: Utility.log(cName + ".ejbCreate");
61: }
62:
63: /**
64: * onMessage method
65: */
66: public void onMessage(String message) {
67: /*tmp*/System.out.println(cName + ".onMessage Message="
68: + message);
69: try {
70: Utility.log(cName + ".onMessage Message=" + message);
71: } catch (Exception ex) {
72: Utility.log(cName + ".onMessage Exception caught="
73: + ex.toString());
74: }
75: }
76:
77: /**
78: * offMessage method
79: */
80: public void offMessage(String message) {
81: try {
82: Utility.log(cName + ".offMessage Message=" + message);
83: } catch (Exception ex) {
84: Utility.log(cName + ".offMessage Exception caught="
85: + ex.toString());
86: }
87: }
88: }
|