[Minor] Updated restful logging

This commit is contained in:
Robert von Burg 2024-04-23 14:29:03 +02:00
parent 3edcec4d08
commit 4b78b30600
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
2 changed files with 7 additions and 3 deletions

View File

@ -204,14 +204,15 @@ public class RestfulStrolchComponent extends StrolchComponent {
@Override
public void start() throws Exception {
DBC.PRE.assertNull("Instance is already set! This component is a singleton resource!", instance);
instance = this;
if (instance == null)
instance = this;
else if (instance != this)
throw new IllegalStateException("Instance is already set! This component is a singleton resource!");
super.start();
}
@Override
public void stop() throws Exception {
instance = null;
super.stop();
}

View File

@ -13,6 +13,7 @@ import java.io.IOException;
import static li.strolch.rest.StrolchRestfulConstants.STROLCH_REMOTE_IP;
import static li.strolch.rest.StrolchRestfulConstants.STROLCH_REQUEST_URL;
import static li.strolch.rest.helper.ServletRequestHelper.logRequest;
@PreMatching
public class LogRequestFilter implements ContainerRequestFilter {
@ -31,5 +32,7 @@ public class LogRequestFilter implements ContainerRequestFilter {
this.request.setAttribute(STROLCH_REMOTE_IP, remoteIp);
this.request.setAttribute(STROLCH_REQUEST_URL,
requestContext.getMethod() + " " + requestContext.getUriInfo().getRequestUri());
logRequest(this.request);
}
}