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);
}
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;
}
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;
}
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());
}
}
}
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);
}
}
}
}
}
Aggregations