use of org.glassfish.persistence.common.Java2DBProcessorHelper in project Payara by payara.
the class JPADeployer method cleanArtifacts.
protected void cleanArtifacts(DeploymentContext dc) throws DeploymentException {
// Drop tables if needed on undeploy.
OpsParams params = dc.getCommandParameters(OpsParams.class);
if (params.origin.isUndeploy() && isDas()) {
boolean hasScopedResource = false;
String appName = params.name();
ApplicationInfo appInfo = applicationRegistry.get(appName);
Application application = appInfo.getMetaData(Application.class);
Set<BundleDescriptor> bundles = application.getBundleDescriptors();
// Iterate through all the bundles of the app and collect pu references in referencedPus
for (BundleDescriptor bundle : bundles) {
Collection<? extends PersistenceUnitDescriptor> pusReferencedFromBundle = bundle.findReferencedPUs();
for (PersistenceUnitDescriptor pud : pusReferencedFromBundle) {
hasScopedResource = hasScopedResource(pud);
if (hasScopedResource) {
break;
}
}
}
// delete tables.
if (hasScopedResource) {
connectorRuntime.registerDataSourceDefinitions(application);
}
Java2DBProcessorHelper helper = new Java2DBProcessorHelper(dc);
helper.init();
// NOI18N
helper.createOrDropTablesInDB(false, "JPA");
// if there are scoped resources, undeploy them.
if (hasScopedResource) {
connectorRuntime.unRegisterDataSourceDefinitions(application);
}
}
}
use of org.glassfish.persistence.common.Java2DBProcessorHelper in project Payara by payara.
the class PersistentEJBTimerService method isUpgrade.
private static boolean isUpgrade(String resource, EjbTimerService _ejbt, File root) {
boolean upgrade = false;
Property prop = null;
if (_ejbt != null) {
List<Property> properties = _ejbt.getProperty();
if (properties != null) {
for (Property p : properties) {
if (p.getName().equals(EjbContainerUtil.TIMER_SERVICE_UPGRADED)) {
String value = p.getValue();
if (value != null && "false".equals(value)) {
upgrade = true;
prop = p;
break;
}
}
}
}
}
if (logger.isLoggable(Level.FINE)) {
logger.fine("===> Upgrade? <==");
}
if (upgrade) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("===> Upgrade! <==");
}
boolean success = false;
try {
File dir = new File(root, "lib/install/databases/upgrade");
if (!dir.exists()) {
logger.log(Level.WARNING, "Cannot upgrade EJBTimerService: " + "required directory is not available");
} else {
Java2DBProcessorHelper h = new Java2DBProcessorHelper(TIMER_SERVICE_APP_NAME);
success = h.executeDDLStatement(dir.getCanonicalPath() + "/ejbtimer_upgrade_", resource);
ConfigSupport.apply(new SingleConfigCode<Property>() {
public Object run(Property p) throws PropertyVetoException, TransactionFailure {
p.setValue("true");
return null;
}
}, prop);
}
} catch (Exception e) {
logger.log(Level.WARNING, "", e);
}
if (!success) {
logger.log(Level.SEVERE, "Failed to upgrade EJBTimerService: see log for details");
}
}
return upgrade;
}
use of org.glassfish.persistence.common.Java2DBProcessorHelper in project Payara by payara.
the class CMPProcessor method process.
/**
* Create and execute the files.
*/
public void process() {
EjbBundleDescriptorImpl bundle = ctx.getModuleMetaData(EjbBundleDescriptorImpl.class);
ResourceReferenceDescriptor cmpResource = bundle.getCMPResourceReference();
// If this bundle's beans are not created by Java2DB, there is nothing to do.
if (!DeploymentHelper.isJavaToDatabase(cmpResource.getSchemaGeneratorProperties())) {
return;
}
helper = new Java2DBProcessorHelper(ctx);
helper.init();
String resourceName = cmpResource.getJndiName();
// NOI18N
helper.setProcessorType("CMP", bundle.getName());
helper.setJndiName(resourceName, bundle.getName());
// If CLI options are not set, use value from the create-tables-at-deploy
// or drop-tables-at-undeploy elements of the sun-ejb-jar.xml
boolean userCreateTables = cmpResource.isCreateTablesAtDeploy();
boolean createTables = helper.getCreateTables(userCreateTables);
boolean userDropTables = cmpResource.isDropTablesAtUndeploy();
if (logger.isLoggable(logger.FINE)) {
// NOI18N
logger.fine(// NOI18N
"ejb.CMPProcessor.createanddroptables", new Object[] { createTables, userDropTables });
}
if (!createTables && !userDropTables) {
// Nothing to do.
return;
}
helper.setCreateTablesValue(userCreateTables, bundle.getName());
helper.setDropTablesValue(userDropTables, bundle.getName());
constructJdbcFileNames(bundle);
if (logger.isLoggable(logger.FINE)) {
logger.fine("ejb.CMPProcessor.createanddropfilenames", helper.getCreateJdbcFileName(bundle.getName()), helper.getDropJdbcFileName(bundle.getName()));
}
if (createTables) {
// NOI18N
helper.createOrDropTablesInDB(true, "CMP");
}
}
use of org.glassfish.persistence.common.Java2DBProcessorHelper in project Payara by payara.
the class CMPProcessor method clean.
/**
* Drop files on undeploy
*/
public void clean() {
helper = new Java2DBProcessorHelper(ctx);
helper.init();
// NOI18N
helper.createOrDropTablesInDB(false, "CMP");
}
Aggregations