Hi Christopher,
> > environments. - Class<?> clazz =
> > Class.forName(className); - return
> > (AuthConfigFactory) clazz.getConstructor().newInstance(); + if
> > (className.equals("org.apache.catalina.authenticator.jaspic.AuthConfig
> FactoryImpl"))
> > {
>
> Why not use AuthConfigFactoryImpl.class.getName()? It may help in the
> future with refactoring.
[Filip Hanik]
Trying to avoid a circular dependency. You see the javax/jakarta package should
not import org.apache.catalina code. I should be able to execute the
AuthConfigFactory code without needing to load
org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl class. The JVM
is smart enough that if the execution doesn't enter the if statement block, it
won't attempt the classloading of the AuthConfigFactoryImpl class. However, if
the AuthConfigFactoryImpl Class itself is part of the evaluation statement, it
will be loaded.
The previous implementation also had it as a string, instead of
AuthConfigFactoryImpl.class.getName() for the same reason.
https://github.com/apache/tomcat/blob/35dc7b9288aad4a7d70750c157543d4ff1593c98/java/jakarta/security/auth/message/config/AuthConfigFactory.java#L48-L49
This way, I can build a jakarta.security.auth.message library, that can be used
without the org.apache.catalina library.
I need to change my commit to use the constant, instead of the duplicated
string in the IF statement.
if
(className.equals(DEFAULT_JASPI_AUTHCONFIGFACTORYIMPL)) {
return new
org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl();
} else {
Class<?> clazz = Class.forName(className);
return (AuthConfigFactory)
clazz.getConstructor().newInstance();
}
>
> - -chris