use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class DolProvider method processDOL.
private Application processDOL(DeploymentContext dc) throws IOException {
ReadableArchive sourceArchive = dc.getSource();
sourceArchive.setExtraData(Types.class, dc.getTransientAppMetaData(Types.class.getName(), Types.class));
sourceArchive.setExtraData(Parser.class, dc.getTransientAppMetaData(Parser.class.getName(), Parser.class));
Optional<ApplicationState> appState = hotDeployService.getApplicationState(dc);
appState.ifPresent(state -> sourceArchive.setExtraData(ApplicationState.class, state));
ClassLoader cl = dc.getClassLoader();
DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
sourceArchive.addArchiveMetaData(DeploymentProperties.APP_PROPS, dc.getAppProps());
sourceArchive.addArchiveMetaData(DeploymentProperties.COMMAND_PARAMS, params);
String name = params.name();
String archiveType = dc.getArchiveHandler().getArchiveType();
Archivist archivist = archivistFactory.getArchivist(archiveType, cl);
if (archivist == null) {
// an empty Application object
return Application.createApplication();
}
archivist.setAnnotationProcessingRequested(true);
String xmlValidationLevel = dasConfig.getDeployXmlValidation();
archivist.setXMLValidationLevel(xmlValidationLevel);
if (xmlValidationLevel.equals("none")) {
archivist.setXMLValidation(false);
}
archivist.setRuntimeXMLValidationLevel(xmlValidationLevel);
if (xmlValidationLevel.equals("none")) {
archivist.setRuntimeXMLValidation(false);
}
Collection<Sniffer> sniffers = dc.getTransientAppMetaData(DeploymentProperties.SNIFFERS, Collection.class);
archivist.setExtensionArchivists(archivistFactory.getExtensionsArchivists(sniffers, archivist.getModuleType()));
ApplicationHolder holder = dc.getModuleMetaData(ApplicationHolder.class);
File deploymentPlan = params.deploymentplan;
handleDeploymentPlan(deploymentPlan, archivist, sourceArchive, holder);
long start = System.currentTimeMillis();
Application application = appState.map(state -> state.getModuleMetaData(Application.class)).orElse(holder != null ? holder.app : null);
if (application != null) {
application.setAppName(name);
application.setClassLoader(cl);
application.setRoleMapper(null);
if (application.isVirtual()) {
ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
md.setModuleName(name);
if (appState.map(ApplicationState::isActive).orElse(false)) {
application.getStandaloneBundleDescriptor().setClassLoader(cl);
dc.addModuleMetaData(application.getStandaloneBundleDescriptor());
for (RootDeploymentDescriptor extension : application.getStandaloneBundleDescriptor().getExtensionsDescriptors()) {
extension.setClassLoader(cl);
dc.addModuleMetaData(extension);
}
}
}
try {
applicationFactory.openWith(application, sourceArchive, archivist);
} catch (SAXParseException e) {
throw new IOException(e);
}
} else {
// and it's a standalone module
try {
application = applicationFactory.openArchive(name, archivist, sourceArchive, true);
application.setAppName(name);
ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
md.setModuleName(name);
} catch (SAXParseException e) {
throw new IOException(e);
}
}
application.setRegistrationName(name);
sourceArchive.removeExtraData(Types.class);
sourceArchive.removeExtraData(Parser.class);
Logger.getAnonymousLogger().log(FINE, "DOL Loading time{0}", System.currentTimeMillis() - start);
return application;
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class ListSubComponentsCommand method execute.
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
ActionReport.MessagePart part = report.getTopMessagePart();
String applicationName = modulename;
if (appname != null) {
applicationName = appname;
}
try {
VersioningUtils.checkIdentifier(applicationName);
} catch (VersioningSyntaxException ex) {
report.setMessage(ex.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (!deployment.isRegistered(applicationName)) {
report.setMessage(localStrings.getLocalString("application.notreg", "Application {0} not registered", applicationName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
Application application = applications.getApplication(applicationName);
if (application.isLifecycleModule()) {
if (!terse) {
part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List."));
}
return;
}
ApplicationInfo appInfo = appRegistry.get(applicationName);
if (appInfo == null) {
report.setMessage(localStrings.getLocalString("application.not.enabled", "Application {0} is not in an enabled state", applicationName));
return;
}
com.sun.enterprise.deployment.Application app = appInfo.getMetaData(com.sun.enterprise.deployment.Application.class);
if (app == null) {
if (!terse) {
part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List."));
}
return;
}
Map<String, String> subComponents;
Map<String, String> subComponentsMap = new HashMap<String, String>();
if (appname == null) {
subComponents = getAppLevelComponents(app, type, subComponentsMap);
} else {
// strip the version suffix (delimited by colon), if present
int versionSuffix = modulename.indexOf(':');
String versionLessModuleName = versionSuffix > 0 ? modulename.substring(0, versionSuffix) : modulename;
BundleDescriptor bundleDesc = app.getModuleByUri(versionLessModuleName);
if (bundleDesc == null) {
report.setMessage(localStrings.getLocalString("listsubcomponents.invalidmodulename", "Invalid module name", appname, modulename));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
subComponents = getModuleLevelComponents(bundleDesc, type, subComponentsMap);
}
// the type param can only have values "ejbs" and "servlets"
if (type != null) {
if (!type.equals("servlets") && !type.equals("ejbs")) {
report.setMessage(localStrings.getLocalString("listsubcomponents.invalidtype", "The type option has invalid value {0}. It should have a value of servlets or ejbs.", type));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
List<String> subModuleInfos = new ArrayList<String>();
if (!app.isVirtual()) {
subModuleInfos = getSubModulesForEar(app, type);
}
int[] longestValue = new int[2];
for (Map.Entry<String, String> entry : subComponents.entrySet()) {
String key = entry.getKey();
if (key.length() > longestValue[0]) {
longestValue[0] = key.length();
}
String value = entry.getValue();
if (value.length() > longestValue[1]) {
longestValue[1] = value.length();
}
}
StringBuilder formattedLineBuf = new StringBuilder();
for (int j = 0; j < 2; j++) {
longestValue[j] += 2;
formattedLineBuf.append("%-").append(longestValue[j]).append("s");
}
String formattedLine = formattedLineBuf.toString();
if (!terse && subComponents.isEmpty()) {
part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List."));
}
int i = 0;
for (Map.Entry<String, String> entry : subComponents.entrySet()) {
ActionReport.MessagePart childPart = part.addChild();
childPart.setMessage(String.format(formattedLine, new Object[] { entry.getKey(), entry.getValue() }));
if (appname == null && !app.isVirtual()) {
// support for JSR88 client
if (subModuleInfos.get(i) != null) {
childPart.addProperty("moduleInfo", subModuleInfos.get(i));
}
}
if (resources) {
Module module = application.getModule(entry.getKey());
if (module != null) {
ActionReport subReport = report.addSubActionsReport();
CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("_list-resources", subReport, context.getSubject());
final ParameterMap parameters = new ParameterMap();
parameters.add("appname", application.getName());
parameters.add("modulename", module.getName());
inv.parameters(parameters).execute();
ActionReport.MessagePart subPart = subReport.getTopMessagePart();
for (ActionReport.MessagePart cp : subPart.getChildren()) {
ActionReport.MessagePart resourcesChildPart = childPart.addChild();
resourcesChildPart.setMessage(" " + cp.getMessage());
}
}
}
i++;
}
// add the properties for GUI to display
Set<String> keys = subComponentsMap.keySet();
for (String key : keys) {
part.addProperty(key, subComponentsMap.get(key));
}
// now this is the normal output for the list-sub-components command
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations