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

FISH-1315 Improve loading time for REST application when there are many password aliases #5177 #5200

Merged
merged 4 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -106,29 +106,29 @@ public void setCorsHeaders(boolean withCorsHeaders) {
this.withCorsHeaders = withCorsHeaders;
}

public void registerApp(String applicationId, DeploymentContext ctx) {
public void registerApp(String applicationId, DeploymentContext ctx) {
final WebBundleDescriptorImpl descriptor = ctx.getModuleMetaData(WebBundleDescriptorImpl.class);
final String contextRoot = descriptor.getContextRoot();
final ReadableArchive archive = ctx.getSource();
final ClassLoader classLoader = ctx.getClassLoader();
documents.put(applicationId, new OpenAPISupplier(applicationId, contextRoot, archive, classLoader));
cachedResult = null;
}
}

public void deregisterApp(String applicationId) {
public void deregisterApp(String applicationId) {
documents.remove(applicationId);
cachedResult = null;
}
}

public void resumeApp(String applicationId) {
public void resumeApp(String applicationId) {
documents.get(applicationId).setEnabled(true);
cachedResult = null;
}
}

public void suspendApp(String applicationId) {
public void suspendApp(String applicationId) {
documents.get(applicationId).setEnabled(false);
cachedResult = null;
}
}

/**
* @return the document If multiple application deployed then merge all the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2018-2020 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2018-2021 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -47,26 +47,29 @@
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.config.support.TranslatedConfigView;
import org.glassfish.internal.api.Globals;

import java.util.Set;
import java.util.HashSet;
import java.util.Objects;

/**
*
* @author steve
*/
public class PasswordAliasConfigSource extends PayaraConfigSource {

private final DomainScopedPasswordAliasStore store;

public PasswordAliasConfigSource() {
store = Globals.getDefaultHabitat().getService(DomainScopedPasswordAliasStore.class);
}

@Override
public int getOrdinal() {
return Integer.parseInt(configService.getMPConfig().getPasswordOrdinality());
Expand All @@ -76,21 +79,21 @@ public int getOrdinal() {
@Override
public Map<String, String> getProperties() {
Map<String,String> properties = new HashMap<>();
if (store != null) {
Iterator<String> keys = store.keys();
while (keys.hasNext()){
String key = keys.next();
properties.put(key, new String(store.get(key)));
}
}
store.keys().forEachRemaining(key -> properties.put(key, new String(store.get(key))));
return properties;
}

@Override
public Set<String> getPropertyNames() {
Set<String> propertyNames = new HashSet<>();
store.keys().forEachRemaining(propertyNames::add);
return propertyNames;
}


@Override
public String getValue(String name) {
if (name == null || store == null) {
return null;
}
Objects.requireNonNull(name, "Name perameter cannot be null");

String value = null;

Expand Down Expand Up @@ -119,5 +122,4 @@ public String getValue(String name) {
public String getName() {
return "Password Alias";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private <T> T getValueInternal(String propertyName, Class<T> propertyType) {
public Iterable<String> getPropertyNames() {
List<String> result = new ArrayList<>();
for (ConfigSource configSource : sources) {
result.addAll(configSource.getProperties().keySet());
result.addAll(configSource.getPropertyNames());
}
return result;
}
Expand Down