-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from openstandia/MID-7135
MID-7135 Add no-serialization option for Wicket
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 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
13 changes: 13 additions & 0 deletions
13
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/WicketConfigurator.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,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); | ||
} |
49 changes: 49 additions & 0 deletions
49
...i/src/main/java/com/evolveum/midpoint/web/security/WicketNoSerializationConfigurator.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,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); | ||
} | ||
} | ||
} |