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-477 Deployment group properties are now resolved #4850

Merged
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 @@ -65,6 +65,7 @@
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.config.support.TranslatedConfigView;
import org.glassfish.hk2.runlevel.RunLevel;
import org.glassfish.internal.api.JavaEEContextUtil;
import org.glassfish.internal.api.JavaEEContextUtil.Context;
Expand Down Expand Up @@ -840,7 +841,7 @@ private void validateJNDIRefs(DeploymentContext deploymentContext, Application a
"JNDI lookup failed for the resource: Name: {0}, Lookup: {1}, Type: {2}",
resource.getName(), null, resource.getType()));
}
String jndiName = resource.getJndiName();
String jndiName = TranslatedConfigView.expandConfigValue(resource.getJndiName());
if (jndiName == null) {
// there's no mapping in this resource, but it exists in JNDI namespace, so it's validated by other ref.
return;
Expand Down Expand Up @@ -895,12 +896,10 @@ private void validateJNDIRefs(DeploymentContext deploymentContext, Application a
} catch (NamingException e) {
deplLogger.log(Level.SEVERE, RESOURCE_REF_JNDI_LOOKUP_FAILED,
new Object[]{resource.getName(), jndiName, resource.getType()});
DeploymentException de = new DeploymentException(localStrings.getLocalString(
throw new DeploymentException(localStrings.getLocalString(
"enterprise.deployment.util.resource.validation",
"JNDI lookup failed for the resource: Name: {0}, Lookup: {1}, Type: {2}",
resource.getName(), jndiName, resource.getType()));
de.initCause(e);
throw de;
resource.getName(), jndiName, resource.getType()), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2020] Payara Foundation and/or affiliates

package com.sun.enterprise.v3.server;

import com.sun.enterprise.config.serverbeans.Cluster;
Expand All @@ -59,6 +61,8 @@
import com.sun.enterprise.util.SystemPropertyConstants;
import com.sun.appserv.server.util.Version;
import com.sun.enterprise.universal.io.SmartFile;
import fish.payara.enterprise.config.serverbeans.DeploymentGroup;
import java.util.ArrayList;

import org.jvnet.hk2.annotations.Optional;
import org.glassfish.hk2.api.PostConstruct;
Expand All @@ -74,6 +78,7 @@
import java.util.logging.Logger;
import java.util.logging.Level;
import org.glassfish.kernel.KernelLoggerInfo;
import org.jvnet.hk2.config.types.Property;

/**
* Init run level service to take care of vm related tasks.
Expand Down Expand Up @@ -107,7 +112,7 @@ public void postConstruct() {
setSystemPropertiesFromEnv();
setSystemPropertiesFromDomainXml();
resolveJavaConfig();
_logger.fine("SystemTasks: loaded server named: " + server.getName());
_logger.log(Level.FINE, "SystemTasks: loaded server named: {0}", server.getName());
}

@Override
Expand All @@ -120,14 +125,11 @@ public void writePidFile() {
String pidString = getPidString();
FileUtils.writeStringToFile(pidString, pidFile);
FileUtils.writeStringToFile(pidString, pidFileCopy);
}
catch (PidException pe) {
} catch (PidException pe) {
_logger.warning(pe.getMessage());
}
catch (Exception e) {
} catch (Exception e) {
_logger.warning(strings.get("internal_error", e));
}
finally {
} finally {
if (pidFile != null) {
FileUtils.deleteOnExit(pidFile);
}
Expand Down Expand Up @@ -157,8 +159,7 @@ private void setSystemPropertiesFromEnv() {
hostname = NetUtils.getCanonicalHostName();


}
catch (Exception ex) {
} catch (Exception ex) {
if (_logger != null) {
_logger.log(Level.SEVERE, KernelLoggerInfo.exceptionHostname, ex);
}
Expand All @@ -173,15 +174,20 @@ private void setSystemPropertiesFromDomainXml() {
// 0. server
// 1. cluster
// 2. <server>-config or <cluster>-config
// 3. domain
// 3. deployment-group
// 4. domain
// so we need to add System Properties in *reverse order* to get the
// right precedence.

List<SystemProperty> domainSPList = domain.getSystemProperty();
List<SystemProperty> configSPList = getConfigSystemProperties();
Cluster cluster = server.getCluster();
List<SystemProperty> clusterSPList = null;

List<DeploymentGroup> depGroups = server.getDeploymentGroup();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be null?
Having trouble reproducing atm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be null, but the list may be of length 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be null, but is can be a 0-sized list.

List<Property> depGroupProperties = new ArrayList<>();
for (DeploymentGroup group : depGroups) {
depGroupProperties.addAll(group.getProperty());
}

if (cluster != null) {
clusterSPList = cluster.getSystemProperty();
Expand All @@ -190,10 +196,9 @@ private void setSystemPropertiesFromDomainXml() {
}
List<SystemProperty> serverSPList = server.getSystemProperty();

setSystemProperties(
domainSPList);
setSystemProperties(
configSPList);
setSystemProperties(domainSPList);
setProperties(depGroupProperties);
setSystemProperties(configSPList);


if (clusterSPList != null) {
Expand Down Expand Up @@ -236,7 +241,7 @@ private void resolveJavaConfig() {
setSystemProperty(m.group(1), value);

if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Setting " + m.group(1) + " = " + value);
_logger.log(Level.FINE, "Setting {0} = {1}", new Object[]{m.group(1), value});
}
}
}
Expand All @@ -253,6 +258,15 @@ private void setSystemProperties(List<SystemProperty> spList) {
}
}
}

private void setProperties(List<Property> propList) {
for (Property prop: propList) {
String name = prop.getName();
if (ok(name)) {
setSystemProperty(name, prop.getValue());
}
}
}

private String getPidString() {
return "" + ProcessUtils.getPid();
Expand Down