use of org.glassfish.jdbc.config.JdbcResource in project Payara by payara.
the class PersistenceManagerFactoryResourceMigrator method postConstruct.
public void postConstruct() {
Collection<PersistenceManagerFactoryResource> pmfResources = resources.getResources(PersistenceManagerFactoryResource.class);
for (final PersistenceManagerFactoryResource pmfResource : pmfResources) {
String jdbcResourceName = pmfResource.getJdbcResourceJndiName();
final JdbcResource jdbcResource = (JdbcResource) ConnectorsUtil.getResourceByName(resources, JdbcResource.class, jdbcResourceName);
try {
ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources resources) throws PropertyVetoException, TransactionFailure {
// delete the persitence-manager-factory resource
resources.getResources().remove(pmfResource);
// create a jdbc resource which points to same connection pool and has same jndi name as pmf resource.
JdbcResource newResource = resources.createChild(JdbcResource.class);
newResource.setJndiName(pmfResource.getJndiName());
newResource.setDescription("Created to migrate persistence-manager-factory-resource from V2 domain");
newResource.setPoolName(jdbcResource.getPoolName());
newResource.setEnabled("true");
resources.getResources().add(newResource);
return newResource;
}
}, resources);
} catch (TransactionFailure tf) {
Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading persistence-manager-factory-resource", tf);
throw new RuntimeException(tf);
}
}
// end of iteration
}
use of org.glassfish.jdbc.config.JdbcResource in project Payara by payara.
the class DataSourceDefinitionDeployer method deployResource.
@Override
public void deployResource(Object resource) throws Exception {
final DataSourceDefinitionDescriptor desc = (DataSourceDefinitionDescriptor) resource;
String poolName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), DSDPOOL);
String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), desc.getResourceType());
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "DataSourceDefinitionDeployer.deployResource() : pool-name [" + poolName + "], " + " resource-name [" + resourceName + "]");
}
JdbcConnectionPool jdbcCp = new MyJdbcConnectionPool(desc, poolName);
// deploy pool
getDeployer(jdbcCp).deployResource(jdbcCp);
// deploy resource
JdbcResource jdbcResource = new MyJdbcResource(poolName, resourceName);
getDeployer(jdbcResource).deployResource(jdbcResource);
}
use of org.glassfish.jdbc.config.JdbcResource in project Payara by payara.
the class JdbcResourceDeployer method deployResource.
/**
* {@inheritDoc}
*/
@Override
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
JdbcResource jdbcRes = (JdbcResource) resource;
String jndiName = jdbcRes.getJndiName();
String poolName = jdbcRes.getPoolName();
PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
ResourceInfo resourceInfo = new ResourceInfo(jndiName, applicationName, moduleName);
runtime.createConnectorResource(resourceInfo, poolInfo, null);
// 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.FINEST)) {
_logger.finest("deployed resource " + jndiName);
}
}
use of org.glassfish.jdbc.config.JdbcResource in project Payara by payara.
the class JdbcResourceDeployer method deployResource.
/**
* {@inheritDoc}
*/
@Override
public void deployResource(Object resource) throws Exception {
JdbcResource jdbcRes = (JdbcResource) resource;
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(jdbcRes);
deployResource(jdbcRes, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
use of org.glassfish.jdbc.config.JdbcResource in project Payara by payara.
the class JdbcResourcesUtil method getResourcesOfPool.
public static Collection<BindableResource> getResourcesOfPool(Resources resources, String connectionPoolName) {
Set<BindableResource> resourcesReferringPool = new HashSet<BindableResource>();
ResourcePool pool = (ResourcePool) getResourceByName(resources, ResourcePool.class, connectionPoolName);
if (pool != null) {
Collection<BindableResource> bindableResources = resources.getResources(BindableResource.class);
for (BindableResource resource : bindableResources) {
if (JdbcResource.class.isAssignableFrom(resource.getClass())) {
if ((((JdbcResource) resource).getPoolName()).equals(connectionPoolName)) {
resourcesReferringPool.add(resource);
}
}
}
}
return resourcesReferringPool;
}
Aggregations