Skip to content

Commit

Permalink
Merge pull request payara#5200 from AngelTG2/issue-5177
Browse files Browse the repository at this point in the history
FISH-1315 Improve loading time for REST application when there are many password aliases payara#5177
  • Loading branch information
Alan authored and JamesHillyard committed Oct 8, 2021
1 parent 5c133be commit 1a84684
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
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

0 comments on commit 1a84684

Please sign in to comment.