private Logger getModelMBeanLogger(String notificationType) throws MBeanException { // Get a copy to avoid synchronization ModelMBeanInfo info = getModelMBeanInfo(); // First look if there is a suitable notification descriptor, otherwise use MBean descriptor Descriptor descriptor = null; Logger modelMBeanLogger = null; if (notificationType != null) { descriptor = info.getDescriptor(notificationType, "notification"); modelMBeanLogger = findLogger(descriptor); } if (modelMBeanLogger == null) { descriptor = info.getMBeanDescriptor(); modelMBeanLogger = findLogger(descriptor); if (modelMBeanLogger != null) return modelMBeanLogger; } return null; }
/** * Create an instance of the {@code ModelMBeanInfoSupport} class supplied with all * JMX implementations and populates the metadata through calls to the subclass. * @param managedBean the bean that will be exposed (might be an AOP proxy) * @param beanKey the key associated with the managed bean * @return the populated ModelMBeanInfo instance * @throws JMException in case of errors * @see #getDescription(Object, String) * @see #getAttributeInfo(Object, String) * @see #getConstructorInfo(Object, String) * @see #getOperationInfo(Object, String) * @see #getNotificationInfo(Object, String) * @see #populateMBeanDescriptor(javax.management.Descriptor, Object, String) */ @Override public ModelMBeanInfo getMBeanInfo(Object managedBean, String beanKey) throws JMException { checkManagedBean(managedBean); ModelMBeanInfo info = new ModelMBeanInfoSupport( getClassName(managedBean, beanKey), getDescription(managedBean, beanKey), getAttributeInfo(managedBean, beanKey), getConstructorInfo(managedBean, beanKey), getOperationInfo(managedBean, beanKey), getNotificationInfo(managedBean, beanKey)); Descriptor desc = info.getMBeanDescriptor(); populateMBeanDescriptor(desc, managedBean, beanKey); info.setMBeanDescriptor(desc); return info; }
/** * Create an instance of the {@code ModelMBeanInfoSupport} class supplied with all * JMX implementations and populates the metadata through calls to the subclass. * @param managedBean the bean that will be exposed (might be an AOP proxy) * @param beanKey the key associated with the managed bean * @return the populated ModelMBeanInfo instance * @throws JMException in case of errors * @see #getDescription(Object, String) * @see #getAttributeInfo(Object, String) * @see #getConstructorInfo(Object, String) * @see #getOperationInfo(Object, String) * @see #getNotificationInfo(Object, String) * @see #populateMBeanDescriptor(javax.management.Descriptor, Object, String) */ @Override public ModelMBeanInfo getMBeanInfo(Object managedBean, String beanKey) throws JMException { checkManagedBean(managedBean); ModelMBeanInfo info = new ModelMBeanInfoSupport( getClassName(managedBean, beanKey), getDescription(managedBean, beanKey), getAttributeInfo(managedBean, beanKey), getConstructorInfo(managedBean, beanKey), getOperationInfo(managedBean, beanKey), getNotificationInfo(managedBean, beanKey)); Descriptor desc = info.getMBeanDescriptor(); populateMBeanDescriptor(desc, managedBean, beanKey); info.setMBeanDescriptor(desc); return info; }
Descriptor mbeanDescriptor = info.getMBeanDescriptor(); if (mbeanDescriptor == null) throw new AttributeNotFoundException(
return null; Descriptor mbeanDescriptor = info.getMBeanDescriptor(); if (mbeanDescriptor == null) {
Descriptor mbeanDescriptor = info.getMBeanDescriptor(); if (mbeanDescriptor == null) throw new AttributeNotFoundException(
@Test public void testManagedResourceDescriptor() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); Descriptor desc = info.getMBeanDescriptor(); assertEquals("Logging should be set to true", "true", desc.getFieldValue("log")); assertEquals("Log file should be jmx.log", "jmx.log", desc.getFieldValue("logFile")); assertEquals("Currency Time Limit should be 15", "15", desc.getFieldValue("currencyTimeLimit")); assertEquals("Persist Policy should be OnUpdate", "OnUpdate", desc.getFieldValue("persistPolicy")); assertEquals("Persist Period should be 200", "200", desc.getFieldValue("persistPeriod")); assertEquals("Persist Location should be foo", "./foo", desc.getFieldValue("persistLocation")); assertEquals("Persist Name should be bar", "bar.jmx", desc.getFieldValue("persistName")); }
Descriptor mbeanDescriptor = info.getMBeanDescriptor(); if (mbeanDescriptor == null) throw new MBeanException(new ServiceNotFoundException(
protected File getStoreFile(MBeanInfo metadata, boolean createFile) throws MBeanException Descriptor d = ((ModelMBeanInfo)metadata).getMBeanDescriptor(); String dirPath = (String)d.getFieldValue(ModelMBeanConstants.PERSIST_LOCATION); String file = (String) d.getFieldValue(ModelMBeanConstants.PERSIST_NAME);
protected File getStoreFile(MBeanInfo metadata, boolean createFile) throws MBeanException Descriptor d = ((ModelMBeanInfo)metadata).getMBeanDescriptor(); String dirPath = (String)d.getFieldValue(ModelMBeanConstants.PERSIST_LOCATION); String file = (String) d.getFieldValue(ModelMBeanConstants.PERSIST_NAME);
logger().debug("curName: " + curName); ModelMBeanInfo curInfo = (ModelMBeanInfo) infos.nextElement(); Descriptor mbeanDescriptor = curInfo.getMBeanDescriptor(); String fieldName = ModelMBeanConstants.RESOURCE_CLASS; String className = (String) mbeanDescriptor.getFieldValue(fieldName);
callback = (PersistentMBean) invocation.getInvoker(); ModelMBeanInfo info = (ModelMBeanInfo) invoker.getMetaData(); Descriptor mbeanDesc = info.getMBeanDescriptor();
logger().debug("curName: " + curName); ModelMBeanInfo curInfo = (ModelMBeanInfo) infos.nextElement(); Descriptor mbeanDescriptor = curInfo.getMBeanDescriptor(); String fieldName = ModelMBeanConstants.RESOURCE_CLASS; String className = (String) mbeanDescriptor.getFieldValue(fieldName);
Descriptor descriptor = minfo.getMBeanDescriptor(); descriptor.setField(ModelMBeanConstants.OBJECT_NAME, name); minfo.setMBeanDescriptor(descriptor);
private Logger getModelMBeanLogger(String notificationType) throws MBeanException { // Get a copy to avoid synchronization ModelMBeanInfo info = getModelMBeanInfo(); // First look if there is a suitable notification descriptor, otherwise use MBean descriptor Descriptor descriptor = null; Logger modelMBeanLogger = null; if (notificationType != null) { descriptor = info.getDescriptor(notificationType, "notification"); modelMBeanLogger = findLogger(descriptor); } if (modelMBeanLogger == null) { descriptor = info.getMBeanDescriptor(); modelMBeanLogger = findLogger(descriptor); if (modelMBeanLogger != null) return modelMBeanLogger; } return null; }
callback = (PersistentMBean) invocation.getInvoker(); ModelMBeanInfo info = (ModelMBeanInfo) invoker.getMetaData(); Descriptor mbeanDesc = info.getMBeanDescriptor();
private Logger getModelMBeanLogger(String notificationType) throws MBeanException { // Get a copy to avoid synchronization ModelMBeanInfo info = getModelMBeanInfo(); // First look if there is a suitable notification descriptor, otherwise use MBean descriptor Descriptor descriptor = null; Logger modelMBeanLogger = null; if (notificationType != null) { descriptor = info.getDescriptor(notificationType, "notification"); modelMBeanLogger = findLogger(descriptor); } if (modelMBeanLogger == null) { descriptor = info.getMBeanDescriptor(); modelMBeanLogger = findLogger(descriptor); if (modelMBeanLogger != null) return modelMBeanLogger; } return null; }
/** * * @param server * @param name * @throws Exception */ protected void init(MBeanServer server, ObjectName name) throws Exception { ModelMBeanInfo minfo = (ModelMBeanInfo) info; configureInterceptorStack(minfo, server, name); initDispatchers(); // add the resource classname to the MBean info Object resource = getResource(); if (resource != null) { Descriptor mbeanDescriptor = minfo.getMBeanDescriptor(); String resClassName = getResource().getClass().getName(); mbeanDescriptor.setField(ModelMBeanConstants.RESOURCE_CLASS, resClassName); minfo.setMBeanDescriptor(mbeanDescriptor); } //Set initial values provided in descriptors setValuesFromMBeanInfo(); initPersistence(server, name); //Set (and override) values from mbean persistence store. load(); }
/** * * @param server * @param name * @throws Exception */ protected void init(MBeanServer server, ObjectName name) throws Exception { ModelMBeanInfo minfo = (ModelMBeanInfo) info; configureInterceptorStack(minfo, server, name); initDispatchers(); // add the resource classname to the MBean info Object resource = getResource(); if (resource != null) { Descriptor mbeanDescriptor = minfo.getMBeanDescriptor(); String resClassName = getResource().getClass().getName(); mbeanDescriptor.setField(ModelMBeanConstants.RESOURCE_CLASS, resClassName); minfo.setMBeanDescriptor(mbeanDescriptor); } //Set initial values provided in descriptors setValuesFromMBeanInfo(); initPersistence(server, name); //Set (and override) values from mbean persistence store. load(); }
/** * Create an instance of the {@code ModelMBeanInfoSupport} class supplied with all * JMX implementations and populates the metadata through calls to the subclass. * @param managedBean the bean that will be exposed (might be an AOP proxy) * @param beanKey the key associated with the managed bean * @return the populated ModelMBeanInfo instance * @throws JMException in case of errors * @see #getDescription(Object, String) * @see #getAttributeInfo(Object, String) * @see #getConstructorInfo(Object, String) * @see #getOperationInfo(Object, String) * @see #getNotificationInfo(Object, String) * @see #populateMBeanDescriptor(javax.management.Descriptor, Object, String) */ @Override public ModelMBeanInfo getMBeanInfo(Object managedBean, String beanKey) throws JMException { checkManagedBean(managedBean); ModelMBeanInfo info = new ModelMBeanInfoSupport( getClassName(managedBean, beanKey), getDescription(managedBean, beanKey), getAttributeInfo(managedBean, beanKey), getConstructorInfo(managedBean, beanKey), getOperationInfo(managedBean, beanKey), getNotificationInfo(managedBean, beanKey)); Descriptor desc = info.getMBeanDescriptor(); populateMBeanDescriptor(desc, managedBean, beanKey); info.setMBeanDescriptor(desc); return info; }