Skip to content

Commit

Permalink
use a wrapped request context instead of a copy (#373)
Browse files Browse the repository at this point in the history
Co-authored-by: Thorsten Marx <[email protected]>
  • Loading branch information
thmarx and Thorsten Marx authored Jan 13, 2025
1 parent 95f224e commit 54cde55
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
*/


import com.condation.cms.api.feature.Feature;
import com.condation.cms.api.feature.FeatureContainer;
import com.condation.cms.api.request.RequestContext;
import com.condation.modules.api.ModuleRequestContext;
import lombok.RequiredArgsConstructor;

Expand All @@ -34,4 +36,39 @@
@RequiredArgsConstructor
public class CMSRequestContext extends FeatureContainer implements ModuleRequestContext {

private final RequestContext requestContext;

@Override
public void close() throws Exception {
if (requestContext == null) {
return;
}
requestContext.close();
}

@Override
public <T extends Feature> T get(Class<T> featureClass) {
if (requestContext == null) {
return null;
}
return requestContext.get(featureClass);
}

@Override
public <T extends Feature> void add(Class<T> featureClass, T feature) {
if (requestContext == null) {
return;
}
requestContext.add(featureClass, feature);
}

@Override
public boolean has(Class<? extends Feature> featureClass) {
if (requestContext == null) {
return false;
}
return requestContext.has(featureClass);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,7 @@ public ModuleManager moduleManager(Injector injector, CMSModuleContext context,
@Singleton
public ModuleRequestContextFactory requestContextFactory() {
return () -> {
final CMSRequestContext requestContext = new CMSRequestContext();
var rc = ThreadLocalRequestContext.REQUEST_CONTEXT.get();
if (rc != null) {
requestContext.features.putAll(rc.features);
}
return requestContext;
return new CMSRequestContext(ThreadLocalRequestContext.REQUEST_CONTEXT.get());
};
}

Expand Down
2 changes: 1 addition & 1 deletion distribution/build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="distribution" default="distribution" basedir=".">
<property name="cms.version">7.5.0</property>
<property name="cms.version">7.6.0</property>

<target name="copy-server" description="--> copy server">
<unzip src="../cms-server/target/cms-server-${cms.version}.zip" dest="temp/" />
Expand Down

0 comments on commit 54cde55

Please sign in to comment.