This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 02e1a57 [OWB-1356] lazy lookup loggers when it is only about errors
and not main code path
02e1a57 is described below
commit 02e1a57bdedc7bc7f3c6b51cc321578ee54ccf98
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Wed Dec 16 11:41:25 2020 +0100
[OWB-1356] lazy lookup loggers when it is only about errors and not main
code path
---
.../webbeans/ee/event/TransactionalEventNotifier.java | 6 ++----
.../webbeans/config/DeploymentValidationService.java | 13 ++++++-------
.../apache/webbeans/config/OpenWebBeansConfiguration.java | 10 ++--------
.../java/org/apache/webbeans/config/WebBeansContext.java | 8 +++-----
.../org/apache/webbeans/portable/AbstractAnnotated.java | 8 +++-----
.../apache/webbeans/portable/AnnotatedElementFactory.java | 5 ++---
.../apache/webbeans/portable/events/ExtensionLoader.java | 15 +++++++--------
7 files changed, 25 insertions(+), 40 deletions(-)
diff --git
a/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java
b/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java
index 0c339f9..487dd80 100644
---
a/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java
+++
b/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java
@@ -34,13 +34,10 @@ import org.apache.webbeans.logger.WebBeansLoggerFacade;
import org.apache.webbeans.spi.TransactionService;
import java.util.logging.Level;
-import java.util.logging.Logger;
@SuppressWarnings("unchecked")
public final class TransactionalEventNotifier
{
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(TransactionalEventNotifier.class);
-
private TransactionalEventNotifier()
{
// utility class ct
@@ -162,7 +159,8 @@ public final class TransactionalEventNotifier
}
catch (Exception e)
{
- logger.log(Level.SEVERE, OWBLogConst.ERROR_0003, e);
+
WebBeansLoggerFacade.getLogger(TransactionalEventNotifier.class)
+ .log(Level.SEVERE, OWBLogConst.ERROR_0003, e);
}
}
}
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/config/DeploymentValidationService.java
b/webbeans-impl/src/main/java/org/apache/webbeans/config/DeploymentValidationService.java
index 7e118f3..3dc5442 100644
---
a/webbeans-impl/src/main/java/org/apache/webbeans/config/DeploymentValidationService.java
+++
b/webbeans-impl/src/main/java/org/apache/webbeans/config/DeploymentValidationService.java
@@ -24,7 +24,6 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Set;
-import java.util.logging.Logger;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.TransientReference;
@@ -48,9 +47,6 @@ import org.apache.webbeans.util.SecurityUtil;
public class DeploymentValidationService
{
- /**Logger instance*/
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(DeploymentValidationService.class);
-
private WebBeansContext webBeansContext;
/**
@@ -110,9 +106,12 @@ public class DeploymentValidationService
{
if
(allowProxyingClasses.contains(beanClass.getName()))
{
- logger.info(beanClass.getName() + " has final
method " + finalMethodName + ". CDI doesn't allow to proxy that." +
- " Continuing because the class is
explicitly configured to be treated as proxyable." +
- " Final methods shall not get invoked on
this proxy!");
+
WebBeansLoggerFacade.getLogger(DeploymentValidationService.class)
+ .info(beanClass.getName() + " has
final method " +
+ finalMethodName + ". CDI
doesn't allow to proxy that." +
+ " Continuing because the class
is explicitly configured " +
+ "to be treated as proxyable." +
+ " Final methods shall not get
invoked on this proxy!");
}
else
{
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
b/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
index 7eab234..0d2b480 100644
---
a/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
+++
b/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
@@ -31,7 +31,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.logger.WebBeansLoggerFacade;
@@ -51,10 +50,6 @@ import org.apache.webbeans.logger.WebBeansLoggerFacade;
*/
public class OpenWebBeansConfiguration
{
- /**Logger instance*/
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(OpenWebBeansConfiguration.class);
-
-
/**Timeout interval in ms*/
public static final String CONVERSATION_TIMEOUT_INTERVAL =
"org.apache.webbeans.conversation.Conversation.timeoutInterval";
@@ -316,8 +311,6 @@ public class OpenWebBeansConfiguration
private void overrideWithGlobalSettings(Properties configProperties)
{
- logger.fine("Overriding properties from System and Env properties");
-
Properties systemProperties;
if(System.getSecurityManager() != null)
{
@@ -508,7 +501,8 @@ public class OpenWebBeansConfiguration
}
catch (IOException e)
{
- logger.log(Level.SEVERE, "Error while loading the propertyFile " +
DEFAULT_CONFIG_PROPERTIES_NAME, e);
+ WebBeansLoggerFacade.getLogger(OpenWebBeansConfiguration.class)
+ .log(Level.SEVERE, "Error while loading the propertyFile "
+ DEFAULT_CONFIG_PROPERTIES_NAME, e);
return Collections.EMPTY_SET;
}
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
b/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
index 8d4976e..2504ed0 100644
---
a/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
+++
b/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.webbeans.annotation.AnnotationManager;
import org.apache.webbeans.container.BeanManagerImpl;
@@ -80,8 +79,6 @@ import org.apache.webbeans.xml.DefaultBeanArchiveService;
*/
public class WebBeansContext
{
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(WebBeansContext.class);
-
private final Map<Class<?>, Object> managerMap = new HashMap<>();
private final Map<Class<?>, Object> serviceMap = new HashMap<>();
@@ -635,7 +632,8 @@ public class WebBeansContext
}
catch (IOException e)
{
- logger.log(Level.SEVERE, "Error while destroying SPI
service " + spiService.getClass().getName(), e);
+ WebBeansLoggerFacade.getLogger(WebBeansContext.class)
+ .log(Level.SEVERE, "Error while destroying SPI
service " + spiService.getClass().getName(), e);
}
}
else if (ExecutorService.class.isInstance(spiService))
@@ -648,7 +646,7 @@ public class WebBeansContext
}
catch (RuntimeException re)
{
- logger.warning(re.getMessage());
+
WebBeansLoggerFacade.getLogger(WebBeansContext.class).warning(re.getMessage());
}
});
}
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
b/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
index 9406c47..741e73a 100644
---
a/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
+++
b/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.enterprise.inject.spi.Annotated;
@@ -48,8 +47,6 @@ import static java.util.stream.Collectors.toList;
*/
public abstract class AbstractAnnotated implements Annotated
{
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(AbstractAnnotated.class);
-
/**Base type of an annotated element*/
private final Type baseType;
@@ -121,8 +118,9 @@ public abstract class AbstractAnnotated implements Annotated
}
catch (IllegalAccessException | InvocationTargetException e)
{
- logger.log(Level.FINER, "Problem while handling repeatable
Annotations "
- + annotation.annotationType());
+ WebBeansLoggerFacade.getLogger(AbstractAnnotated.class)
+ .log(Level.FINER, "Problem while handling
repeatable Annotations "
+ + annotation.annotationType());
}
}
}
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
b/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
index 65b2683..afa78bc 100644
---
a/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
+++
b/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
@@ -50,9 +50,6 @@ public final class AnnotatedElementFactory
public static final String OWB_DEFAULT_KEY = "OWB_DEFAULT_KEY";
- // Logger instance
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(AnnotatedElementFactory.class);
-
/**
* Cache of the initial AnnotatedTypes
*/
@@ -192,6 +189,7 @@ public final class AnnotatedElementFactory
{
if (e instanceof ClassNotFoundException || e instanceof
ArrayStoreException)
{
+ final Logger logger =
WebBeansLoggerFacade.getLogger(AnnotatedElementFactory.class);
if (logger.isLoggable(Level.SEVERE))
{
logger.log(Level.SEVERE,
WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0027,
annotatedClass.getName(), e.getCause()), e);
@@ -206,6 +204,7 @@ public final class AnnotatedElementFactory
}
catch (NoClassDefFoundError ncdfe)
{
+ final Logger logger =
WebBeansLoggerFacade.getLogger(AnnotatedElementFactory.class);
if (logger.isLoggable(Level.SEVERE))
{
logger.log(Level.SEVERE,
WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0027,
annotatedClass.getName(), ncdfe.getCause()), ncdfe);
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
b/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
index d40ef20..8a2459c 100644
---
a/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
+++
b/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
import javax.enterprise.inject.spi.DefinitionException;
import javax.enterprise.inject.spi.DeploymentException;
@@ -58,9 +57,6 @@ import org.apache.xbean.finder.archive.FileArchive;
*/
public class ExtensionLoader
{
- /**Logger instance*/
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(ExtensionLoader.class);
-
/**Map of extensions*/
private final Map<Class<?>, Object> extensions = new
ConcurrentHashMap<>();
private final Set<Class<? extends Extension>> extensionClasses = new
HashSet<>();
@@ -102,8 +98,10 @@ public class ExtensionLoader
Set<String> ignoredExtensions =
webBeansContext.getOpenWebBeansConfiguration().getIgnoredExtensions();
if (!ignoredExtensions.isEmpty())
{
- logger.info("Ignoring the following CDI Extensions. See " +
OpenWebBeansConfiguration.IGNORED_EXTENSIONS +
- " " + ignoredExtensions.toString());
+ WebBeansLoggerFacade.getLogger(ExtensionLoader.class)
+ .info("Ignoring the following CDI Extensions. " +
+ "See " +
OpenWebBeansConfiguration.IGNORED_EXTENSIONS +
+ " " + ignoredExtensions.toString());
}
List<Extension> loader =
webBeansContext.getLoaderService().load(Extension.class, classLoader);
@@ -111,7 +109,8 @@ public class ExtensionLoader
{
if (ignoredExtensions.contains(extension.getClass().getName()))
{
- logger.info("Skipping CDI Extension due to exclusion: " +
extension.getClass().getName());
+ WebBeansLoggerFacade.getLogger(ExtensionLoader.class)
+ .info("Skipping CDI Extension due to exclusion: " +
extension.getClass().getName());
continue;
}
@@ -177,7 +176,7 @@ public class ExtensionLoader
}
catch (final IOException ioe)
{
- logger.warning(ioe.getMessage());
+
WebBeansLoggerFacade.getLogger(ExtensionLoader.class).warning(ioe.getMessage());
}
return null;
}