/** Marks this repository as complete and ready for use. */ @Override public void start() { final Status status = _status.get(); if (status == Status.STARTING) { return; // already starting } checkStatus(status, Status.CREATING); if (_status.compareAndSet(status, Status.STARTING) == false) { return; // another thread just beat this one } try { // Spring interfaces for (final Lifecycle obj : _lifecycles) { obj.start(); } // JMX managed resources final MBeanServer jmxServer = findInstance(MBeanServer.class); if (jmxServer != null) { final MBeanExporter exporter = new MBeanExporter(); exporter.setServer(jmxServer); for (final Map.Entry<ObjectName, Object> resourceEntry : _managedResources.entrySet()) { exporter.registerManagedResource(resourceEntry.getValue(), resourceEntry.getKey()); } } _status.set(Status.RUNNING); } catch (final RuntimeException ex) { _status.set(Status.FAILED); throw ex; } finally { // reduce memory usage and avoid memory leaks _managedResources.clear(); _initialized.clear(); } }
@Override public void setServer(MBeanServer server) { threadServer.set(server); super.setServer(server); }