From a0d4cb0fcd9498ca5cb0dc6bc1a1936052c6d84c Mon Sep 17 00:00:00 2001 From: John McClean Date: Thu, 19 Mar 2015 16:15:41 +0000 Subject: [PATCH 1/3] log servlets, filters, listeners --- .../servers/grizzly/FilterConfigurer.java | 17 ++++++++++++++++- .../servers/grizzly/ServletConfigurer.java | 13 +++++++++---- .../ServletContextListenerConfigurer.java | 11 ++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/FilterConfigurer.java b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/FilterConfigurer.java index 174e112fb..0b95077ef 100644 --- a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/FilterConfigurer.java +++ b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/FilterConfigurer.java @@ -9,15 +9,19 @@ import org.glassfish.grizzly.servlet.FilterRegistration; import org.glassfish.grizzly.servlet.WebappContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.aol.micro.server.auto.discovery.FilterConfiguration; +import com.aol.micro.server.auto.discovery.ServletConfiguration; import com.aol.micro.server.servers.model.FilterData; import com.aol.micro.server.servers.model.ServerData; +import com.aol.micro.server.servers.model.ServletData; import com.google.common.collect.ImmutableList; @AllArgsConstructor public class FilterConfigurer { - + private final Logger logger = LoggerFactory.getLogger(getClass()); private final ServerData serverData; private final ImmutableList filterData; @@ -33,6 +37,8 @@ private void addAutoDiscoveredFilters(WebappContext webappContext) { .getRootContext() .getBeansOfType(FilterConfiguration.class) .values() + .stream() + .peek(this::logFilter) .forEach( filter -> setInitParameters( webappContext.addFilter(getName(filter), @@ -49,8 +55,17 @@ private void addExplicitlyDeclaredFilters(WebappContext webappContext) { filterReg.addMappingForUrlPatterns( EnumSet.allOf(DispatcherType.class), filterData.getMapping()); + logFilter(filterData); } } + private void logFilter(FilterData filter) { + logger.info("Registering {} filter on {}",filter.getFilter().getClass().getName(), filter.getMapping()); + + } + + private void logFilter(FilterConfiguration filter) { + logger.info("Registering {} filter on {}",filter.getClass().getName(),filter.getMapping()[0]); + } private Class getClass(FilterConfiguration filter) { if (filter.getFilter() != null) diff --git a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletConfigurer.java b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletConfigurer.java index 0af0e76e2..d7fb520ed 100644 --- a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletConfigurer.java +++ b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletConfigurer.java @@ -43,15 +43,20 @@ private void addAutoDiscoveredServlets(WebappContext webappContext) { private void addExplicitlyDeclaredServlets(WebappContext webappContext) { for (ServletData servletData : servletData) { - ServletRegistration filterReg = webappContext.addServlet( + ServletRegistration servletReg = webappContext.addServlet( servletData.getServletName(), servletData.getServlet()); - filterReg.addMapping(servletData.getMapping()); + servletReg.addMapping(servletData.getMapping()); + logServlet(servletData); } } + private void logServlet(ServletData servlet) { + logger.info("Registering {} servlet on {}",servlet.getServlet().getClass().getName(), servlet.getMapping()); + + } + private void logServlet(ServletConfiguration servlet) { - logger.info("Registering servlet on " + servlet.getMapping()[0]); - ; + logger.info("Registering {} servlet on {}",servlet.getClass().getName(), servlet.getMapping()[0]); } private Class getServlet(ServletConfiguration servlet) { diff --git a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java index 38c58c910..dba313152 100644 --- a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java +++ b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java @@ -7,15 +7,18 @@ import lombok.AllArgsConstructor; import org.glassfish.grizzly.servlet.WebappContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.web.context.ContextLoaderListener; - import com.aol.micro.server.rest.jersey.JerseySpringIntegrationContextListener; +import com.aol.micro.server.servers.model.FilterData; import com.aol.micro.server.servers.model.ServerData; @AllArgsConstructor public class ServletContextListenerConfigurer { + private final Logger logger = LoggerFactory.getLogger(getClass()); private final ServerData serverData; private final List listenerData; @@ -24,9 +27,15 @@ public void addListeners(WebappContext webappContext) { serverData.getRootContext() .getBeansOfType(ServletContextListener.class) .values() + .stream() + .peek(this::logListener) .forEach(listener -> webappContext.addListener(listener)); listenerData.forEach(it -> webappContext.addListener(it)); } + private void logListener(ServletContextListener listener) { + logger.info("Registering servlet context listener {}",listener.getClass().getName()); + + } From 1eacc2b269a654ed5546389336bc4e342daf7711 Mon Sep 17 00:00:00 2001 From: John McClean Date: Thu, 19 Mar 2015 23:17:49 +0000 Subject: [PATCH 2/3] increment version --- micro-boot/build.gradle | 2 +- .../grizzly/ServletContextListenerConfigurer.java | 2 ++ readme.md | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/micro-boot/build.gradle b/micro-boot/build.gradle index 3f19ca564..e55f7a62d 100644 --- a/micro-boot/build.gradle +++ b/micro-boot/build.gradle @@ -18,7 +18,7 @@ modifyPom { groupId 'com.aol.microservices' artifactId 'microserver-boot' - version '0.5' + version '0.51' scm { url 'scm:git@github.com:aol/micro-server.git' diff --git a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java index dba313152..48ea4eb1f 100644 --- a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java +++ b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/ServletContextListenerConfigurer.java @@ -27,7 +27,9 @@ public void addListeners(WebappContext webappContext) { serverData.getRootContext() .getBeansOfType(ServletContextListener.class) .values() + .stream() + .peek(this::logListener) .forEach(listener -> webappContext.addListener(listener)); listenerData.forEach(it -> webappContext.addListener(it)); diff --git a/readme.md b/readme.md index d3912176b..b89122e1d 100644 --- a/readme.md +++ b/readme.md @@ -17,9 +17,9 @@ To make developing, debuging and deploying Java microservices simple. [Example Apps : Microserver Boot](https://github.com/aol/micro-server/tree/master/micro-boot/src/test/java/app) -[Java Doc : Microserver Core](http://www.javadoc.io/doc/com.aol.microservices/microserver-core/0.5) +[Java Doc : Microserver Core](http://www.javadoc.io/doc/com.aol.microservices/microserver-core/0.51) -[Java Doc : Microserver Boot](http://www.javadoc.io/doc/com.aol.microservices/microserver-core/0.5) +[Java Doc : Microserver Boot](http://www.javadoc.io/doc/com.aol.microservices/microserver-core/0.51) ##Getting started @@ -40,7 +40,7 @@ Microserver core com.aol.microservices microserver-core - 0.5 + 0.51 Microserver Spring Boot @@ -48,7 +48,7 @@ Microserver Spring Boot com.aol.microservices microserver-boot - 0.5 + 0.51 @@ -57,11 +57,11 @@ Microserver Spring Boot Microserver core - compile group: 'com.aol.microservices', name:'microserver-core', version:'0.5' + compile group: 'com.aol.microservices', name:'microserver-core', version:'0.51' Microserver Spring Boot - compile group: 'com.aol.microservices', name:'microserver-boot', version:'0.5' + compile group: 'com.aol.microservices', name:'microserver-boot', version:'0.51' ##Tech Stack From 61cb729c6d4a34be54e1ce78300884334d7b81f0 Mon Sep 17 00:00:00 2001 From: John McClean Date: Fri, 20 Mar 2015 15:28:49 +0000 Subject: [PATCH 3/3] clean up --- .../java/app/minimal/com/aol/micro/server/MinimalClassTest.java | 2 +- .../java/app/minimal/com/aol/micro/server/MinimalClassTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/micro-boot/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java b/micro-boot/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java index 2f31dd121..4d54e1b58 100644 --- a/micro-boot/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java +++ b/micro-boot/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java @@ -20,7 +20,7 @@ @Rest @Path("/single") -public class MinimalClassTest implements RestResource{ +public class MinimalClassTest { RestAgent rest = new RestAgent(); diff --git a/micro-core/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java b/micro-core/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java index 26f3b3ee0..04367ecbd 100644 --- a/micro-core/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java +++ b/micro-core/src/test/java/app/minimal/com/aol/micro/server/MinimalClassTest.java @@ -20,7 +20,7 @@ @Rest @Path("/single") -public class MinimalClassTest implements RestResource{ +public class MinimalClassTest { RestAgent rest = new RestAgent();