You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/07/10 09:19:34 UTC
[tomcat] branch 7.0.x updated: Clean-up. Align with 8.5.x
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new b04a324 Clean-up. Align with 8.5.x
b04a324 is described below
commit b04a3244183c6a3f5975064b06335a038a1f5970
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jul 10 10:19:20 2019 +0100
Clean-up. Align with 8.5.x
Spacing, use of final, fix Javadoc warnings/errors, better field naming,
improved i18n
---
.../org/apache/naming/ContextAccessController.java | 25 +-
java/org/apache/naming/ContextBindings.java | 296 +++++++++++----------
java/org/apache/naming/LocalStrings.properties | 10 +-
java/org/apache/naming/LocalStrings_es.properties | 10 +-
java/org/apache/naming/LocalStrings_fr.properties | 12 +-
java/org/apache/naming/LocalStrings_ja.properties | 10 +-
java/org/apache/naming/NamingContext.java | 48 ++--
java/org/apache/naming/NamingEntry.java | 19 --
java/org/apache/naming/SelectorContext.java | 118 ++++----
java/org/apache/naming/StringManager.java | 5 +-
java/org/apache/naming/package.html | 2 -
11 files changed, 285 insertions(+), 270 deletions(-)
diff --git a/java/org/apache/naming/ContextAccessController.java b/java/org/apache/naming/ContextAccessController.java
index 4821e8b..6dd81ac 100644
--- a/java/org/apache/naming/ContextAccessController.java
+++ b/java/org/apache/naming/ContextAccessController.java
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.naming;
import java.util.Hashtable;
@@ -27,27 +25,22 @@ import java.util.Hashtable;
*/
public class ContextAccessController {
-
// -------------------------------------------------------------- Variables
-
/**
* Catalina context names on which writing is not allowed.
*/
- private static Hashtable<Object,Object> readOnlyContexts =
- new Hashtable<Object,Object>();
+ private static final Hashtable<Object,Object> readOnlyContexts = new Hashtable<Object,Object>();
/**
* Security tokens repository.
*/
- private static Hashtable<Object,Object> securityTokens =
- new Hashtable<Object,Object>();
+ private static final Hashtable<Object,Object> securityTokens = new Hashtable<Object,Object>();
// --------------------------------------------------------- Public Methods
-
/**
* Set a security token for a Catalina context. Can be set only once.
*
@@ -81,12 +74,14 @@ public class ContextAccessController {
/**
- * Check a submitted security token. The submitted token must be equal to
- * the token present in the repository. If no token is present for the
- * context, then returns true.
+ * Check a submitted security token.
*
* @param name Name of the Catalina context
* @param token Submitted security token
+ *
+ * @return <code>true</code> if the submitted token is equal to the token
+ * in the repository or if no token is present in the repository.
+ * Otherwise, <code>false</code>
*/
public static boolean checkSecurityToken
(Object name, Object token) {
@@ -118,14 +113,14 @@ public class ContextAccessController {
/**
- * Returns if a context is writable.
+ * Is the context is writable?
*
* @param name Name of the Catalina context
+ *
+ * @return <code>true</code> if it is writable, otherwise <code>false</code>
*/
public static boolean isWritable(Object name) {
return !(readOnlyContexts.containsKey(name));
}
-
-
}
diff --git a/java/org/apache/naming/ContextBindings.java b/java/org/apache/naming/ContextBindings.java
index efbfe25..990d1e0 100644
--- a/java/org/apache/naming/ContextBindings.java
+++ b/java/org/apache/naming/ContextBindings.java
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.naming;
import java.util.Hashtable;
@@ -26,319 +24,343 @@ import javax.naming.NamingException;
/**
* Handles the associations :
* <ul>
- * <li>Catalina context name with the NamingContext</li>
- * <li>Calling thread with the NamingContext</li>
+ * <li>Object with a NamingContext</li>
+ * <li>Calling thread with a NamingContext</li>
+ * <li>Calling thread with object bound to the same naming context</li>
+ * <li>Thread context class loader with a NamingContext</li>
+ * <li>Thread context class loader with object bound to the same
+ * NamingContext</li>
* </ul>
+ * The objects are typically Catalina Server or Context objects.
*
* @author Remy Maucherat
*/
public class ContextBindings {
-
// -------------------------------------------------------------- Variables
-
/**
- * Bindings name - naming context. Keyed by name.
+ * Bindings object - naming context. Keyed by object.
*/
- private static final Hashtable<Object,Context> contextNameBindings =
- new Hashtable<Object,Context>();
+ private static final Hashtable<Object,Context> objectBindings = new Hashtable<Object,Context>();
/**
- * Bindings thread - naming context. Keyed by thread id.
+ * Bindings thread - naming context. Keyed by thread.
*/
- private static final Hashtable<Thread,Context> threadBindings =
- new Hashtable<Thread,Context>();
+ private static final Hashtable<Thread,Context> threadBindings = new Hashtable<Thread,Context>();
/**
- * Bindings thread - name. Keyed by thread id.
+ * Bindings thread - object. Keyed by thread.
*/
- private static final Hashtable<Thread,Object> threadNameBindings =
- new Hashtable<Thread,Object>();
+ private static final Hashtable<Thread,Object> threadObjectBindings = new Hashtable<Thread,Object>();
/**
- * Bindings class loader - naming context. Keyed by CL id.
+ * Bindings class loader - naming context. Keyed by class loader.
*/
- private static final Hashtable<ClassLoader,Context> clBindings =
- new Hashtable<ClassLoader,Context>();
+ private static final Hashtable<ClassLoader,Context> clBindings = new Hashtable<ClassLoader,Context>();
/**
- * Bindings class loader - name. Keyed by CL id.
+ * Bindings class loader - object. Keyed by class loader.
*/
- private static final Hashtable<ClassLoader,Object> clNameBindings =
- new Hashtable<ClassLoader,Object>();
+ private static final Hashtable<ClassLoader,Object> clObjectBindings = new Hashtable<ClassLoader,Object>();
/**
* The string manager for this package.
*/
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
+ protected static final StringManager sm = StringManager.getManager(ContextBindings.class);
// --------------------------------------------------------- Public Methods
-
/**
- * Binds a context name.
+ * Binds an object and a naming context.
*
- * @param name Name of the context
- * @param context Associated naming context instance
+ * @param obj Object to bind with naming context
+ * @param context Associated naming context instance
*/
- public static void bindContext(Object name, Context context) {
- bindContext(name, context, null);
+ public static void bindContext(Object obj, Context context) {
+ bindContext(obj, context, null);
}
/**
- * Binds a context name.
+ * Binds an object and a naming context.
*
- * @param name Name of the context
- * @param context Associated naming context instance
- * @param token Security token
+ * @param obj Object to bind with naming context
+ * @param context Associated naming context instance
+ * @param token Security token
*/
- public static void bindContext(Object name, Context context,
- Object token) {
- if (ContextAccessController.checkSecurityToken(name, token))
- contextNameBindings.put(name, context);
+ public static void bindContext(Object obj, Context context, Object token) {
+ if (ContextAccessController.checkSecurityToken(obj, token)) {
+ objectBindings.put(obj, context);
+ }
}
/**
- * Unbind context name.
+ * Unbinds an object and a naming context.
*
- * @param name Name of the context
+ * @param obj Object to unbind
*
* @deprecated - unused
*/
@Deprecated
- public static void unbindContext(Object name) {
- unbindContext(name, null);
+ public static void unbindContext(Object obj) {
+ unbindContext(obj, null);
}
/**
- * Unbind context name.
+ * Unbinds an object and a naming context.
*
- * @param name Name of the context
+ * @param obj Object to unbind
* @param token Security token
*/
- public static void unbindContext(Object name, Object token) {
- if (ContextAccessController.checkSecurityToken(name, token))
- contextNameBindings.remove(name);
+ public static void unbindContext(Object obj, Object token) {
+ if (ContextAccessController.checkSecurityToken(obj, token)) {
+ objectBindings.remove(obj);
+ }
}
/**
* Retrieve a naming context.
*
- * @param name Name of the context
+ * @param obj Object bound to the required naming context
*/
- static Context getContext(Object name) {
- return contextNameBindings.get(name);
+ static Context getContext(Object obj) {
+ return objectBindings.get(obj);
}
/**
* Binds a naming context to a thread.
*
- * @param name Name of the context
+ * @param obj Object bound to the required naming context
*
* @deprecated - unused
*/
@Deprecated
- public static void bindThread(Object name)
+ public static void bindThread(Object obj)
throws NamingException {
- bindThread(name, null);
+ bindThread(obj, null);
}
/**
* Binds a naming context to a thread.
*
- * @param name Name of the context
+ * @param obj Object bound to the required naming context
* @param token Security token
+ *
+ * @throws NamingException If no naming context is bound to the provided
+ * object
*/
- public static void bindThread(Object name, Object token)
- throws NamingException {
- if (ContextAccessController.checkSecurityToken(name, token)) {
- Context context = contextNameBindings.get(name);
- if (context == null)
- throw new NamingException
- (sm.getString("contextBindings.unknownContext", name));
+ public static void bindThread(Object obj, Object token) throws NamingException {
+ if (ContextAccessController.checkSecurityToken(obj, token)) {
+ Context context = objectBindings.get(obj);
+ if (context == null) {
+ throw new NamingException(
+ sm.getString("contextBindings.unknownContext", obj));
+ }
threadBindings.put(Thread.currentThread(), context);
- threadNameBindings.put(Thread.currentThread(), name);
+ threadObjectBindings.put(Thread.currentThread(), obj);
}
}
/**
- * Unbinds a naming context to a thread.
+ * Unbinds a thread and a naming context.
*
- * @param name Name of the context
+ * @param obj Object bound to the required naming context
*
* @deprecated - unused
*/
@Deprecated
- public static void unbindThread(Object name) {
- unbindThread(name, null);
+ public static void unbindThread(Object obj) {
+ unbindThread(obj, null);
}
/**
- * Unbinds a naming context to a thread.
+ * Unbinds a thread and a naming context.
*
- * @param name Name of the context
+ * @param obj Object bound to the required naming context
* @param token Security token
*/
- public static void unbindThread(Object name, Object token) {
- if (ContextAccessController.checkSecurityToken(name, token)) {
+ public static void unbindThread(Object obj, Object token) {
+ if (ContextAccessController.checkSecurityToken(obj, token)) {
threadBindings.remove(Thread.currentThread());
- threadNameBindings.remove(Thread.currentThread());
+ threadObjectBindings.remove(Thread.currentThread());
}
}
/**
- * Retrieves the naming context bound to a thread.
+ * Retrieves the naming context bound to the current thread.
+ *
+ * @return The naming context bound to the current thread.
+ *
+ * @throws NamingException If no naming context is bound to the current
+ * thread
*/
- public static Context getThread()
- throws NamingException {
+ public static Context getThread() throws NamingException {
Context context = threadBindings.get(Thread.currentThread());
- if (context == null)
+ if (context == null) {
throw new NamingException
- (sm.getString("contextBindings.noContextBoundToThread"));
+ (sm.getString("contextBindings.noContextBoundToThread"));
+ }
return context;
}
/**
- * Retrieves the naming context name bound to a thread.
+ * Retrieves the name of the object bound to the naming context that is also
+ * bound to the current thread.
*/
- static Object getThreadName()
- throws NamingException {
- Object name = threadNameBindings.get(Thread.currentThread());
- if (name == null)
+ static Object getThreadName() throws NamingException {
+ Object obj = threadObjectBindings.get(Thread.currentThread());
+ if (obj == null) {
throw new NamingException
- (sm.getString("contextBindings.noContextBoundToThread"));
- return name;
+ (sm.getString("contextBindings.noContextBoundToThread"));
+ }
+ return obj.toString();
}
/**
- * Tests if current thread is bound to a context.
+ * Tests if current thread is bound to a naming context.
+ *
+ * @return <code>true</code> if the current thread is bound to a naming
+ * context, otherwise <code>false</code>
*/
public static boolean isThreadBound() {
- return (threadBindings.containsKey(Thread.currentThread()));
+ return threadBindings.containsKey(Thread.currentThread());
}
/**
* Binds a naming context to a class loader.
*
- * @param name Name of the context
+ * @param obj Object bound to the required naming context
+ *
+ * @throws NamingException If no naming context is bound to the provided
+ * object
*
* @deprecated - unused
*/
@Deprecated
- public static void bindClassLoader(Object name)
+ public static void bindClassLoader(Object obj)
throws NamingException {
- bindClassLoader(name, null);
+ bindClassLoader(obj, null);
}
/**
- * Binds a naming context to a thread.
+ * Binds a naming context to a class loader.
*
- * @param name Name of the context
- * @param token Security token
+ * @param obj Object bound to the required naming context
+ * @param token Security token
+ *
+ * @throws NamingException If no naming context is bound to the provided
+ * object
*
* @deprecated - unused
*/
@Deprecated
- public static void bindClassLoader(Object name, Object token)
+ public static void bindClassLoader(Object obj, Object token)
throws NamingException {
bindClassLoader
- (name, token, Thread.currentThread().getContextClassLoader());
+ (obj, token, Thread.currentThread().getContextClassLoader());
}
/**
- * Binds a naming context to a thread.
+ * Binds a naming context to a class loader.
*
- * @param name Name of the context
- * @param token Security token
+ * @param obj Object bound to the required naming context
+ * @param token Security token
+ * @param classLoader The class loader to bind to the naming context
+ *
+ * @throws NamingException If no naming context is bound to the provided
+ * object
*/
- public static void bindClassLoader(Object name, Object token,
- ClassLoader classLoader)
- throws NamingException {
- if (ContextAccessController.checkSecurityToken(name, token)) {
- Context context = contextNameBindings.get(name);
- if (context == null)
+ public static void bindClassLoader(Object obj, Object token,
+ ClassLoader classLoader) throws NamingException {
+ if (ContextAccessController.checkSecurityToken(obj, token)) {
+ Context context = objectBindings.get(obj);
+ if (context == null) {
throw new NamingException
- (sm.getString("contextBindings.unknownContext", name));
+ (sm.getString("contextBindings.unknownContext", obj));
+ }
clBindings.put(classLoader, context);
- clNameBindings.put(classLoader, name);
+ clObjectBindings.put(classLoader, obj);
}
}
/**
- * Unbinds a naming context to a class loader.
+ * Unbinds a naming context and a class loader.
*
- * @param name Name of the context
+ * @param obj Object bound to the required naming context
*
* @deprecated - unused
*/
@Deprecated
- public static void unbindClassLoader(Object name) {
- unbindClassLoader(name, null);
+ public static void unbindClassLoader(Object obj) {
+ unbindClassLoader(obj, null);
}
/**
- * Unbinds a naming context to a class loader.
+ * Unbinds a naming context and a class loader.
*
- * @param name Name of the context
- * @param token Security token
+ * @param obj Object bound to the required naming context
+ * @param token Security token
*
* @deprecated - unused
*/
@Deprecated
- public static void unbindClassLoader(Object name, Object token) {
- unbindClassLoader(name, token,
+ public static void unbindClassLoader(Object obj, Object token) {
+ unbindClassLoader(obj, token,
Thread.currentThread().getContextClassLoader());
}
/**
- * Unbinds a naming context to a class loader.
+ * Unbinds a naming context and a class loader.
*
- * @param name Name of the context
- * @param token Security token
+ * @param obj Object bound to the required naming context
+ * @param token Security token
+ * @param classLoader The class loader bound to the naming context
*/
- public static void unbindClassLoader(Object name, Object token,
- ClassLoader classLoader) {
- if (ContextAccessController.checkSecurityToken(name, token)) {
- Object n = clNameBindings.get(classLoader);
- if ((n==null) || !(n.equals(name))) {
+ public static void unbindClassLoader(Object obj, Object token,
+ ClassLoader classLoader) {
+ if (ContextAccessController.checkSecurityToken(obj, token)) {
+ Object o = clObjectBindings.get(classLoader);
+ if (o == null || !o.equals(obj)) {
return;
}
clBindings.remove(classLoader);
- clNameBindings.remove(classLoader);
+ clObjectBindings.remove(classLoader);
}
}
/**
* Retrieves the naming context bound to a class loader.
+ *
+ * @return the naming context bound to current class loader or one of its
+ * parents
+ *
+ * @throws NamingException If no naming context was bound
*/
- public static Context getClassLoader()
- throws NamingException {
+ public static Context getClassLoader() throws NamingException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Context context = null;
do {
@@ -347,31 +369,33 @@ public class ContextBindings {
return context;
}
} while ((cl = cl.getParent()) != null);
- throw new NamingException
- (sm.getString("contextBindings.noContextBoundToCL"));
+ throw new NamingException(sm.getString("contextBindings.noContextBoundToCL"));
}
/**
- * Retrieves the naming context name bound to a class loader.
+ * Retrieves the name of the object bound to the naming context that is also
+ * bound to the thread context class loader.
*/
- static Object getClassLoaderName()
- throws NamingException {
+ static Object getClassLoaderName() throws NamingException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Object name = null;
+ Object obj = null;
do {
- name = clNameBindings.get(cl);
- if (name != null) {
- return name;
+ obj = clObjectBindings.get(cl);
+ if (obj != null) {
+ return obj.toString();
}
} while ((cl = cl.getParent()) != null);
- throw new NamingException
- (sm.getString("contextBindings.noContextBoundToCL"));
+ throw new NamingException (sm.getString("contextBindings.noContextBoundToCL"));
}
/**
- * Tests if current class loader is bound to a context.
+ * Tests if the thread context class loader is bound to a context.
+ *
+ * @return <code>true</code> if the thread context class loader or one of
+ * its parents is bound to a naming context, otherwise
+ * <code>false</code>
*/
public static boolean isClassLoaderBound() {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -382,6 +406,4 @@ public class ContextBindings {
} while ((cl = cl.getParent()) != null);
return false;
}
-
-
}
diff --git a/java/org/apache/naming/LocalStrings.properties b/java/org/apache/naming/LocalStrings.properties
index fa14030..952aaae 100644
--- a/java/org/apache/naming/LocalStrings.properties
+++ b/java/org/apache/naming/LocalStrings.properties
@@ -15,16 +15,16 @@
contextBindings.noContextBoundToCL=No naming context bound to this class loader
contextBindings.noContextBoundToThread=No naming context bound to this thread
-contextBindings.unknownContext=Unknown context name : {0}
+contextBindings.unknownContext=Unknown context name : [{0}]
-namingContext.alreadyBound=Name {0} is already bound in this Context
+namingContext.alreadyBound=Name [{0}] is already bound in this Context
namingContext.contextExpected=Name is not bound to a Context
namingContext.failResolvingReference=Unexpected exception resolving reference
namingContext.invalidName=Name is not valid
namingContext.nameNotBound=Name [{0}] is not bound in this Context. Unable to find [{1}].
-namingContext.noAbsoluteName=Can''t generate an absolute name for this namespace
+namingContext.noAbsoluteName=Cannot generate an absolute name for this namespace
namingContext.readOnly=Context is read only
-selectorContext.methodUsingName=Call to method ''{0}'' with a Name of ''{1}''
-selectorContext.methodUsingString=Call to method ''{0}'' with a String of ''{1}''
+selectorContext.methodUsingName=Call to method [{0}] with a Name of [{1}]
+selectorContext.methodUsingString=Call to method [{0}] with a String of [{1}]
selectorContext.noJavaUrl=This context must be accessed through a java: URL
diff --git a/java/org/apache/naming/LocalStrings_es.properties b/java/org/apache/naming/LocalStrings_es.properties
index 09968c4..72e75d6 100644
--- a/java/org/apache/naming/LocalStrings_es.properties
+++ b/java/org/apache/naming/LocalStrings_es.properties
@@ -15,16 +15,16 @@
contextBindings.noContextBoundToCL=No hay contexto de nombres asociado a este cargador de clase
contextBindings.noContextBoundToThread=No hay contexto de nombres asociado a este hilo
-contextBindings.unknownContext=Contexto {0} desconocido
+contextBindings.unknownContext=Contexto [{0}] desconocido
-namingContext.alreadyBound=El nombre {0} este ya asociado en este Contexto
+namingContext.alreadyBound=El nombre [{0}] este ya asociado en este Contexto
namingContext.contextExpected=El nombre no esta asociado a ningun Contexto
namingContext.failResolvingReference=Excepción inesperada resolviendo referencia
namingContext.invalidName=Nombre no valido
-namingContext.nameNotBound=El nombre {0} no este asociado a este contexto
+namingContext.nameNotBound=El nombre [{0}] no este asociado a este contexto
namingContext.noAbsoluteName=No se puede generar un nombre absoluto para este espacio de nombres
namingContext.readOnly=El contexto es de solo lectura
-selectorContext.methodUsingName=Llamada al método ''{0}'' con un Nombre de ''{1}''
-selectorContext.methodUsingString=Llamada al método ''{0}'' con una Cadena de ''{1}''
+selectorContext.methodUsingName=Llamada al método [{0}] con un Nombre de [{1}]
+selectorContext.methodUsingString=Llamada al método [{0}] con una Cadena de [{1}]
selectorContext.noJavaUrl=Este contexto debe de ser accedido a traves de una URL de tipo java:
diff --git a/java/org/apache/naming/LocalStrings_fr.properties b/java/org/apache/naming/LocalStrings_fr.properties
index 219fe12..33dd57d 100644
--- a/java/org/apache/naming/LocalStrings_fr.properties
+++ b/java/org/apache/naming/LocalStrings_fr.properties
@@ -15,14 +15,16 @@
contextBindings.noContextBoundToCL=Aucun Contexte de nommage lié à ce chargeur de classes
contextBindings.noContextBoundToThread=Aucun Contexte de nommage lié à ce thread
-contextBindings.unknownContext=Nom de Contexte inconnu : {0}
+contextBindings.unknownContext=Nom de Contexte inconnu : [{0}]
-namingContext.alreadyBound=Le Nom {0} est déjà lié à ce Contexte
-namingContext.contextExpected=Le Nom n''est pas lié à un Contexte
+namingContext.alreadyBound=Le Nom [{0}] est déjà lié à ce Contexte
+namingContext.contextExpected=Le Nom n'est pas lié à un Contexte
namingContext.failResolvingReference=Une erreur s est produite durant la résolution de la référence
namingContext.invalidName=Le Nom est invalide
-namingContext.nameNotBound=Le Nom {0} n''est pas lié à ce Contexte
+namingContext.nameNotBound=Le Nom [{0}] n''est pas lié à ce Contexte
namingContext.noAbsoluteName=Impossible de générer un nom absolu pour cet espace de nommage (namespace)
namingContext.readOnly=Le Contexte est en lecture seule
-selectorContext.noJavaUrl=Ce Contexte doit être accédé par une java: URL
+selectorContext.methodUsingName=Appel de la méthode [{0}] avec le nom [{1}]
+selectorContext.methodUsingString=Appel de la méthode [{0}] avec la String [{1}]
+selectorContext.noJavaUrl=Ce Contexte doit être accédé par une URL commençant par 'java:'
diff --git a/java/org/apache/naming/LocalStrings_ja.properties b/java/org/apache/naming/LocalStrings_ja.properties
index 5f00c0e..f976573 100644
--- a/java/org/apache/naming/LocalStrings_ja.properties
+++ b/java/org/apache/naming/LocalStrings_ja.properties
@@ -13,16 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-contextBindings.noContextBoundToCL=名前付けコンテキストはこのクラスローダにバインドされていません
+contextBindings.noContextBoundToCL=Naming Contextはこのクラスローダにバインドされていません
contextBindings.noContextBoundToThread=名前付けコンテキストはこのスレッドにバインドされていません
-contextBindings.unknownContext=未知のコンテキスト名です: {0}
+contextBindings.unknownContext=未知のコンテキスト名です: [{0}]
-namingContext.alreadyBound=名前 {0} は既にこのコンテキストにバインドされています
+namingContext.alreadyBound=名前 [{0}] は既にこのコンテキストにバインドされています
namingContext.contextExpected=名前がコンテキストにバインドされていません
namingContext.failResolvingReference=参照の解決中に予測しない例外が発生しました
namingContext.invalidName=名前は無効です
-namingContext.nameNotBound=名前 {0} はこのコンテキストにバインドされていません
+namingContext.nameNotBound=名前 [{0}] はこのコンテキストにバインドされていません
namingContext.noAbsoluteName=この名前空間に絶対名を生成できません
namingContext.readOnly=コンテキストはリードオンリーです
+selectorContext.methodUsingName=オブジェクト名 [{1}] に対してメソッド [{0}] を呼び出します。
+selectorContext.methodUsingString=メソッド[{0}]を[{1}]の文字列で呼び出します。
selectorContext.noJavaUrl=このコンテキストにはjava: URLを用いてアクセスされねばいけません
diff --git a/java/org/apache/naming/NamingContext.java b/java/org/apache/naming/NamingContext.java
index 6fc4fdc..5c22b3c 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -40,6 +40,9 @@ import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.spi.NamingManager;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
/**
* Catalina JNDI Context implementation.
*
@@ -57,8 +60,7 @@ public class NamingContext implements Context {
protected static final NameParser nameParser = new NameParserImpl();
- private static final org.apache.juli.logging.Log log =
- org.apache.juli.logging.LogFactory.getLog(NamingContext.class);
+ private static final Log log = LogFactory.getLog(NamingContext.class);
// ----------------------------------------------------------- Constructors
@@ -70,19 +72,8 @@ public class NamingContext implements Context {
* @param env The environment to use to construct the naming context
* @param name The name of the associated Catalina Context
*/
- public NamingContext(Hashtable<String,Object> env, String name)
- throws NamingException {
- this.bindings = new HashMap<String,NamingEntry>();
- this.env = new Hashtable<String,Object>();
- this.name = name;
- // Populating the environment hashtable
- if (env != null ) {
- Enumeration<String> envEntries = env.keys();
- while (envEntries.hasMoreElements()) {
- String entryName = envEntries.nextElement();
- addToEnvironment(entryName, env.get(entryName));
- }
- }
+ public NamingContext(Hashtable<String,Object> env, String name) {
+ this(env, name, new HashMap<String,NamingEntry>());
}
@@ -94,9 +85,18 @@ public class NamingContext implements Context {
* @param bindings The initial bindings for the naming context
*/
public NamingContext(Hashtable<String,Object> env, String name,
- HashMap<String,NamingEntry> bindings)
- throws NamingException {
- this(env, name);
+ HashMap<String,NamingEntry> bindings) {
+
+ this.env = new Hashtable<>();
+ this.name = name;
+ // Populating the environment hashtable
+ if (env != null ) {
+ Enumeration<String> envEntries = env.keys();
+ while (envEntries.hasMoreElements()) {
+ String entryName = envEntries.nextElement();
+ addToEnvironment(entryName, env.get(entryName));
+ }
+ }
this.bindings = bindings;
}
@@ -113,7 +113,7 @@ public class NamingContext implements Context {
/**
* The string manager for this package.
*/
- protected static final StringManager sm = StringManager.getManager(Constants.Package);
+ protected static final StringManager sm = StringManager.getManager(NamingContext.class);
/**
@@ -683,8 +683,7 @@ public class NamingContext implements Context {
* @exception NamingException if a naming exception is encountered
*/
@Override
- public Name composeName(Name name, Name prefix)
- throws NamingException {
+ public Name composeName(Name name, Name prefix) throws NamingException {
prefix = (Name) prefix.clone();
return prefix.addAll(name);
}
@@ -841,7 +840,7 @@ public class NamingContext implements Context {
// Link relative to this context
return lookup(link.substring(1));
} else {
- return (new InitialContext(env)).lookup(link);
+ return new InitialContext(env).lookup(link);
}
} else if (entry.type == NamingEntry.REFERENCE) {
try {
@@ -951,7 +950,7 @@ public class NamingContext implements Context {
/**
- * Returns true if writing is allowed on this context.
+ * @return <code>true</code> if writing is allowed on this context.
*/
protected boolean isWritable() {
return ContextAccessController.isWritable(name);
@@ -960,6 +959,9 @@ public class NamingContext implements Context {
/**
* Throws a naming exception is Context is not writable.
+ * @return <code>true</code> if the Context is writable
+ * @throws NamingException if the Context is not writable and
+ * <code>exceptionOnFailedWrite</code> is <code>true</code>
*/
protected boolean checkWritable() throws NamingException {
if (isWritable()) {
diff --git a/java/org/apache/naming/NamingEntry.java b/java/org/apache/naming/NamingEntry.java
index de6779c..ee7ed23 100644
--- a/java/org/apache/naming/NamingEntry.java
+++ b/java/org/apache/naming/NamingEntry.java
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.naming;
@@ -24,23 +22,14 @@ package org.apache.naming;
*
* @author Remy Maucherat
*/
-
public class NamingEntry {
-
- // -------------------------------------------------------------- Constants
-
-
public static final int ENTRY = 0;
public static final int LINK_REF = 1;
public static final int REFERENCE = 2;
-
public static final int CONTEXT = 10;
- // ----------------------------------------------------------- Constructors
-
-
public NamingEntry(String name, Object value, int type) {
this.name = name;
this.value = value;
@@ -48,9 +37,6 @@ public class NamingEntry {
}
- // ----------------------------------------------------- Instance Variables
-
-
/**
* The type instance variable is used to avoid using RTTI when doing
* lookups.
@@ -60,9 +46,6 @@ public class NamingEntry {
public Object value;
- // --------------------------------------------------------- Object Methods
-
-
@Override
public boolean equals(Object obj) {
if (obj instanceof NamingEntry) {
@@ -77,6 +60,4 @@ public class NamingEntry {
public int hashCode() {
return name.hashCode();
}
-
-
}
diff --git a/java/org/apache/naming/SelectorContext.java b/java/org/apache/naming/SelectorContext.java
index c98db71..ed0bd02 100644
--- a/java/org/apache/naming/SelectorContext.java
+++ b/java/org/apache/naming/SelectorContext.java
@@ -28,6 +28,9 @@ import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
/**
* Catalina JNDI Context implementation.
*
@@ -57,26 +60,30 @@ public class SelectorContext implements Context {
public static final String IC_PREFIX = "IC_";
- private static final org.apache.juli.logging.Log log =
- org.apache.juli.logging.LogFactory.getLog(SelectorContext.class);
+ private static final Log log = LogFactory.getLog(SelectorContext.class);
// ----------------------------------------------------------- Constructors
/**
* Builds a Catalina selector context using the given environment.
+ * @param env The environment
*/
public SelectorContext(Hashtable<String,Object> env) {
this.env = env;
+ this.initialContext = false;
}
/**
* Builds a Catalina selector context using the given environment.
+ * @param env The environment
+ * @param initialContext <code>true</code> if this is the main
+ * initial context
*/
public SelectorContext(Hashtable<String,Object> env,
boolean initialContext) {
- this(env);
+ this.env = env;
this.initialContext = initialContext;
}
@@ -116,7 +123,7 @@ public class SelectorContext implements Context {
*
* @param name the name of the object to look up
* @return the object bound to name
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Object lookup(Name name)
@@ -164,11 +171,11 @@ public class SelectorContext implements Context {
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception javax.naming.NameAlreadyBoundException if name is already
+ * @throws javax.naming.NameAlreadyBoundException if name is already
* bound
- * @exception javax.naming.directory.InvalidAttributesException if object did not
+ * @throws javax.naming.directory.InvalidAttributesException if object did not
* supply all mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void bind(Name name, Object obj)
@@ -182,11 +189,11 @@ public class SelectorContext implements Context {
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception javax.naming.NameAlreadyBoundException if name is already
+ * @throws javax.naming.NameAlreadyBoundException if name is already
* bound
- * @exception javax.naming.directory.InvalidAttributesException if object did not
+ * @throws javax.naming.directory.InvalidAttributesException if object did not
* supply all mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void bind(String name, Object obj)
@@ -206,9 +213,9 @@ public class SelectorContext implements Context {
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception javax.naming.directory.InvalidAttributesException if object did not
+ * @throws javax.naming.directory.InvalidAttributesException if object did not
* supply all mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void rebind(Name name, Object obj)
@@ -222,9 +229,9 @@ public class SelectorContext implements Context {
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception javax.naming.directory.InvalidAttributesException if object did not
+ * @throws javax.naming.directory.InvalidAttributesException if object did not
* supply all mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void rebind(String name, Object obj)
@@ -243,9 +250,9 @@ public class SelectorContext implements Context {
* NameNotFoundException if any of the intermediate contexts do not exist.
*
* @param name the name to bind; may not be empty
- * @exception javax.naming NameNotFoundException if an intermediate context
+ * @throws javax.naming.NameNotFoundException if an intermediate context
* does not exist
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void unbind(Name name)
@@ -258,9 +265,9 @@ public class SelectorContext implements Context {
* Unbinds the named object.
*
* @param name the name to bind; may not be empty
- * @exception javax.naming NameNotFoundException if an intermediate context
+ * @throws javax.naming.NameNotFoundException if an intermediate context
* does not exist
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void unbind(String name)
@@ -277,9 +284,9 @@ public class SelectorContext implements Context {
*
* @param oldName the name of the existing binding; may not be empty
* @param newName the name of the new binding; may not be empty
- * @exception javax.naming.NameAlreadyBoundException if name is already
+ * @throws javax.naming.NameAlreadyBoundException if name is already
* bound
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void rename(Name oldName, Name newName)
@@ -294,9 +301,9 @@ public class SelectorContext implements Context {
*
* @param oldName the name of the existing binding; may not be empty
* @param newName the name of the new binding; may not be empty
- * @exception javax.naming.NameAlreadyBoundException if name is already
+ * @throws javax.naming.NameAlreadyBoundException if name is already
* bound
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void rename(String oldName, String newName)
@@ -316,7 +323,7 @@ public class SelectorContext implements Context {
* @param name the name of the context to list
* @return an enumeration of the names and class names of the bindings in
* this context. Each element of the enumeration is of type NameClassPair.
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<NameClassPair> list(Name name)
@@ -338,7 +345,7 @@ public class SelectorContext implements Context {
* @param name the name of the context to list
* @return an enumeration of the names and class names of the bindings in
* this context. Each element of the enumeration is of type NameClassPair.
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<NameClassPair> list(String name)
@@ -364,7 +371,7 @@ public class SelectorContext implements Context {
* @param name the name of the context to list
* @return an enumeration of the bindings in this context.
* Each element of the enumeration is of type Binding.
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<Binding> listBindings(Name name)
@@ -386,7 +393,7 @@ public class SelectorContext implements Context {
* @param name the name of the context to list
* @return an enumeration of the bindings in this context.
* Each element of the enumeration is of type Binding.
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<Binding> listBindings(String name)
@@ -421,9 +428,9 @@ public class SelectorContext implements Context {
* the foreign context's "native" naming system.
*
* @param name the name of the context to be destroyed; may not be empty
- * @exception javax.naming NameNotFoundException if an intermediate context
+ * @throws javax.naming.NameNotFoundException if an intermediate context
* does not exist
- * @exception javax.naming.NotContextException if the name is bound but does
+ * @throws javax.naming.NotContextException if the name is bound but does
* not name a context, or does not name a context of the appropriate type
*/
@Override
@@ -437,9 +444,9 @@ public class SelectorContext implements Context {
* Destroys the named context and removes it from the namespace.
*
* @param name the name of the context to be destroyed; may not be empty
- * @exception javax.naming NameNotFoundException if an intermediate context
+ * @throws javax.naming.NameNotFoundException if an intermediate context
* does not exist
- * @exception javax.naming.NotContextException if the name is bound but does
+ * @throws javax.naming.NotContextException if the name is bound but does
* not name a context, or does not name a context of the appropriate type
*/
@Override
@@ -457,11 +464,11 @@ public class SelectorContext implements Context {
*
* @param name the name of the context to create; may not be empty
* @return the newly created context
- * @exception javax.naming.NameAlreadyBoundException if name is already
+ * @throws javax.naming.NameAlreadyBoundException if name is already
* bound
- * @exception javax.naming.directory.InvalidAttributesException if creation of the
+ * @throws javax.naming.directory.InvalidAttributesException if creation of the
* sub-context requires specification of mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Context createSubcontext(Name name)
@@ -475,11 +482,11 @@ public class SelectorContext implements Context {
*
* @param name the name of the context to create; may not be empty
* @return the newly created context
- * @exception javax.naming.NameAlreadyBoundException if name is already
+ * @throws javax.naming.NameAlreadyBoundException if name is already
* bound
- * @exception javax.naming.directory.InvalidAttributesException if creation of the
+ * @throws javax.naming.directory.InvalidAttributesException if creation of the
* sub-context requires specification of mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Context createSubcontext(String name)
@@ -496,7 +503,7 @@ public class SelectorContext implements Context {
* @param name the name of the object to look up
* @return the object bound to name, not following the terminal link
* (if any).
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Object lookupLink(Name name)
@@ -518,7 +525,7 @@ public class SelectorContext implements Context {
* @param name the name of the object to look up
* @return the object bound to name, not following the terminal link
* (if any).
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Object lookupLink(String name)
@@ -545,7 +552,7 @@ public class SelectorContext implements Context {
* @param name the name of the context from which to get the parser
* @return a name parser that can parse compound names into their atomic
* components
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public NameParser getNameParser(Name name)
@@ -560,7 +567,7 @@ public class SelectorContext implements Context {
* @param name the name of the context from which to get the parser
* @return a name parser that can parse compound names into their atomic
* components
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public NameParser getNameParser(String name)
@@ -582,7 +589,7 @@ public class SelectorContext implements Context {
* @param name a name relative to this context
* @param prefix the name of this context relative to one of its ancestors
* @return the composition of prefix and name
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Name composeName(Name name, Name prefix)
@@ -598,7 +605,7 @@ public class SelectorContext implements Context {
* @param name a name relative to this context
* @param prefix the name of this context relative to one of its ancestors
* @return the composition of prefix and name
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public String composeName(String name, String prefix)
@@ -614,7 +621,7 @@ public class SelectorContext implements Context {
* @param propName the name of the environment property to add; may not
* be null
* @param propVal the value of the property to add; may not be null
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Object addToEnvironment(String propName, Object propVal)
@@ -628,7 +635,7 @@ public class SelectorContext implements Context {
*
* @param propName the name of the environment property to remove;
* may not be null
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Object removeFromEnvironment(String propName)
@@ -645,7 +652,7 @@ public class SelectorContext implements Context {
* may be changed using addToEnvironment() and removeFromEnvironment().
*
* @return the environment of this context; never null
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public Hashtable<?,?> getEnvironment()
@@ -662,7 +669,7 @@ public class SelectorContext implements Context {
* been closed has no effect. Invoking any other method on a closed
* context is not allowed, and results in undefined behaviour.
*
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public void close()
@@ -684,9 +691,9 @@ public class SelectorContext implements Context {
* OperationNotSupportedException is thrown.
*
* @return this context's name in its own namespace; never null
- * @exception javax.naming.OperationNotSupportedException if the naming
+ * @throws javax.naming.OperationNotSupportedException if the naming
* system does not have the notion of a full name
- * @exception NamingException if a naming exception is encountered
+ * @throws NamingException if a naming exception is encountered
*/
@Override
public String getNameInNamespace()
@@ -700,6 +707,9 @@ public class SelectorContext implements Context {
/**
* Get the bound context.
+ * @return the Context bound with either the current thread or
+ * the current classloader
+ * @throws NamingException Bindings exception
*/
protected Context getBoundContext()
throws NamingException {
@@ -732,19 +742,19 @@ public class SelectorContext implements Context {
/**
* Strips the URL header.
- *
+ * @param name The name
* @return the parsed name
- * @exception NamingException if there is no "java:" header or if no
+ * @throws NamingException if there is no "java:" header or if no
* naming context has been bound to this thread
*/
protected String parseName(String name)
throws NamingException {
if ((!initialContext) && (name.startsWith(prefix))) {
- return (name.substring(prefixLength));
+ return name.substring(prefixLength);
} else {
if (initialContext) {
- return (name);
+ return name;
} else {
throw new NamingException
(sm.getString("selectorContext.noJavaUrl"));
@@ -756,9 +766,9 @@ public class SelectorContext implements Context {
/**
* Strips the URL header.
- *
+ * @param name The name
* @return the parsed name
- * @exception NamingException if there is no "java:" header or if no
+ * @throws NamingException if there is no "java:" header or if no
* naming context has been bound to this thread
*/
protected Name parseName(Name name)
diff --git a/java/org/apache/naming/StringManager.java b/java/org/apache/naming/StringManager.java
index b8cb795..663ce06 100644
--- a/java/org/apache/naming/StringManager.java
+++ b/java/org/apache/naming/StringManager.java
@@ -110,7 +110,10 @@ public class StringManager {
String str = null;
try {
- str = bundle.getString(key);
+ // Avoid NPE if bundle is null and treat it like an MRE
+ if (bundle != null) {
+ str = bundle.getString(key);
+ }
} catch(MissingResourceException mre) {
//bad: shouldn't mask an exception the following way:
// str = "[cannot find message associated with key '" + key + "' due to " + mre + "]";
diff --git a/java/org/apache/naming/package.html b/java/org/apache/naming/package.html
index 798fb28..c16c6d3 100644
--- a/java/org/apache/naming/package.html
+++ b/java/org/apache/naming/package.html
@@ -18,6 +18,4 @@
<p>This package contains a memory based naming service provider.</p>
-<p></p>
-
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org