This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push: new 7f3c66fd8e Code clean-up - formatting. No functional change 7f3c66fd8e is described below commit 7f3c66fd8e59c618c0897a3ee3f1ee78264987aa Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Apr 3 17:27:10 2025 +0100 Code clean-up - formatting. No functional change --- java/org/apache/naming/factory/BeanFactory.java | 33 ++++++++--------- java/org/apache/naming/factory/Constants.java | 3 +- .../naming/factory/DataSourceLinkFactory.java | 42 +++++++++++----------- java/org/apache/naming/factory/EjbFactory.java | 8 ++--- java/org/apache/naming/factory/FactoryBase.java | 40 ++++++++++----------- java/org/apache/naming/factory/LookupFactory.java | 25 +++++++------ .../apache/naming/factory/MailSessionFactory.java | 38 ++++++++++---------- java/org/apache/naming/factory/OpenEjbFactory.java | 16 ++++----- .../org/apache/naming/factory/ResourceFactory.java | 16 ++++----- .../apache/naming/factory/ResourceLinkFactory.java | 38 ++++++++++---------- .../org/apache/naming/factory/SendMailFactory.java | 22 +++++------- 11 files changed, 133 insertions(+), 148 deletions(-) diff --git a/java/org/apache/naming/factory/BeanFactory.java b/java/org/apache/naming/factory/BeanFactory.java index 8509a309d8..d23b3b8c78 100644 --- a/java/org/apache/naming/factory/BeanFactory.java +++ b/java/org/apache/naming/factory/BeanFactory.java @@ -37,10 +37,11 @@ import org.apache.naming.StringManager; /** * Object factory for any Resource conforming to the JavaBean spec. + * <p> + * This factory can be configured in a <code><Context></code> element in your <code>conf/server.xml</code> + * configuration file. An example of factory configuration is: + * </p> * - * <p>This factory can be configured in a <code><Context></code> element - * in your <code>conf/server.xml</code> - * configuration file. An example of factory configuration is:</p> * <pre> * <Resource name="jdbc/myDataSource" * auth="SERVLET" @@ -68,11 +69,13 @@ public class BeanFactory implements ObjectFactory { /** * Create a new Bean instance. * - * @param obj The reference object describing the Bean - * @param name the bound name - * @param nameCtx unused + * @param obj The reference object describing the Bean + * @param name the bound name + * @param nameCtx unused * @param environment unused + * * @return the object instance + * * @throws NamingException if an error occur creating the instance */ @Override @@ -92,7 +95,7 @@ public class BeanFactory implements ObjectFactory { } else { beanClass = Class.forName(beanClassName); } - } catch(ClassNotFoundException cnfe) { + } catch (ClassNotFoundException cnfe) { NamingException ne = new NamingException(sm.getString("beanFactory.classNotFound", beanClassName)); ne.initCause(cnfe); throw ne; @@ -117,14 +120,12 @@ public class BeanFactory implements ObjectFactory { ra = e.nextElement(); String propName = ra.getType(); - if (propName.equals(Constants.FACTORY) || - propName.equals("scope") || propName.equals("auth") || - propName.equals("forceString") || - propName.equals("singleton")) { + if (propName.equals(Constants.FACTORY) || propName.equals("scope") || propName.equals("auth") || + propName.equals("forceString") || propName.equals("singleton")) { continue; } - value = (String)ra.getContent(); + value = (String) ra.getContent(); Object[] valueArray = new Object[1]; @@ -162,12 +163,12 @@ public class BeanFactory implements ObjectFactory { setProp = bean.getClass().getMethod(setterName, String.class); valueArray[0] = value; } catch (NoSuchMethodException nsme) { - throw new NamingException(sm.getString( - "beanFactory.noStringConversion", propName, propType.getName())); + throw new NamingException(sm.getString("beanFactory.noStringConversion", propName, + propType.getName())); } } else { - throw new NamingException(sm.getString( - "beanFactory.noStringConversion", propName, propType.getName())); + throw new NamingException( + sm.getString("beanFactory.noStringConversion", propName, propType.getName())); } if (setProp != null) { diff --git a/java/org/apache/naming/factory/Constants.java b/java/org/apache/naming/factory/Constants.java index b8690af3bc..d2255b088d 100644 --- a/java/org/apache/naming/factory/Constants.java +++ b/java/org/apache/naming/factory/Constants.java @@ -37,8 +37,7 @@ public final class Constants { public static final String DEFAULT_HANDLER_FACTORY = Package + ".HandlerFactory"; - public static final String DBCP_DATASOURCE_FACTORY = - "org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory"; + public static final String DBCP_DATASOURCE_FACTORY = "org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory"; public static final String OPENEJB_EJB_FACTORY = Package + ".OpenEjbFactory"; diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java b/java/org/apache/naming/factory/DataSourceLinkFactory.java index 286ef18207..60e8bb6550 100644 --- a/java/org/apache/naming/factory/DataSourceLinkFactory.java +++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java @@ -31,10 +31,10 @@ import javax.naming.Reference; import javax.sql.DataSource; - /** - * <p>Object factory for resource links for shared data sources.</p> - * + * <p> + * Object factory for resource links for shared data sources. + * </p> */ public class DataSourceLinkFactory extends ResourceLinkFactory { @@ -46,14 +46,15 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { @Override public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) - throws NamingException { + throws NamingException { Object result = super.getObjectInstance(obj, name, nameCtx, environment); // Can we process this request? - if (result!=null) { + if (result != null) { Reference ref = (Reference) obj; RefAddr userAttr = ref.get("username"); RefAddr passAttr = ref.get("password"); - if (userAttr != null && passAttr != null && userAttr.getContent() != null && passAttr.getContent() != null) { + if (userAttr != null && passAttr != null && userAttr.getContent() != null && + passAttr.getContent() != null) { result = wrapDataSource(result, userAttr.getContent().toString(), passAttr.getContent().toString()); } } @@ -62,11 +63,10 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { protected Object wrapDataSource(Object datasource, String username, String password) throws NamingException { try { - DataSourceHandler handler = - new DataSourceHandler((DataSource)datasource, username, password); - return Proxy.newProxyInstance(datasource.getClass().getClassLoader(), - datasource.getClass().getInterfaces(), handler); - }catch (Exception x) { + DataSourceHandler handler = new DataSourceHandler((DataSource) datasource, username, password); + return Proxy.newProxyInstance(datasource.getClass().getClassLoader(), datasource.getClass().getInterfaces(), + handler); + } catch (Exception x) { Exception exception = x; if (exception instanceof InvocationTargetException) { Throwable cause = exception.getCause(); @@ -88,8 +88,8 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { } /** - * Simple wrapper class that will allow a user to configure a ResourceLink for a data source - * so that when {@link javax.sql.DataSource#getConnection()} is called, it will invoke + * Simple wrapper class that will allow a user to configure a ResourceLink for a data source so that when + * {@link javax.sql.DataSource#getConnection()} is called, it will invoke * {@link javax.sql.DataSource#getConnection(String, String)} with the preconfigured username and password. */ public static class DataSourceHandler implements InvocationHandler { @@ -97,6 +97,7 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { private final String username; private final String password; private final Method getConnection; + public DataSourceHandler(DataSource ds, String username, String password) throws Exception { this.ds = ds; this.username = username; @@ -107,17 +108,16 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if ("getConnection".equals(method.getName()) && (args==null || args.length==0)) { - args = new String[] {username,password}; + if ("getConnection".equals(method.getName()) && (args == null || args.length == 0)) { + args = new String[] { username, password }; method = getConnection; } else if ("unwrap".equals(method.getName())) { - return unwrap((Class<?>)args[0]); + return unwrap((Class<?>) args[0]); } try { - return method.invoke(ds,args); - }catch (Throwable t) { - if (t instanceof InvocationTargetException - && t.getCause() != null) { + return method.invoke(ds, args); + } catch (Throwable t) { + if (t instanceof InvocationTargetException && t.getCause() != null) { throw t.getCause(); } else { throw t; @@ -136,7 +136,5 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { } - - } diff --git a/java/org/apache/naming/factory/EjbFactory.java b/java/org/apache/naming/factory/EjbFactory.java index 415386ecbe..7d1c47915e 100644 --- a/java/org/apache/naming/factory/EjbFactory.java +++ b/java/org/apache/naming/factory/EjbFactory.java @@ -43,12 +43,10 @@ public class EjbFactory extends FactoryBase { protected ObjectFactory getDefaultFactory(Reference ref) throws NamingException { ObjectFactory factory; - String javaxEjbFactoryClassName = System.getProperty( - "jakarta.ejb.Factory", Constants.OPENEJB_EJB_FACTORY); + String javaxEjbFactoryClassName = System.getProperty("jakarta.ejb.Factory", Constants.OPENEJB_EJB_FACTORY); try { - factory = (ObjectFactory) - Class.forName(javaxEjbFactoryClassName).getConstructor().newInstance(); - } catch(Throwable t) { + factory = (ObjectFactory) Class.forName(javaxEjbFactoryClassName).getConstructor().newInstance(); + } catch (Throwable t) { if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } diff --git a/java/org/apache/naming/factory/FactoryBase.java b/java/org/apache/naming/factory/FactoryBase.java index dd0c7fdd28..f80b2c7202 100644 --- a/java/org/apache/naming/factory/FactoryBase.java +++ b/java/org/apache/naming/factory/FactoryBase.java @@ -28,16 +28,16 @@ import javax.naming.spi.ObjectFactory; import org.apache.naming.StringManager; /** - * Abstract base class that provides common functionality required by - * subclasses. This class exists primarily to reduce code duplication. + * Abstract base class that provides common functionality required by subclasses. This class exists primarily to reduce + * code duplication. */ public abstract class FactoryBase implements ObjectFactory { private static final StringManager sm = StringManager.getManager(FactoryBase.class); @Override - public final Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable<?,?> environment) throws Exception { + public final Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) + throws Exception { if (isReferenceTypeSupported(obj)) { Reference ref = (Reference) obj; @@ -61,14 +61,14 @@ public abstract class FactoryBase implements ObjectFactory { } else { factoryClass = Class.forName(factoryClassName); } - } catch(ClassNotFoundException e) { + } catch (ClassNotFoundException e) { NamingException ex = new NamingException(sm.getString("factoryBase.factoryClassError")); ex.initCause(e); throw ex; } try { factory = (ObjectFactory) factoryClass.getConstructor().newInstance(); - } catch(Throwable t) { + } catch (Throwable t) { if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } @@ -93,37 +93,33 @@ public abstract class FactoryBase implements ObjectFactory { /** - * Determines if this factory supports processing the provided reference - * object. + * Determines if this factory supports processing the provided reference object. * - * @param obj The object to be processed + * @param obj The object to be processed * - * @return <code>true</code> if this factory can process the object, - * otherwise <code>false</code> + * @return <code>true</code> if this factory can process the object, otherwise <code>false</code> */ protected abstract boolean isReferenceTypeSupported(Object obj); /** - * If a default factory is available for the given reference type, create - * the default factory. + * If a default factory is available for the given reference type, create the default factory. * - * @param ref The reference object to be processed + * @param ref The reference object to be processed * - * @return The default factory for the given reference object or - * <code>null</code> if no default factory exists. + * @return The default factory for the given reference object or <code>null</code> if no default factory exists. * - * @throws NamingException If the default factory cannot be created + * @throws NamingException If the default factory cannot be created */ - protected abstract ObjectFactory getDefaultFactory(Reference ref) - throws NamingException; + protected abstract ObjectFactory getDefaultFactory(Reference ref) throws NamingException; /** * If this reference is a link to another JNDI object, obtain that object. * - * @param ref The reference object to be processed + * @param ref The reference object to be processed + * + * @return The linked object or <code>null</code> if linked objects are not supported by or not configured for this + * reference object * - * @return The linked object or <code>null</code> if linked objects are - * not supported by or not configured for this reference object * @throws NamingException Error accessing linked object */ protected abstract Object getLinked(Reference ref) throws NamingException; diff --git a/java/org/apache/naming/factory/LookupFactory.java b/java/org/apache/naming/factory/LookupFactory.java index 07d907de53..fed05d4dc9 100644 --- a/java/org/apache/naming/factory/LookupFactory.java +++ b/java/org/apache/naming/factory/LookupFactory.java @@ -45,16 +45,18 @@ public class LookupFactory implements ObjectFactory { /** * Create a new Resource env instance. * - * @param obj The reference object describing the DataSource - * @param name the bound name - * @param nameCtx unused + * @param obj The reference object describing the DataSource + * @param name the bound name + * @param nameCtx unused * @param environment unused + * * @return the object instance + * * @throws Exception if an error occur creating the instance */ @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable<?, ?> environment) throws Exception { + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) + throws Exception { String lookupName = null; Object result = null; @@ -86,8 +88,7 @@ public class LookupFactory implements ObjectFactory { try { factoryClass = tcl.loadClass(factoryClassName); } catch (ClassNotFoundException e) { - NamingException ex = new NamingException( - sm.getString("lookupFactory.loadFailed")); + NamingException ex = new NamingException(sm.getString("lookupFactory.loadFailed")); ex.initCause(e); throw ex; } @@ -95,8 +96,7 @@ public class LookupFactory implements ObjectFactory { try { factoryClass = Class.forName(factoryClassName); } catch (ClassNotFoundException e) { - NamingException ex = new NamingException( - sm.getString("lookupFactory.loadFailed")); + NamingException ex = new NamingException(sm.getString("lookupFactory.loadFailed")); ex.initCause(e); throw ex; } @@ -105,8 +105,7 @@ public class LookupFactory implements ObjectFactory { try { factory = (ObjectFactory) factoryClass.getConstructor().newInstance(); } catch (Throwable t) { - NamingException ex = new NamingException( - sm.getString("lookupFactory.createFailed")); + NamingException ex = new NamingException(sm.getString("lookupFactory.createFailed")); ex.initCause(t); throw ex; } @@ -125,8 +124,8 @@ public class LookupFactory implements ObjectFactory { Class<?> clazz = Class.forName(ref.getClassName()); if (result != null && !clazz.isAssignableFrom(result.getClass())) { - String msg = sm.getString("lookupFactory.typeMismatch", - name, ref.getClassName(), lookupName, result.getClass().getName()); + String msg = sm.getString("lookupFactory.typeMismatch", name, ref.getClassName(), lookupName, + result.getClass().getName()); NamingException ne = new NamingException(msg); log.warn(msg, ne); // Close the resource we no longer need if we know how to do so diff --git a/java/org/apache/naming/factory/MailSessionFactory.java b/java/org/apache/naming/factory/MailSessionFactory.java index fbd04121ac..e487cf9a75 100644 --- a/java/org/apache/naming/factory/MailSessionFactory.java +++ b/java/org/apache/naming/factory/MailSessionFactory.java @@ -31,19 +31,20 @@ import jakarta.mail.PasswordAuthentication; import jakarta.mail.Session; /** - * <p>Factory class that creates a JNDI named JavaMail Session factory, - * which can be used for managing inbound and outbound electronic mail - * messages via JavaMail APIs. All messaging environment properties - * described in the JavaMail Specification may be passed to the Session - * factory; however the following properties are the most commonly used:</p> + * <p> + * Factory class that creates a JNDI named JavaMail Session factory, which can be used for managing inbound and outbound + * electronic mail messages via JavaMail APIs. All messaging environment properties described in the JavaMail + * Specification may be passed to the Session factory; however the following properties are the most commonly used: + * </p> * <ul> - * <li><strong>mail.smtp.host</strong> - Hostname for outbound transport - * connections. Defaults to <code>localhost</code> if not specified.</li> + * <li><strong>mail.smtp.host</strong> - Hostname for outbound transport connections. Defaults to <code>localhost</code> + * if not specified.</li> * </ul> + * <p> + * This factory can be configured in a <code><Context></code> element in your <code>conf/server.xml</code> + * configuration file. An example of factory configuration is: + * </p> * - * <p>This factory can be configured in a - * <code><Context></code> element in your <code>conf/server.xml</code> - * configuration file. An example of factory configuration is:</p> * <pre> * <Resource name="mail/smtp" * auth="CONTAINER" @@ -64,8 +65,7 @@ public class MailSessionFactory implements ObjectFactory { @Override - public Object getObjectInstance(Object refObj, Name name, Context context, - Hashtable<?,?> env) throws Exception { + public Object getObjectInstance(Object refObj, Name name, Context context, Hashtable<?,?> env) throws Exception { // Return null if we cannot create an object of the requested type final Reference ref = (Reference) refObj; @@ -98,18 +98,18 @@ public class MailSessionFactory implements ObjectFactory { Authenticator auth = null; if (password != null) { String user = props.getProperty("mail.smtp.user"); - if(user == null) { + if (user == null) { user = props.getProperty("mail.user"); } - if(user != null) { + if (user != null) { final PasswordAuthentication pa = new PasswordAuthentication(user, password); auth = new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return pa; - } - }; + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return pa; + } + }; } } diff --git a/java/org/apache/naming/factory/OpenEjbFactory.java b/java/org/apache/naming/factory/OpenEjbFactory.java index 10d47210c5..27454b5893 100644 --- a/java/org/apache/naming/factory/OpenEjbFactory.java +++ b/java/org/apache/naming/factory/OpenEjbFactory.java @@ -39,8 +39,7 @@ public class OpenEjbFactory implements ObjectFactory { // -------------------------------------------------------------- Constants - protected static final String DEFAULT_OPENEJB_FACTORY = - "org.openejb.client.LocalInitialContextFactory"; + protected static final String DEFAULT_OPENEJB_FACTORY = "org.openejb.client.LocalInitialContextFactory"; // -------------------------------------------------- ObjectFactory Methods @@ -49,17 +48,18 @@ public class OpenEjbFactory implements ObjectFactory { /** * Create a new EJB instance using OpenEJB. * - * @param obj The reference object describing the DataSource - * @param name the bound name - * @param nameCtx unused + * @param obj The reference object describing the DataSource + * @param name the bound name + * @param nameCtx unused * @param environment unused + * * @return the object instance + * * @throws Exception if an error occur creating the instance */ @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable<?,?> environment) - throws Exception { + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) + throws Exception { Object beanObj = null; diff --git a/java/org/apache/naming/factory/ResourceFactory.java b/java/org/apache/naming/factory/ResourceFactory.java index d58fb8413b..c3f4f8fdf0 100644 --- a/java/org/apache/naming/factory/ResourceFactory.java +++ b/java/org/apache/naming/factory/ResourceFactory.java @@ -44,11 +44,10 @@ public class ResourceFactory extends FactoryBase { if (ref.getClassName().equals("javax.sql.DataSource")) { String javaxSqlDataSourceFactoryClassName = - System.getProperty("javax.sql.DataSource.Factory", - Constants.DBCP_DATASOURCE_FACTORY); + System.getProperty("javax.sql.DataSource.Factory", Constants.DBCP_DATASOURCE_FACTORY); try { - factory = (ObjectFactory) Class.forName( - javaxSqlDataSourceFactoryClassName).getConstructor().newInstance(); + factory = (ObjectFactory) Class.forName(javaxSqlDataSourceFactoryClassName).getConstructor() + .newInstance(); } catch (Exception e) { NamingException ex = new NamingException(sm.getString("resourceFactory.factoryCreationError")); ex.initCause(e); @@ -56,12 +55,11 @@ public class ResourceFactory extends FactoryBase { } } else if (ref.getClassName().equals("jakarta.mail.Session")) { String javaxMailSessionFactoryClassName = - System.getProperty("jakarta.mail.Session.Factory", - "org.apache.naming.factory.MailSessionFactory"); + System.getProperty("jakarta.mail.Session.Factory", "org.apache.naming.factory.MailSessionFactory"); try { - factory = (ObjectFactory) Class.forName( - javaxMailSessionFactoryClassName).getConstructor().newInstance(); - } catch(Throwable t) { + factory = + (ObjectFactory) Class.forName(javaxMailSessionFactoryClassName).getConstructor().newInstance(); + } catch (Throwable t) { if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } diff --git a/java/org/apache/naming/factory/ResourceLinkFactory.java b/java/org/apache/naming/factory/ResourceLinkFactory.java index f1f22fb509..dd27c7513f 100644 --- a/java/org/apache/naming/factory/ResourceLinkFactory.java +++ b/java/org/apache/naming/factory/ResourceLinkFactory.java @@ -31,7 +31,9 @@ import org.apache.naming.ResourceLinkRef; import org.apache.naming.StringManager; /** - * <p>Object factory for resource links.</p> + * <p> + * Object factory for resource links. + * </p> * * @author Remy Maucherat */ @@ -46,8 +48,7 @@ public class ResourceLinkFactory implements ObjectFactory { */ private static Context globalContext = null; - private static final Map<ClassLoader,Map<String,String>> globalResourceRegistrations = - new ConcurrentHashMap<>(); + private static final Map<ClassLoader,Map<String,String>> globalResourceRegistrations = new ConcurrentHashMap<>(); // --------------------------------------------------------- Public Methods @@ -61,8 +62,7 @@ public class ResourceLinkFactory implements ObjectFactory { } - public static void registerGlobalResourceAccess(Context globalContext, String localName, - String globalName) { + public static void registerGlobalResourceAccess(Context globalContext, String localName, String globalName) { validateGlobalContext(globalContext); ClassLoader cl = Thread.currentThread().getContextClassLoader(); // Web application initialization is single threaded so this is @@ -89,8 +89,7 @@ public class ResourceLinkFactory implements ObjectFactory { private static void validateGlobalContext(Context globalContext) { - if (ResourceLinkFactory.globalContext != null && - ResourceLinkFactory.globalContext != globalContext) { + if (ResourceLinkFactory.globalContext != null && ResourceLinkFactory.globalContext != globalContext) { throw new SecurityException(sm.getString("resourceLinkFactory.invalidGlobalContext")); } } @@ -114,15 +113,17 @@ public class ResourceLinkFactory implements ObjectFactory { /** * Create a new resource instance. * - * @param name the bound name - * @param nameCtx unused + * @param name the bound name + * @param nameCtx unused * @param environment unused + * * @return the object instance + * * @throws NamingException if an error occur creating the instance */ @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable<?,?> environment) throws NamingException { + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) + throws NamingException { if (!(obj instanceof ResourceLinkRef ref)) { return null; @@ -144,19 +145,18 @@ public class ResourceLinkFactory implements ObjectFactory { // Check the expected type String expectedClassName = ref.getClassName(); if (expectedClassName == null) { - throw new IllegalArgumentException( - sm.getString("resourceLinkFactory.nullType", name, globalName)); + throw new IllegalArgumentException(sm.getString("resourceLinkFactory.nullType", name, globalName)); } try { - Class<?> expectedClazz = Class.forName( - expectedClassName, true, Thread.currentThread().getContextClassLoader()); + Class<?> expectedClazz = + Class.forName(expectedClassName, true, Thread.currentThread().getContextClassLoader()); if (!expectedClazz.isAssignableFrom(result.getClass())) { - throw new IllegalArgumentException(sm.getString("resourceLinkFactory.wrongType", - name, globalName, expectedClassName, result.getClass().getName())); + throw new IllegalArgumentException(sm.getString("resourceLinkFactory.wrongType", name, globalName, + expectedClassName, result.getClass().getName())); } } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(sm.getString("resourceLinkFactory.unknownType", - name, globalName, expectedClassName), e); + throw new IllegalArgumentException( + sm.getString("resourceLinkFactory.unknownType", name, globalName, expectedClassName), e); } return result; } diff --git a/java/org/apache/naming/factory/SendMailFactory.java b/java/org/apache/naming/factory/SendMailFactory.java index f22841836c..fa1dd2367f 100644 --- a/java/org/apache/naming/factory/SendMailFactory.java +++ b/java/org/apache/naming/factory/SendMailFactory.java @@ -34,13 +34,13 @@ import jakarta.mail.internet.MimePartDataSource; import org.apache.tomcat.util.ExceptionUtils; /** - * Factory class that creates a JNDI named javamail MimePartDataSource - * object which can be used for sending email using SMTP. + * Factory class that creates a JNDI named javamail MimePartDataSource object which can be used for sending email using + * SMTP. * <p> - * Can be configured in the Context scope - * of your server.xml configuration file. + * Can be configured in the Context scope of your server.xml configuration file. * <p> * Example: + * * <pre> * <Resource name="mail/send" * auth="CONTAINER" @@ -58,16 +58,13 @@ import org.apache.tomcat.util.ExceptionUtils; * @author Glenn Nielsen Rich Catlett */ -public class SendMailFactory implements ObjectFactory -{ +public class SendMailFactory implements ObjectFactory { // The class name for the javamail MimeMessageDataSource - protected static final String DataSourceClassName = - "jakarta.mail.internet.MimePartDataSource"; + protected static final String DataSourceClassName = "jakarta.mail.internet.MimePartDataSource"; @Override - public Object getObjectInstance(Object refObj, Name name, Context ctx, - Hashtable<?,?> env) throws Exception { - final Reference ref = (Reference)refObj; + public Object getObjectInstance(Object refObj, Name name, Context ctx, Hashtable<?,?> env) throws Exception { + final Reference ref = (Reference) refObj; if (ref.getClassName().equals(DataSourceClassName)) { // set up the smtp session that will send the message @@ -85,8 +82,7 @@ public class SendMailFactory implements ObjectFactory // set property props.put(refaddr.getType(), refaddr.getContent()); } - MimeMessage message = new MimeMessage( - Session.getInstance(props)); + MimeMessage message = new MimeMessage(Session.getInstance(props)); try { RefAddr fromAddr = ref.get("mail.from"); String from = null; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org