use of com.sun.enterprise.config.serverbeans.Application in project jersey by jersey.
the class EjbComponentProvider method getApplicationInfo.
private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws NamingException {
ApplicationRegistry appRegistry = ejbUtil.getServices().getService(ApplicationRegistry.class);
Applications applications = ejbUtil.getServices().getService(Applications.class);
String appNamePrefix = (String) initialContext.lookup("java:app/AppName");
Set<String> appNames = appRegistry.getAllApplicationNames();
Set<String> disabledApps = new TreeSet<>();
for (String appName : appNames) {
if (appName.startsWith(appNamePrefix)) {
Application appDesc = applications.getApplication(appName);
if (appDesc != null && !ejbUtil.getDeployment().isAppEnabled(appDesc)) {
// skip disabled version of the app
disabledApps.add(appName);
} else {
return ejbUtil.getDeployment().get(appName);
}
}
}
// grab the latest one, there is no way to make
// sure which one the user is actually enabling,
// so use the best case, i.e. upgrade
Iterator<String> it = disabledApps.iterator();
String lastDisabledApp = null;
while (it.hasNext()) {
lastDisabledApp = it.next();
}
if (lastDisabledApp != null) {
return ejbUtil.getDeployment().get(lastDisabledApp);
}
throw new NamingException("Application Information Not Found");
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ApplicationConfigListener method handleOtherAppConfigChanges.
private void handleOtherAppConfigChanges(Object parent, String appName) {
Application application = applications.getApplication(appName);
if (application.isLifecycleModule()) {
return;
}
// config changes if the application is in enabled state
if (isCurrentInstanceMatchingTarget(parent) && deployment.isAppEnabled(application)) {
disableApplication(appName);
enableApplication(appName);
}
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ApplicationConfigListener method disableApplication.
private void disableApplication(String appName) {
Application app = applications.getApplication(appName);
ApplicationRef appRef = domain.getApplicationRefInServer(server.getName(), appName);
// by the current server instance, do not unload
if (app == null || appRef == null) {
return;
}
ApplicationInfo appInfo = appRegistry.get(appName);
if (appInfo == null || !appInfo.isLoaded()) {
return;
}
try {
ActionReport report = new HTMLActionReporter();
UndeployCommandParameters commandParams = new UndeployCommandParameters();
commandParams.name = appName;
commandParams.target = server.getName();
commandParams.origin = UndeployCommandParameters.Origin.unload;
commandParams.command = UndeployCommandParameters.Command.disable;
deployment.disable(commandParams, app, appInfo, report, logger);
if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
throw new Exception(report.getMessage());
}
} catch (Exception e) {
logger.log(Level.SEVERE, KernelLoggerInfo.loadingApplicationErrorDisable, e);
throw new RuntimeException(e);
}
}
use of com.sun.enterprise.config.serverbeans.Application 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"));
HK2Module 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.Application in project Payara by payara.
the class CreateLifecycleModuleCommand method validateTarget.
private void validateTarget(String target, String name) {
List<String> referencedTargets = domain.getAllReferencedTargetsForApplication(name);
Application app = apps.getApplication(name);
if (app != null && !app.isLifecycleModule()) {
throw new IllegalArgumentException(localStrings.getLocalString("application_withsamename_exists", "Application with same name {0} already exists, please pick a different name for the lifecycle module.", name));
}
if (referencedTargets.isEmpty()) {
if (deployment.isRegistered(name)) {
throw new IllegalArgumentException(localStrings.getLocalString("lifecycle.use.create_app_ref_2", "Lifecycle module {0} is already created in this domain. Please use create application ref to create application reference on target {1}", name, target));
}
} else {
if (referencedTargets.contains(target)) {
throw new IllegalArgumentException(localStrings.getLocalString("lifecycle.alreadyreg", "Lifecycle module {0} is already created on this target {1}", name, target));
} else {
throw new IllegalArgumentException(localStrings.getLocalString("lifecycle.use.create_app_ref", "Lifecycle module {0} is already referenced by other target(s). Please use create application ref to create application reference on target {1}", name, target));
}
}
}
Aggregations