KickJava   Java API By Example, From Geeks To Geeks.

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


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
24 /**
25  * Represents a reference address to a resource environment.
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 ResourceEnvRef
32     extends Reference JavaDoc {
33
34
35     // -------------------------------------------------------------- Constants
36

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

41     public static final String JavaDoc DEFAULT_FACTORY =
42         org.apache.naming.factory.Constants.DEFAULT_RESOURCE_ENV_FACTORY;
43
44
45     // ----------------------------------------------------------- Constructors
46

47
48     /**
49      * Resource env reference.
50      *
51      * @param resourceType Type
52      */

53     public ResourceEnvRef(String JavaDoc resourceType) {
54         super(resourceType);
55     }
56
57
58     /**
59      * Resource env reference.
60      *
61      * @param resourceType Type
62      * @param factory The factory class
63      * @param factoryLocation The factory location
64      */

65     public ResourceEnvRef(String JavaDoc resourceType, String JavaDoc factory,
66                           String JavaDoc factoryLocation) {
67         super(resourceType, factory, factoryLocation);
68     }
69
70
71     // ----------------------------------------------------- Instance Variables
72

73
74     // ------------------------------------------------------ Reference Methods
75

76
77     /**
78      * Retrieves the class name of the factory of the object to which this
79      * reference refers.
80      */

81     public String JavaDoc getFactoryClassName() {
82         String JavaDoc 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
96     // ------------------------------------------------------------- Properties
97

98
99 }
100
Popular Tags