use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class UpgradeService method upgradeV3_0_1_AppClientElements.
private void upgradeV3_0_1_AppClientElements() {
/*
* If an app client has a property setting for javaWebStartEnabled we
* convert it to java-web-start-enabled which is the documented name.
* App clients can be either applications or modules within an EAR.
*/
final Transaction t = new Transaction();
try {
for (Application app : domain.getApplications().getApplications()) {
System.out.println("Checking app " + app.getName());
Application app_w = null;
Property oldSetting = app.getProperty(V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME);
if (oldSetting != null) {
logger.log(Level.INFO, "For application {0} converting property {1} to {2}", new Object[] { app.getName(), V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME });
app_w = t.enroll(app);
addProperty(GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, oldSetting.getValue(), app_w);
app_w.getProperty().remove(oldSetting);
}
for (Module mod : app.getModule()) {
if (mod.getEngine(APPCLIENT_SNIFFER_NAME) != null) {
/*
* This is an app client. See if the client has
* a property setting using the old name.
*/
oldSetting = mod.getProperty(V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME);
if (oldSetting != null) {
logger.log(Level.INFO, "For application {0}/module {1} converting property {2} to {3}", new Object[] { app.getName(), mod.getName(), V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME });
final Module mod_w = t.enroll(mod);
addProperty(GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, oldSetting.getValue(), mod_w);
mod_w.getProperty().remove(oldSetting);
}
}
}
}
t.commit();
} catch (Exception ex) {
t.rollback();
throw new RuntimeException("Error upgrading application", ex);
}
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class ConnectorDeployer method event.
public void event(Event event) {
if (/*env.isDas() && */
Deployment.UNDEPLOYMENT_VALIDATION.equals(event.type())) {
// this is an application undeploy event
DeploymentContext dc = (DeploymentContext) event.hook();
UndeployCommandParameters dcp = dc.getCommandParameters(UndeployCommandParameters.class);
String appName = dcp.name;
Boolean cascade = dcp.cascade;
Boolean ignoreCascade = dcp._ignoreCascade;
if (cascade != null && ignoreCascade != null) {
if (cascade || ignoreCascade) {
return;
}
}
com.sun.enterprise.config.serverbeans.Application app = domain.getApplications().getApplication(appName);
boolean isRAR = false;
if (app != null && Boolean.valueOf(app.getEnabled())) {
isRAR = app.containsSnifferType(ConnectorConstants.CONNECTOR_MODULE);
}
if (!isRAR) {
return;
}
boolean isAppRefEnabled = false;
Server server = domain.getServers().getServer(env.getInstanceName());
ApplicationRef appRef = server.getApplicationRef(appName);
if (appRef != null && Boolean.valueOf(appRef.getEnabled())) {
isAppRefEnabled = true;
}
if (isAppRefEnabled) {
return;
}
boolean isEAR = app.containsSnifferType(EAR);
String moduleName = appName;
ResourcesUtil resourcesUtil = ResourcesUtil.createInstance();
if (isEAR) {
List<Module> modules = app.getModule();
for (Module module : modules) {
moduleName = module.getName();
if (module.getEngine(ConnectorConstants.CONNECTOR_MODULE) != null) {
moduleName = appName + ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER + moduleName;
if (moduleName.toLowerCase(Locale.getDefault()).endsWith(".rar")) {
int index = moduleName.lastIndexOf(".rar");
moduleName = moduleName.substring(0, index);
if (resourcesUtil.filterConnectorResources(resourceManager.getAllResources(), moduleName, true).size() > 0) {
setFailureStatus(dc, moduleName);
return;
}
}
}
}
} else {
if (resourcesUtil.filterConnectorResources(resourceManager.getAllResources(), moduleName, true).size() > 0) {
setFailureStatus(dc, moduleName);
}
}
}
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class UpgradeTest method applicationUpgrade.
@Test
public void applicationUpgrade() {
Applications apps = getHabitat().getService(Applications.class);
assertTrue(apps != null);
for (Application app : apps.getApplications()) {
assertTrue(app.getEngine().isEmpty());
assertTrue(app.getModule().size() == 1);
for (Module module : app.getModule()) {
assertTrue(module.getName().equals(app.getName()));
assertTrue(!module.getEngines().isEmpty());
}
}
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class GetRelativeJWSURICommand method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
final Application app = apps.getApplication(appname);
if (app != null) {
Module appClient = app.getModule(modulename);
if (appClient == null) {
appClient = app.getModule(modulename + ".jar");
}
if (appClient != null) {
String result = appClient.getPropertyValue("jws.user.friendly.path");
/*
* For stand-alone app clients the property is stored at the
* application level instead of the module level.
*/
if (result == null) {
result = app.getPropertyValue("jws.user.friendly.path");
}
if (result != null) {
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
report.getTopMessagePart().addProperty(URI_PROPERTY_NAME, result);
report.setMessage(result);
return;
}
}
}
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(localStrings.getLocalString(this.getClass(), "getreljwsuri.appOrModuleNotFound", "Could not find application {0}, module {1}", new Object[] { appname, modulename }));
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class FlushConnectionPoolLocal method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
Resources resources = domain.getResources();
String scope = "";
if (moduleName != null) {
if (!poolUtil.isValidModule(applicationName, moduleName, poolName, report)) {
return;
}
Application application = applications.getApplication(applicationName);
Module module = application.getModule(moduleName);
resources = module.getResources();
scope = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX;
} else if (applicationName != null) {
if (!poolUtil.isValidApplication(applicationName, poolName, report)) {
return;
}
Application application = applications.getApplication(applicationName);
resources = application.getResources();
scope = ConnectorConstants.JAVA_APP_SCOPE_PREFIX;
}
if (!poolUtil.isValidPool(resources, poolName, scope, report)) {
return;
}
boolean poolingEnabled = false;
ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolName);
if (pool instanceof ConnectorConnectionPool) {
ConnectorConnectionPool ccp = (ConnectorConnectionPool) pool;
poolingEnabled = Boolean.valueOf(ccp.getPooling());
} else {
JdbcConnectionPool ccp = (JdbcConnectionPool) pool;
poolingEnabled = Boolean.valueOf(ccp.getPooling());
}
if (!poolingEnabled) {
String i18nMsg = localStrings.getLocalString("flush.connection.pool.pooling.disabled", "Attempt to Flush Connection Pool failed because Pooling is disabled for pool : {0}", poolName);
report.setMessage(i18nMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
_runtime.flushConnectionPool(poolInfo);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
Logger.getLogger("org.glassfish.connectors.admin.cli").log(Level.FINE, "Flush connection pool for {0} succeeded", poolName);
} catch (ConnectorRuntimeException e) {
report.setMessage(localStrings.getLocalString("flush.connection.pool.fail", "Flush connection pool for {0} failed", poolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
}
Aggregations