/** * Records reload information about the currently-known applications. * * @param applications */ private synchronized void initAppReloadInfo(Applications applications) throws URISyntaxException { appReloadInfo = new HashMap<String,AppReloadInfo>(); logger.fine("[Reloader] Preparing list of apps to monitor:"); for (ApplicationName m : applications.getModules()) { if (m instanceof Application) { Application app = (Application) m; if (Boolean.valueOf(app.getDeployProperties().getProperty (ServerTags.IS_LIFECYCLE))) { // skip lifecycle modules continue; } AppReloadInfo info = new AppReloadInfo(app); appReloadInfo.put(app.getName(), info); logger.fine("[Reloader] Monitoring " + app.getName() + " at " + app.getLocation()); } } }
public static Map<String, Properties> getModulePropertiesMap( Application me) { Map<String, Properties> modulePropertiesMap = new HashMap<String, Properties>(); for (Module module: me.getModule()) { if (module.getProperty() != null) { Properties moduleProps = new Properties(); for (Property property : module.getProperty()) { moduleProps.put(property.getName(), property.getValue()); } modulePropertiesMap.put(module.getName(), moduleProps); } } return modulePropertiesMap; }
public Object run(Application application) throws PropertyVetoException, TransactionFailure { Module module = application.createChild(Module.class); module.setName(application.getName()); for (Engine engine : application.getEngine()) { module.getEngines().add(engine); } application.getModule().add(module); application.getEngine().clear(); return null; } }, app);
public Object run(Application param) throws PropertyVetoException, TransactionFailure { if (!Boolean.parseBoolean(param.getEnabled())) { param.setEnabled(Boolean.TRUE.toString()); } return null; } }, app);
private List<Engine> getAppEngines(final Application app) { final List<Engine> engineList = new ArrayList<Engine>(); // first add application level engines engineList.addAll(app.getEngine()); // now add module level engines for (Module module: app.getModule()) { engineList.addAll(module.getEngines()); } return engineList; }
} catch (VersioningWildcardException ex) { if (app.isLifecycleModule()) { handleLifecycleModule(context, t); return; File file = null; DeployCommandParameters commandParams=null; Properties contextProps = new Properties(); Map<String, Properties> modulePropsMap = null; ApplicationConfigInfo savedAppConfig = null; try { commandParams = app.getDeployParameters(null); commandParams.origin = Origin.create_application_ref; commandParams.target = target; if (app.containsSnifferType(Application.OSGI_SNIFFER_TYPE)) { commandParams.type = DeploymentProperties.OSGI; contextProps = app.getDeployProperties(); modulePropsMap = app.getModulePropertiesMap(); savedAppConfig = new ApplicationConfigInfo(app); URI uri = new URI(app.getLocation()); file = new File(uri); String location = DeploymentUtils.relativizeWithinDomainIfPossible(new URI(app.getLocation())); appProps.setProperty(ServerTags.LOCATION, location);
public static Properties getDeployProperties(Application instance) { Properties deploymentProps = new Properties(); for (Property prop : instance.getProperty()) { deploymentProps.put(prop.getName(), prop.getValue()); } deploymentProps.setProperty(ServerTags.OBJECT_TYPE, instance.getObjectType()); if (instance.getContextRoot() != null) { deploymentProps.setProperty(ServerTags.CONTEXT_ROOT, instance.getContextRoot()); } if (instance.getDirectoryDeployed() != null) { deploymentProps.setProperty(ServerTags.DIRECTORY_DEPLOYED, instance.getDirectoryDeployed()); } return deploymentProps; }
public static boolean isStandaloneModule(Application me) { return !(Boolean.valueOf(me.getDeployProperties().getProperty (ServerTags.IS_COMPOSITE))); }
private void setRestAppAttributes(Application app, Properties appProps) throws PropertyVetoException, TransactionFailure { // context-root element if (appProps.getProperty(ServerTags.CONTEXT_ROOT) != null) { app.setContextRoot(appProps.getProperty( ServerTags.CONTEXT_ROOT)); } // property element // trim the properties that have been written as attributes // the rest properties will be written as property element for (Iterator itr = appProps.keySet().iterator(); itr.hasNext();) { String propName = (String) itr.next(); if (!propName.equals(ServerTags.LOCATION) && !propName.equals(ServerTags.CONTEXT_ROOT) && !propName.equals(ServerTags.OBJECT_TYPE) && !propName.equals(ServerTags.DIRECTORY_DEPLOYED) && !propName.startsWith( DeploymentProperties.APP_CONFIG)) { if (appProps.getProperty(propName) != null) { Property prop = app.createChild(Property.class); app.getProperty().add(prop); prop.setName(propName); prop.setValue(appProps.getProperty(propName)); } } } }
String source = app.getLocation(); final String appName = app.getName(); if (Boolean.valueOf(app.getDeployProperties().getProperty (ServerTags.IS_LIFECYCLE))) { return; app.getDeployParameters(appRef); deploymentParams.target = server.getName(); deploymentParams.origin = DeployCommandParameters.Origin.load; deploymentParams.command = DeployCommandParameters.Command.startup_server; if (domain.isAppReferencedByPaaSTarget(appName)) { if (server.isDas()) { depContext.getAppProps().putAll(app.getDeployProperties()); depContext.setModulePropsMap(app.getModulePropertiesMap()); if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) { if (tracing!=null) { tracing.print(System.out); appName, (Calendar.getInstance().getTimeInMillis() - operationStartTime)}); } else { logger.log(Level.SEVERE, KernelLoggerInfo.deployFail, report.getMessage());
private Properties prepareUndeployActionProperties(String archiveName, String target) { DeploymentProperties dProps = new DeploymentProperties(); // we need to find the application registration name // which is not always the same as archive name String appName = archiveName; List<Application> applications = apps.getApplications(); for (Application app : applications) { String defaultAppName = app.getDeployProperties().getProperty (DeploymentProperties.DEFAULT_APP_NAME); if (defaultAppName != null && defaultAppName.equals(archiveName)) { appName = app.getName(); } } dProps.setName(appName); // dProps.setResourceAction(DeploymentProperties.RES_UNDEPLOYMENT); // dProps.setResourceTargetList(target); return (Properties)dProps; }
private File repackageArchive(Application app) throws IOException { URI uri = null; try { uri = new URI(app.getLocation()); } catch (URISyntaxException e) { logger.log(Level.SEVERE, e.getMessage(), e); Properties appProperties = app.getDeployProperties(); String moduleType = appProperties.getProperty(MODULE_TYPE); String suffix = getSuffixFromType(moduleType); if (suffix == null) {
systemApplications = domain.getSystemApplications(); for (Application systemApp : systemApplications.getApplications()) { appOrderInfoMap.put(systemApp.getName(), Integer.valueOf(appOrder++)); applications.getApplicationsWithSnifferType(ServerTags.CONNECTOR, true); for (Application standaloneAdapter : standaloneAdapters) { appOrderInfoMap.put(standaloneAdapter.getName(), Integer.valueOf(appOrder++)); List<Application> allApplications = applications.getApplications(); for (Application app : allApplications) { appOrderInfoMap.put(app.getName(), Integer.valueOf(appOrder++)); if (Boolean.valueOf(systemApp.getDeployProperties().getProperty (ServerTags.LOAD_SYSTEM_APP_ON_STARTUP))) { if (deployment.isAppEnabled(systemApp) || loadAppOnDAS(systemApp.getName())) { Integer order = appOrderInfoMap.get(systemApp.getName()); ApplicationOrderInfo info = new ApplicationOrderInfo(systemApp, order); DeploymentOrder.addApplicationDeployment(info); if (deployment.isAppEnabled(standaloneAdapter) || loadAppOnDAS(standaloneAdapter.getName())) { DeploymentOrder.addApplicationDeployment(new ApplicationOrderInfo(standaloneAdapter, appOrderInfoMap.get(standaloneAdapter.getName()).intValue())); if (app.isStandaloneModule() && app.containsSnifferType(ServerTags.CONNECTOR)) { continue; if (deployment.isAppEnabled(app) || loadAppOnDAS(app.getName())) { DeploymentOrder.addApplicationDeployment(new ApplicationOrderInfo(app, appOrderInfoMap.get(app.getName()).intValue()));
private boolean redeployApp(Application app) { if (app.getModule().size() > 0 ) { logger.log(Level.INFO, "Skip redeploying v3 type application " + app.getName()); return true; DeployCommandParameters deployParams = app.getDeployParameters(null); if (! Boolean.valueOf(app.getDirectoryDeployed())) { File repackagedFile = null; try { repackagedFile = repackageArchive(app); } catch (IOException ioe) { logger.log(Level.SEVERE, "Repackaging of application " + app.getName() + " failed: " + ioe.getMessage(), ioe); return false; logger.log(Level.SEVERE, "Repackaging of application " + app.getName() + " failed."); return false; logger.log(Level.INFO, "Repackaged application " + app.getName() + " at " + repackagedFile.getPath()); deployParams.path = repackagedFile; deployParams.properties = app.getDeployProperties(); if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) { logger.log(Level.SEVERE, "Redeployment of application " + app.getName() + " failed: " + report.getMessage() + "\nPlease redeploy " + app.getName() + " manually.", report.getFailureCause()); return false;
private void loadApplicationForTenants(Application app, ApplicationRef appRef, ActionReport report) { if (app.getAppTenants() == null) { return; for (AppTenant tenant : app.getAppTenants().getAppTenant()) { DeployCommandParameters commandParams = app.getDeployParameters(appRef); commandParams.contextroot = tenant.getContextRoot(); commandParams.target = server.getName(); commandParams.name = DeploymentUtils.getInternalNameForTenant(app.getName(), tenant.getTenant()); commandParams.enabled = Boolean.TRUE; commandParams.origin = DeployCommandParameters.Origin.load; ActionReport subReport = report.addSubActionsReport(); ReadableArchive archive = null; URI uri = new URI(app.getLocation()); File file = new File(uri); deployment.getBuilder(KernelLoggerInfo.getLogger(), commandParams, subReport).source(archive).build(); deploymentContext.getAppProps().putAll(app.getDeployProperties()); deploymentContext.getAppProps().putAll(tenant.getDeployProperties()); deploymentContext.setModulePropsMap(app.getModulePropertiesMap()); deploymentContext.setTenant(tenant.getTenant(), app.getName()); deployment.deploy(deployment.getSniffersFromApp(app), deploymentContext); } else { logger.log(Level.SEVERE, KernelLoggerInfo.notFoundInOriginalLocation, app.getLocation());
final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); String appName = (String)it.next(); report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", appName)); report.setMessage(localStrings.getLocalString("appref.not.exists","Target {1} does not have a reference to application {0}.", appName, target)); if (application.isLifecycleModule()) { try { deployment.unregisterAppFromDomainXML(appName, target, true); source = appInfo.getSource(); } else { File location = new File(new URI(application.getLocation())); source = archiveFactory.openArchive(location); deploymentContext.getAppProps().putAll( application.getDeployProperties()); deploymentContext.setModulePropsMap( application.getModulePropertiesMap()); if (domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)&& appInfo != null) { if (!Boolean.valueOf(application.getDirectoryDeployed()) && source.exists()) { FileUtils.whack(new File(source.getURI()));
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } else { logger.fine(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); Application application = apps.getModule(Application.class, appName); uri = new URI(application.getLocation()); } catch (URISyntaxException e) { logger.severe("Cannot determine original location for application : " + e.getMessage()); appProps.putAll(application.getDeployProperties()); appProps.putAll(properties); application.getModulePropertiesMap()); List<String> targets = domain.getAllReferencedTargetsForApplication(appName); isDirectoryDeployed = Boolean.valueOf(application.getDirectoryDeployed());
public ExtendedDeploymentContext disable(UndeployCommandParameters commandParams, Application app, ApplicationInfo appInfo, ActionReport report, Logger logger) throws Exception { if (appInfo == null) { report.failure(logger, "Application not registered", null); return null; } // if it's not on DAS and the application is not loaded, do not unload // when it's on DAS, there is some necessary clean up we need to do if (!env.isDas() && !appInfo.isLoaded()) { return null; } if (app != null) { commandParams._type = app.archiveType(); } final ExtendedDeploymentContext deploymentContext = getBuilder(logger, commandParams, report).source(appInfo.getSource()).build(); if (app != null) { deploymentContext.getAppProps().putAll( app.getDeployProperties()); deploymentContext.setModulePropsMap( app.getModulePropertiesMap()); } if (commandParams.properties != null) { deploymentContext.getAppProps().putAll(commandParams.properties); } unload(appInfo, deploymentContext); return deploymentContext; }
throw new TransactionFailure(localStrings.getLocalString( "noTransaction", "Internal Error - Cannot obtain transaction object")); if (domain.getNodeNamed(node) == null) { throw new TransactionFailure(localStrings.getLocalString( "noSuchNode", "Node {0} does not exist.", node)); instance.setConfigRef(configName); clusterExists = true; ourConfig = domain.getConfigNamed(configName); break; instance.setConfigRef(configName); final CopyConfig command = (CopyConfig) runner .getCommand("copy-config", context.getActionReport(), context.getLogger()); Configs configs = domain.getConfigs(); for (Application application : domain.getApplications().getApplications()) { if (application.getObjectType().equals("system-all") || application.getObjectType().equals("system-instance")) { ApplicationRef newAppRef = instance.createChild(ApplicationRef.class); newAppRef.setRef(application.getName()); ActionReport report = context.getActionReport(); report.setMessage(message);
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); 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.")); report.setMessage(localStrings.getLocalString("application.not.enabled","Application {0} is not in an enabled state", applicationName)); return; Module module = application.getModule(subComponent.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();