01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.naming;
19:
20: import javax.naming.Context;
21: import javax.naming.Reference;
22: import javax.naming.StringRefAddr;
23:
24: /**
25: * Represents a reference address to a resource.
26: *
27: * @author Remy Maucherat
28: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
29: */
30:
31: public class ResourceLinkRef extends Reference {
32:
33: // -------------------------------------------------------------- Constants
34:
35: /**
36: * Default factory for this reference.
37: */
38: public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_RESOURCE_LINK_FACTORY;
39:
40: /**
41: * Description address type.
42: */
43: public static final String GLOBALNAME = "globalName";
44:
45: // ----------------------------------------------------------- Constructors
46:
47: /**
48: * ResourceLink Reference.
49: *
50: * @param resourceClass Resource class
51: * @param globalName Global name
52: */
53: public ResourceLinkRef(String resourceClass, String globalName) {
54: this (resourceClass, globalName, null, null);
55: }
56:
57: /**
58: * ResourceLink Reference.
59: *
60: * @param resourceClass Resource class
61: * @param globalName Global name
62: */
63: public ResourceLinkRef(String resourceClass, String globalName,
64: String factory, String factoryLocation) {
65: super (resourceClass, factory, factoryLocation);
66: StringRefAddr refAddr = null;
67: if (globalName != null) {
68: refAddr = new StringRefAddr(GLOBALNAME, globalName);
69: add(refAddr);
70: }
71: }
72:
73: // ----------------------------------------------------- Instance Variables
74:
75: // ------------------------------------------------------ Reference Methods
76:
77: /**
78: * Retrieves the class name of the factory of the object to which this
79: * reference refers.
80: */
81: public String getFactoryClassName() {
82: String factory = super .getFactoryClassName();
83: if (factory != null) {
84: return factory;
85: } else {
86: factory = System.getProperty(Context.OBJECT_FACTORIES);
87: if (factory != null) {
88: return null;
89: } else {
90: return DEFAULT_FACTORY;
91: }
92: }
93: }
94:
95: // ------------------------------------------------------------- Properties
96:
97: }
|