/** * Invoke {@link XAResourceFunction} apply method before making sure that JMS connection is available. Current * connection is used if one is available. If connection is not available, new connection is created before the * apply call and closed after it. * * @param function {@link XAResourceFunction} to be executed. * @param <T> Return type of the {@link XAResourceFunction}. * @return The result of {@link XAResourceFunction}. * @throws XAException if JMS connection cannot be created. */ public <T> T connectAndApply(XAResourceFunction<T> function) throws XAException { if (isConnected()) { return function.apply(session.getXAResource()); } connect(); try { return function.apply(session.getXAResource()); } finally { disconnect(); } }
/** * Invoke {@link XAResourceFunction} apply method before making sure that JMS connection is available. Current * connection is used if one is available. If connection is not available, new connection is created before the * apply call and closed after it. * * @param function {@link XAResourceFunction} to be executed. * @param <T> Return type of the {@link XAResourceFunction}. * @return The result of {@link XAResourceFunction}. * @throws XAException if JMS connection cannot be created. */ public <T> T connectAndApply(XAResourceFunction<T> function) throws XAException { if (isConnected()) { return function.apply(session.getXAResource()); } connect(); try { return function.apply(session.getXAResource()); } finally { disconnect(); } }
/** * Invoke {@link XAResourceFunction} apply method before making sure that JMS connection is available. Current * connection is used if one is available. If connection is not available, new connection is created before the * apply call and closed after it. * * @param function {@link XAResourceFunction} to be executed. * @param <T> Return type of the {@link XAResourceFunction}. * @return The result of {@link XAResourceFunction}. * @throws XAException if JMS connection cannot be created. */ public <T> T connectAndApply(XAResourceFunction<T> function) throws XAException { if (isConnected()) { return function.apply(session.getXAResource()); } connect(); try { return function.apply(session.getXAResource()); } finally { disconnect(); } }