Skip to content

Commit

Permalink
MID-7135 Add no-serialization option for Wicket
Browse files Browse the repository at this point in the history
  • Loading branch information
wadahiro committed May 6, 2022
1 parent 1e141fb commit 17dcb5c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public class MidPointApplication extends AuthenticatedWebApplication implements
@Autowired private SystemConfigurationChangeDispatcher systemConfigurationChangeDispatcher;
@Autowired private Clock clock;
@Autowired private AccessCertificationService certificationService;
@Autowired(required = false) private List<WicketConfigurator> wicketConfigurators = new ArrayList<>();
@Autowired @Qualifier("descriptorLoader") private DescriptorLoader descriptorLoader;
@Value("${midpoint.additionalPackagesToScan:}") private String additionalPackagesToScan;

Expand Down Expand Up @@ -323,6 +324,8 @@ public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior, AjaxReque
taskManager.setWebContextPath(servletContext.getContextPath());
}

// Additional wicket configuration
wicketConfigurators.forEach(c -> c.configure(this));
}

public DeploymentInformationType getDeploymentInfo() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.web.security;

import org.apache.wicket.Application;

public interface WicketConfigurator {
void configure(Application application);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.web.security;

import org.apache.wicket.Application;
import org.apache.wicket.DefaultPageManagerProvider;
import org.apache.wicket.page.IPageManager;
import org.apache.wicket.page.PageManager;
import org.apache.wicket.pageStore.IPageStore;
import org.apache.wicket.pageStore.InMemoryPageStore;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnProperty(name = "wicket.no-serialization.enabled", havingValue = "true")
public class WicketNoSerializationConfigurator implements WicketConfigurator {

@Value("${wicket.no-serialization.max-pages:1}")
private int maxPages;

@Override
public void configure(Application application) {
application.setPageManagerProvider(new NoSerializationPageManagerProvider(application));
}

private class NoSerializationPageManagerProvider extends DefaultPageManagerProvider {

public NoSerializationPageManagerProvider(Application application) {
super(application);
}

@Override
public IPageManager get() {
IPageStore store = newPersistentStore();
store = newCachingStore(store);
store = newRequestStore(store);
return new PageManager(store);
}

protected IPageStore newPersistentStore() {
return new InMemoryPageStore(application.getName(), maxPages);
}
}
}

0 comments on commit 17dcb5c

Please sign in to comment.