001: /*--
002:
003: Copyright (C) 2002-2005 Adrian Price.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: adrianprice@sourceforge.net.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Adrian Price (adrianprice@users.sourceforge.net).
027:
028: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
029: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
030: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
031: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
032: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
033: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
034: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
036: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
037: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
038: POSSIBILITY OF SUCH DAMAGE.
039:
040: For more information on OBE, please see
041: <http://obe.sourceforge.net/>.
042:
043: */
044:
045: package org.obe.server.j2ee.repository;
046:
047: import org.obe.server.j2ee.TxHelperLocalHome;
048: import org.obe.server.j2ee.audit.AuditEntryLocalHome;
049: import org.obe.server.j2ee.ejb.ApplicationEventLocalHome;
050: import org.obe.server.j2ee.ejb.EJBHelper;
051: import org.obe.server.j2ee.ejb.EventSubscriptionLocalHome;
052:
053: /**
054: * Provides access to local EJB homes used for persistence.
055: *
056: * @author Adrian Price
057: */
058: public final class EJBLocalHelper extends EJBHelper {
059: static final String PACKAGE = "Package";
060: static final String PROCESS_DEFINITION = "ProcessDefinition";
061: private static TxHelperLocalHome _txHelperHome;
062: private static PackageROLocalHome _pkgROHome;
063: private static PackageLocalHome _pkgHome;
064: private static ProcessDefinitionROLocalHome _procDefROHome;
065: private static ProcessDefinitionLocalHome _procDefHome;
066: private static ProcessInstanceLocalHome _procInstHome;
067: private static ActivityInstanceLocalHome _actInstHome;
068: private static AttributeInstanceLocalHome _attrInstHome;
069: private static WorkItemLocalHome _workItemHome;
070: private static AuditEntryLocalHome _auditHome;
071: private static EventSubscriptionLocalHome _eventSubscriptionLocalHome;
072: private static ApplicationEventLocalHome _applicationEventLocalHome;
073:
074: static TxHelperLocalHome getTxHelperHome() {
075: if (_txHelperHome == null) {
076: try {
077: _txHelperHome = (TxHelperLocalHome) getEJBLocalHome(TxHelperLocalHome.COMP_NAME);
078: } catch (Exception e) {
079: _txHelperHome = (TxHelperLocalHome) getEJBLocalHome(TxHelperLocalHome.JNDI_NAME);
080: }
081: }
082: return _txHelperHome;
083: }
084:
085: static PackageLocalHome getPackageHome() {
086: TransactionUtil.markReadWrite(PACKAGE);
087: if (_pkgHome == null) {
088: try {
089: _pkgHome = (PackageLocalHome) getEJBLocalHome(PackageLocalHome.COMP_NAME);
090: } catch (Exception e) {
091: _pkgHome = (PackageLocalHome) getEJBLocalHome(PackageLocalHome.JNDI_NAME);
092: }
093: }
094: return _pkgHome;
095: }
096:
097: static PackageROLocalHome getPackageROHome() {
098: if (_pkgROHome == null) {
099: try {
100: _pkgROHome = (PackageROLocalHome) getEJBLocalHome(PackageROLocalHome.COMP_NAME);
101: } catch (Exception e) {
102: _pkgROHome = (PackageROLocalHome) getEJBLocalHome(PackageROLocalHome.JNDI_NAME);
103: }
104: }
105: return _pkgROHome;
106: }
107:
108: static ProcessDefinitionLocalHome getProcessDefinitionHome() {
109: TransactionUtil.markReadWrite(PROCESS_DEFINITION);
110: if (_procDefHome == null) {
111: try {
112: _procDefHome = (ProcessDefinitionLocalHome) getEJBLocalHome(ProcessDefinitionLocalHome.COMP_NAME);
113: } catch (Exception e) {
114: _procDefHome = (ProcessDefinitionLocalHome) getEJBLocalHome(ProcessDefinitionLocalHome.JNDI_NAME);
115: }
116: }
117: return _procDefHome;
118: }
119:
120: static ProcessDefinitionROLocalHome getProcessDefinitionROHome() {
121: if (_procDefROHome == null) {
122: try {
123: _procDefROHome = (ProcessDefinitionROLocalHome) getEJBLocalHome(ProcessDefinitionROLocalHome.COMP_NAME);
124: } catch (Exception e) {
125: _procDefROHome = (ProcessDefinitionROLocalHome) getEJBLocalHome(ProcessDefinitionROLocalHome.JNDI_NAME);
126: }
127: }
128: return _procDefROHome;
129: }
130:
131: static ProcessInstanceLocalHome getProcessInstanceHome() {
132: if (_procInstHome == null) {
133: try {
134: _procInstHome = (ProcessInstanceLocalHome) getEJBLocalHome(ProcessInstanceLocalHome.COMP_NAME);
135: } catch (Exception e) {
136: _procInstHome = (ProcessInstanceLocalHome) getEJBLocalHome(ProcessInstanceLocalHome.JNDI_NAME);
137: }
138: }
139: return _procInstHome;
140: }
141:
142: static ActivityInstanceLocalHome getActivityInstanceHome() {
143: if (_actInstHome == null) {
144: try {
145: _actInstHome = (ActivityInstanceLocalHome) getEJBLocalHome(ActivityInstanceLocalHome.COMP_NAME);
146: } catch (Exception e) {
147: _actInstHome = (ActivityInstanceLocalHome) getEJBLocalHome(ActivityInstanceLocalHome.JNDI_NAME);
148: }
149: }
150: return _actInstHome;
151: }
152:
153: static WorkItemLocalHome getWorkItemHome() {
154: if (_workItemHome == null) {
155: try {
156: _workItemHome = (WorkItemLocalHome) getEJBLocalHome(WorkItemLocalHome.COMP_NAME);
157: } catch (Exception e) {
158: _workItemHome = (WorkItemLocalHome) getEJBLocalHome(WorkItemLocalHome.JNDI_NAME);
159: }
160: }
161: return _workItemHome;
162: }
163:
164: static AttributeInstanceLocalHome getAttributeInstanceHome() {
165: if (_attrInstHome == null) {
166: try {
167: _attrInstHome = (AttributeInstanceLocalHome) getEJBLocalHome(AttributeInstanceLocalHome.COMP_NAME);
168: } catch (Exception e) {
169: _attrInstHome = (AttributeInstanceLocalHome) getEJBLocalHome(AttributeInstanceLocalHome.JNDI_NAME);
170: }
171: }
172: return _attrInstHome;
173: }
174:
175: public static AuditEntryLocalHome getAuditEntryHome() {
176: if (_auditHome == null) {
177: try {
178: _auditHome = (AuditEntryLocalHome) getEJBLocalHome(AuditEntryLocalHome.COMP_NAME);
179: } catch (Exception e) {
180: _auditHome = (AuditEntryLocalHome) getEJBLocalHome(AuditEntryLocalHome.JNDI_NAME);
181: }
182: }
183: return _auditHome;
184: }
185:
186: public static EventSubscriptionLocalHome getEventSubscriptionHome() {
187: if (_eventSubscriptionLocalHome == null) {
188: try {
189: _eventSubscriptionLocalHome = (EventSubscriptionLocalHome) getEJBLocalHome(EventSubscriptionLocalHome.COMP_NAME);
190: } catch (Exception e) {
191: _eventSubscriptionLocalHome = (EventSubscriptionLocalHome) getEJBLocalHome(EventSubscriptionLocalHome.JNDI_NAME);
192: }
193: }
194: return _eventSubscriptionLocalHome;
195: }
196:
197: public static ApplicationEventLocalHome getApplicationEventHome() {
198: if (_applicationEventLocalHome == null) {
199: try {
200: _applicationEventLocalHome = (ApplicationEventLocalHome) getEJBLocalHome(ApplicationEventLocalHome.COMP_NAME);
201: } catch (Exception e) {
202: _applicationEventLocalHome = (ApplicationEventLocalHome) getEJBLocalHome(ApplicationEventLocalHome.JNDI_NAME);
203: }
204: }
205: return _applicationEventLocalHome;
206: }
207:
208: private EJBLocalHelper() {
209: }
210: }
|