Search in sources :

Example 21 with Module

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);
    }
}
Also used : Transaction(org.jvnet.hk2.config.Transaction) Module(com.sun.enterprise.config.serverbeans.Module) Property(org.jvnet.hk2.config.types.Property) RetryableException(org.jvnet.hk2.config.RetryableException) PropertyVetoException(java.beans.PropertyVetoException)

Example 22 with Module

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);
            }
        }
    }
}
Also used : ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil) com.sun.enterprise.config.serverbeans(com.sun.enterprise.config.serverbeans) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters) Module(com.sun.enterprise.config.serverbeans.Module)

Example 23 with Module

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());
        }
    }
}
Also used : Applications(com.sun.enterprise.config.serverbeans.Applications) Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application) Test(org.junit.Test)

Example 24 with Module

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 }));
}
Also used : ActionReport(org.glassfish.api.ActionReport) Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application)

Example 25 with Module

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);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ActionReport(org.glassfish.api.ActionReport) Module(com.sun.enterprise.config.serverbeans.Module)

Aggregations

Module (com.sun.enterprise.config.serverbeans.Module)42 Application (com.sun.enterprise.config.serverbeans.Application)11 ActionReport (org.glassfish.api.ActionReport)9 PropertyVetoException (java.beans.PropertyVetoException)5 Engine (com.sun.enterprise.config.serverbeans.Engine)3 Resource (com.sun.enterprise.config.serverbeans.Resource)3 Resources (com.sun.enterprise.config.serverbeans.Resources)3 ArrayList (java.util.ArrayList)3 Property (org.jvnet.hk2.config.types.Property)3 Server (com.sun.enterprise.config.serverbeans.Server)2 ConnectorApplication (com.sun.enterprise.connectors.module.ConnectorApplication)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)2 WorkSecurityMap (org.glassfish.connectors.config.WorkSecurityMap)2 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)2 Resource (org.glassfish.resources.api.Resource)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 RemoteRestAdminCommand (com.sun.enterprise.admin.remote.RemoteRestAdminCommand)1 ServerRemoteRestAdminCommand (com.sun.enterprise.admin.remote.ServerRemoteRestAdminCommand)1