当前位置: 首页>>代码示例>>Java>>正文


Java TransactionManagerFactory类代码示例

本文整理汇总了Java中com.arjuna.mw.wst11.TransactionManagerFactory的典型用法代码示例。如果您正苦于以下问题:Java TransactionManagerFactory类的具体用法?Java TransactionManagerFactory怎么用?Java TransactionManagerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransactionManagerFactory类属于com.arjuna.mw.wst11包,在下文中一共展示了TransactionManagerFactory类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeBooking

import com.arjuna.mw.wst11.TransactionManagerFactory; //导入依赖的package包/类
/**
 * Book a number of seats in the restaurant. Enrols a Participant, then passes the call through to the business logic.
 */
@WebMethod
public void makeBooking() throws RestaurantException {

    System.out.println("[SERVICE] Restaurant service invoked to make a booking");
    String transactionId;
    try {
        // get the transaction ID associated with this thread
        transactionId = UserTransactionFactory.userTransaction().toString();

        // enlist the Participant for this service:
        RestaurantParticipant restaurantParticipant = new RestaurantParticipant(transactionId);
        TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
        System.out.println("[SERVICE] Enlisting a Durable2PC participant into the AT");
        transactionManager.enlistForDurableTwoPhase(restaurantParticipant, "restaurantServiceAT:" + UUID.randomUUID());
    } catch (Exception e) {
        throw new RestaurantException("Error when enlisting participant", e);
    }

    // invoke the backend business logic:
    System.out.println("[SERVICE] Invoking the back-end business logic");
    mockRestaurantManager.makeBooking(transactionId);
}
 
开发者ID:red-fox-mulder,项目名称:eap-6.1-quickstarts,代码行数:26,代码来源:RestaurantServiceATImpl.java

示例2: order

import com.arjuna.mw.wst11.TransactionManagerFactory; //导入依赖的package包/类
/**
 * Order flight ticket defined by fltid for a user identified by name.
 * @param name username
 * @param fltid flight identifier
 */
@WebMethod
public void order(@WebParam(name = "name") String name,
    @WebParam(name = "fltid") String fltid) {
    log.info("AirportService:order");

    UserTransaction transactionId = UserTransactionFactory
        .userTransaction();

    if (transactionId != null) {
        log.info("Transaction ID = " + transactionId.toString());
        if (transactionId.toString().compareTo("Unknown") == 0) {
            log.info("JBoss AS is badly configured. (Enable XTS)");
            return;
        }

        // Create order participant (fly ticket)
        OrderParticipant op = new OrderParticipant(
            transactionId.toString(), fltid);

        try {
            // Enlist order participant to the transaction
            TransactionManagerFactory.transactionManager()
                .enlistForDurableTwoPhase(
                    op,
                    "org.switchyard.quickstarts.bpel.xts.wsat.ws:AirportService:" + name
                        + ":" + fltid);
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getMessage());
            e.printStackTrace();
        }
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:38,代码来源:AirportService.java

示例3: bridgeIncomingTransaction

import com.arjuna.mw.wst11.TransactionManagerFactory; //导入依赖的package包/类
private boolean bridgeIncomingTransaction(HttpServletRequest request) {
    try {
        // extract WS-AT transaction context from response header and resume it
        String txContextHeader = request.getHeader(TransactionContextSerializer.HEADER_TXCONTEXT);
        if (txContextHeader == null) {
            return false;
        } else {
            if (_log.isDebugEnabled()) {
                _log.debug("Transaction context is found in request message: " + txContextHeader);
            }
            
            if (_endpointPublisher.isDisableRemoteTransaction()) {
                SCALogger.ROOT_LOGGER.ignoringReceivedTransactionContext();
                return false;
            }
            
            ClassLoader origCl = Thread.currentThread().getContextClassLoader();
            CoordinationContextType cc = null;
            try {
                Thread.currentThread().setContextClassLoader(SwitchYardRemotingServlet.class.getClassLoader());
                cc = _txSerializer.deserialise(txContextHeader);
            } finally {
                Thread.currentThread().setContextClassLoader(origCl);
            }
            final TxContext txContext = new TxContextImple(cc);
            TransactionManagerFactory.transactionManager().resume(txContext);

            // create or resume subordinate JTA transaction
            InboundBridge txInboundBridge = InboundBridgeManager.getInboundBridge();
            txInboundBridge.start();
            return true;
        }
    } catch (Throwable t) {
        throw new SwitchYardException(t);
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:37,代码来源:SwitchYardRemotingServlet.java

示例4: bridgeOutgoingTransaction

import com.arjuna.mw.wst11.TransactionManagerFactory; //导入依赖的package包/类
private void bridgeOutgoingTransaction() {
    try {
        // disassociate subordinate JTA transaction
        InboundBridge txInboundBridge = InboundBridgeManager.getInboundBridge();
        txInboundBridge.stop();

        // disassociate WS-AT transaction
        final com.arjuna.mw.wst11.TransactionManager wsatManager = TransactionManagerFactory.transactionManager();
        if (wsatManager != null) {
            wsatManager.suspend();
        }
    } catch (final Throwable th) {
        throw new SwitchYardException(th);
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:16,代码来源:SwitchYardRemotingServlet.java

示例5: bridgeOutgoingTransaction

import com.arjuna.mw.wst11.TransactionManagerFactory; //导入依赖的package包/类
private boolean bridgeOutgoingTransaction(RemoteMessage request) throws HandlerException {
    if (_disableRemoteTransaction) {
        return false;
    }
    
    Transaction currentTransaction = null;
    try {
        currentTransaction = com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction();
    } catch (Throwable t) {
        if (_log.isDebugEnabled()) {
            _log.debug(t);
        }
    }
    if (currentTransaction == null) {
        return false;
    }
    
    try {
        // create/resume subordinate WS-AT transaction
        OutboundBridge txOutboundBridge = OutboundBridgeManager.getOutboundBridge();
        if (txOutboundBridge == null) {
            return false;
        }
        txOutboundBridge.start();
        
        // embed WS-AT transaction context into request header 
        final com.arjuna.mw.wst11.TransactionManager wsatManager = TransactionManagerFactory.transactionManager();
        CoordinationContextType coordinationContext = null;
        if (wsatManager != null) {
            final TxContextImple txContext = (TxContextImple)wsatManager.currentTransaction();
            if (txContext != null) {
                coordinationContext = txContext.context().getCoordinationContext();
            }
        }

        if (coordinationContext != null) {
            String txContextString = _txSerializer.serialise(coordinationContext);
            if (_log.isDebugEnabled()) {
                _log.debug("Embedding transaction context into request header: " + txContextString);
            }
            request.getContext()
                   .setProperty(TransactionContextSerializer.HEADER_TXCONTEXT, txContextString)
                   .addLabels(BehaviorLabel.TRANSIENT.label(), HttpInvokerLabel.HEADER.label());
        }
        return true;
    } catch (final Throwable th) {
        throw createHandlerException(th);
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:50,代码来源:SCAInvoker.java


注:本文中的com.arjuna.mw.wst11.TransactionManagerFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。