Hi,

if someone can verify the attached
WebSphereTransactionManagerFactory file,
I will check in this updated file.

regsrds
Armin

----- Original Message ----- 
From: "Matthias Roth" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Sunday, August 24, 2003 11:33 PM
Subject: RE: WebSphere Transaction Manager


> Hi,
> The problem is:
> In WAS5 the class JTSXA has been moved to another package (not
> "com.ibm.EJCS.jts.jta" but "com.ibm.EJS.jts.jta") and its method
> "getTransactionManager" is renamed to "instance". So the
> WebSphereTransactionManagerFactory should be
> changed!
> 
> regard
> Matthias Roth
> 
> 
> -----Original Message-----
> From: Gary [mailto:[EMAIL PROTECTED]
> Sent: Freitag, 22. August 2003 20:27
> To: OJB Users List
> Subject: WebSphere Transaction Manager
> 
> 
> I need to access the transaction services of WebSphere
> v5.0.
> 
> I see that the WebSphereTransactionManagerFactory
> tries to instantiate "com.ibm.ejcs.jts.jta.JTSXA."  I
> do not see where this class lives in WebSphere.
> 
> Has anyone successfully accessed v5.0 JTA support via
> OJB?
> 
> Thanks, Gary
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
package org.apache.ojb.odmg.transaction;
/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" and
 *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products derived from this software may not be called "Apache",
 *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
 *    prior written permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
/**
 * @author matthew.baird
 */
import org.apache.commons.lang.SystemUtils;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;

import javax.transaction.TransactionManager;
import java.lang.reflect.Method;


public class WebSphereTransactionManagerFactory
        implements TransactionManagerFactory
{

        private static Logger log;

    protected static final String TM_WAS_5_NAME 
="com.ibm.ejs.jts.jta.TransactionManagerFactory";
    protected static final String TM_WAS_5_METHOD_NAME ="instance";

    protected static final String TM_WAS_4x_NAME ="com.ibm.ejcs.jts.jta.JTSXA";
    protected static final String TM_WAS_4x_METHOD_NAME ="getTransactionManager";

        /**
         * Constructor for WebSphereTransactionManagerFactory.
         */
        public WebSphereTransactionManagerFactory()
        {
                super();
                log = 
LoggerFactory.getLogger(WebSphereTransactionManagerFactory.class);
        }

        /**
         * use reflection to bind to the appropriate websphere classes so we don't have
         * to import or have those libraries available.
         *
         * com.ibm.ejcs.jts.jta.JTSXA.getTransactionManager()
         * @see 
org.apache.ojb.odmg.transaction.TransactionManagerFactory#getTransactionManager()
         */
        public TransactionManager getTransactionManager()
                throws TransactionManagerFactoryException
        {
                if (log.isDebugEnabled()) 
log.debug("WeblogicTransactionManagerFactory.getTransactionManager called");
                TransactionManager txManager = null;
                try
                {
                        Class TransactionManagerFactory = Class.forName(TM_WAS_5_NAME);
                        Method method = 
TransactionManagerFactory.getMethod(TM_WAS_5_METHOD_NAME, null);
                        txManager = (TransactionManager) 
method.invoke(TransactionManagerFactory, null);
                }
                catch (Exception e)
                {
                        log.info("Can not found WAS 5x TransactionManager, try to find 
WAS 4x TM");
            /**
                         * error getting tm for websphere 5, fall back to 4
                         */
                        try
                        {
                                /**
                                 * call the method on the class because it is static.
                                 * WebSphere 4
                                 */
                                Class JTSXA = Class.forName(TM_WAS_4x_NAME);
                                Method method = JTSXA.getMethod(TM_WAS_4x_METHOD_NAME, 
null);
                                txManager = (TransactionManager) method.invoke(JTSXA, 
null);
                        }
                        catch (Exception ee)
                        {
                                throw new TransactionManagerFactoryException("Can not 
get instance of TransactionManager."
                        + SystemUtils.LINE_SEPARATOR + "Message WAS 4x was " + 
ee.getMessage()
                        + SystemUtils.LINE_SEPARATOR + "Message WAS 5x was " + 
e.getMessage());
                        }
                }
                return txManager;
        }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to