Skip to content

Commit

Permalink
Merge branch 'master' of github.com:aol/micro-server
Browse files Browse the repository at this point in the history
  • Loading branch information
Ke Wang committed Mar 20, 2015
2 parents 74a11ac + 404f2e2 commit 0e56f2f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion micro-boot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ modifyPom {

groupId 'com.aol.microservices'
artifactId 'microserver-boot'
version '0.5'
version '0.51'

scm {
url 'scm:[email protected]:aol/micro-server.git'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@Rest
@Path("/single")
public class MinimalClassTest implements RestResource{
public class MinimalClassTest {

RestAgent rest = new RestAgent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> filterData;

Expand All @@ -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),
Expand All @@ -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<? extends Filter> getClass(FilterConfiguration filter) {
if (filter.getFilter() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Servlet> getServlet(ServletConfiguration servlet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServletContextListener> listenerData;

Expand All @@ -24,9 +27,17 @@ 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());

}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@Rest
@Path("/single")
public class MinimalClassTest implements RestResource{
public class MinimalClassTest {

RestAgent rest = new RestAgent();

Expand Down
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -40,15 +40,15 @@ Microserver core
<dependency>
<groupId>com.aol.microservices</groupId>
<artifactId>microserver-core</artifactId>
<version>0.5</version>
<version>0.51</version>
</dependency>

Microserver Spring Boot

<dependency>
<groupId>com.aol.microservices</groupId>
<artifactId>microserver-boot</artifactId>
<version>0.5</version>
<version>0.51</version>
</dependency>


Expand All @@ -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

Expand Down

0 comments on commit 0e56f2f

Please sign in to comment.