diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java index 22571e6f2cd..37f9ad691e4 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java @@ -491,7 +491,9 @@ public class AnnotationConfiguration extends AbstractConfiguration LOG.debug("Scanned {} in {}ms", p.getResource(), TimeUnit.MILLISECONDS.convert(p.getStatistic().getElapsed(), TimeUnit.NANOSECONDS)); LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}", - _containerPathStats.getTotal(), _webInfLibStats.getTotal(), _webInfClassesStats.getTotal(), + (_containerPathStats==null?-1:_containerPathStats.getTotal()), + (_webInfLibStats==null?-1:_webInfLibStats.getTotal()), + (_webInfClassesStats==null?-1:_webInfClassesStats.getTotal()), elapsedMs, context); } @@ -935,7 +937,8 @@ public class AnnotationConfiguration extends AbstractConfiguration if (_classInheritanceHandler != null) handlers.add(_classInheritanceHandler); - _containerPathStats = new CounterStatistic(); + if (LOG.isDebugEnabled()) + _containerPathStats = new CounterStatistic(); for (Resource r : context.getMetaData().getContainerResources()) { @@ -944,9 +947,11 @@ public class AnnotationConfiguration extends AbstractConfiguration { ParserTask task = new ParserTask(parser, handlers, r); _parserTasks.add(task); - _containerPathStats.increment(); if (LOG.isDebugEnabled()) + { + _containerPathStats.increment(); task.setStatistic(new TimeStatistic()); + } } } } @@ -969,14 +974,18 @@ public class AnnotationConfiguration extends AbstractConfiguration ArrayList webInfUris = new ArrayList(); List jars = null; - + if (context.getMetaData().getOrdering() != null) jars = context.getMetaData().getOrderedWebInfJars(); else //No ordering just use the jars in any order jars = context.getMetaData().getWebInfJars(); - _webInfLibStats = new CounterStatistic(); + if (LOG.isDebugEnabled()) + { + if (_webInfLibStats == null) + _webInfLibStats = new CounterStatistic(); + } for (Resource r : jars) { @@ -1006,9 +1015,11 @@ public class AnnotationConfiguration extends AbstractConfiguration { ParserTask task = new ParserTask(parser, handlers,r); _parserTasks.add (task); - _webInfLibStats.increment(); if (LOG.isDebugEnabled()) + { + _webInfLibStats.increment(); task.setStatistic(new TimeStatistic()); + } } } } @@ -1023,7 +1034,7 @@ public class AnnotationConfiguration extends AbstractConfiguration * @throws Exception if unable to scan and/or parse */ public void parseWebInfClasses (final WebAppContext context, final AnnotationParser parser) - throws Exception + throws Exception { Set handlers = new HashSet(); handlers.addAll(_discoverableAnnotationHandlers); @@ -1031,7 +1042,8 @@ public class AnnotationConfiguration extends AbstractConfiguration handlers.add(_classInheritanceHandler); handlers.addAll(_containerInitializerAnnotationHandlers); - _webInfClassesStats = new CounterStatistic(); + if (LOG.isDebugEnabled()) + _webInfClassesStats = new CounterStatistic(); for (Resource dir : context.getMetaData().getWebInfClassesDirs()) { @@ -1039,9 +1051,11 @@ public class AnnotationConfiguration extends AbstractConfiguration { ParserTask task = new ParserTask(parser, handlers, dir); _parserTasks.add(task); - _webInfClassesStats.increment(); if (LOG.isDebugEnabled()) + { + _webInfClassesStats.increment(); task.setStatistic(new TimeStatistic()); + } } } } diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java index bc1ca64b7ef..a57c8a606d4 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java @@ -33,6 +33,7 @@ import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.resource.Resource; +import org.eclipse.jetty.util.statistic.CounterStatistic; import org.eclipse.jetty.webapp.WebAppContext; import org.osgi.framework.Bundle; import org.osgi.framework.Constants; @@ -110,6 +111,9 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot throws Exception { AnnotationParser oparser = (AnnotationParser)parser; + + if (_webInfLibStats == null) + _webInfLibStats = new CounterStatistic(); Bundle webbundle = (Bundle) context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE); Set fragAndRequiredBundles = (Set)context.getAttribute(OSGiWebInfConfiguration.FRAGMENT_AND_REQUIRED_BUNDLES); @@ -132,12 +136,14 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot { //a fragment indeed: parseFragmentBundle(context,oparser,webbundle,bundle); + _webInfLibStats.increment(); } } } //scan ourselves oparser.indexBundle(webbundle); parseWebBundle(context,oparser,webbundle); + _webInfLibStats.increment(); //scan the WEB-INF/lib super.parseWebInfLib(context,parser); @@ -154,6 +160,7 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot { //a bundle indeed: parseRequiredBundle(context,oparser,webbundle,requiredBundle); + _webInfLibStats.increment(); } } } diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java index 4ce92cb4e4f..d65d947cf8a 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java @@ -53,7 +53,7 @@ import org.osgi.framework.BundleContext; public class TestJettyOSGiBootWithAnnotations { - private static final String LOG_LEVEL = "WARN"; + private static final String LOG_LEVEL = "DEBUG"; @Inject BundleContext bundleContext = null;