001    /*
002      Copyright (C) 2001-2003 Lionel Seinturier <Lionel.Seinturier@lip6.fr>
003    
004      This program is free software; you can redistribute it and/or modify
005      it under the terms of the GNU Lesser General Public License as
006      published by the Free Software Foundation; either version 2 of the
007      License, or (at your option) any later version.
008    
009      This program is distributed in the hope that it will be useful,
010      but WITHOUT ANY WARRANTY; without even the implied warranty of
011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012      GNU Lesser General Public License for more details.
013    
014      You should have received a copy of the GNU Lesser General Public License
015      along with this program; if not, write to the Free Software
016      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
017    
018    package org.objectweb.jac.aspects.distrans;
019    
020    import javax.naming.NamingException;
021    
022    import org.objectweb.jotm.Jotm;
023    import org.objectweb.jotm.TraceTm;
024    
025    /**
026     * Helper class used to retrieve the JOTM singleton instance
027     * used by JAC.
028     * 
029     * @author Lionel Seinturier <Lionel.Seinturier@lip6.fr>
030     * @version 1.0
031     */
032    public class JOTMHelper {
033    
034        /** The singleton instance of JOTM. */
035        private static Jotm jotm;    
036    
037        public static Jotm get() {
038            
039            if ( jotm != null )
040                return jotm;
041            
042            /**
043             * Creates an instance of JOTM with a local transaction factory
044             * which is not bound to a registry. 
045             */
046            try {
047                jotm = new Jotm(true,false);
048            } catch (NamingException ne) {
049                ne.printStackTrace();
050                System.exit(1);
051            }
052            TraceTm.configure();
053            
054            return jotm;
055        }
056    
057    }