KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > JmsDestinationReferenceDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment;
24
25 import com.sun.enterprise.deployment.JmsDestinationReference;
26         
27 /**
28  * I am an object representing a dependency on a JMS Destination
29  * (Queue/Topic)
30  * @author Kenneth Saks
31  */

32
33 public class JmsDestinationReferenceDescriptor extends EnvironmentProperty implements NamedDescriptor, JmsDestinationReference {
34
35     private String JavaDoc refType;
36
37     private static final String JavaDoc SESSION_CTX_TYPE = "javax.ejb.SessionContext";
38     private static final String JavaDoc MDB_CTX_TYPE ="javax.ejb.MessageDrivenContext";
39     private static final String JavaDoc EJB_CTX_TYPE ="javax.ejb.EJBContext";
40     private static final String JavaDoc EJB_TIMER_SERVICE_TYPE
41         = "javax.ejb.TimerService";
42
43     public JmsDestinationReferenceDescriptor() {
44     }
45     
46     public JmsDestinationReferenceDescriptor(String JavaDoc name, String JavaDoc description, String JavaDoc refType) {
47         super(name, "", description);
48         this.refType = refType;
49     }
50
51     public void setRefType(String JavaDoc refType) {
52         this.refType = refType;
53         this.changed();
54     }
55
56     public String JavaDoc getRefType() {
57         return this.refType;
58     }
59
60     public String JavaDoc getInjectResourceType() {
61         return getRefType();
62     }
63
64     public void setInjectResourceType(String JavaDoc refType) {
65         setRefType(refType);
66     }
67
68    /**
69     * Return the jndi name of the destination to which I refer.
70     */

71     public String JavaDoc getJndiName() {
72         String JavaDoc jndiName = this.getValue();
73         return (jndiName != null && ! jndiName.equals("")) ?
74             jndiName : getMappedName();
75     }
76
77    /**
78     * Sets the jndi name of the destination to which I refer
79     */

80     public void setJndiName(String JavaDoc jndiName) {
81         this.setValue(jndiName);
82     }
83
84     public boolean isEJBContext() {
85         return (getRefType().equals(SESSION_CTX_TYPE) ||
86                 getRefType().equals(MDB_CTX_TYPE) ||
87                 getRefType().equals(EJB_CTX_TYPE) ||
88                 getRefType().equals(EJB_TIMER_SERVICE_TYPE));
89     }
90
91     /* Equality on name. */
92     public boolean equals(Object JavaDoc object) {
93         if (object instanceof JmsDestinationReference) {
94             JmsDestinationReference destReference = (JmsDestinationReference) object;
95             return destReference.getName().equals(this.getName());
96         }
97         return false;
98     }
99 }
100
Popular Tags