1 package org.andromda.cartridges.ejb.metafacades;
2
3 import java.util.Collection;
4 import java.util.List;
5 import org.andromda.cartridges.ejb.EJBGlobals;
6 import org.andromda.cartridges.ejb.EJBProfile;
7 import org.apache.commons.collections.CollectionUtils;
8 import org.apache.commons.collections.Predicate;
9 import org.apache.commons.lang.StringUtils;
10
11
12
13
14
15
16 public class EJBSessionFacadeLogicImpl
17 extends EJBSessionFacadeLogic
18 {
19 private static final long serialVersionUID = 34L;
20
21
22
23
24
25
26 public EJBSessionFacadeLogicImpl(Object metaObject, String context)
27 {
28 super(metaObject, context);
29 }
30
31
32
33
34
35
36 protected java.util.Collection handleGetCreateMethods(boolean follow)
37 {
38 return EJBMetafacadeUtils.getCreateMethods(this, follow);
39 }
40
41
42
43
44
45 protected String handleGetHomeInterfaceName()
46 {
47 return EJBMetafacadeUtils.getHomeInterfaceName(this);
48 }
49
50
51
52
53
54 protected String handleGetViewType()
55 {
56 return EJBMetafacadeUtils.getViewType(this);
57 }
58
59
60
61
62 protected List handleGetInheritedInstanceAttributes()
63 {
64 return EJBMetafacadeUtils.getInheritedInstanceAttributes(this);
65 }
66
67
68
69
70 protected List handleGetAllInstanceAttributes()
71 {
72 return EJBMetafacadeUtils.getAllInstanceAttributes(this);
73 }
74
75
76
77
78
79
80 protected Collection handleGetEnvironmentEntries(boolean follow)
81 {
82 return EJBMetafacadeUtils.getEnvironmentEntries(this, follow);
83 }
84
85
86
87
88
89
90 protected Collection handleGetConstants(boolean follow)
91 {
92 return EJBMetafacadeUtils.getConstants(this, follow);
93 }
94
95
96
97
98
99 protected String handleGetJndiName()
100 {
101 StringBuilder jndiName = new StringBuilder();
102 String jndiNamePrefix = StringUtils.trimToEmpty(this.getJndiNamePrefix());
103 if (StringUtils.isNotBlank(jndiNamePrefix))
104 {
105 jndiName.append(jndiNamePrefix);
106 jndiName.append('/');
107 }
108 jndiName.append("ejb/");
109 jndiName.append(this.getFullyQualifiedName());
110 return jndiName.toString();
111 }
112
113
114
115
116
117
118 protected String getJndiNamePrefix()
119 {
120 String prefix = null;
121 if (this.isConfiguredProperty(EJBGlobals.JNDI_NAME_PREFIX))
122 {
123 prefix = (String)this.getConfiguredProperty(EJBGlobals.JNDI_NAME_PREFIX);
124 }
125 return prefix;
126 }
127
128
129
130
131
132 protected boolean handleIsStateful()
133 {
134 return !isStateless();
135 }
136
137
138
139
140
141 protected boolean handleIsStateless()
142 {
143 return this.getAllInstanceAttributes() == null || this.getAllInstanceAttributes().isEmpty();
144 }
145
146
147
148
149
150 protected String handleGetType()
151 {
152 String type = "Stateful";
153 if (this.isStateless())
154 {
155 type = "Stateless";
156 }
157 return type;
158 }
159
160
161
162
163
164
165 protected boolean handleIsSyntheticCreateMethodAllowed()
166 {
167 return EJBMetafacadeUtils.allowSyntheticCreateMethod(this);
168 }
169
170
171
172
173
174 protected Collection handleGetBusinessOperations()
175 {
176 Collection operations = super.getOperations();
177 CollectionUtils.filter(operations, new Predicate()
178 {
179 public boolean evaluate(Object object)
180 {
181 boolean businessOperation = false;
182 if (EJBOperationFacade.class.isAssignableFrom(object.getClass()))
183 {
184 businessOperation = ((EJBOperationFacade)object).isBusinessOperation();
185 }
186 return businessOperation;
187 }
188 });
189 return operations;
190 }
191
192
193
194
195
196 protected String handleGetTransactionType()
197 {
198 String transactionType = (String)this.findTaggedValue(EJBProfile.TAGGEDVALUE_EJB_TRANSACTION_TYPE);
199 if (StringUtils.isBlank(transactionType))
200 {
201 transactionType = String.valueOf(this.getConfiguredProperty(EJBGlobals.TRANSACTION_TYPE));
202 }
203 if (StringUtils.isBlank(transactionType))
204 {
205 transactionType = "Required";
206 }
207 return transactionType;
208 }
209 }