Coordinator getCoordinator ( ) { coordinator = new Coordinator ( ) ; try { for ( String pu : clientMap . keySet ( ) ) { PersistenceUnitMetadata puMetadata = KunderaMetadataManager . getPersistenceUnitMetadata ( kunderaMetadata , pu ) ; String txResource = puMetadata . getProperty ( PersistenceProperties . KUNDERA_TRANSACTION_RESOURCE ) ; if ( txResource != null ) { TransactionResource resource = ( TransactionResource ) Class . forName ( txResource ) . newInstance ( ) ; coordinator . addResource ( resource , pu ) ; Client client = clientMap . get ( pu ) ; if ( ! ( client instanceof TransactionBinder ) ) { throw new KunderaTransactionException ( "Client : " + client . getClass ( ) + " must implement TransactionBinder interface, if {kundera.transaction.resource.class} property provided!" ) ; } else { ( ( TransactionBinder ) client ) . bind ( resource ) ; } } else { coordinator . addResource ( new DefaultTransactionResource ( clientMap . get ( pu ) ) , pu ) ; } } } catch ( Exception e ) { log . error ( "Error while initializing Transaction Resource:" , e ) ; throw new KunderaTransactionException ( e ) ; } return coordinator ; }
Returns transaction coordinator .