throw new PackageManagerException("JBoss home " + jbHome + " does not exist!");
}
logger.info("Using JBoss Home: " + jbossHome);
// Create a package manager now
PackageManager pm = PackageManagerFactory.getDefaultPackageManager(env, jbossHome);
// Parse the options from the command line and do appropriate action(s)
Boolean query = (Boolean) cmdLineParser.getOptionValue(queryCmdOption, Boolean.FALSE);
String packageToInstall = (String) cmdLineParser.getOptionValue(installCmdOption);
String packageToUpgrade = (String) cmdLineParser.getOptionValue(upgradeCmdOption);
String packageToRemove = (String) cmdLineParser.getOptionValue(removeCmdOption);
if (query)
{
Set<String> installedPackages = pm.getAllInstalledPackages();
if (installedPackages.isEmpty())
{
logger.info("There are no packages installed in the system");
}
else
{
logger.info("Following packages have been installed in the system: ");
logger.info("----------------------------------------------------");
for (String packageName : installedPackages)
{
logger.info(packageName);
}
logger.info("----------------------------------------------------");
}
}
if (packageToInstall != null)
{
// it's time to install
pm.installPackage(packageToInstall);
}
if (packageToUpgrade != null)
{
// upgrade!
pm.updatePackage(packageToUpgrade);
}
if (packageToRemove != null)
{
// out you go!
pm.removePackage(packageToRemove);
}
}