use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectionManagerImpl method validateResourceAndPool.
private void validateResourceAndPool() throws ResourceException {
ResourceInfo resourceInfo = this.resourceInfo;
ResourcesUtil resourcesUtil = ResourcesUtil.createInstance();
ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
ConnectorRegistry registry = ConnectorRegistry.getInstance();
// are disabled.
if (!registry.isResourceDeployed(resourceInfo)) {
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "resourceInfo not found in connector-registry : " + resourceInfo);
}
boolean isDefaultResource = false;
boolean isSunRAResource = false;
ConnectorDescriptor descriptor = registry.getDescriptor(rarName);
if (descriptor != null) {
isDefaultResource = descriptor.getDefaultResourcesNames().contains(resourceInfo.getName());
if (descriptor.getSunDescriptor() != null) {
com.sun.enterprise.deployment.runtime.connector.ResourceAdapter rar = descriptor.getSunDescriptor().getResourceAdapter();
if (rar != null) {
String sunRAJndiName = (String) rar.getValue(com.sun.enterprise.deployment.runtime.connector.ResourceAdapter.JNDI_NAME);
isSunRAResource = resourceInfo.getName().equals(sunRAJndiName);
}
}
}
if ((runtime.isServer() || runtime.isEmbedded()) && (!resourceInfo.getName().contains(ConnectorConstants.DATASOURCE_DEFINITION_JNDINAME_PREFIX) && (!isDefaultResource) && (!isSunRAResource))) {
// resources config bean each time.
if (resourceConfiguration == null) {
resourceConfiguration = (BindableResource) resourcesUtil.getResource(resourceInfo, BindableResource.class);
if (resourceConfiguration == null) {
String suffix = ConnectorsUtil.getValidSuffix(resourceInfo.getName());
// check for the enabled status and existence using non-prefixed resource-name
if (suffix != null) {
String nonPrefixedName = resourceInfo.getName().substring(0, resourceInfo.getName().lastIndexOf(suffix));
resourceInfo = new ResourceInfo(nonPrefixedName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
resourceConfiguration = (BindableResource) resourcesUtil.getResource(resourceInfo, BindableResource.class);
}
}
} else {
// we cache the resourceConfiguration for performance optimization.
// make sure that appropriate (actual) resourceInfo is used for validation.
String suffix = ConnectorsUtil.getValidSuffix(resourceInfo.getName());
// check for the enabled status and existence using non-prefixed resource-name
if (suffix != null) {
String nonPrefixedName = resourceInfo.getName().substring(0, resourceInfo.getName().lastIndexOf(suffix));
resourceInfo = new ResourceInfo(nonPrefixedName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
}
if (resourceConfiguration == null) {
throw new ResourceException("No such resource : " + resourceInfo);
}
if (!resourcesUtil.isEnabled(resourceConfiguration, resourceInfo)) {
throw new ResourceException(resourceInfo + " is not enabled");
}
}
}
if (registry.getPoolMetaData(poolInfo) == null) {
String msg = getLocalStrings().getString("con_mgr.no_pool_meta_data", poolInfo);
throw new ResourceException(poolInfo + ": " + msg);
}
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectorRuntime method lookupNonTxResource.
/**
* {@inheritDoc}
*/
public Object lookupNonTxResource(ResourceInfo resourceInfo, boolean force) throws NamingException {
Object result;
try {
if (!resourceInfo.getName().endsWith(NON_TX_JNDI_SUFFIX)) {
ResourceInfo tmpInfo = new ResourceInfo(resourceInfo.getName() + NON_TX_JNDI_SUFFIX, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
resourceInfo = tmpInfo;
}
result = connectorResourceAdmService.lookup(resourceInfo);
} catch (NamingException ne) {
if (force && isDAS()) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "jdbc.unable_to_lookup_resource", new Object[] { resourceInfo });
}
result = lookupDataSourceInDAS(resourceInfo);
} else {
throw ne;
}
}
return result;
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectorRuntime method lookupPMResource.
/**
* {@inheritDoc}
*/
public Object lookupPMResource(ResourceInfo resourceInfo, boolean force) throws NamingException {
Object result;
try {
if (!resourceInfo.getName().endsWith(PM_JNDI_SUFFIX)) {
ResourceInfo tmpInfo = new ResourceInfo(resourceInfo.getName() + PM_JNDI_SUFFIX, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
resourceInfo = tmpInfo;
}
result = connectorResourceAdmService.lookup(resourceInfo);
} catch (NamingException ne) {
if (force && isDAS()) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "jdbc.unable_to_lookup_resource", new Object[] { resourceInfo });
}
result = lookupDataSourceInDAS(resourceInfo);
} else {
throw ne;
}
}
return result;
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectorResourceAdminServiceImpl method lookup.
/**
* Look up the JNDI name with appropriate suffix.
* Suffix can be either __pm or __nontx.
*
* @param resourceInfo resource-name
* @return Object - from jndi
* @throws NamingException - when unable to get the object form jndi
*/
public Object lookup(ResourceInfo resourceInfo) throws NamingException {
Hashtable env = null;
String jndiName = resourceInfo.getName();
String suffix = ConnectorsUtil.getValidSuffix(jndiName);
// To pass suffix that will be used by connector runtime during lookup
if (suffix != null) {
env = new Hashtable();
env.put(ConnectorConstants.JNDI_SUFFIX_PROPERTY, suffix);
jndiName = jndiName.substring(0, jndiName.lastIndexOf(suffix));
}
ResourceInfo actualResourceInfo = new ResourceInfo(jndiName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
return namingService.lookup(actualResourceInfo, actualResourceInfo.getName(), env);
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class AdminObjectResourceDeployer method undeployResource.
/**
* {@inheritDoc}
*/
public synchronized void undeployResource(Object resource) throws Exception {
final AdminObjectResource aor = (AdminObjectResource) resource;
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(aor);
deleteAdminObjectResource(aor, resourceInfo);
}
Aggregations