KickJava   Java API By Example, From Geeks To Geeks.

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


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 a resource.
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 ResourceLinkRef
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_RESOURCE_LINK_FACTORY;
44
45
46     /**
47      * Description address type.
48      */

49     public static final String JavaDoc GLOBALNAME = "globalName";
50
51
52     // ----------------------------------------------------------- Constructors
53

54
55     /**
56      * ResourceLink Reference.
57      *
58      * @param resourceClass Resource class
59      * @param globalName Global name
60      */

61     public ResourceLinkRef(String JavaDoc resourceClass, String JavaDoc globalName) {
62         this(resourceClass, globalName, null, null);
63     }
64
65
66     /**
67      * ResourceLink Reference.
68      *
69      * @param resourceClass Resource class
70      * @param globalName Global name
71      */

72     public ResourceLinkRef(String JavaDoc resourceClass, String JavaDoc globalName,
73                            String JavaDoc factory, String JavaDoc factoryLocation) {
74         super(resourceClass, factory, factoryLocation);
75         StringRefAddr JavaDoc refAddr = null;
76         if (globalName != null) {
77             refAddr = new StringRefAddr JavaDoc(GLOBALNAME, globalName);
78             add(refAddr);
79         }
80     }
81
82
83     // ----------------------------------------------------- Instance Variables
84

85
86     // ------------------------------------------------------ Reference Methods
87

88
89     /**
90      * Retrieves the class name of the factory of the object to which this
91      * reference refers.
92      */

93     public String JavaDoc getFactoryClassName() {
94         String JavaDoc factory = super.getFactoryClassName();
95         if (factory != null) {
96             return factory;
97         } else {
98             factory = System.getProperty(Context.OBJECT_FACTORIES);
99             if (factory != null) {
100                 return null;
101             } else {
102                 return DEFAULT_FACTORY;
103             }
104         }
105     }
106
107
108     // ------------------------------------------------------------- Properties
109

110
111 }
112
Popular Tags