001: /* ApplicationMappingMgrAdminEJBBean.java */
002: package org.enhydra.shark.ws;
003:
004: import javax.naming.InitialContext;
005: import javax.transaction.Status;
006: import javax.transaction.UserTransaction;
007:
008: import org.enhydra.shark.Shark;
009: import org.enhydra.shark.api.admin.ApplicationMappingManagerAdmin;
010: import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
011: import org.enhydra.shark.api.common.SharkConstants;
012: import org.enhydra.shark.api.internal.appmappersistence.ApplicationMap;
013: import org.enhydra.shark.api.internal.working.CallbackUtilities;
014: import org.enhydra.shark.ejb.SharkEJBUtilities;
015:
016: /**
017: *
018: * @author V.Puskas
019: * @author S.Bojanic
020: * @author T.Jovanovic
021: * @version 0.1
022: */
023: public class ApplicationMappingMgrAdminWrapper implements
024: ApplicationMappingManagerAdmin {
025:
026: /**
027: * @ejb:interface-method
028: * view-type="all"
029: */
030: public void configure(CallbackUtilities cus) throws Exception {
031: if (SharkEJBUtilities.getEnvType() == 1) {
032: UserTransaction t = null;
033: try {
034: t = (UserTransaction) new InitialContext()
035: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
036: t.begin();
037: getSharkObject().configure(cus);
038: t.commit();
039:
040: } catch (Exception ex) {
041: try {
042: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
043: t.rollback();
044: } catch (Exception ex1) {
045: ex1.printStackTrace();
046: }
047: throw ex;
048: }
049: } else {
050: getSharkObject().configure(cus);
051: }
052: }
053:
054: /**
055: * @ejb:interface-method
056: * view-type="all"
057: */
058: public ApplicationMap getApplicationMap(WMSessionHandle shandle,
059: String pkgId, String pkgVer, String pDefId, String appDefId)
060: throws Exception {
061: if (SharkEJBUtilities.getEnvType() == 1) {
062: UserTransaction t = null;
063: ApplicationMap retVal = null;
064: try {
065: t = (UserTransaction) new InitialContext()
066: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
067: t.begin();
068: retVal = getSharkObject().getApplicationMap(shandle,
069: pkgId, pkgVer, pDefId, appDefId);
070: t.commit();
071:
072: } catch (Exception ex) {
073: try {
074: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
075: t.rollback();
076: } catch (Exception ex1) {
077: ex1.printStackTrace();
078: }
079: throw ex;
080: }
081:
082: return retVal;
083: } else {
084: return getSharkObject().getApplicationMap(shandle, pkgId,
085: pkgVer, pDefId, appDefId);
086: }
087: }
088:
089: /**
090: * @ejb:interface-method
091: * view-type="all"
092: */
093: public boolean saveApplicationMapping(ApplicationMap am)
094: throws Exception {
095: if (SharkEJBUtilities.getEnvType() == 1) {
096: UserTransaction t = null;
097: boolean retVal;
098: try {
099: t = (UserTransaction) new InitialContext()
100: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
101: t.begin();
102: retVal = getSharkObject().saveApplicationMapping(am);
103: t.commit();
104:
105: } catch (Exception ex) {
106: try {
107: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
108: t.rollback();
109: } catch (Exception ex1) {
110: ex1.printStackTrace();
111: }
112: throw ex;
113: }
114:
115: return retVal;
116: } else {
117: return getSharkObject().saveApplicationMapping(am);
118: }
119: }
120:
121: /**
122: * @ejb:interface-method
123: * view-type="all"
124: */
125: public boolean deleteApplicationMappingByMap(ApplicationMap am)
126: throws Exception {
127: if (SharkEJBUtilities.getEnvType() == 1) {
128: UserTransaction t = null;
129: boolean retVal;
130: try {
131: t = (UserTransaction) new InitialContext()
132: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
133: t.begin();
134: retVal = getSharkObject()
135: .deleteApplicationMappingByMap(am);
136: t.commit();
137:
138: } catch (Exception ex) {
139: try {
140: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
141: t.rollback();
142: } catch (Exception ex1) {
143: ex1.printStackTrace();
144: }
145: throw ex;
146: }
147:
148: return retVal;
149: } else {
150: return getSharkObject().deleteApplicationMappingByMap(am);
151: }
152: }
153:
154: /**
155: * @ejb:interface-method
156: * view-type="all"
157: */
158: public ApplicationMap[] getAllApplicationMappings()
159: throws Exception {
160: if (SharkEJBUtilities.getEnvType() == 1) {
161: UserTransaction t = null;
162: ApplicationMap[] retVal = null;
163: try {
164: t = (UserTransaction) new InitialContext()
165: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
166: t.begin();
167: retVal = getSharkObject().getAllApplicationMappings();
168: t.commit();
169:
170: } catch (Exception ex) {
171: try {
172: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
173: t.rollback();
174: } catch (Exception ex1) {
175: ex1.printStackTrace();
176: }
177: throw ex;
178: }
179:
180: return retVal;
181: } else {
182: return getSharkObject().getAllApplicationMappings();
183: }
184: }
185:
186: /**
187: * @ejb:interface-method
188: * view-type="all"
189: */
190: public ApplicationMap createApplicationMap() throws Exception {
191: if (SharkEJBUtilities.getEnvType() == 1) {
192: UserTransaction t = null;
193: ApplicationMap retVal = null;
194: try {
195: t = (UserTransaction) new InitialContext()
196: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
197: t.begin();
198: retVal = getSharkObject().createApplicationMap();
199: t.commit();
200:
201: } catch (Exception ex) {
202: try {
203: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
204: t.rollback();
205: } catch (Exception ex1) {
206: ex1.printStackTrace();
207: }
208: throw ex;
209: }
210:
211: return retVal;
212: } else {
213: return getSharkObject().createApplicationMap();
214: }
215: }
216:
217: /**
218: * @ejb:interface-method
219: * view-type="all"
220: */
221: public boolean deleteApplicationMapping(String packageId,
222: String packageVersion, String processDefinitionId,
223: String applicationId) throws Exception {
224: if (SharkEJBUtilities.getEnvType() == 1) {
225: UserTransaction t = null;
226: boolean retVal;
227: try {
228: t = (UserTransaction) new InitialContext()
229: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
230: t.begin();
231: retVal = getSharkObject().deleteApplicationMapping(
232: packageId, packageVersion, processDefinitionId,
233: applicationId);
234: t.commit();
235:
236: } catch (Exception ex) {
237: try {
238: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
239: t.rollback();
240: } catch (Exception ex1) {
241: ex1.printStackTrace();
242: }
243: throw ex;
244: }
245:
246: return retVal;
247: } else {
248: return getSharkObject().deleteApplicationMapping(packageId,
249: packageVersion, processDefinitionId, applicationId);
250: }
251: }
252:
253: protected ApplicationMappingManagerAdmin getSharkObject()
254: throws Exception {
255: return (ApplicationMappingManagerAdmin) Shark.getInstance()
256: .getPlugIn(SharkConstants.PLUGIN_APPLICATION_MAPPING);
257: }
258:
259: }
|