use of com.sun.enterprise.config.serverbeans.Engine 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.Engine in project Payara by payara.
the class ApplicationInfo method save.
/**
* Saves its state to the configuration. this method must be called within a transaction
* to the configured Application instance.
*
* @param app the application being persisted
*/
public void save(Application app) throws TransactionFailure, PropertyVetoException {
for (EngineRef ref : engines) {
Engine engine = app.createChild(Engine.class);
app.getEngine().add(engine);
ref.save(engine);
}
for (ModuleInfo module : modules) {
Module modConfig = app.getModule(module.getName());
if (modConfig == null) {
// not a JavaEE module, create it here
modConfig = app.createChild(Module.class);
modConfig.setName(module.getName());
app.getModule().add(modConfig);
}
module.save(modConfig);
}
}
use of com.sun.enterprise.config.serverbeans.Engine in project Payara by payara.
the class ModuleInfo method save.
/**
* Saves its state to the configuration. this method must be called within a transaction
* to the configured module instance.
*
* @param module the module being persisted
*/
public void save(Module module) throws TransactionFailure, PropertyVetoException {
// write out the module properties only for composite app
if (Boolean.valueOf(moduleProps.getProperty(ServerTags.IS_COMPOSITE))) {
moduleProps.remove(ServerTags.IS_COMPOSITE);
for (Iterator itr = moduleProps.keySet().iterator(); itr.hasNext(); ) {
String propName = (String) itr.next();
Property prop = module.createChild(Property.class);
module.getProperty().add(prop);
prop.setName(propName);
prop.setValue(moduleProps.getProperty(propName));
}
}
for (EngineRef ref : _getEngineRefs()) {
Engine engine = module.createChild(Engine.class);
module.getEngines().add(engine);
ref.save(engine);
}
}
use of com.sun.enterprise.config.serverbeans.Engine in project Payara by payara.
the class ListContainersCommand method execute.
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
report.setActionDescription(localStrings.getLocalString("list.containers.command", "List of Containers"));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
ActionReport.MessagePart top = report.getTopMessagePart();
top.setMessage(localStrings.getLocalString("list.containers.command", "List of Containers"));
top.setChildrenType(localStrings.getLocalString("container", "Container"));
Iterable<? extends Sniffer> sniffers = habitat.getAllServices(Sniffer.class);
if (sniffers == null) {
top.setMessage(localStrings.getLocalString("list.containers.nocontainer", "No container currently configured"));
} else {
for (Sniffer sniffer : sniffers) {
ActionReport.MessagePart container = top.addChild();
container.setMessage(sniffer.getModuleType());
container.addProperty(localStrings.getLocalString("contractprovider", "ContractProvider"), sniffer.getModuleType());
EngineInfo engineInfo = containerRegistry.getContainer(sniffer.getModuleType());
if (engineInfo != null) {
container.addProperty(localStrings.getLocalString("status", "Status"), localStrings.getLocalString("started", "Started"));
Module connectorModule = modulesRegistry.find(engineInfo.getSniffer().getClass());
container.addProperty(localStrings.getLocalString("connector", "Connector"), connectorModule.getModuleDefinition().getName() + ":" + connectorModule.getModuleDefinition().getVersion());
container.addProperty(localStrings.getLocalString("implementation", "Implementation"), engineInfo.getContainer().getClass().toString());
boolean atLeastOne = false;
for (Application app : applications.getApplications()) {
for (com.sun.enterprise.config.serverbeans.Module module : app.getModule()) {
Engine engine = module.getEngine(engineInfo.getSniffer().getModuleType());
if (engine != null) {
if (!atLeastOne) {
atLeastOne = true;
container.setChildrenType(localStrings.getLocalString("list.containers.listapps", "Applications deployed"));
}
container.addChild().setMessage(app.getName());
}
}
}
if (!atLeastOne) {
container.addProperty("Status", "Not Started");
}
}
}
}
}
use of com.sun.enterprise.config.serverbeans.Engine in project Payara by payara.
the class WebModuleConfigCommand method engine.
protected Engine engine(final ActionReport report) {
Module module = module(report);
if (module == null) {
return null;
}
Engine e = module.getEngine(WEB_SNIFFER_TYPE);
if (e == null) {
fail(report, "noSuchEngine", "Application {0}/module {1} does not contain engine {2}", appName(), moduleName(), WEB_SNIFFER_TYPE);
}
return e;
}
Aggregations