public void run() { getTarget().addService( mbeanName, mbeanService ). addDependency( DependencyType.OPTIONAL, MBeanServerService.SERVICE_NAME, MBeanServer.class, mbeanService.getMBeanServerInjector() ). setInitialMode( Mode.PASSIVE ). install(); } } );
/** * Unregister the mbean from the mbean server. * * @param context The stop context */ public synchronized void stop(StopContext context) { if (objectName == null) { ROOT_LOGGER.cannotUnregisterObject(); } final MBeanServer mBeanServer = getMBeanServer(); try { for (SetupAction action : setupActions) { action.setup(Collections.<String, Object>emptyMap()); } try { mBeanServer.unregisterMBean(objectName); } catch (Exception e) { ROOT_LOGGER.unregistrationFailure(e, objectName); } } finally { for (SetupAction action : setupActions) { action.teardown(Collections.<String, Object>emptyMap()); } } }
public ServiceName installMBean(final ServiceName name, final String groupName, Object mbean) { return installMBean( name, new MBeanRegistrationService<Object>( mbeanName( groupName, name ), name, new ImmediateValue<Object>( mbean ) ) ); }
/** * Unregister the mbean from the mbean server. * * @param context The stop context */ public synchronized void stop(StopContext context) { if(objectName == null){ ROOT_LOGGER.cannotUnregisterObject(); } final MBeanServer mBeanServer = getMBeanServer(); WritableServiceBasedNamingStore.pushOwner(duServiceName); try { mBeanServer.unregisterMBean(objectName); } catch (Exception e) { ROOT_LOGGER.unregistrationFailure(e, objectName); } finally { WritableServiceBasedNamingStore.popOwner(); } }
/** * Register the mbean with the mbean server. * * @param context The start context * @throws StartException If any registration problems occur */ public synchronized void start(final StartContext context) throws StartException { final MBeanServer mBeanServer = getMBeanServer(); final T value = this.value.getValue(); try { objectName = new ObjectName(name); } catch (MalformedObjectNameException e) { throw MESSAGES.mbeanRegistrationFailed(e, name); } try { for (SetupAction action : setupActions) { action.setup(Collections.<String, Object>emptyMap()); } try { ROOT_LOGGER.debugf("Registering [%s] with name [%s]", value, objectName); mBeanServer.registerMBean(value, objectName); } catch (Exception e) { throw MESSAGES.mbeanRegistrationFailed(e, name); } } finally { for (SetupAction action : setupActions) { action.teardown(Collections.<String, Object>emptyMap()); } } }
/** * Register the mbean with the mbean server. * * @param context The start context * @throws StartException If any registration problems occur */ public synchronized void start(final StartContext context) throws StartException { final MBeanServer mBeanServer = getMBeanServer(); final T value = this.value.getValue(); try { objectName = new ObjectName(name); } catch (MalformedObjectNameException e) { throw MESSAGES.mbeanRegistrationFailed(e, name); } WritableServiceBasedNamingStore.pushOwner(duServiceName); try { ROOT_LOGGER.debugf("Registering [%s] with name [%s]", value, objectName); mBeanServer.registerMBean(value, objectName); } catch (Exception e) { throw MESSAGES.mbeanRegistrationFailed(e, name); } finally { WritableServiceBasedNamingStore.popOwner(); } }