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.sdlctools.services.codegeneration.servicedistributiongenerator.j2ee.jboss;
16:
17: import com.metaboss.enterprise.bo.BOException;
18: import com.metaboss.enterprise.bs.BSException;
19: import com.metaboss.enterprise.bs.BSUnexpectedProgramConditionException;
20: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
21: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Operation;
22: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
23: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
24: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.TransactionPolicy;
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.TransactionPolicyEnum;
26: import com.metaboss.sdlctools.services.codegeneration.CodeGenerationStylesheetAccessor;
27: import com.metaboss.sdlctools.services.codegenerationstylesheet.STServiceStylesheet;
28:
29: /** Internal package utilities */
30: class Util {
31: /* Helper. Suggests the ejb reference for the service */
32: public static String getEjbRef(Service pService)
33: throws BSException, BOException {
34: STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
35: .getServiceStylesheet(pService);
36: Servicemodule lServicemodule = pService.getServicemodule();
37: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lServicemodule
38: .getSystem();
39: Enterprise lEnterprise = lSystem.getEnterprise();
40: return lEnterprise.getName().toLowerCase() + "/"
41: + lSystem.getName().toLowerCase()
42: + "/BusinessServices/"
43: + lServicemodule.getName().toLowerCase() + "/"
44: + lServiceStylesheet.getInterfaceName() + "Bean";
45: }
46:
47: public static String getHomeInterfaceName(Service pService)
48: throws BSException, BOException {
49: STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
50: .getServiceStylesheet(pService);
51: return lServiceStylesheet.getInterfaceName() + "HomeInterface";
52: }
53:
54: public static String getRemoteInterfaceName(Service pService)
55: throws BSException, BOException {
56: STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
57: .getServiceStylesheet(pService);
58: return lServiceStylesheet.getInterfaceName()
59: + "RemoteInterface";
60: }
61:
62: public static String getBeanClassName(Service pService)
63: throws BSException, BOException {
64: STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
65: .getServiceStylesheet(pService);
66: return lServiceStylesheet.getInterfaceName() + "Bean";
67: }
68:
69: /* Helper. Suggests the transaction attribute for the operation */
70: public static String getTransactionAttribute(Operation pOperation)
71: throws BSException, BOException {
72: TransactionPolicy lTransactionPolicy = pOperation
73: .getTransactionPolicy();
74: if (lTransactionPolicy
75: .equals(TransactionPolicyEnum.NOT_SUPPORTED))
76: return "NotSupported";
77: if (lTransactionPolicy.equals(TransactionPolicyEnum.MANDATORY))
78: return "Mandatory";
79: if (lTransactionPolicy.equals(TransactionPolicyEnum.SUPPORTED))
80: return "Supports";
81: if (lTransactionPolicy.equals(TransactionPolicyEnum.NEVER))
82: return "Never";
83: if (lTransactionPolicy.equals(TransactionPolicyEnum.REQUIRED))
84: return "Required";
85: if (lTransactionPolicy
86: .equals(TransactionPolicyEnum.REQUIRED_NEW))
87: return "RequiresNew";
88: throw new BSUnexpectedProgramConditionException(
89: "Unsupported transaction policy: " + lTransactionPolicy);
90: }
91: }
|