private void registerControl(ControlService cs) { if (cs == null) throw new IllegalArgumentException("ControlService must not be null"); logger.trace("Registering control for job id {}, job name {}", job.getId(), job.getName()); this.controlService = cs; JobMXBean oldControl = cs.getControl(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControl != null) { String oldControlId = cs.getControlId(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControlId != null) { if (isJobClosed(oldControl)) { cs.unregister(oldControlId); logger.debug("Old control id {} for CLOSED job name {} was unregistered", oldControlId, job.getName()); } else { throw new IllegalStateException( "Cannot register job control for alias " + job.getName() + " because a job control with id " + oldControlId + " for the same alias already exists and is not CLOSED"); } } } this.controlId = cs.registerControl(JobMXBean.TYPE, job.getId(), job.getName(), JobMXBean.class, this); logger.debug("Control for job id {}, job name {} was registered with id {}", job.getId(), job.getName(), controlId); }
private void registerControl(ControlService cs) { if (cs == null) throw new IllegalArgumentException("ControlService must not be null"); logger.trace("Registering control for job id {}, job name {}", job.getId(), job.getName()); this.controlService = cs; JobMXBean oldControl = cs.getControl(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControl != null) { String oldControlId = cs.getControlId(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControlId != null) { if (isJobClosed(oldControl)) { cs.unregister(oldControlId); logger.debug("Old control id {} for CLOSED job name {} was unregistered", oldControlId, job.getName()); } else { throw new IllegalStateException( "Cannot register job control for alias " + job.getName() + " because a job control with id " + oldControlId + " for the same alias already exists and is not CLOSED"); } } } this.controlId = cs.registerControl(JobMXBean.TYPE, job.getId(), job.getName(), JobMXBean.class, this); logger.debug("Control for job id {}, job name {} was registered with id {}", job.getId(), job.getName(), controlId); }