01: package org.mockejb;
02:
03: import javax.jms.MessageListener;
04:
05: /**
06: * Provides the information that MockEJB needs to "deploy" MDB.
07: * This includes JNDI names of the connection factory and destination.
08: * MockEJB uses its mock JMS implementation to create connection factory and
09: * destination and bind them to JNDI.
10: * It then creates MDB and sets it as the message listener to the destination.
11: *
12: * @author Alexander Ananiev
13: */
14: public class MDBDescriptor extends BasicEjbDescriptor {
15:
16: private String connectionFactoryJndiName;
17: private String destinationJndiName;
18: private boolean isTopic = false;
19: private boolean isAlreadyBound = false;
20:
21: private final static String MDB_JNDI_NAME = "FakeMDBJNDIName";
22:
23: /**
24: * Creates a new instance of the descriptor.
25: * @param connectionFactoryJndiName JNDI name of the connection factory.
26: * @param destinationJndiName JNDI name of the desination. Queue is the default,
27: * unless isTopic is set.
28: * @param bean bean object. Must implement MessageListener interface.
29: */
30: // TODO: Do we need a constructor with the class?
31: public MDBDescriptor(String connectionFactoryJndiName,
32: String destinationJndiName, Object bean) {
33: super (MDB_JNDI_NAME, MDBHomeIface.class, MessageListener.class,
34: bean);
35:
36: this .connectionFactoryJndiName = connectionFactoryJndiName;
37: this .destinationJndiName = destinationJndiName;
38: }
39:
40: public void setIsTopic(boolean isTopic) {
41: this .isTopic = isTopic;
42: }
43:
44: /**
45: * If set to True, MockEJB will assume that the connection factory and
46: * desination already exist and bound in JNDI. Otherwise, MockEJB will try
47: * to create them using Mock JMS objects and bind them to JNDI.
48: * The default is "false".
49: *
50: * @param isAlreadyBound do not create destination and connection factory if set to true
51: */
52: public void setIsAlreadyBound(boolean isAlreadyBound) {
53: this .isAlreadyBound = isAlreadyBound;
54: }
55:
56: public String getConnectionFactoryJndiName() {
57: return connectionFactoryJndiName;
58: }
59:
60: public String getDestinationJndiName() {
61: return destinationJndiName;
62: }
63:
64: public boolean isTopic() {
65: return isTopic;
66: }
67:
68: public boolean isAlreadyBound() {
69:
70: return isAlreadyBound;
71: }
72:
73: }
|