-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rafactor theme context path update request context creation
- Loading branch information
Thorsten Marx
committed
Jan 30, 2024
1 parent
86df562
commit 86f3774
Showing
29 changed files
with
254 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
cms-server/src/main/java/com/github/thmarx/cms/server/jetty/filter/RequestContextFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.github.thmarx.cms.server.jetty.filter; | ||
|
||
/*- | ||
* #%L | ||
* cms-server | ||
* %% | ||
* Copyright (C) 2023 Marx-Software | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ | ||
import com.github.thmarx.cms.api.request.ThreadLocalRequestContext; | ||
import com.github.thmarx.cms.request.RequestContextFactory; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.eclipse.jetty.server.Handler; | ||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.Response; | ||
import org.eclipse.jetty.util.Callback; | ||
|
||
/** | ||
* | ||
* @author t.marx | ||
*/ | ||
@Slf4j | ||
public class RequestContextFilter extends Handler.Wrapper { | ||
|
||
private final RequestContextFactory requestContextFactory; | ||
|
||
public static final String REQUEST_CONTEXT = "_requestContext"; | ||
|
||
public RequestContextFilter(final Handler handler, final RequestContextFactory requestContextFactory) { | ||
super(handler); | ||
this.requestContextFactory = requestContextFactory; | ||
} | ||
|
||
@Override | ||
public boolean handle(Request rqst, Response rspns, Callback clbck) throws Exception { | ||
try ( | ||
var requestContext = requestContextFactory.create(rqst)) { | ||
|
||
ThreadLocalRequestContext.REQUEST_CONTEXT.set(requestContext); | ||
|
||
rqst.setAttribute(REQUEST_CONTEXT, requestContext); | ||
|
||
return super.handle(rqst, rspns, clbck); | ||
|
||
} finally { | ||
ThreadLocalRequestContext.REQUEST_CONTEXT.remove(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.