KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > naming > EjbRef


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.naming;
20
21 import javax.naming.Context JavaDoc;
22 import javax.naming.Reference JavaDoc;
23 import javax.naming.StringRefAddr JavaDoc;
24
25 /**
26  * Represents a reference address to an EJB.
27  *
28  * @author Remy Maucherat
29  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
30  */

31
32 public class EjbRef
33     extends Reference JavaDoc {
34
35
36     // -------------------------------------------------------------- Constants
37

38
39     /**
40      * Default factory for this reference.
41      */

42     public static final String JavaDoc DEFAULT_FACTORY =
43         org.apache.naming.factory.Constants.DEFAULT_EJB_FACTORY;
44
45
46     /**
47      * EJB type address type.
48      */

49     public static final String JavaDoc TYPE = "type";
50
51
52     /**
53      * Remote interface classname address type.
54      */

55     public static final String JavaDoc REMOTE = "remote";
56
57
58     /**
59      * Link address type.
60      */

61     public static final String JavaDoc LINK = "link";
62
63
64     // ----------------------------------------------------------- Constructors
65

66
67     /**
68      * EJB Reference.
69      *
70      * @param ejbType EJB type
71      * @param home Home interface classname
72      * @param remote Remote interface classname
73      * @param link EJB link
74      */

75     public EjbRef(String JavaDoc ejbType, String JavaDoc home, String JavaDoc remote, String JavaDoc link) {
76         this(ejbType, home, remote, link, null, null);
77     }
78
79
80     /**
81      * EJB Reference.
82      *
83      * @param ejbType EJB type
84      * @param home Home interface classname
85      * @param remote Remote interface classname
86      * @param link EJB link
87      */

88     public EjbRef(String JavaDoc ejbType, String JavaDoc home, String JavaDoc remote, String JavaDoc link,
89                   String JavaDoc factory, String JavaDoc factoryLocation) {
90         super(home, factory, factoryLocation);
91         StringRefAddr JavaDoc refAddr = null;
92         if (ejbType != null) {
93             refAddr = new StringRefAddr JavaDoc(TYPE, ejbType);
94             add(refAddr);
95         }
96         if (remote != null) {
97             refAddr = new StringRefAddr JavaDoc(REMOTE, remote);
98             add(refAddr);
99         }
100         if (link != null) {
101             refAddr = new StringRefAddr JavaDoc(LINK, link);
102             add(refAddr);
103         }
104     }
105
106
107     // ----------------------------------------------------- Instance Variables
108

109
110     // -------------------------------------------------------- RefAddr Methods
111

112
113     // ------------------------------------------------------ Reference Methods
114

115
116     /**
117      * Retrieves the class name of the factory of the object to which this
118      * reference refers.
119      */

120     public String JavaDoc getFactoryClassName() {
121         String JavaDoc factory = super.getFactoryClassName();
122         if (factory != null) {
123             return factory;
124         } else {
125             factory = System.getProperty(Context.OBJECT_FACTORIES);
126             if (factory != null) {
127                 return null;
128             } else {
129                 return DEFAULT_FACTORY;
130             }
131         }
132     }
133
134
135     // ------------------------------------------------------------- Properties
136

137
138 }
139
Popular Tags