diff --git a/micro-core/src/main/java/com/aol/micro/server/servers/AccessLogLocationBean.java b/micro-core/src/main/java/com/aol/micro/server/servers/AccessLogLocationBean.java index 7783ffd31..0710417f5 100644 --- a/micro-core/src/main/java/com/aol/micro/server/servers/AccessLogLocationBean.java +++ b/micro-core/src/main/java/com/aol/micro/server/servers/AccessLogLocationBean.java @@ -13,7 +13,7 @@ public class AccessLogLocationBean { private final String accessLogLocation; @Autowired - public AccessLogLocationBean(@Value("${access.log.output:/data/servers/logs/}") String accessLogLocation) { + public AccessLogLocationBean(@Value("${access.log.output:./logs/}") String accessLogLocation) { this.accessLogLocation = accessLogLocation; } diff --git a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/GrizzlyApplication.java b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/GrizzlyApplication.java index 5a9691aa9..40270f7b6 100644 --- a/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/GrizzlyApplication.java +++ b/micro-core/src/main/java/com/aol/micro/server/servers/grizzly/GrizzlyApplication.java @@ -16,6 +16,7 @@ import org.glassfish.grizzly.http.server.accesslog.AccessLogBuilder; import org.glassfish.grizzly.servlet.ServletRegistration; import org.glassfish.grizzly.servlet.WebappContext; +import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletContainer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,6 +86,10 @@ private void startServer(WebappContext webappContext, HttpServer httpServer, Com .getModule().getContext(), serverData.getPort()); logger.info("Browse to http://localhost:{}/{}/application.wadl", serverData.getPort(), serverData.getModule().getContext()); + logger.info("Configured resource classes :-"); + serverData.extractResources() + .forEach(t -> logger.info(t.v1 + " : " + "http://localhost:"+serverData.getPort() + +"/"+serverData.getModule().getContext() + t.v2 ));; httpServer.start(); start.complete(true); end.get(); diff --git a/micro-core/src/main/java/com/aol/micro/server/servers/model/ServerData.java b/micro-core/src/main/java/com/aol/micro/server/servers/model/ServerData.java index aa253b474..8d7e5d00b 100644 --- a/micro-core/src/main/java/com/aol/micro/server/servers/model/ServerData.java +++ b/micro-core/src/main/java/com/aol/micro/server/servers/model/ServerData.java @@ -1,10 +1,18 @@ package com.aol.micro.server.servers.model; +import static org.jooq.lambda.tuple.Tuple.tuple; + import java.util.List; +import java.util.stream.Stream; + +import javax.ws.rs.Path; import lombok.Getter; import lombok.experimental.Builder; +import org.jooq.lambda.tuple.Tuple2; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import com.aol.micro.server.module.Module; @@ -13,6 +21,8 @@ @Getter @Builder public class ServerData { + + private final Logger logger = LoggerFactory.getLogger(getClass()); private final int port; @@ -32,5 +42,14 @@ public ServerData(int port, List resources, this.baseUrlPattern = baseUrlPattern; } + public Stream> extractResources() { + + + return resources.stream().map(resource -> tuple(resource.getClass().getName(), + resource.getClass().getAnnotation(Path.class).value())); + + + } + } diff --git a/micro-core/src/test/java/com/aol/micro/server/model/ServerDataTest.java b/micro-core/src/test/java/com/aol/micro/server/model/ServerDataTest.java index cb6ef0085..d4aa0f4d4 100644 --- a/micro-core/src/test/java/com/aol/micro/server/model/ServerDataTest.java +++ b/micro-core/src/test/java/com/aol/micro/server/model/ServerDataTest.java @@ -3,9 +3,8 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; + +import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; @@ -13,8 +12,6 @@ import app.servlet.com.aol.micro.server.ServletStatusResource; -import com.aol.micro.server.module.Module; -import com.aol.micro.server.rest.swagger.SwaggerInitializer; import com.aol.micro.server.servers.model.ServerData; import com.google.common.collect.Lists; @@ -38,6 +35,30 @@ public void testGetters() { assertThat(serverData.getModule().getContext(), is("context")); assertThat(serverData.getPort(), is(8080)); } + + @Test(expected=NullPointerException.class) + public void testExtractNull(){ + + serverData = new ServerData(8080, Lists.newArrayList((Object)null), rootContext, "url", + ()->"context"); + serverData.extractResources(); + + } + + @Test + public void testExtractResourceClassName(){ + + + assertThat(serverData.extractResources().collect(Collectors.toList()).get(0).v1,is(ServletStatusResource.class.getName())); + + } + @Test + public void testExtractResourcePath(){ + + + assertThat(serverData.extractResources().collect(Collectors.toList()).get(0).v2,is("/servlet")); + + } }