1 // SECTION-START[License Header] 2 // <editor-fold defaultstate="collapsed" desc=" Generated License "> 3 /* 4 * Copyright (c) 2010 The JOMC Project 5 * Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * o Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * o Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * $Id: GeronimoJTAContextFactory.java 2242 2010-06-29 07:54:56Z schulte2005 $ 33 * 34 */ 35 // </editor-fold> 36 // SECTION-END 37 package org.jomc.standalone.ri.naming.support; 38 39 import java.util.Hashtable; 40 import javax.naming.Context; 41 import javax.naming.NamingException; 42 import javax.transaction.xa.XAException; 43 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager; 44 45 // SECTION-START[Documentation] 46 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 47 /** 48 * Standalone Geronimo JTA context factory. 49 * <p><b>Specifications</b><ul> 50 * <li>{@code 'javax.naming.spi.InitialContextFactory'} {@code (javax.naming.spi.InitialContextFactory)} {@code Multiton}</li> 51 * </ul></p> 52 * 53 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0 54 * @version $Id: GeronimoJTAContextFactory.java 2242 2010-06-29 07:54:56Z schulte2005 $ 55 */ 56 // </editor-fold> 57 // SECTION-END 58 // SECTION-START[Annotations] 59 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 60 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 61 // </editor-fold> 62 // SECTION-END 63 public final class GeronimoJTAContextFactory extends AbstractContextFactory 64 { 65 // SECTION-START[InitialContextFactory] 66 67 public Context getInitialContext( final Hashtable<?, ?> environment ) throws NamingException 68 { 69 try 70 { 71 final GeronimoTransactionManager txManager = new GeronimoTransactionManager(); 72 this.getStandaloneContext().bind( this.getStandaloneEnvironment().getTransactionManagerJndiName(), 73 txManager ); 74 75 this.getStandaloneContext().bind( this.getStandaloneEnvironment().getUserTransactionJndiName(), 76 txManager ); 77 78 this.getStandaloneContext().bind( 79 this.getStandaloneEnvironment().getTransactionSynchronizationRegistryJndiName(), txManager ); 80 81 return null; 82 } 83 catch ( final XAException e ) 84 { 85 throw (NamingException) new NamingException( e.getMessage() ).initCause( e ); 86 } 87 } 88 89 // SECTION-END 90 // SECTION-START[GeronimoJTAContextFactory] 91 // SECTION-END 92 // SECTION-START[Constructors] 93 // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> 94 95 /** Creates a new {@code GeronimoJTAContextFactory} instance. */ 96 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 97 public GeronimoJTAContextFactory() 98 { 99 // SECTION-START[Default Constructor] 100 super(); 101 // SECTION-END 102 } 103 // </editor-fold> 104 // SECTION-END 105 // SECTION-START[Dependencies] 106 // SECTION-END 107 // SECTION-START[Properties] 108 // SECTION-END 109 // SECTION-START[Messages] 110 // SECTION-END 111 }