01: /*
02: * Copyright 1999,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.naming;
18:
19: import javax.naming.Context;
20: import javax.naming.Reference;
21: import javax.naming.StringRefAddr;
22:
23: /**
24: * Represents a reference address to a resource.
25: *
26: * @author Remy Maucherat
27: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:53 $
28: */
29:
30: public class ResourceLinkRef extends Reference {
31:
32: // -------------------------------------------------------------- Constants
33:
34: /**
35: * Default factory for this reference.
36: */
37: public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_RESOURCE_LINK_FACTORY;
38:
39: /**
40: * Description address type.
41: */
42: public static final String GLOBALNAME = "globalName";
43:
44: // ----------------------------------------------------------- Constructors
45:
46: /**
47: * ResourceLink Reference.
48: *
49: * @param resourceClass Resource class
50: * @param globalName Global name
51: */
52: public ResourceLinkRef(String resourceClass, String globalName) {
53: this (resourceClass, globalName, null, null);
54: }
55:
56: /**
57: * ResourceLink Reference.
58: *
59: * @param resourceClass Resource class
60: * @param globalName Global name
61: */
62: public ResourceLinkRef(String resourceClass, String globalName,
63: String factory, String factoryLocation) {
64: super (resourceClass, factory, factoryLocation);
65: StringRefAddr refAddr = null;
66: if (globalName != null) {
67: refAddr = new StringRefAddr(GLOBALNAME, globalName);
68: add(refAddr);
69: }
70: }
71:
72: // ----------------------------------------------------- Instance Variables
73:
74: // ------------------------------------------------------ Reference Methods
75:
76: /**
77: * Retrieves the class name of the factory of the object to which this
78: * reference refers.
79: */
80: public String getFactoryClassName() {
81: String factory = super .getFactoryClassName();
82: if (factory != null) {
83: return factory;
84: } else {
85: factory = System.getProperty(Context.OBJECT_FACTORIES);
86: if (factory != null) {
87: return null;
88: } else {
89: return DEFAULT_FACTORY;
90: }
91: }
92: }
93:
94: // ------------------------------------------------------------- Properties
95:
96: }
|