01: /**********************************************************************
02: Copyright (c) 2007 Guido Anzuoni and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15: Contributors:
16: ...
17: **********************************************************************/package org.jpox.jta;
18:
19: import org.jpox.OMFContext;
20: import org.jpox.exceptions.JPOXException;
21:
22: /**
23: * Locator for the TransactionManager in a user-defined JNDI location defined by persistence properties.
24: * @version $Revision: 1.2 $
25: */
26: public class CustomJNDITransactionManagerLocator extends
27: JNDIBasedTransactionManagerLocator {
28: /** The JNDI Location to use with this locator. */
29: protected String jndiLocation;
30:
31: /**
32: * Constructor.
33: */
34: public CustomJNDITransactionManagerLocator() {
35: super ();
36: }
37:
38: /**
39: * Constructor.
40: * @param omfCtx the OMF context this locator operates in
41: */
42: public CustomJNDITransactionManagerLocator(OMFContext omfCtx) {
43: super ();
44: setJNDILocation(omfCtx);
45: }
46:
47: /**
48: * Extracts the custom JNDI location from persistence configuration.
49: * @param omfCtx OMF Context
50: */
51: private void setJNDILocation(OMFContext omfCtx) {
52: jndiLocation = omfCtx.getPersistenceConfiguration()
53: .getJtaJndiLocation();
54: if (jndiLocation == null) {
55: // TODO Localise this
56: new JPOXException(
57: "NO Custom JNDI Location specified in configuration.")
58: .setFatal();
59: }
60: }
61:
62: /**
63: * Accessor for the JNDI name to lookup the txn manager under.
64: * @return The JNDI name
65: */
66: public String getJNDIName() {
67: return jndiLocation;
68: }
69: }
|