protected void addRemoteTransactionsDependency ( ) { this . getConfigurators ( ) . add ( new ComponentConfigurator ( ) { @ Override public void configure ( DeploymentPhaseContext context , ComponentDescription description , ComponentConfiguration componentConfiguration ) throws DeploymentUnitProcessingException { if ( this . hasRemoteView ( ( EJBComponentDescription ) description ) ) { // add a dependency on local transaction service componentConfiguration . getCreateDependencies ( ) . add ( ( sb , cs ) -> sb . requires ( TxnServices . JBOSS_TXN_REMOTE_TRANSACTION_SERVICE ) ) ; } } /** * Returns true if the passed EJB component description has at least one remote view * @param ejbComponentDescription * @return */ private boolean hasRemoteView ( final EJBComponentDescription ejbComponentDescription ) { final Set < ViewDescription > views = ejbComponentDescription . getViews ( ) ; for ( final ViewDescription view : views ) { if ( ! ( view instanceof EJBViewDescription ) ) { continue ; } final MethodIntf viewType = ( ( EJBViewDescription ) view ) . getMethodIntf ( ) ; if ( viewType == MethodIntf . REMOTE || viewType == MethodIntf . HOME ) { return true ; } } return false ; } } ) ; }
Adds a dependency for the ComponentConfiguration on the remote transaction service if the EJB exposes at least one remote view