Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#675 - Prevent jsonb instantiation on every call. #686

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,24 @@ public class JsonbUtil {
*/
public static final String JSONB_CONFIG_PREFIX = "coffee.jsonb.config";

/**
* Create {@link Jsonb} instance with {@link FieldOnlyVisibilityStrategy} property visibility strategy.
*
* @return configured {@link Jsonb} instance
*/
public static Jsonb getContext() {
private static final Jsonb JSONB;

static {
Config config = ConfigUtil.getInstance().defaultConfig();
JsonbConfig jsonbConfig = new JsonbConfig()
// property visibility strategy setting
.withPropertyVisibilityStrategy(getPropertyVisibilityStrategyClass(config))
.withBinaryDataStrategy(getBinaryDataStrategy(config));
return JsonbBuilder.newBuilder().withConfig(jsonbConfig).build();
JSONB = JsonbBuilder.newBuilder().withConfig(jsonbConfig).build();
bucherarnold marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* {@link Jsonb} instance getter.
*
* @return configured {@link Jsonb} instance
*/
public static Jsonb getContext() {
return JSONB;
bucherarnold marked this conversation as resolved.
Show resolved Hide resolved
}

private static PropertyVisibilityStrategy getPropertyVisibilityStrategyClass(Config config) {
Expand Down
Loading