protected T doGetManagedResource() throws MBeanException { try { @SuppressWarnings("unchecked") T resource = (T) getManagedResource(); return resource; } catch (InstanceNotFoundException | RuntimeOperationsException | InvalidTargetObjectTypeException e) { throw new MBeanException(e); } }
/** * Set the value of a specific attribute of this MBean. * * @param attribute The identification of the attribute to be set * and the new value * * @exception AttributeNotFoundException if this attribute is not * supported by this MBean * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectionException if a Java reflection exception * occurs when invoking the getter */ @Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { super.setAttribute(attribute); ContextEnvironment ce = doGetManagedResource(); // cannot use side-effects. It's removed and added back each time // there is a modification in a resource. NamingResources nr = ce.getNamingResources(); nr.removeEnvironment(ce.getName()); nr.addEnvironment(ce); } }
/** * Set the value of a specific attribute of this MBean. * * @param attribute The identification of the attribute to be set * and the new value * * @exception AttributeNotFoundException if this attribute is not * supported by this MBean * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectionException if a Java reflection exception * occurs when invoking the getter */ @Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { super.setAttribute(attribute); ContextEnvironment ce = doGetManagedResource(); // cannot use side-effects. It's removed and added back each time // there is a modification in a resource. NamingResources nr = ce.getNamingResources(); nr.removeEnvironment(ce.getName()); nr.addEnvironment(ce); } }
protected T doGetManagedResource() throws MBeanException { try { @SuppressWarnings("unchecked") T resource = (T) getManagedResource(); return resource; } catch (InstanceNotFoundException | RuntimeOperationsException | InvalidTargetObjectTypeException e) { throw new MBeanException(e); } }