use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectorResourceDeployer method deployResource.
/**
* {@inheritDoc}
*/
public synchronized void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
// deployResource is not synchronized as there is only one caller
// ResourceProxy which is synchronized
ConnectorResource domainResource = (ConnectorResource) resource;
ResourceInfo resourceInfo = new ResourceInfo(domainResource.getJndiName(), applicationName, moduleName);
PoolInfo poolInfo = new PoolInfo(domainResource.getPoolName(), applicationName, moduleName);
createConnectorResource(domainResource, resourceInfo, poolInfo);
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectorResourceDeployer method checkAndDeletePool.
/**
* Checks if no more resource-refs to resources exists for the
* connector connection pool and then deletes the pool
*
* @param cr ConnectorResource
* @throws Exception (ConfigException / undeploy exception)
* @since 8.1 pe/se/ee
*/
private void checkAndDeletePool(ConnectorResource cr) throws Exception {
String poolName = cr.getPoolName();
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(cr);
PoolInfo poolInfo = new PoolInfo(poolName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
Resources resources = (Resources) cr.getParent();
// Its possible that the ConnectorResource here is a ConnectorResourceeDefinition. Ignore optimization.
if (resources != null) {
try {
boolean poolReferred = ResourcesUtil.createInstance().isPoolReferredInServerInstance(poolInfo);
if (!poolReferred) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Deleting connector connection pool [" + poolName + "] as there are no more " + "resource-refs to the pool in this server instance");
}
ConnectorConnectionPool ccp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(resources, ConnectorConnectionPool.class, poolName);
// Delete/Undeploy Pool
runtime.getResourceDeployer(ccp).undeployResource(ccp);
}
} catch (Exception ce) {
_logger.warning(ce.getMessage());
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Exception while deleting pool [ " + poolName + " ] : " + ce);
}
throw ce;
}
}
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectorResourceDeployer method createConnectorResource.
private void createConnectorResource(ConnectorResource connectorResource, ResourceInfo resourceInfo, PoolInfo poolInfo) throws ConnectorRuntimeException {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Calling backend to add connector resource", resourceInfo);
}
runtime.createConnectorResource(resourceInfo, poolInfo, null);
String jndiName = resourceInfo.getName();
// In-case the resource is explicitly created with a suffix (__nontx or __PM), no need to create one
if (ConnectorsUtil.getValidSuffix(jndiName) == null) {
ResourceInfo pmResourceInfo = new ResourceInfo(ConnectorsUtil.getPMJndiName(jndiName), resourceInfo.getApplicationName(), resourceInfo.getModuleName());
runtime.createConnectorResource(pmResourceInfo, poolInfo, null);
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Added connector resource in backend", resourceInfo);
}
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ConnectorsRecoveryResourceHandler method loadAllConnectorResources.
/**
* does a lookup of resources so that they are loaded for sure.
*/
private void loadAllConnectorResources() {
try {
Collection<ConnectorResource> connResources = getAllConnectorResources();
InitialContext ic = new InitialContext();
for (ConnectorResource connResource : connResources) {
if (getResourcesUtil().isEnabled(connResource)) {
try {
ic.lookup(connResource.getJndiName());
// } catch (NameNotFoundException ne) {
} catch (NamingException ne) {
// So we need to explicitly load that rar and create the resources
try {
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(connResource);
ConnectorConnectionPool connConnectionPool = ResourcesUtil.createInstance().getConnectorConnectionPoolOfResource(resourceInfo);
if (connConnectionPool != null) {
// TODO V3 ideally this should not happen if connector modules (and embedded rars)
// TODO are loaded before recovery
createActiveResourceAdapter(connConnectionPool.getResourceAdapterName());
getConnectorResourceDeployer().deployResource(connResource);
}
} catch (Exception ex) {
_logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ne.toString(), ne);
}
_logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ex.toString(), ex);
}
}
} catch (Exception ex) {
_logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ex.toString(), ex);
}
}
}
}
} catch (NamingException ne) {
_logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", ne.getMessage());
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ne.toString(), ne);
}
}
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class ContextServiceDeployer method undeployResource.
@Override
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
ContextService contextServiceRes = (ContextService) resource;
ResourceInfo resourceInfo = new ResourceInfo(contextServiceRes.getJndiName(), applicationName, moduleName);
namingService.unpublishObject(resourceInfo, contextServiceRes.getJndiName());
// stop the runtime object
concurrentRuntime.shutdownContextService(contextServiceRes.getJndiName());
}
Aggregations