use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class WebModuleConfigCommand method module.
private Module module(final ActionReport report) {
final Application app = application();
if (app == null) {
fail(report, "appNotReg", "Application {0} not registered", appName());
return null;
}
/*
* Be helpful by announcing if the user specified a submodule but this
* is not an EAR or if the user did NOT specify a submodule but this IS
* an EAR.
*/
if (app.isStandaloneModule() && appNameAndOptionalModuleName.contains("/")) {
fail(report, "standaloneAppNoSubMods", "Application {0} is a stand-alone application and contains no submodules but submodule {1} was specified", appName(), moduleName());
return null;
}
if (!app.isStandaloneModule() && !appNameAndOptionalModuleName.contains("/")) {
fail(report, "earNoModuleSelection", "Application {0} is an enterprise application; please also specify one of the web module names ({1}) as part of the command argument (for example, {0}/{2})", appName(), webModuleList(app), app.getModule().get(0).getName());
return null;
}
final Module module = app.getModule(moduleName());
if (module == null) {
if (app.getModule().isEmpty()) {
fail(report, "noWebModules", "Application {0} contains no web modules", appName());
} else {
fail(report, "noSuchModule", "Application {0} contains web modules {1} but {2} is not one of them", appName(), webModuleList(app), moduleName());
}
}
return module;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class RestMonitoringLoader method createAndRegisterApplication.
/**
* Create the system application entry and register the application
* @throws Exception
*/
private void createAndRegisterApplication() throws Exception {
LOGGER.log(Level.FINE, "Registering the Rest Monitoring Application...");
// Create the system application entry and application-ref in the config
ConfigCode code = new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
// Create the system application
SystemApplications systemApplications = (SystemApplications) proxies[0];
Application application = systemApplications.createChild(Application.class);
// Check if the application name is valid, generating a new one if it isn't
checkAndResolveApplicationName(systemApplications);
systemApplications.getModules().add(application);
application.setName(applicationName);
application.setEnabled(Boolean.TRUE.toString());
application.setObjectType("system-admin");
application.setDirectoryDeployed("true");
application.setContextRoot(contextRoot);
try {
application.setLocation("${com.sun.aas.installRootURI}/lib/install/applications/" + RestMonitoringService.DEFAULT_REST_MONITORING_APP_NAME);
} catch (Exception me) {
throw new RuntimeException(me);
}
// Set the engine types
Module singleModule = application.createChild(Module.class);
application.getModule().add(singleModule);
singleModule.setName(applicationName);
Engine webEngine = singleModule.createChild(Engine.class);
webEngine.setSniffer("web");
Engine weldEngine = singleModule.createChild(Engine.class);
weldEngine.setSniffer("weld");
Engine securityEngine = singleModule.createChild(Engine.class);
securityEngine.setSniffer("security");
singleModule.getEngines().add(webEngine);
singleModule.getEngines().add(weldEngine);
singleModule.getEngines().add(securityEngine);
// Create the application-ref
Server s = (Server) proxies[1];
List<ApplicationRef> arefs = s.getApplicationRef();
ApplicationRef aref = s.createChild(ApplicationRef.class);
aref.setRef(application.getName());
aref.setEnabled(Boolean.TRUE.toString());
aref.setVirtualServers(getVirtualServerListAsString());
arefs.add(aref);
return true;
}
};
Server server = domain.getServerNamed(serverEnv.getInstanceName());
ConfigSupport.apply(code, domain.getSystemApplications(), server);
LOGGER.log(Level.FINE, "Rest Monitoring Application Registered.");
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class RestMonitoringLoader method registerApplication.
private void registerApplication() throws Exception {
LOGGER.log(Level.FINE, "Registering the Rest Monitoring Application...");
// Create the application-ref entry in the domain.xml
ConfigCode code = new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
// Get the system application config
SystemApplications systemApplications = (SystemApplications) proxies[0];
Application application = null;
for (Application systemApplication : systemApplications.getApplications()) {
if (systemApplication.getName().equals(applicationName)) {
application = systemApplication;
break;
}
}
if (application == null) {
throw new IllegalStateException("The Rest Monitoring application has no system app entry!");
}
// Create the application-ref
Server s = (Server) proxies[1];
List<ApplicationRef> arefs = s.getApplicationRef();
ApplicationRef aref = s.createChild(ApplicationRef.class);
aref.setRef(application.getName());
aref.setEnabled(Boolean.TRUE.toString());
aref.setVirtualServers(getVirtualServerListAsString());
arefs.add(aref);
return true;
}
};
Server server = domain.getServerNamed(serverEnv.getInstanceName());
ConfigSupport.apply(code, domain.getSystemApplications(), server);
// Update the adapter state
LOGGER.log(Level.FINE, "Rest Monitoring Application Registered.");
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class RestMonitoringLoader method reconfigureSystemApplication.
private void reconfigureSystemApplication() throws Exception {
Application systemApplication = restMonitoringAdapter.getSystemApplicationConfig();
LOGGER.log(Level.FINE, "Reconfiguring the Rest Monitoring Application...");
// Reconfigure the system-application entry in the domain.xml
ConfigCode code = new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
Application systemApplication = (Application) proxies[0];
systemApplication.setContextRoot(contextRoot);
return true;
}
};
ConfigSupport.apply(code, systemApplication);
LOGGER.log(Level.FINE, "Rest Monitoring Application Reconfigured.");
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class RestMonitoringLoader method loadApplication.
/**
* Loads the application
*/
private void loadApplication() {
ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class);
ApplicationInfo appInfo = appRegistry.get(applicationName);
if (appInfo != null && appInfo.isLoaded()) {
LOGGER.log(Level.FINE, "Rest Monitoring Application already loaded.");
return;
}
Application config = null;
if (dynamicStart) {
config = restMonitoringAdapter.getSystemApplicationConfig(contextRoot);
} else {
config = restMonitoringAdapter.getSystemApplicationConfig();
}
if (config == null) {
throw new IllegalStateException("The Rest Monitoring application has no system app entry!");
}
// Load the Rest Monitoring Application
String instanceName = serverEnv.getInstanceName();
ApplicationRef ref = domain.getApplicationRefInServer(instanceName, applicationName);
habitat.getService(ApplicationLoaderService.class).processApplication(config, ref);
// Mark as registered
restMonitoringAdapter.setAppRegistered(true);
LOGGER.log(Level.FINE, "Rest Monitoring Application Loaded.");
}
Aggregations