public synchronized void shutDown(String serviceUnitName) throws DeploymentException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { logger.debug("Shutting down service unit"); if (serviceUnitName == null || serviceUnitName.length() == 0) { throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); } ServiceUnit su = getServiceUnit(serviceUnitName); if (su == null) { throw failure("shutDown", "Service Unit '" + serviceUnitName + "' is not deployed", null); } if (!LifeCycleMBean.STOPPED.equals(su.getCurrentState())) { throw failure("shutDown", "ServiceUnit should be in a STOPPED state", null); } Thread.currentThread().setContextClassLoader(su.getConfigurationClassLoader()); su.shutDown(); logger.debug("Service unit shut down"); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw failure("shutDown", "Unable to shutdown service unit", e); } finally { Thread.currentThread().setContextClassLoader(cl); } }
public synchronized void stop(String serviceUnitName) throws DeploymentException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { logger.debug("Stopping service unit"); if (serviceUnitName == null || serviceUnitName.length() == 0) { throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); } ServiceUnit su = getServiceUnit(serviceUnitName); if (su == null) { throw failure("stop", "Service Unit '" + serviceUnitName + "' is not deployed", null); } if (!LifeCycleMBean.STARTED.equals(su.getCurrentState())) { throw failure("stop", "ServiceUnit should be in a STARTED state", null); } Thread.currentThread().setContextClassLoader(su.getConfigurationClassLoader()); su.stop(); logger.debug("Service unit stopped"); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw failure("stop", "Unable to stop service unit", e); } finally { Thread.currentThread().setContextClassLoader(cl); } }
public synchronized void start(String serviceUnitName) throws DeploymentException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { logger.debug("Starting service unit"); if (serviceUnitName == null || serviceUnitName.length() == 0) { throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); } ServiceUnit su = (ServiceUnit) getServiceUnit(serviceUnitName); if (su == null) { throw failure("start", "Service Unit '" + serviceUnitName + "' is not deployed", null); } if (!LifeCycleMBean.STOPPED.equals(su.getCurrentState())) { throw failure("start", "ServiceUnit should be in a STOPPED state", null); } Thread.currentThread().setContextClassLoader(su.getConfigurationClassLoader()); su.start(); logger.debug("Service unit started"); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw failure("start", "Unable to start service unit", e); } finally { Thread.currentThread().setContextClassLoader(cl); } }
public synchronized String undeploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { logger.debug("Undeploying service unit"); logger.debug("Shutting down service unit"); if (serviceUnitName == null || serviceUnitName.length() == 0) { throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); } ServiceUnit su = getServiceUnit(serviceUnitName); if (su == null) { throw failure("undeploy", "Service Unit '" + serviceUnitName + "' is not deployed", null); } if (!LifeCycleMBean.SHUTDOWN.equals(su.getCurrentState())) { throw failure("undeploy", "ServiceUnit should be in a SHUTDOWN state", null); } Thread.currentThread().setContextClassLoader(su.getConfigurationClassLoader()); if (serviceUnitRootPath != null) { doUndeploy(su); } component.getRegistry().unregisterServiceUnit(su); logger.debug("Service unit undeployed"); return createSuccessMessage("undeploy"); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw failure("undeploy", "Unable to undeploy service unit", e); } finally { Thread.currentThread().setContextClassLoader(cl); } }
throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); ServiceUnit su = getServiceUnit(serviceUnitName); if (su == null) { if (!persistent) {
public synchronized String deploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException { try { logger.debug("Deploying service unit"); if (serviceUnitName == null || serviceUnitName.length() == 0) { throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); } if (getServiceUnit(serviceUnitName) != null) { throw failure("deploy", "Service Unit '" + serviceUnitName + "' is already deployed", null); } ServiceUnit su = doDeploy(serviceUnitName, serviceUnitRootPath); if (su == null) { throw failure("deploy", "Unable to find suitable deployer for Service Unit '" + serviceUnitName + "'", null); } component.getRegistry().registerServiceUnit(su); logger.debug("Service unit deployed"); return createSuccessMessage("deploy"); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw failure("deploy", "Unable to deploy service unit", e); } }