public int stop(long bundleId) {
   WebApp webApp = webApps.get(bundleId);
   if (webApp == null) {
     return WAR_NOT_FOUND;
   }
   if (webApp.getDeploymentState() == WebApp.UNDEPLOYED_STATE) {
     return ALREADY_STOPPED;
   }
   undeploy(webApp);
   return SUCCESS;
 }
 public int start(long bundleId, String contextName) {
   WebApp webApp = webApps.get(bundleId);
   if (webApp == null) {
     return WAR_NOT_FOUND;
   }
   if (webApp.getDeploymentState() != WebApp.UNDEPLOYED_STATE) {
     return ALREADY_STARTED;
   }
   if (contextName != null) {
     webApp.setContextName(contextName);
   }
   deploy(webApp);
   return SUCCESS;
 }
 /**
  * Unregisters registered web app once that the bundle that contains the web.xml gets stopped. The
  * list of web.xml's is expected to contain only one entry (only first will be used).
  *
  * @throws NullArgumentException if bundle or list of web xmls is null
  * @throws PreConditionException if the list of web xmls is empty or more then one xml
  * @see BundleObserver#removingEntries(Bundle,List)
  */
 public void removingEntries(final Bundle bundle, final List<URL> entries) {
   WebApp webApp = webApps.remove(bundle.getBundleId());
   if (webApp != null && webApp.getDeploymentState() != WebApp.UNDEPLOYED_STATE) {
     undeploy(webApp);
   }
 }