KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jms > destination > JBossDestination


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.jms.destination;
8
9 import java.io.Serializable JavaDoc;
10
11 import javax.jms.Destination JavaDoc;
12 import javax.jms.JMSException JavaDoc;
13 import javax.naming.NamingException JavaDoc;
14 import javax.naming.Reference JavaDoc;
15 import javax.naming.Referenceable JavaDoc;
16 import javax.naming.StringRefAddr JavaDoc;
17
18 /**
19  * A destination
20  *
21  * @author <a HREF="mailto:adrian@jboss.org>Adrian Brock</a>
22  * @version $Revision: 1.2 $
23  */

24 public class JBossDestination
25    implements Destination JavaDoc, Referenceable JavaDoc, Serializable JavaDoc
26 {
27    // Constants -----------------------------------------------------
28

29    // Attributes ----------------------------------------------------
30

31    /** The name */
32    private String JavaDoc name;
33
34    // Static --------------------------------------------------------
35

36    // Constructors --------------------------------------------------
37

38    /**
39     * Construct a new destination
40     *
41     * @param name the name
42     */

43    public JBossDestination(String JavaDoc name)
44    {
45       if (name == null)
46          throw new IllegalArgumentException JavaDoc("Null name");
47       this.name = name;
48    }
49
50    // Public --------------------------------------------------------
51

52    /**
53     * Retrieve the name
54     *
55     * @return the name
56     * @throws JMSExeption for any error
57     */

58    public String JavaDoc getName()
59       throws JMSException JavaDoc
60    {
61       return name;
62    }
63
64    // Destination implementation ------------------------------------
65

66    // Referenceable implementation ----------------------------------
67

68    public Reference JavaDoc getReference()
69       throws NamingException JavaDoc
70    {
71       return new Reference JavaDoc
72       (
73          getClass().getName(),
74          new StringRefAddr JavaDoc("name", name),
75          JBossDestinationFactory.class.getName(),
76          null
77       );
78    }
79
80    // Object overrides ----------------------------------------------
81

82    public String JavaDoc toString()
83    {
84       return name;
85    }
86
87    public boolean equals(Object JavaDoc obj)
88    {
89       if (obj == null) return false;
90       if (obj == this) return true;
91       if (getClass() != obj.getClass()) return false;
92       JBossDestination other = (JBossDestination) obj;
93       return name.equals(other.name);
94    }
95
96    public int hashCode()
97    {
98       return name.hashCode();
99    }
100
101    // Protected ------------------------------------------------------
102

103    // Package Private ------------------------------------------------
104

105    // Private --------------------------------------------------------
106

107    // Inner Classes --------------------------------------------------
108

109 }
110
Popular Tags