This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 41dd39a24e253e78b13f184cdb1872d66d78afe7 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Apr 17 12:51:40 2025 +0100 Code clean-up - formatting. No functional change. --- .../org/apache/naming/ContextAccessController.java | 20 +-- java/org/apache/naming/ContextBindings.java | 74 ++++---- java/org/apache/naming/EjbRef.java | 25 ++- java/org/apache/naming/HandlerRef.java | 22 ++- java/org/apache/naming/NameParserImpl.java | 6 +- java/org/apache/naming/NamingContext.java | 189 ++++++++------------- .../naming/NamingContextBindingsEnumeration.java | 18 +- .../apache/naming/NamingContextEnumeration.java | 12 +- java/org/apache/naming/NamingEntry.java | 3 +- java/org/apache/naming/ResourceEnvRef.java | 3 +- java/org/apache/naming/ResourceLinkRef.java | 15 +- java/org/apache/naming/ResourceRef.java | 38 ++--- java/org/apache/naming/SelectorContext.java | 156 +++++++---------- java/org/apache/naming/ServiceRef.java | 24 ++- java/org/apache/naming/StringManager.java | 83 ++++----- java/org/apache/naming/TransactionRef.java | 5 +- .../apache/naming/java/javaURLContextFactory.java | 57 +++---- 17 files changed, 300 insertions(+), 450 deletions(-) diff --git a/java/org/apache/naming/ContextAccessController.java b/java/org/apache/naming/ContextAccessController.java index 0fad089be5..275ae39312 100644 --- a/java/org/apache/naming/ContextAccessController.java +++ b/java/org/apache/naming/ContextAccessController.java @@ -45,15 +45,13 @@ public class ContextAccessController { /** * Set a security token for a Catalina context. Can be set only once. * - * @param name Name of the Catalina context + * @param name Name of the Catalina context * @param token Security token */ public static void setSecurityToken(Object name, Object token) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPermission(new RuntimePermission( - ContextAccessController.class.getName() - + ".setSecurityToken")); + sm.checkPermission(new RuntimePermission(ContextAccessController.class.getName() + ".setSecurityToken")); } if ((!securityTokens.containsKey(name)) && (token != null)) { securityTokens.put(name, token); @@ -64,7 +62,7 @@ public class ContextAccessController { /** * Remove a security token for a context. * - * @param name Name of the Catalina context + * @param name Name of the Catalina context * @param token Security token */ public static void unsetSecurityToken(Object name, Object token) { @@ -77,15 +75,13 @@ public class ContextAccessController { /** * Check a submitted security token. * - * @param name Name of the Catalina context + * @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> + * @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) { + public static boolean checkSecurityToken(Object name, Object token) { Object refToken = securityTokens.get(name); return (refToken == null || refToken.equals(token)); } @@ -94,7 +90,7 @@ public class ContextAccessController { /** * Allow writing to a context. * - * @param name Name of the Catalina context + * @param name Name of the Catalina context * @param token Security token */ public static void setWritable(Object name, Object token) { diff --git a/java/org/apache/naming/ContextBindings.java b/java/org/apache/naming/ContextBindings.java index 17f93d3d81..22e0e99214 100644 --- a/java/org/apache/naming/ContextBindings.java +++ b/java/org/apache/naming/ContextBindings.java @@ -29,8 +29,7 @@ import javax.naming.NamingException; * <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> + * <li>Thread context class loader with object bound to the same NamingContext</li> * </ul> * The objects are typically Catalina Server or Context objects. * @@ -81,8 +80,8 @@ public class ContextBindings { /** * Binds an object and a naming context. * - * @param obj Object to bind with naming 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 obj, Context context) { bindContext(obj, context, null); @@ -92,9 +91,9 @@ public class ContextBindings { /** * Binds an object and a naming context. * - * @param obj Object to bind with naming 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 obj, Context context, Object token) { if (ContextAccessController.checkSecurityToken(obj, token)) { @@ -119,7 +118,7 @@ public class ContextBindings { /** * Retrieve a naming context. * - * @param obj Object bound to the required naming context + * @param obj Object bound to the required naming context */ static Context getContext(Object obj) { return objectBindings.get(obj); @@ -132,15 +131,13 @@ public class ContextBindings { * @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 + * @throws NamingException If no naming context is bound to the provided object */ 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)); + throw new NamingException(sm.getString("contextBindings.unknownContext", obj)); } Thread currentThread = Thread.currentThread(); threadBindings.put(currentThread, context); @@ -169,28 +166,24 @@ public class ContextBindings { * * @return The naming context bound to the current thread. * - * @throws NamingException If no naming context is bound to the current - * thread + * @throws NamingException If no naming context is bound to the current thread */ public static Context getThread() throws NamingException { Context context = threadBindings.get(Thread.currentThread()); if (context == null) { - throw new NamingException - (sm.getString("contextBindings.noContextBoundToThread")); + throw new NamingException(sm.getString("contextBindings.noContextBoundToThread")); } return context; } /** - * Retrieves the name of the object bound to the naming context that is also - * bound to the current thread. + * Retrieves the name of the object bound to the naming context that is also bound to the current thread. */ static String getThreadName() throws NamingException { Object obj = threadObjectBindings.get(Thread.currentThread()); if (obj == null) { - throw new NamingException - (sm.getString("contextBindings.noContextBoundToThread")); + throw new NamingException(sm.getString("contextBindings.noContextBoundToThread")); } return obj.toString(); } @@ -199,8 +192,7 @@ public class ContextBindings { /** * 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> + * @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()); @@ -210,20 +202,17 @@ public class ContextBindings { /** * Binds a naming context to a class loader. * - * @param obj Object bound to the required naming context - * @param token Security token - * @param classLoader The class loader to bind to the naming context + * @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 + * @throws NamingException If no naming context is bound to the provided object */ - public static void bindClassLoader(Object obj, Object token, - ClassLoader classLoader) throws NamingException { + 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", obj)); + throw new NamingException(sm.getString("contextBindings.unknownContext", obj)); } clBindings.put(classLoader, context); clObjectBindings.put(classLoader, obj); @@ -234,12 +223,11 @@ public class ContextBindings { /** * Unbinds a naming context and a class loader. * - * @param obj Object bound to the required naming context - * @param token Security token - * @param classLoader The class loader bound to the naming context + * @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 obj, Object token, - ClassLoader classLoader) { + 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)) { @@ -254,8 +242,7 @@ public class ContextBindings { /** * Retrieves the naming context bound to a class loader. * - * @return the naming context bound to current class loader or one of its - * parents + * @return the naming context bound to current class loader or one of its parents * * @throws NamingException If no naming context was bound */ @@ -273,8 +260,8 @@ public class ContextBindings { /** - * Retrieves the name of the object bound to the naming context that is also - * bound to the thread context class loader. + * Retrieves the name of the object bound to the naming context that is also bound to the thread context class + * loader. */ static String getClassLoaderName() throws NamingException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); @@ -285,16 +272,15 @@ public class ContextBindings { return obj.toString(); } } while ((cl = cl.getParent()) != null); - throw new NamingException (sm.getString("contextBindings.noContextBoundToCL")); + throw new NamingException(sm.getString("contextBindings.noContextBoundToCL")); } /** * 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> + * @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(); diff --git a/java/org/apache/naming/EjbRef.java b/java/org/apache/naming/EjbRef.java index 0083b7e41a..f768d32186 100644 --- a/java/org/apache/naming/EjbRef.java +++ b/java/org/apache/naming/EjbRef.java @@ -31,8 +31,7 @@ public class EjbRef extends AbstractRef { /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_EJB_FACTORY; + public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_EJB_FACTORY; /** @@ -57,9 +56,9 @@ public class EjbRef extends AbstractRef { * EJB Reference. * * @param ejbType EJB type - * @param home Home interface classname - * @param remote Remote interface classname - * @param link EJB link + * @param home Home interface classname + * @param remote Remote interface classname + * @param link EJB link */ public EjbRef(String ejbType, String home, String remote, String link) { this(ejbType, home, remote, link, null, null); @@ -69,16 +68,14 @@ public class EjbRef extends AbstractRef { /** * EJB Reference. * - * @param ejbType EJB type - * @param home Home interface classname - * @param remote Remote interface classname - * @param link EJB link - * @param factory The possibly null class name of the object's factory. - * @param factoryLocation The possibly null location from which to load - * the factory (e.g. URL) + * @param ejbType EJB type + * @param home Home interface classname + * @param remote Remote interface classname + * @param link EJB link + * @param factory The possibly null class name of the object's factory. + * @param factoryLocation The possibly null location from which to load the factory (e.g. URL) */ - public EjbRef(String ejbType, String home, String remote, String link, - String factory, String factoryLocation) { + public EjbRef(String ejbType, String home, String remote, String link, String factory, String factoryLocation) { super(home, factory, factoryLocation); StringRefAddr refAddr; if (ejbType != null) { diff --git a/java/org/apache/naming/HandlerRef.java b/java/org/apache/naming/HandlerRef.java index ece66497a1..61cc5adcea 100644 --- a/java/org/apache/naming/HandlerRef.java +++ b/java/org/apache/naming/HandlerRef.java @@ -31,56 +31,55 @@ public class HandlerRef extends AbstractRef { /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_HANDLER_FACTORY; + public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_HANDLER_FACTORY; /** * HandlerName address type. */ - public static final String HANDLER_NAME = "handlername"; + public static final String HANDLER_NAME = "handlername"; /** * Handler Classname address type. */ - public static final String HANDLER_CLASS = "handlerclass"; + public static final String HANDLER_CLASS = "handlerclass"; /** * Handler Classname address type. */ - public static final String HANDLER_LOCALPART = "handlerlocalpart"; + public static final String HANDLER_LOCALPART = "handlerlocalpart"; /** * Handler Classname address type. */ - public static final String HANDLER_NAMESPACE = "handlernamespace"; + public static final String HANDLER_NAMESPACE = "handlernamespace"; /** * Handler Classname address type. */ - public static final String HANDLER_PARAMNAME = "handlerparamname"; + public static final String HANDLER_PARAMNAME = "handlerparamname"; /** * Handler Classname address type. */ - public static final String HANDLER_PARAMVALUE = "handlerparamvalue"; + public static final String HANDLER_PARAMVALUE = "handlerparamvalue"; /** * Handler SoapRole address type. */ - public static final String HANDLER_SOAPROLE = "handlersoaprole"; + public static final String HANDLER_SOAPROLE = "handlersoaprole"; /** * Handler PortName address type. */ - public static final String HANDLER_PORTNAME = "handlerportname"; + public static final String HANDLER_PORTNAME = "handlerportname"; public HandlerRef(String refname, String handlerClass) { @@ -88,8 +87,7 @@ public class HandlerRef extends AbstractRef { } - public HandlerRef(String refname, String handlerClass, - String factory, String factoryLocation) { + public HandlerRef(String refname, String handlerClass, String factory, String factoryLocation) { super(refname, factory, factoryLocation); StringRefAddr refAddr; if (refname != null) { diff --git a/java/org/apache/naming/NameParserImpl.java b/java/org/apache/naming/NameParserImpl.java index f2650da31c..e2f585eb69 100644 --- a/java/org/apache/naming/NameParserImpl.java +++ b/java/org/apache/naming/NameParserImpl.java @@ -26,16 +26,14 @@ import javax.naming.NamingException; * * @author Remy Maucherat */ -public class NameParserImpl - implements NameParser { +public class NameParserImpl implements NameParser { // ----------------------------------------------------- NameParser Methods @Override - public Name parse(String name) - throws NamingException { + public Name parse(String name) throws NamingException { return new CompositeName(name); } diff --git a/java/org/apache/naming/NamingContext.java b/java/org/apache/naming/NamingContext.java index 53bac20977..9cb5579128 100644 --- a/java/org/apache/naming/NamingContext.java +++ b/java/org/apache/naming/NamingContext.java @@ -68,7 +68,7 @@ public class NamingContext implements Context { /** * Builds a naming context. * - * @param env The environment to use to construct the naming 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) { @@ -79,17 +79,16 @@ public class NamingContext implements Context { /** * Builds a naming context. * - * @param env The environment to use to construct the naming context - * @param name The name of the associated Catalina Context + * @param env The environment to use to construct the naming context + * @param name The name of the associated Catalina Context * @param bindings The initial bindings for the naming context */ - public NamingContext(Hashtable<String,Object> env, String name, - HashMap<String,NamingEntry> bindings) { + public NamingContext(Hashtable<String,Object> env, String name, HashMap<String,NamingEntry> bindings) { this.env = new Hashtable<>(); this.name = name; // Populating the environment hashtable - if (env != null ) { + if (env != null) { Enumeration<String> envEntries = env.keys(); while (envEntries.hasMoreElements()) { String entryName = envEntries.nextElement(); @@ -128,13 +127,14 @@ public class NamingContext implements Context { /** - * Determines if an attempt to write to a read-only context results in an - * exception or if the request is ignored. + * Determines if an attempt to write to a read-only context results in an exception or if the request is ignored. */ private boolean exceptionOnFailedWrite = true; + public boolean getExceptionOnFailedWrite() { return exceptionOnFailedWrite; } + public void setExceptionOnFailedWrite(boolean exceptionOnFailedWrite) { this.exceptionOnFailedWrite = exceptionOnFailedWrite; } @@ -143,43 +143,37 @@ public class NamingContext implements Context { // -------------------------------------------------------- Context Methods @Override - public Object lookup(Name name) - throws NamingException { + public Object lookup(Name name) throws NamingException { return lookup(name, true); } @Override - public Object lookup(String name) - throws NamingException { + public Object lookup(String name) throws NamingException { return lookup(new CompositeName(name), true); } @Override - public void bind(Name name, Object obj) - throws NamingException { + public void bind(Name name, Object obj) throws NamingException { bind(name, obj, false); } @Override - public void bind(String name, Object obj) - throws NamingException { + public void bind(String name, Object obj) throws NamingException { bind(new CompositeName(name), obj); } @Override - public void rebind(Name name, Object obj) - throws NamingException { + public void rebind(Name name, Object obj) throws NamingException { bind(name, obj, true); } @Override - public void rebind(String name, Object obj) - throws NamingException { + public void rebind(String name, Object obj) throws NamingException { rebind(new CompositeName(name), obj); } @@ -195,23 +189,20 @@ public class NamingContext implements Context { name = name.getSuffix(1); } if (name.isEmpty()) { - throw new NamingException - (sm.getString("namingContext.invalidName")); + throw new NamingException(sm.getString("namingContext.invalidName")); } NamingEntry entry = bindings.get(name.get(0)); if (entry == null) { - throw new NameNotFoundException - (sm.getString("namingContext.nameNotBound", name, name.get(0))); + throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); } if (name.size() > 1) { if (entry.type == NamingEntry.CONTEXT) { ((Context) entry.value).unbind(name.getSuffix(1)); } else { - throw new NamingException - (sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected")); } } else { bindings.remove(name.get(0)); @@ -221,15 +212,13 @@ public class NamingContext implements Context { @Override - public void unbind(String name) - throws NamingException { + public void unbind(String name) throws NamingException { unbind(new CompositeName(name)); } @Override - public void rename(Name oldName, Name newName) - throws NamingException { + public void rename(Name oldName, Name newName) throws NamingException { Object value = lookup(oldName); bind(newName, value); unbind(oldName); @@ -237,15 +226,13 @@ public class NamingContext implements Context { @Override - public void rename(String oldName, String newName) - throws NamingException { + public void rename(String oldName, String newName) throws NamingException { rename(new CompositeName(oldName), new CompositeName(newName)); } @Override - public NamingEnumeration<NameClassPair> list(Name name) - throws NamingException { + public NamingEnumeration<NameClassPair> list(Name name) throws NamingException { // Removing empty parts while ((!name.isEmpty()) && (name.get(0).isEmpty())) { name = name.getSuffix(1); @@ -257,28 +244,24 @@ public class NamingContext implements Context { NamingEntry entry = bindings.get(name.get(0)); if (entry == null) { - throw new NameNotFoundException - (sm.getString("namingContext.nameNotBound", name, name.get(0))); + throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); } if (entry.type != NamingEntry.CONTEXT) { - throw new NamingException - (sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected")); } return ((Context) entry.value).list(name.getSuffix(1)); } @Override - public NamingEnumeration<NameClassPair> list(String name) - throws NamingException { + public NamingEnumeration<NameClassPair> list(String name) throws NamingException { return list(new CompositeName(name)); } @Override - public NamingEnumeration<Binding> listBindings(Name name) - throws NamingException { + public NamingEnumeration<Binding> listBindings(Name name) throws NamingException { // Removing empty parts while ((!name.isEmpty()) && (name.get(0).isEmpty())) { name = name.getSuffix(1); @@ -290,21 +273,18 @@ public class NamingContext implements Context { NamingEntry entry = bindings.get(name.get(0)); if (entry == null) { - throw new NameNotFoundException - (sm.getString("namingContext.nameNotBound", name, name.get(0))); + throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); } if (entry.type != NamingEntry.CONTEXT) { - throw new NamingException - (sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected")); } return ((Context) entry.value).listBindings(name.getSuffix(1)); } @Override - public NamingEnumeration<Binding> listBindings(String name) - throws NamingException { + public NamingEnumeration<Binding> listBindings(String name) throws NamingException { return listBindings(new CompositeName(name)); } @@ -320,31 +300,27 @@ public class NamingContext implements Context { name = name.getSuffix(1); } if (name.isEmpty()) { - throw new NamingException - (sm.getString("namingContext.invalidName")); + throw new NamingException(sm.getString("namingContext.invalidName")); } NamingEntry entry = bindings.get(name.get(0)); if (entry == null) { - throw new NameNotFoundException - (sm.getString("namingContext.nameNotBound", name, name.get(0))); + throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); } if (name.size() > 1) { if (entry.type == NamingEntry.CONTEXT) { ((Context) entry.value).destroySubcontext(name.getSuffix(1)); } else { - throw new NamingException - (sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected")); } } else { if (entry.type == NamingEntry.CONTEXT) { ((Context) entry.value).close(); bindings.remove(name.get(0)); } else { - throw new NotContextException - (sm.getString("namingContext.contextExpected")); + throw new NotContextException(sm.getString("namingContext.contextExpected")); } } @@ -352,8 +328,7 @@ public class NamingContext implements Context { @Override - public void destroySubcontext(String name) - throws NamingException { + public void destroySubcontext(String name) throws NamingException { destroySubcontext(new CompositeName(name)); } @@ -374,29 +349,25 @@ public class NamingContext implements Context { @Override - public Context createSubcontext(String name) - throws NamingException { + public Context createSubcontext(String name) throws NamingException { return createSubcontext(new CompositeName(name)); } @Override - public Object lookupLink(Name name) - throws NamingException { + public Object lookupLink(Name name) throws NamingException { return lookup(name, false); } @Override - public Object lookupLink(String name) - throws NamingException { + public Object lookupLink(String name) throws NamingException { return lookup(new CompositeName(name), false); } @Override - public NameParser getNameParser(Name name) - throws NamingException { + public NameParser getNameParser(Name name) throws NamingException { while ((!name.isEmpty()) && (name.get(0).isEmpty())) { name = name.getSuffix(1); @@ -410,8 +381,7 @@ public class NamingContext implements Context { if (obj instanceof Context) { return ((Context) obj).getNameParser(name.getSuffix(1)); } else { - throw new NotContextException - (sm.getString("namingContext.contextExpected")); + throw new NotContextException(sm.getString("namingContext.contextExpected")); } } @@ -421,8 +391,7 @@ public class NamingContext implements Context { @Override - public NameParser getNameParser(String name) - throws NamingException { + public NameParser getNameParser(String name) throws NamingException { return getNameParser(new CompositeName(name)); } @@ -447,7 +416,7 @@ public class NamingContext implements Context { @Override - public Object removeFromEnvironment(String propName){ + public Object removeFromEnvironment(String propName) { return env.remove(propName); } @@ -468,10 +437,8 @@ public class NamingContext implements Context { @Override - public String getNameInNamespace() - throws NamingException { - throw new OperationNotSupportedException - (sm.getString("namingContext.noAbsoluteName")); + public String getNameInNamespace() throws NamingException { + throw new OperationNotSupportedException(sm.getString("namingContext.noAbsoluteName")); } @@ -496,13 +463,14 @@ public class NamingContext implements Context { /** * Retrieves the named object. * - * @param name the name of the object to look up + * @param name the name of the object to look up * @param resolveLinks If true, the links will be resolved + * * @return the object bound to name + * * @exception NamingException if a naming exception is encountered */ - protected Object lookup(Name name, boolean resolveLinks) - throws NamingException { + protected Object lookup(Name name, boolean resolveLinks) throws NamingException { // Removing empty parts while ((!name.isEmpty()) && (name.get(0).isEmpty())) { @@ -516,16 +484,14 @@ public class NamingContext implements Context { NamingEntry entry = bindings.get(name.get(0)); if (entry == null) { - throw new NameNotFoundException - (sm.getString("namingContext.nameNotBound", name, name.get(0))); + throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); } if (name.size() > 1) { // If the size of the name is greater than 1, then we go through a // number of sub contexts. if (entry.type != NamingEntry.CONTEXT) { - throw new NamingException - (sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected")); } return ((Context) entry.value).lookup(name.getSuffix(1)); } else { @@ -556,8 +522,7 @@ public class NamingContext implements Context { } if (entry.value instanceof ResourceRef) { boolean singleton = Boolean.parseBoolean( - (String) ((ResourceRef) entry.value).get( - ResourceRef.SINGLETON).getContent()); + (String) ((ResourceRef) entry.value).get(ResourceRef.SINGLETON).getContent()); if (singleton) { entry.type = NamingEntry.ENTRY; entry.value = obj; @@ -585,20 +550,18 @@ public class NamingContext implements Context { /** - * Binds a name to an object. All intermediate contexts and the target - * context (that named by all but terminal atomic component of the name) - * must already exist. + * Binds a name to an object. All intermediate contexts and the target context (that named by all but terminal + * atomic component of the name) must already exist. * - * @param name the name to bind; may not be empty - * @param obj the object to bind; possibly null + * @param name the name to bind; may not be empty + * @param obj the object to bind; possibly null * @param rebind if true, then perform a rebind (ie, overwrite) - * @exception NameAlreadyBoundException if name is already bound - * @exception javax.naming.directory.InvalidAttributesException if object - * did not supply all mandatory attributes - * @exception NamingException if a naming exception is encountered + * + * @exception NameAlreadyBoundException if name is already bound + * @exception javax.naming.directory.InvalidAttributesException if object did not supply all mandatory attributes + * @exception NamingException if a naming exception is encountered */ - protected void bind(Name name, Object obj, boolean rebind) - throws NamingException { + protected void bind(Name name, Object obj, boolean rebind) throws NamingException { if (!checkWritable()) { return; @@ -608,16 +571,14 @@ public class NamingContext implements Context { name = name.getSuffix(1); } if (name.isEmpty()) { - throw new NamingException - (sm.getString("namingContext.invalidName")); + throw new NamingException(sm.getString("namingContext.invalidName")); } NamingEntry entry = bindings.get(name.get(0)); if (name.size() > 1) { if (entry == null) { - throw new NameNotFoundException(sm.getString( - "namingContext.nameNotBound", name, name.get(0))); + throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); } if (entry.type == NamingEntry.CONTEXT) { if (rebind) { @@ -626,34 +587,26 @@ public class NamingContext implements Context { ((Context) entry.value).bind(name.getSuffix(1), obj); } } else { - throw new NamingException - (sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected")); } } else { if ((!rebind) && (entry != null)) { - throw new NameAlreadyBoundException - (sm.getString("namingContext.alreadyBound", name.get(0))); + throw new NameAlreadyBoundException(sm.getString("namingContext.alreadyBound", name.get(0))); } else { // Getting the type of the object and wrapping it within a new // NamingEntry - Object toBind = - NamingManager.getStateToBind(obj, name, this, env); + Object toBind = NamingManager.getStateToBind(obj, name, this, env); if (toBind instanceof Context) { - entry = new NamingEntry(name.get(0), toBind, - NamingEntry.CONTEXT); + entry = new NamingEntry(name.get(0), toBind, NamingEntry.CONTEXT); } else if (toBind instanceof LinkRef) { - entry = new NamingEntry(name.get(0), toBind, - NamingEntry.LINK_REF); + entry = new NamingEntry(name.get(0), toBind, NamingEntry.LINK_REF); } else if (toBind instanceof Reference) { - entry = new NamingEntry(name.get(0), toBind, - NamingEntry.REFERENCE); + entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else if (toBind instanceof Referenceable) { toBind = ((Referenceable) toBind).getReference(); - entry = new NamingEntry(name.get(0), toBind, - NamingEntry.REFERENCE); + entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else { - entry = new NamingEntry(name.get(0), toBind, - NamingEntry.ENTRY); + entry = new NamingEntry(name.get(0), toBind, NamingEntry.ENTRY); } bindings.put(name.get(0), entry); } @@ -672,9 +625,11 @@ 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> + * + * @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/NamingContextBindingsEnumeration.java b/java/org/apache/naming/NamingContextBindingsEnumeration.java index 0b939a8ec2..902072b323 100644 --- a/java/org/apache/naming/NamingContextBindingsEnumeration.java +++ b/java/org/apache/naming/NamingContextBindingsEnumeration.java @@ -29,15 +29,13 @@ import javax.naming.NamingException; * * @author Remy Maucherat */ -public class NamingContextBindingsEnumeration - implements NamingEnumeration<Binding> { +public class NamingContextBindingsEnumeration implements NamingEnumeration<Binding> { // ----------------------------------------------------------- Constructors - public NamingContextBindingsEnumeration(Iterator<NamingEntry> entries, - Context ctx) { + public NamingContextBindingsEnumeration(Iterator<NamingEntry> entries, Context ctx) { iterator = entries; this.ctx = ctx; } @@ -61,22 +59,19 @@ public class NamingContextBindingsEnumeration @Override - public Binding next() - throws NamingException { + public Binding next() throws NamingException { return nextElementInternal(); } @Override - public boolean hasMore() - throws NamingException { + public boolean hasMore() throws NamingException { return iterator.hasNext(); } @Override - public void close() - throws NamingException { + public void close() throws NamingException { } @@ -100,8 +95,7 @@ public class NamingContextBindingsEnumeration Object value; // If the entry is a reference, resolve it - if (entry.type == NamingEntry.REFERENCE - || entry.type == NamingEntry.LINK_REF) { + if (entry.type == NamingEntry.REFERENCE || entry.type == NamingEntry.LINK_REF) { try { value = ctx.lookup(new CompositeName(entry.name)); } catch (NamingException e) { diff --git a/java/org/apache/naming/NamingContextEnumeration.java b/java/org/apache/naming/NamingContextEnumeration.java index e2c8fd7e00..5eecd67853 100644 --- a/java/org/apache/naming/NamingContextEnumeration.java +++ b/java/org/apache/naming/NamingContextEnumeration.java @@ -27,8 +27,7 @@ import javax.naming.NamingException; * * @author Remy Maucherat */ -public class NamingContextEnumeration - implements NamingEnumeration<NameClassPair> { +public class NamingContextEnumeration implements NamingEnumeration<NameClassPair> { // ----------------------------------------------------------- Constructors @@ -52,22 +51,19 @@ public class NamingContextEnumeration @Override - public NameClassPair next() - throws NamingException { + public NameClassPair next() throws NamingException { return nextElement(); } @Override - public boolean hasMore() - throws NamingException { + public boolean hasMore() throws NamingException { return iterator.hasNext(); } @Override - public void close() - throws NamingException { + public void close() throws NamingException { } diff --git a/java/org/apache/naming/NamingEntry.java b/java/org/apache/naming/NamingEntry.java index c1a7273c55..b340c0a89e 100644 --- a/java/org/apache/naming/NamingEntry.java +++ b/java/org/apache/naming/NamingEntry.java @@ -38,8 +38,7 @@ public class NamingEntry { /** - * The type instance variable is used to avoid using RTTI when doing - * lookups. + * The type instance variable is used to avoid using RTTI when doing lookups. */ public int type; public final String name; diff --git a/java/org/apache/naming/ResourceEnvRef.java b/java/org/apache/naming/ResourceEnvRef.java index 8d1c222a2b..79556730b0 100644 --- a/java/org/apache/naming/ResourceEnvRef.java +++ b/java/org/apache/naming/ResourceEnvRef.java @@ -29,8 +29,7 @@ public class ResourceEnvRef extends AbstractRef { /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_RESOURCE_ENV_FACTORY; + public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_RESOURCE_ENV_FACTORY; /** diff --git a/java/org/apache/naming/ResourceLinkRef.java b/java/org/apache/naming/ResourceLinkRef.java index a66f4da9f9..008d6711da 100644 --- a/java/org/apache/naming/ResourceLinkRef.java +++ b/java/org/apache/naming/ResourceLinkRef.java @@ -31,8 +31,7 @@ public class ResourceLinkRef extends AbstractRef { /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_RESOURCE_LINK_FACTORY; + public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_RESOURCE_LINK_FACTORY; /** @@ -44,14 +43,12 @@ public class ResourceLinkRef extends AbstractRef { /** * ResourceLink Reference. * - * @param resourceClass Resource class - * @param globalName Global name - * @param factory The possibly null class name of the object's factory. - * @param factoryLocation The possibly null location from which to load the - * factory (e.g. URL) + * @param resourceClass Resource class + * @param globalName Global name + * @param factory The possibly null class name of the object's factory. + * @param factoryLocation The possibly null location from which to load the factory (e.g. URL) */ - public ResourceLinkRef(String resourceClass, String globalName, - String factory, String factoryLocation) { + public ResourceLinkRef(String resourceClass, String globalName, String factory, String factoryLocation) { super(resourceClass, factory, factoryLocation); if (globalName != null) { add(new StringRefAddr(GLOBALNAME, globalName)); diff --git a/java/org/apache/naming/ResourceRef.java b/java/org/apache/naming/ResourceRef.java index 2b84e08f73..b045cf3112 100644 --- a/java/org/apache/naming/ResourceRef.java +++ b/java/org/apache/naming/ResourceRef.java @@ -31,8 +31,7 @@ public class ResourceRef extends AbstractRef { /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_RESOURCE_FACTORY; + public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_RESOURCE_FACTORY; /** @@ -63,14 +62,13 @@ public class ResourceRef extends AbstractRef { * Resource Reference. * * @param resourceClass Resource class - * @param description Description of the resource - * @param scope Resource scope - * @param auth Resource authentication - * @param singleton Is this resource a singleton (every lookup should return - * the same instance rather than a new instance)? + * @param description Description of the resource + * @param scope Resource scope + * @param auth Resource authentication + * @param singleton Is this resource a singleton (every lookup should return the same instance rather than a new + * instance)? */ - public ResourceRef(String resourceClass, String description, - String scope, String auth, boolean singleton) { + public ResourceRef(String resourceClass, String description, String scope, String auth, boolean singleton) { this(resourceClass, description, scope, auth, singleton, null, null); } @@ -78,19 +76,17 @@ public class ResourceRef extends AbstractRef { /** * Resource Reference. * - * @param resourceClass Resource class - * @param description Description of the resource - * @param scope Resource scope - * @param auth Resource authentication - * @param singleton Is this resource a singleton (every lookup should return - * the same instance rather than a new instance)? - * @param factory The possibly null class name of the object's factory. - * @param factoryLocation The possibly null location from which to load the - * factory (e.g. URL) + * @param resourceClass Resource class + * @param description Description of the resource + * @param scope Resource scope + * @param auth Resource authentication + * @param singleton Is this resource a singleton (every lookup should return the same instance rather than a + * new instance)? + * @param factory The possibly null class name of the object's factory. + * @param factoryLocation The possibly null location from which to load the factory (e.g. URL) */ - public ResourceRef(String resourceClass, String description, - String scope, String auth, boolean singleton, - String factory, String factoryLocation) { + public ResourceRef(String resourceClass, String description, String scope, String auth, boolean singleton, + String factory, String factoryLocation) { super(resourceClass, factory, factoryLocation); StringRefAddr refAddr; if (description != null) { diff --git a/java/org/apache/naming/SelectorContext.java b/java/org/apache/naming/SelectorContext.java index af2a2d12f2..2be6366ed3 100644 --- a/java/org/apache/naming/SelectorContext.java +++ b/java/org/apache/naming/SelectorContext.java @@ -65,6 +65,7 @@ public class SelectorContext implements Context { /** * Builds a Catalina selector context using the given environment. + * * @param env The environment */ public SelectorContext(Hashtable<String,Object> env) { @@ -75,12 +76,11 @@ public class SelectorContext implements Context { /** * 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 + * + * @param env The environment + * @param initialContext <code>true</code> if this is the main initial context */ - public SelectorContext(Hashtable<String,Object> env, - boolean initialContext) { + public SelectorContext(Hashtable<String,Object> env, boolean initialContext) { this.env = env; this.initialContext = initialContext; } @@ -114,12 +114,10 @@ public class SelectorContext implements Context { @Override - public Object lookup(Name name) - throws NamingException { + public Object lookup(Name name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingName", "lookup", - name)); + log.trace(sm.getString("selectorContext.methodUsingName", "lookup", name)); } // Strip the URL header @@ -130,12 +128,10 @@ public class SelectorContext implements Context { @Override - public Object lookup(String name) - throws NamingException { + public Object lookup(String name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingString", "lookup", - name)); + log.trace(sm.getString("selectorContext.methodUsingString", "lookup", name)); } // Strip the URL header @@ -146,68 +142,58 @@ public class SelectorContext implements Context { @Override - public void bind(Name name, Object obj) - throws NamingException { + public void bind(Name name, Object obj) throws NamingException { getBoundContext().bind(parseName(name), obj); } @Override - public void bind(String name, Object obj) - throws NamingException { + public void bind(String name, Object obj) throws NamingException { getBoundContext().bind(parseName(name), obj); } @Override - public void rebind(Name name, Object obj) - throws NamingException { + public void rebind(Name name, Object obj) throws NamingException { getBoundContext().rebind(parseName(name), obj); } @Override - public void rebind(String name, Object obj) - throws NamingException { + public void rebind(String name, Object obj) throws NamingException { getBoundContext().rebind(parseName(name), obj); } @Override - public void unbind(Name name) - throws NamingException { + public void unbind(Name name) throws NamingException { getBoundContext().unbind(parseName(name)); } @Override - public void unbind(String name) - throws NamingException { + public void unbind(String name) throws NamingException { getBoundContext().unbind(parseName(name)); } @Override - public void rename(Name oldName, Name newName) - throws NamingException { + public void rename(Name oldName, Name newName) throws NamingException { getBoundContext().rename(parseName(oldName), parseName(newName)); } @Override - public void rename(String oldName, String newName) - throws NamingException { + public void rename(String oldName, String newName) throws NamingException { getBoundContext().rename(parseName(oldName), parseName(newName)); } @Override - public NamingEnumeration<NameClassPair> list(Name name) - throws NamingException { + public NamingEnumeration<NameClassPair> list(Name name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingName", "list", - name)); + log.trace(sm.getString("selectorContext.methodUsingName", "list", name)); } return getBoundContext().list(parseName(name)); @@ -215,12 +201,10 @@ public class SelectorContext implements Context { @Override - public NamingEnumeration<NameClassPair> list(String name) - throws NamingException { + public NamingEnumeration<NameClassPair> list(String name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingString", "list", - name)); + log.trace(sm.getString("selectorContext.methodUsingString", "list", name)); } return getBoundContext().list(parseName(name)); @@ -228,12 +212,10 @@ public class SelectorContext implements Context { @Override - public NamingEnumeration<Binding> listBindings(Name name) - throws NamingException { + public NamingEnumeration<Binding> listBindings(Name name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingName", - "listBindings", name)); + log.trace(sm.getString("selectorContext.methodUsingName", "listBindings", name)); } return getBoundContext().listBindings(parseName(name)); @@ -241,12 +223,10 @@ public class SelectorContext implements Context { @Override - public NamingEnumeration<Binding> listBindings(String name) - throws NamingException { + public NamingEnumeration<Binding> listBindings(String name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingString", - "listBindings", name)); + log.trace(sm.getString("selectorContext.methodUsingString", "listBindings", name)); } return getBoundContext().listBindings(parseName(name)); @@ -254,40 +234,34 @@ public class SelectorContext implements Context { @Override - public void destroySubcontext(Name name) - throws NamingException { + public void destroySubcontext(Name name) throws NamingException { getBoundContext().destroySubcontext(parseName(name)); } @Override - public void destroySubcontext(String name) - throws NamingException { + public void destroySubcontext(String name) throws NamingException { getBoundContext().destroySubcontext(parseName(name)); } @Override - public Context createSubcontext(Name name) - throws NamingException { + public Context createSubcontext(Name name) throws NamingException { return getBoundContext().createSubcontext(parseName(name)); } @Override - public Context createSubcontext(String name) - throws NamingException { + public Context createSubcontext(String name) throws NamingException { return getBoundContext().createSubcontext(parseName(name)); } @Override - public Object lookupLink(Name name) - throws NamingException { + public Object lookupLink(Name name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingName", - "lookupLink", name)); + log.trace(sm.getString("selectorContext.methodUsingName", "lookupLink", name)); } return getBoundContext().lookupLink(parseName(name)); @@ -295,12 +269,10 @@ public class SelectorContext implements Context { @Override - public Object lookupLink(String name) - throws NamingException { + public Object lookupLink(String name) throws NamingException { if (log.isTraceEnabled()) { - log.trace(sm.getString("selectorContext.methodUsingString", - "lookupLink", name)); + log.trace(sm.getString("selectorContext.methodUsingString", "lookupLink", name)); } return getBoundContext().lookupLink(parseName(name)); @@ -308,65 +280,56 @@ public class SelectorContext implements Context { @Override - public NameParser getNameParser(Name name) - throws NamingException { + public NameParser getNameParser(Name name) throws NamingException { return getBoundContext().getNameParser(parseName(name)); } @Override - public NameParser getNameParser(String name) - throws NamingException { + public NameParser getNameParser(String name) throws NamingException { return getBoundContext().getNameParser(parseName(name)); } @Override - public Name composeName(Name name, Name prefix) - throws NamingException { + public Name composeName(Name name, Name prefix) throws NamingException { Name prefixClone = (Name) prefix.clone(); return prefixClone.addAll(name); } @Override - public String composeName(String name, String prefix) - throws NamingException { + public String composeName(String name, String prefix) throws NamingException { return prefix + "/" + name; } @Override - public Object addToEnvironment(String propName, Object propVal) - throws NamingException { + public Object addToEnvironment(String propName, Object propVal) throws NamingException { return getBoundContext().addToEnvironment(propName, propVal); } @Override - public Object removeFromEnvironment(String propName) - throws NamingException { + public Object removeFromEnvironment(String propName) throws NamingException { return getBoundContext().removeFromEnvironment(propName); } @Override - public Hashtable<?,?> getEnvironment() - throws NamingException { + public Hashtable<?,?> getEnvironment() throws NamingException { return getBoundContext().getEnvironment(); } @Override - public void close() - throws NamingException { + public void close() throws NamingException { getBoundContext().close(); } @Override - public String getNameInNamespace() - throws NamingException { + public String getNameInNamespace() throws NamingException { return prefix; } @@ -376,12 +339,12 @@ public class SelectorContext implements Context { /** * Get the bound context. - * @return the Context bound with either the current thread or - * the current classloader + * + * @return the Context bound with either the current thread or the current classloader + * * @throws NamingException Bindings exception */ - protected Context getBoundContext() - throws NamingException { + protected Context getBoundContext() throws NamingException { if (initialContext) { String ICName = IC_PREFIX; @@ -411,13 +374,14 @@ public class SelectorContext implements Context { /** * Strips the URL header. + * * @param name The name + * * @return the parsed name - * @throws NamingException if there is no "java:" header or if no - * naming context has been bound to this thread + * + * @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 { + protected String parseName(String name) throws NamingException { if ((!initialContext) && (name.startsWith(prefix))) { return name.substring(prefixLength); @@ -425,8 +389,7 @@ public class SelectorContext implements Context { if (initialContext) { return name; } else { - throw new NamingException - (sm.getString("selectorContext.noJavaUrl")); + throw new NamingException(sm.getString("selectorContext.noJavaUrl")); } } @@ -435,16 +398,16 @@ public class SelectorContext implements Context { /** * Strips the URL header. + * * @param name The name + * * @return the parsed name - * @throws NamingException if there is no "java:" header or if no - * naming context has been bound to this thread + * + * @throws NamingException if there is no "java:" header or if no naming context has been bound to this thread */ - protected Name parseName(Name name) - throws NamingException { + protected Name parseName(Name name) throws NamingException { - if (!initialContext && !name.isEmpty() && - name.get(0).startsWith(prefix)) { + if (!initialContext && !name.isEmpty() && name.get(0).startsWith(prefix)) { if (name.get(0).equals(prefix)) { return name.getSuffix(1); } else { @@ -456,8 +419,7 @@ public class SelectorContext implements Context { if (initialContext) { return name; } else { - throw new NamingException( - sm.getString("selectorContext.noJavaUrl")); + throw new NamingException(sm.getString("selectorContext.noJavaUrl")); } } diff --git a/java/org/apache/naming/ServiceRef.java b/java/org/apache/naming/ServiceRef.java index c9f1c89552..00f41797d2 100644 --- a/java/org/apache/naming/ServiceRef.java +++ b/java/org/apache/naming/ServiceRef.java @@ -34,20 +34,19 @@ public class ServiceRef extends AbstractRef { /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_SERVICE_FACTORY; + public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_SERVICE_FACTORY; /** * Service Classname address type. */ - public static final String SERVICE_INTERFACE = "serviceInterface"; + public static final String SERVICE_INTERFACE = "serviceInterface"; /** * ServiceQname address type. */ - public static final String SERVICE_NAMESPACE = "service namespace"; + public static final String SERVICE_NAMESPACE = "service namespace"; public static final String SERVICE_LOCAL_PART = "service local part"; @@ -76,23 +75,19 @@ public class ServiceRef extends AbstractRef { /** - * The list to save the handler Reference objects, because they can't be - * saved in the addrs vector. + * The list to save the handler Reference objects, because they can't be saved in the addrs vector. */ private final List<HandlerRef> handlers = new CopyOnWriteArrayList<>(); - public ServiceRef(String refname, String serviceInterface, String[] serviceQname, - String wsdl, String jaxrpcmapping) { - this(refname, serviceInterface, serviceQname, wsdl, jaxrpcmapping, - null, null); + public ServiceRef(String refname, String serviceInterface, String[] serviceQname, String wsdl, + String jaxrpcmapping) { + this(refname, serviceInterface, serviceQname, wsdl, jaxrpcmapping, null, null); } - public ServiceRef(@SuppressWarnings("unused") String refname, - String serviceInterface, String[] serviceQname, - String wsdl, String jaxrpcmapping, - String factory, String factoryLocation) { + public ServiceRef(@SuppressWarnings("unused") String refname, String serviceInterface, String[] serviceQname, + String wsdl, String jaxrpcmapping, String factory, String factoryLocation) { super(serviceInterface, factory, factoryLocation); StringRefAddr refAddr; if (serviceInterface != null) { @@ -120,6 +115,7 @@ public class ServiceRef extends AbstractRef { /** * Add and Get Handlers classes. + * * @return the handler */ public HandlerRef getHandler() { diff --git a/java/org/apache/naming/StringManager.java b/java/org/apache/naming/StringManager.java index 8ebb0f0dd3..3af12442c0 100644 --- a/java/org/apache/naming/StringManager.java +++ b/java/org/apache/naming/StringManager.java @@ -24,27 +24,22 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; /** - * An internationalization / localization helper class which reduces - * the bother of handling ResourceBundles and takes care of the - * common cases of message formatting which otherwise require the - * creation of Object arrays and such. - * - * <p>The StringManager operates on a package basis. One StringManager - * per package can be created and accessed via the getManager method - * call. - * - * <p>The StringManager will look for a ResourceBundle named by - * the package name given plus the suffix of "LocalStrings". In - * practice, this means that the localized information will be contained - * in a LocalStrings.properties file located in the package - * directory of the classpath. - * - * <p>Please see the documentation for java.util.ResourceBundle for - * more information. + * An internationalization / localization helper class which reduces the bother of handling ResourceBundles and takes + * care of the common cases of message formatting which otherwise require the creation of Object arrays and such. + * <p> + * The StringManager operates on a package basis. One StringManager per package can be created and accessed via the + * getManager method call. + * <p> + * The StringManager will look for a ResourceBundle named by the package name given plus the suffix of "LocalStrings". + * In practice, this means that the localized information will be contained in a LocalStrings.properties file located in + * the package directory of the classpath. + * <p> + * Please see the documentation for java.util.ResourceBundle for more information. * * @author James Duncan Davidson [dun...@eng.sun.com] * @author James Todd [go...@eng.sun.com] * @author Mel Martinez [mmarti...@g1440.com] + * * @see java.util.ResourceBundle */ public class StringManager { @@ -56,10 +51,8 @@ public class StringManager { private final Locale locale; /** - * Creates a new StringManager for a given package. This is a - * private method and all access to it is arbitrated by the - * static getManager method call so that only one StringManager - * per package will be created. + * Creates a new StringManager for a given package. This is a private method and all access to it is arbitrated by + * the static getManager method call so that only one StringManager per package will be created. * * @param packageName Name of package to create StringManager for. */ @@ -75,8 +68,7 @@ public class StringManager { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl != null) { try { - tempBundle = ResourceBundle.getBundle( - bundleName, Locale.getDefault(), cl); + tempBundle = ResourceBundle.getBundle(bundleName, Locale.getDefault(), cl); } catch (MissingResourceException ex2) { // Ignore } @@ -92,13 +84,13 @@ public class StringManager { } /** - * Get a string from the underlying resource bundle or return - * null if the String is not found. + * Get a string from the underlying resource bundle or return null if the String is not found. + * + * @param key to desired resource String + * + * @return resource String matching <i>key</i> from underlying bundle or null if not found. * - * @param key to desired resource String - * @return resource String matching <i>key</i> from underlying - * bundle or null if not found. - * @throws IllegalArgumentException if <i>key</i> is null. + * @throws IllegalArgumentException if <i>key</i> is null. */ public String getString(String key) { if (key == null) { @@ -115,16 +107,16 @@ public class StringManager { 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 + "]"; - // because it hides the fact that the String was missing - // from the calling code. - //good: could just throw the exception (or wrap it in another) - // but that would probably cause much havoc on existing - // code. - //better: consistent with container pattern to - // simply return null. Calling code can then do - // a null check. + // bad: shouldn't mask an exception the following way: + // str = "[cannot find message associated with key '" + key + "' due to " + mre + "]"; + // because it hides the fact that the String was missing + // from the calling code. + // good: could just throw the exception (or wrap it in another) + // but that would probably cause much havoc on existing + // code. + // better: consistent with container pattern to + // simply return null. Calling code can then do + // a null check. // str is already set to null } @@ -132,14 +124,12 @@ public class StringManager { } /** - * Get a string from the underlying resource bundle and format - * it with the given set of arguments. + * Get a string from the underlying resource bundle and format it with the given set of arguments. * * @param key The key for the required message * @param args The values to insert into the message * - * @return The request string formatted with the provided arguments or the - * key if the key was not found. + * @return The request string formatted with the provided arguments or the key if the key was not found. */ public String getString(final String key, final Object... args) { String value = getString(key); @@ -156,12 +146,11 @@ public class StringManager { // STATIC SUPPORT METHODS // -------------------------------------------------------------- - private static final Map<String, StringManager> managers = new HashMap<>(); + private static final Map<String,StringManager> managers = new HashMap<>(); /** - * Get the StringManager for a particular package. If a manager for - * a package already exists, it will be reused, else a new - * StringManager will be created and returned. + * Get the StringManager for a particular package. If a manager for a package already exists, it will be reused, + * else a new StringManager will be created and returned. * * @param packageName The package name * diff --git a/java/org/apache/naming/TransactionRef.java b/java/org/apache/naming/TransactionRef.java index fc1e14b42f..8fc3003eab 100644 --- a/java/org/apache/naming/TransactionRef.java +++ b/java/org/apache/naming/TransactionRef.java @@ -29,8 +29,7 @@ public class TransactionRef extends AbstractRef { /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_TRANSACTION_FACTORY; + public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_TRANSACTION_FACTORY; /** @@ -44,7 +43,7 @@ public class TransactionRef extends AbstractRef { /** * Resource Reference. * - * @param factory The factory class + * @param factory The factory class * @param factoryLocation The factory location */ public TransactionRef(String factory, String factoryLocation) { diff --git a/java/org/apache/naming/java/javaURLContextFactory.java b/java/org/apache/naming/java/javaURLContextFactory.java index 99ae388ee9..4a1eef726c 100644 --- a/java/org/apache/naming/java/javaURLContextFactory.java +++ b/java/org/apache/naming/java/javaURLContextFactory.java @@ -31,22 +31,17 @@ import org.apache.naming.SelectorContext; /** * Context factory for the "java:" namespace. * <p> - * <b>Important note</b> : This factory MUST be associated with the "java" URL - * prefix, which can be done by either : + * <b>Important note</b> : This factory MUST be associated with the "java" URL prefix, which can be done by either : * <ul> - * <li>Adding a - * java.naming.factory.url.pkgs=org.apache.naming property - * to the JNDI properties file</li> - * <li>Setting an environment variable named Context.URL_PKG_PREFIXES with - * its value including the org.apache.naming package name. - * More detail about this can be found in the JNDI documentation : + * <li>Adding a java.naming.factory.url.pkgs=org.apache.naming property to the JNDI properties file</li> + * <li>Setting an environment variable named Context.URL_PKG_PREFIXES with its value including the org.apache.naming + * package name. More detail about this can be found in the JNDI documentation : * {@link javax.naming.spi.NamingManager#getURLContext(String, java.util.Hashtable)}.</li> * </ul> * * @author Remy Maucherat */ -public class javaURLContextFactory - implements ObjectFactory, InitialContextFactory { +public class javaURLContextFactory implements ObjectFactory, InitialContextFactory { // ----------------------------------------------------------- Constructors @@ -75,22 +70,22 @@ public class javaURLContextFactory /** * Create a new Context's instance. - * @param obj unused - * @param name unused - * @param nameCtx unused + * + * @param obj unused + * @param name unused + * @param nameCtx unused * @param environment the environment used - * @return a selector context if the thread or classloader are bound, and - * null otherwise + * + * @return a selector context if the thread or classloader are bound, and null otherwise + * * @throws NamingException not thrown by this implementationm */ @SuppressWarnings("unchecked") @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable<?,?> environment) - throws NamingException { - if ((ContextBindings.isThreadBound()) || - (ContextBindings.isClassLoaderBound())) { - return new SelectorContext((Hashtable<String,Object>)environment); + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) + throws NamingException { + if ((ContextBindings.isThreadBound()) || (ContextBindings.isClassLoaderBound())) { + return new SelectorContext((Hashtable<String,Object>) environment); } return null; } @@ -98,28 +93,26 @@ public class javaURLContextFactory /** * Get a new (writable) initial context. + * * @param environment the environment used - * @return a selector context if the thread or classloader are bound, and - * a shared writable context otherwise + * + * @return a selector context if the thread or classloader are bound, and a shared writable context otherwise + * * @throws NamingException not thrown by this implementationm */ @SuppressWarnings("unchecked") @Override - public Context getInitialContext(Hashtable<?,?> environment) - throws NamingException { - if (ContextBindings.isThreadBound() || - (ContextBindings.isClassLoaderBound())) { + public Context getInitialContext(Hashtable<?,?> environment) throws NamingException { + if (ContextBindings.isThreadBound() || (ContextBindings.isClassLoaderBound())) { // Redirect the request to the bound initial context - return new SelectorContext( - (Hashtable<String,Object>)environment, true); + return new SelectorContext((Hashtable<String,Object>) environment, true); } // If the thread is not bound, return a shared writable context if (initialContext == null) { - synchronized(javaURLContextFactory.class) { + synchronized (javaURLContextFactory.class) { if (initialContext == null) { - initialContext = new NamingContext( - (Hashtable<String,Object>)environment, MAIN); + initialContext = new NamingContext((Hashtable<String,Object>) environment, MAIN); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org