Package com.arjuna.mw.wst.service

Source Code of com.arjuna.mw.wst.service.GlueIncomingContextInterceptor

/*
* JBoss, Home of Professional Open Source
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags.
* See the copyright.txt in the distribution for a full listing
* of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License, v. 2.0.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.  See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License,
* v. 2.0 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA  02110-1301, USA.
*
* (C) 2005-2006,
* @author JBoss Inc.
*/
/*
* Copyright (C) 2005,
*
* Arjuna Technologies Limited,
* Newcastle upon Tyne,
* Tyne and Wear,
* UK.
*
* $Id$
*
* @author Malik SAHEB
*/

package com.arjuna.mw.wst.service;

import com.arjuna.mw.wst.BusinessActivityManager;
import com.arjuna.mw.wst.BusinessActivityManagerFactory;
import com.arjuna.mw.wst.TransactionManager;
import com.arjuna.mw.wst.TransactionManagerFactory;
import com.arjuna.mw.wst.TxContext;
import com.arjuna.mw.wst.common.CoordinationContextHelper;
import com.arjuna.mw.wstx.logging.wstxLogger;
import com.arjuna.webservices.wsat.AtomicTransactionConstants;
import com.arjuna.webservices.wsba.BusinessActivityConstants;
import com.arjuna.webservices.wscoor.CoordinationConstants;
import com.arjuna.webservices.wscoor.CoordinationContextType;

import electric.soap.ISOAPInterceptor;
import electric.xml.Element;

/**
* The class is used to perform WS-Transaction context insertion
* and extraction for application level SOAP messages within WebMethods Glue.
*
* @message com.arjuna.mw.wst.service.GlueICI_1 [com.arjuna.mw.wst.service.GlueICI_1] - Error in:
* @message com.arjuna.mw.wst.service.GlueICI_2 [com.arjuna.mw.wst.service.GlueICI_2] - Stack trace:
* @message com.arjuna.mw.wst.service.GlueICI_3 [com.arjuna.mw.wst.service.GlueICI_3] - Unknown context type:
*/

public class GlueIncomingContextInterceptor implements ISOAPInterceptor
{
    public void intercept( electric.soap.SOAPMessage soapMessage, electric.util.Context messageContext )
    {
        if (soapMessage != null)
        {
            try
            {
                final TransactionManager transactionManager = TransactionManagerFactory.transactionManager() ;
                final BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager() ;

                if (transactionManager != null)
                {
                    final com.arjuna.mwlabs.wst.at.context.TxContextImple txContext =
                        (com.arjuna.mwlabs.wst.at.context.TxContextImple)transactionManager.suspend() ;

                    if (txContext != null)
                    {
                        messageContext.setProperty(AtomicTransactionConstants.WSAT_PROTOCOL, txContext) ;
                    }
                }

                if (businessActivityManager != null)
                {
                    final com.arjuna.mwlabs.wst.ba.context.TxContextImple txContext =
                        (com.arjuna.mwlabs.wst.ba.context.TxContextImple)businessActivityManager.suspend() ;

                    if (txContext != null)
                    {
                        messageContext.setProperty(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, txContext) ;
                    }
                }

                final Element soapHeaderElement = soapMessage.getHeaderElement(CoordinationConstants.WSCOOR_NAMESPACE, CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT) ;

                if (soapHeaderElement != null)
                {
                    final CoordinationContextType cc = CoordinationContextHelper.deserialise(soapHeaderElement) ;

                    final String coordinationType = cc.getCoordinationType().getValue() ;

                    if (AtomicTransactionConstants.WSAT_PROTOCOL.equals(coordinationType))
                    {
                        final TxContext txContext = new com.arjuna.mwlabs.wst.at.context.TxContextImple(cc) ;
                        transactionManager.resume(txContext) ;
                    }
                    else if (BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME.equals(coordinationType))
                    {
                        final TxContext txContext = new com.arjuna.mwlabs.wst.ba.context.TxContextImple(cc);
                        businessActivityManager.resume(txContext) ;
                    }
                    else
                    {
                    wstxLogger.arjLoggerI18N.warn("com.arjuna.mw.wst.service.GlueICI_1",
                            new Object[]{"com.arjuna.mw.wst.service.GlueOutgoingContextInterceptor.intercept()"});

                    wstxLogger.arjLoggerI18N.warn("com.arjuna.mw.wst.service.GlueICI_3",
                            new Object[]{coordinationType});
                    }
                }
            }
            catch (final Throwable th)
            {
            wstxLogger.arjLoggerI18N.warn("com.arjuna.mw.wst.service.GlueICI_1",
                    new Object[]{"com.arjuna.mw.wst.service.GlueIncomingContextInterceptor.intercept()"});

            wstxLogger.arjLoggerI18N.warn("com.arjuna.mw.wst.service.GlueICI_2",
                    new Object[]{th});
            }
        }
    }   
}


TOP

Related Classes of com.arjuna.mw.wst.service.GlueIncomingContextInterceptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.