private GenericKieSessionMonitoringImpl getKnowledgeSessionBean ( CBSKey cbsKey , KieRuntimeEventManager ksession ) { if ( mbeansRefs . get ( cbsKey ) != null ) { return ( GenericKieSessionMonitoringImpl ) mbeansRefs . get ( cbsKey ) ; } else { if ( ksession instanceof StatelessKnowledgeSession ) { synchronized ( mbeansRefs ) { if ( mbeansRefs . get ( cbsKey ) != null ) { return ( GenericKieSessionMonitoringImpl ) mbeansRefs . get ( cbsKey ) ; } else { try { StatelessKieSessionMonitoringImpl mbean = new StatelessKieSessionMonitoringImpl ( cbsKey . kcontainerId , cbsKey . kbaseId , cbsKey . ksessionName ) ; registerMBean ( cbsKey , mbean , mbean . getName ( ) ) ; mbeansRefs . put ( cbsKey , mbean ) ; return mbean ; } catch ( Exception e ) { logger . error ( "Unable to instantiate and register StatelessKieSessionMonitoringMBean" ) ; } return null ; } } } else { synchronized ( mbeansRefs ) { if ( mbeansRefs . get ( cbsKey ) != null ) { return ( GenericKieSessionMonitoringImpl ) mbeansRefs . get ( cbsKey ) ; } else { try { KieSessionMonitoringImpl mbean = new KieSessionMonitoringImpl ( cbsKey . kcontainerId , cbsKey . kbaseId , cbsKey . ksessionName ) ; registerMBean ( cbsKey , mbean , mbean . getName ( ) ) ; mbeansRefs . put ( cbsKey , mbean ) ; return mbean ; } catch ( Exception e ) { logger . error ( "Unable to instantiate and register (stateful) KieSessionMonitoringMBean" ) ; } return null ; } } } } }
Get currently registered session monitor eventually creating it if necessary .