public synchronized <S> void startService(String name, PlatformService<S> service) {
ObjectName serviceName = getObjectName(name);
if (getService(serviceName) != null) {
throw new ProcessEngineException("Cannot register service " + serviceName + " with MBeans Container, service with same name already registered.");
}
final MBeanServer beanServer = getmBeanServer();
// call the service-provided start behavior
service.start(this);
try {
beanServer.registerMBean(service, serviceName);
servicesByName.put(serviceName, service);
Stack<DeploymentOperation> currentOperationContext = activeDeploymentOperations.get();
if (currentOperationContext != null) {
currentOperationContext.peek().serviceAdded(name);
}
} catch (Exception e) {
throw new ProcessEngineException("Could not register service " + serviceName + " with the MBean server", e);
}
}