Search in sources :

Example 41 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ApplicationConfigListener method enableApplication.

private void enableApplication(String appName) {
    Application app = applications.getApplication(appName);
    ApplicationRef appRef = domain.getApplicationRefInServer(server.getName(), appName);
    // by the current server instance, do not load
    if (app == null || appRef == null) {
        return;
    }
    // if the application is not in enable state, do not load
    if (!deployment.isAppEnabled(app)) {
        return;
    }
    ApplicationInfo appInfo = appRegistry.get(appName);
    if (appInfo == null || appInfo.isLoaded()) {
        return;
    }
    long operationStartTime = Calendar.getInstance().getTimeInMillis();
    try {
        ActionReport report = new HTMLActionReporter();
        deployment.enable(server.getName(), app, appRef, report, logger);
        if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
            logger.log(Level.INFO, KernelLoggerInfo.loadingApplicationTime, new Object[] { appName, (Calendar.getInstance().getTimeInMillis() - operationStartTime) });
        } else if (report.getActionExitCode().equals(ActionReport.ExitCode.WARNING)) {
            logger.log(Level.WARNING, KernelLoggerInfo.loadingApplicationWarning, new Object[] { appName, report.getMessage() });
        } else if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
            throw new Exception(report.getMessage());
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, KernelLoggerInfo.loadingApplicationErrorEnable, e);
        throw new RuntimeException(e);
    }
}
Also used : HTMLActionReporter(com.sun.enterprise.v3.common.HTMLActionReporter) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ActionReport(org.glassfish.api.ActionReport) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef)

Example 42 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ContainerExtensionTest method applicationExtensionTest.

@Test
public void applicationExtensionTest() {
    Application a = habitat.getService(Application.class);
    List<AnApplicationExtension> taes = a.getExtensionsByType(AnApplicationExtension.class);
    assertEquals(taes.size(), 2);
}
Also used : Application(com.sun.enterprise.config.serverbeans.Application) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 43 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class CollectionsAccessTest method semiProtectedTest.

@Test(expected = TransactionFailure.class)
public void semiProtectedTest() throws TransactionFailure {
    final Applications apps = getHabitat().getService(Applications.class);
    assertTrue(apps != null);
    ConfigSupport.apply(new SingleConfigCode<Applications>() {

        public Object run(Applications param) throws PropertyVetoException, TransactionFailure {
            // this is the bug, we should not get the list from apps but from param.
            List<ApplicationName> modules = apps.getModules();
            Application m = param.createChild(Application.class);
            // should throw an exception
            modules.add(m);
            return m;
        }
    }, apps);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Applications(com.sun.enterprise.config.serverbeans.Applications) List(java.util.List) Application(com.sun.enterprise.config.serverbeans.Application) Test(org.junit.Test)

Example 44 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class CollectionsAccessTest method protectedTest.

@Test
public void protectedTest() throws TransactionFailure {
    final Applications apps = getHabitat().getService(Applications.class);
    assertTrue(apps != null);
    ConfigSupport.apply(new SingleConfigCode<Applications>() {

        public Object run(Applications param) throws PropertyVetoException, TransactionFailure {
            List<ApplicationName> modules = param.getModules();
            Application m = param.createChild(Application.class);
            m.setName("ejb-test");
            m.setLocation("test-location");
            m.setObjectType("ejb");
            modules.add(m);
            modules.remove(m);
            return m;
        }
    }, apps);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Applications(com.sun.enterprise.config.serverbeans.Applications) List(java.util.List) Application(com.sun.enterprise.config.serverbeans.Application) Test(org.junit.Test)

Aggregations

Application (com.sun.enterprise.config.serverbeans.Application)44 Module (com.sun.enterprise.config.serverbeans.Module)10 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)9 ActionReport (org.glassfish.api.ActionReport)9 ArrayList (java.util.ArrayList)8 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)7 Property (org.jvnet.hk2.config.types.Property)7 Applications (com.sun.enterprise.config.serverbeans.Applications)6 PropertyVetoException (java.beans.PropertyVetoException)6 HashMap (java.util.HashMap)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 Test (org.junit.Test)4 Server (com.sun.enterprise.config.serverbeans.Server)3 SystemApplications (com.sun.enterprise.config.serverbeans.SystemApplications)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Logger (java.util.logging.Logger)3 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)3 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3