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: JotmContextFactory.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 org.objectweb.jotm.Jotm;
43
44 // SECTION-START[Documentation]
45 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
46 /**
47 * Standalone Jonas JTA context factory.
48 * <p><b>Specifications</b><ul>
49 * <li>{@code 'javax.naming.spi.InitialContextFactory'} {@code (javax.naming.spi.InitialContextFactory)} {@code Multiton}</li>
50 * </ul></p>
51 *
52 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
53 * @version $Id: JotmContextFactory.java 2242 2010-06-29 07:54:56Z schulte2005 $
54 */
55 // </editor-fold>
56 // SECTION-END
57 // SECTION-START[Annotations]
58 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
59 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
60 // </editor-fold>
61 // SECTION-END
62 public final class JotmContextFactory extends AbstractContextFactory
63 {
64 // SECTION-START[InitialContextFactory]
65
66 public Context getInitialContext( final Hashtable<?, ?> environment ) throws NamingException
67 {
68 final Jotm jotm = new Jotm( true, false );
69 this.getStandaloneContext().bind( this.getStandaloneEnvironment().getTransactionManagerJndiName(),
70 jotm.getTransactionManager() );
71
72 this.getStandaloneContext().bind( this.getStandaloneEnvironment().getUserTransactionJndiName(),
73 jotm.getUserTransaction() );
74
75 this.getStandaloneContext().bind(
76 this.getStandaloneEnvironment().getTransactionSynchronizationRegistryJndiName(),
77 jotm.getTransactionSynchronizationRegistry() );
78
79 return null;
80 }
81
82 // SECTION-END
83 // SECTION-START[JotmContextFactory]
84 // SECTION-END
85 // SECTION-START[Constructors]
86 // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
87
88 /** Creates a new {@code JotmContextFactory} instance. */
89 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
90 public JotmContextFactory()
91 {
92 // SECTION-START[Default Constructor]
93 super();
94 // SECTION-END
95 }
96 // </editor-fold>
97 // SECTION-END
98 // SECTION-START[Dependencies]
99 // SECTION-END
100 // SECTION-START[Properties]
101 // SECTION-END
102 // SECTION-START[Messages]
103 // SECTION-END
104 }