83
83
* via the {@link #setListeners(MBeanExporterListener[]) listeners} property, allowing
84
84
* application code to be notified of MBean registration and unregistration events.
85
85
*
86
- * <p>This exporter is compatible with MBeans and MXBeans on Java 6 and above .
86
+ * <p>This exporter is compatible with MBeans as well as MXBeans .
87
87
*
88
88
* @author Rob Harrop
89
89
* @author Juergen Hoeller
@@ -466,7 +466,7 @@ public ObjectName registerManagedResource(Object managedResource) throws MBeanEx
466
466
objectName = JmxUtils .appendIdentityToObjectName (objectName , managedResource );
467
467
}
468
468
}
469
- catch (Exception ex ) {
469
+ catch (Throwable ex ) {
470
470
throw new MBeanExportException ("Unable to generate ObjectName for MBean [" + managedResource + "]" , ex );
471
471
}
472
472
registerManagedResource (managedResource , objectName );
@@ -578,7 +578,8 @@ protected boolean isBeanDefinitionLazyInit(ListableBeanFactory beanFactory, Stri
578
578
* @param mapValue the value configured for this bean in the beans map;
579
579
* may be either the {@code String} name of a bean, or the bean itself
580
580
* @param beanKey the key associated with this bean in the beans map
581
- * @return the {@code ObjectName} under which the resource was registered
581
+ * @return the {@code ObjectName} under which the resource was registered,
582
+ * or {@code null} if the actual resource was {@code null} as well
582
583
* @throws MBeanExportException if the export failed
583
584
* @see #setBeans
584
585
* @see #registerBeanInstance
@@ -599,12 +600,14 @@ protected ObjectName registerBeanNameOrInstance(Object mapValue, String beanKey)
599
600
}
600
601
else {
601
602
Object bean = this .beanFactory .getBean (beanName );
602
- ObjectName objectName = registerBeanInstance (bean , beanKey );
603
- replaceNotificationListenerBeanNameKeysIfNecessary (beanName , objectName );
604
- return objectName ;
603
+ if (bean != null ) {
604
+ ObjectName objectName = registerBeanInstance (bean , beanKey );
605
+ replaceNotificationListenerBeanNameKeysIfNecessary (beanName , objectName );
606
+ return objectName ;
607
+ }
605
608
}
606
609
}
607
- else {
610
+ else if ( mapValue != null ) {
608
611
// Plain bean instance -> register it directly.
609
612
if (this .beanFactory != null ) {
610
613
Map <String , ?> beansOfSameType =
@@ -621,10 +624,11 @@ protected ObjectName registerBeanNameOrInstance(Object mapValue, String beanKey)
621
624
return registerBeanInstance (mapValue , beanKey );
622
625
}
623
626
}
624
- catch (Exception ex ) {
627
+ catch (Throwable ex ) {
625
628
throw new UnableToRegisterMBeanException (
626
629
"Unable to register MBean [" + mapValue + "] with key '" + beanKey + "'" , ex );
627
630
}
631
+ return null ;
628
632
}
629
633
630
634
/**
@@ -816,7 +820,7 @@ protected ModelMBean createAndConfigureMBean(Object managedResource, String bean
816
820
mbean .setManagedResource (managedResource , MR_TYPE_OBJECT_REFERENCE );
817
821
return mbean ;
818
822
}
819
- catch (Exception ex ) {
823
+ catch (Throwable ex ) {
820
824
throw new MBeanExportException ("Could not create ModelMBean for managed resource [" +
821
825
managedResource + "] with key '" + beanKey + "'" , ex );
822
826
}
@@ -984,7 +988,7 @@ private void registerNotificationListeners() throws MBeanExportException {
984
988
}
985
989
}
986
990
}
987
- catch (Exception ex ) {
991
+ catch (Throwable ex ) {
988
992
throw new MBeanExportException ("Unable to register NotificationListener" , ex );
989
993
}
990
994
}
@@ -1004,7 +1008,7 @@ private void unregisterNotificationListeners() {
1004
1008
this .server .removeNotificationListener (mappedObjectName , bean .getNotificationListener (),
1005
1009
bean .getNotificationFilter (), bean .getHandback ());
1006
1010
}
1007
- catch (Exception ex ) {
1011
+ catch (Throwable ex ) {
1008
1012
if (logger .isDebugEnabled ()) {
1009
1013
logger .debug ("Unable to unregister NotificationListener" , ex );
1010
1014
}
0 commit comments