Search in sources :

Example 6 with Applications

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

the class CollectionsAccessTest method unprotectedAccess.

@Test(expected = IllegalStateException.class)
public void unprotectedAccess() throws IllegalStateException {
    Applications apps = getHabitat().getService(Applications.class);
    assertTrue(apps != null);
    apps.getModules().add(null);
}
Also used : Applications(com.sun.enterprise.config.serverbeans.Applications) Test(org.junit.Test)

Example 7 with Applications

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

the class VirtualServer method getDefaultWebModule.

protected WebModuleConfig getDefaultWebModule(Domain domain, WebArchivist webArchivist, ApplicationRegistry appRegistry) {
    WebModuleConfig wmInfo = null;
    String wmID = getDefaultWebModuleID();
    if (wmID != null) {
        // Check if the default-web-module is part of a
        // j2ee-application
        Applications appsBean = domain.getApplications();
        wmInfo = findWebModuleInJ2eeApp(appsBean, wmID, appRegistry);
        if (wmInfo == null) {
            ConfigBeansUtilities cbu = getConfigBeansUtilities();
            String contextRoot = null;
            String location = null;
            if (cbu != null) {
                contextRoot = cbu.getContextRoot(wmID);
                location = cbu.getLocation(wmID);
            }
            if (contextRoot != null && location != null) {
                File docroot = new File(location);
                final WebBundleDescriptorImpl wbd = webArchivist.getDefaultWebXmlBundleDescriptor();
                wmInfo = new WebModuleConfig();
                wbd.setName(Constants.DEFAULT_WEB_MODULE_NAME);
                wbd.setContextRoot(contextRoot);
                wmInfo.setLocation(docroot);
                wmInfo.setDescriptor(wbd);
                wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {

                    @Override
                    public WebappClassLoader run() {
                        return new WebappClassLoader(EmbeddedWebContainer.class.getClassLoader(), wbd.getApplication());
                    }
                });
                wmInfo.setAppClassLoader(cloader);
            }
        }
        if (wmInfo == null) {
            _logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_NOT_FOUND, new Object[] { wmID, getID() });
        }
    }
    return wmInfo;
}
Also used : WebappClassLoader(org.glassfish.web.loader.WebappClassLoader) Applications(com.sun.enterprise.config.serverbeans.Applications) WebBundleDescriptorImpl(org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl) ConfigBeansUtilities(com.sun.enterprise.config.serverbeans.ConfigBeansUtilities) File(java.io.File)

Example 8 with Applications

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

the class VirtualServer method getDefaultContextPath.

// ------------------------------------------------------ Protected Methods
/**
 * Gets the context root of the web module that the user/configuration
 * has designated as the default-web-module for this virtual server.
 *
 * The default-web-module for a virtual server is specified via the
 * 'default-web-module' attribute of the 'virtual-server' element in
 * server.xml. This is an optional attribute and if the configuration
 * does not specify another web module (standalone or part of a
 * j2ee-application) that is configured at a context-root="", then
 * a default web module will be created and loaded. The value for this
 * attribute is either "${standalone-web-module-name}" or
 * "${j2ee-app-name}:${web-module-uri}".
 *
 * @param domain
 * @param appRegistry
 * @return null if the default-web-module has not been specified or
 *              if the web module specified either could not be found or
 *              is disabled or does not specify this virtual server (if
 *              it specifies a value for the virtual-servers attribute) or
 *              if there was an error loading its deployment descriptors.
 */
protected String getDefaultContextPath(Domain domain, ApplicationRegistry appRegistry) {
    String contextRoot = null;
    String wmID = getDefaultWebModuleID();
    if (wmID != null) {
        // Check if the default-web-module is part of a
        // j2ee-application
        Applications appsBean = domain.getApplications();
        WebModuleConfig wmInfo = findWebModuleInJ2eeApp(appsBean, wmID, appRegistry);
        if (wmInfo == null) {
            ConfigBeansUtilities cbu = getConfigBeansUtilities();
            if (cbu == null) {
                contextRoot = null;
            } else {
                contextRoot = cbu.getContextRoot(wmID);
            }
        } else {
            contextRoot = wmInfo.getContextPath();
        }
        if (contextRoot == null) {
            Object[] params = { wmID, getID() };
            _logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_NOT_FOUND, params);
        }
    }
    return contextRoot;
}
Also used : Applications(com.sun.enterprise.config.serverbeans.Applications) ConfigBeansUtilities(com.sun.enterprise.config.serverbeans.ConfigBeansUtilities)

Example 9 with Applications

use of com.sun.enterprise.config.serverbeans.Applications 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 10 with Applications

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

the class ApplicationConfigListener method transactionCommited.

public void transactionCommited(final List<PropertyChangeEvent> changes) {
    boolean isUpdatingAttribute = true;
    for (PropertyChangeEvent event : changes) {
        Object oldValue = event.getOldValue();
        Object newValue = event.getNewValue();
        if (event.getSource() instanceof Applications) {
            if (event.getPropertyName().equals(ServerTags.APPLICATION)) {
                if (oldValue == null || newValue == null) {
                    // we are adding/removing application element here
                    // and updating existing attribute
                    isUpdatingAttribute = false;
                    break;
                }
            }
        } else if (event.getSource() instanceof Server || event.getSource() instanceof Cluster) {
            if (event.getPropertyName().equals(ServerTags.APPLICATION_REF)) {
                if (oldValue == null || newValue == null) {
                    // we are adding/removing application-ref element here
                    // and updating existing attribute
                    isUpdatingAttribute = false;
                    break;
                }
            }
        }
    }
    if (!isUpdatingAttribute) {
        // skip the config listener
        return;
    }
    for (PropertyChangeEvent event : changes) {
        if (event.getSource() instanceof Application || event.getSource() instanceof ApplicationRef || event.getSource() instanceof Property) {
            Object oldValue = event.getOldValue();
            Object newValue = event.getNewValue();
            String propertyName = null;
            if (oldValue != null && newValue != null && oldValue instanceof String && newValue instanceof String && !((String) oldValue).equals((String) newValue)) {
                // if it's an attribute change of the application
                // element or application-ref element
                Object parent = event.getSource();
                String appName = null;
                if (parent instanceof Application) {
                    appName = ((Application) parent).getName();
                    propertyName = event.getPropertyName();
                } else if (parent instanceof ApplicationRef) {
                    appName = ((ApplicationRef) parent).getRef();
                    propertyName = event.getPropertyName();
                } else if (parent instanceof Property) {
                    appName = ((Property) parent).getParent(Application.class).getName();
                    propertyName = ((Property) parent).getName();
                }
                // anything
                if (applications.getApplication(appName) == null) {
                    return;
                }
                if (ServerTags.ENABLED.equals(propertyName)) {
                    // enable or disable application accordingly
                    handleAppEnableChange(event.getSource(), appName, Boolean.valueOf((String) newValue));
                } else if (ServerTags.CONTEXT_ROOT.equals(propertyName) || ServerTags.VIRTUAL_SERVERS.equals(propertyName) || ServerTags.AVAILABILITY_ENABLED.equals(propertyName) || ServerTags.CDI_DEV_MODE_ENABLED_PROP.equals(propertyName)) {
                    // for other changes, reload the application
                    handleOtherAppConfigChanges(event.getSource(), appName);
                }
            }
        }
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Applications(com.sun.enterprise.config.serverbeans.Applications) Server(com.sun.enterprise.config.serverbeans.Server) Cluster(com.sun.enterprise.config.serverbeans.Cluster) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef) Property(org.jvnet.hk2.config.types.Property)

Aggregations

Applications (com.sun.enterprise.config.serverbeans.Applications)13 Application (com.sun.enterprise.config.serverbeans.Application)6 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)4 Test (org.junit.Test)4 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)3 Application (com.sun.enterprise.deployment.Application)3 ConfigBeansUtilities (com.sun.enterprise.config.serverbeans.ConfigBeansUtilities)2 PropertyVetoException (java.beans.PropertyVetoException)2 File (java.io.File)2 List (java.util.List)2 ApplicationRegistry (org.glassfish.internal.data.ApplicationRegistry)2 WebappClassLoader (org.glassfish.web.loader.WebappClassLoader)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 Cluster (com.sun.enterprise.config.serverbeans.Cluster)1 Domain (com.sun.enterprise.config.serverbeans.Domain)1 Module (com.sun.enterprise.config.serverbeans.Module)1 Server (com.sun.enterprise.config.serverbeans.Server)1 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)1 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 JMSDestinationDefinitionDescriptor (com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor)1