01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.enterprise.spi.tyreximpl;
16:
17: import java.util.HashMap;
18: import java.util.Map;
19:
20: import javax.transaction.SystemException;
21:
22: import org.apache.commons.logging.Log;
23: import org.apache.commons.logging.LogFactory;
24: import tyrex.tm.Journal;
25: import tyrex.tm.JournalFactory;
26:
27: /** Implement tyrex's Transaction Journal Factory */
28: public class JournalFactoryImpl implements JournalFactory {
29: private static final Log sLogger = LogFactory
30: .getLog(JournalFactoryImpl.class);
31: private static Map sJournals = new HashMap();
32:
33: public JournalFactoryImpl() {
34: sLogger.debug("Creating another factory instance");
35: }
36:
37: /**
38: * Opens a new journal with the specified name. The journal name
39: * is always the transaction domain name.
40: * <p>
41: * The journal name is not guaranteed to be a valid name. The journal
42: * name must map to the same journal across server restarts.
43: *
44: * @param name The journal name
45: * @throws SystemException An error occured while attempting to
46: * open the journal
47: */
48: public Journal openJournal(String pJournalName)
49: throws SystemException {
50: sLogger
51: .debug("Received request to load transaction journal with name: "
52: + pJournalName);
53: // Only create journals if we do not have one
54: synchronized (sJournals) {
55: Journal lJournal = (Journal) sJournals.get(pJournalName);
56: if (lJournal == null) {
57: sLogger.debug("Loading transaction journal with name: "
58: + pJournalName);
59: lJournal = JournalImpl.createJournal(pJournalName);
60: sJournals.put(pJournalName, lJournal);
61: } else
62: sLogger
63: .debug("Using previously loaded transaction journal with name: "
64: + pJournalName);
65: return lJournal;
66: }
67: }
68: }
|