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-9098: fix for deployments caused by referenced resources from apps #6852

Merged
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 @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2024] [Payara Foundation and/or its affiliates]

package org.glassfish.resourcebase.resources.util;

Expand All @@ -54,6 +55,7 @@

import org.glassfish.logging.annotation.LoggerInfo;
import org.glassfish.logging.annotation.LogMessagesResourceBundle;
import org.jvnet.hk2.config.TransactionFailure;


/**
Expand Down Expand Up @@ -187,14 +189,35 @@ public boolean isBindableResourceEnabled(BindableResource br){
resourceRefEnabled = Boolean.valueOf(ref.getEnabled());
} else {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourcesUtil :: isResourceReferenceEnabled null ref");
_logger.fine("ResourcesUtil :: isResourceReferenceEnabled null ref in Server" + getServer().getName());
}
try {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourcesUtil :: Verifying resource in domain" + br.getJndiName());
}
return verifyResourceInDomain(br.getJndiName());
} catch (TransactionFailure e) {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourcesUtil :: issue when verifying resource in domain:" + br.getJndiName());
}
return false;
}

}

boolean resourceEnabled = Boolean.valueOf(br.getEnabled());
boolean resourceEnabled = Boolean.parseBoolean(br.getEnabled());
return resourceEnabled && resourceRefEnabled;
}

private boolean verifyResourceInDomain(String jndiName) throws TransactionFailure {
Resources resources = getDomainResources();
if (resources == null) {
return false;
}
BindableResource bindableResource = ResourceUtil.getBindableResourceByName(resources, jndiName);
return bindableResource != null;
}

//TODO duplicate code in com.sun.enterprise.connectors.util.ResourcesUtil.java
/*public boolean isNonConnectorBindableResourceEnabled(BindableResource br, ResourceInfo resourceInfo){
boolean enabled = false;
Expand Down Expand Up @@ -262,9 +285,21 @@ public boolean isBindableResourceEnabled(BindableResource br){

private Server getServer(){
if(server == null){
server = habitat.<Domain>getService(Domain.class).getServerNamed(environment.getInstanceName());
server = habitat.getService(Domain.class).getServerNamed(environment.getInstanceName());
}
return server;
}

private Domain getDomain() {
return habitat.getService(Domain.class);
}

private Resources getDomainResources() {
Domain domain = getDomain();
if(domain != null) {
return getDomain().getResources();
}
return null;
}

}