001: package org.andromda.cartridges.ejb.metafacades;
002:
003: import org.andromda.cartridges.ejb.EJBGlobals;
004: import org.andromda.cartridges.ejb.EJBProfile;
005: import org.apache.commons.collections.CollectionUtils;
006: import org.apache.commons.collections.Predicate;
007: import org.apache.commons.lang.StringUtils;
008:
009: import java.util.Collection;
010: import java.util.List;
011:
012: /**
013: * MetafacadeLogic implementation.
014: *
015: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade
016: */
017: public class EJBSessionFacadeLogicImpl extends EJBSessionFacadeLogic {
018: // ---------------- constructor -------------------------------
019:
020: public EJBSessionFacadeLogicImpl(java.lang.Object metaObject,
021: java.lang.String context) {
022: super (metaObject, context);
023: }
024:
025: /**
026: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#getCreateMethods(boolean)
027: */
028: protected java.util.Collection handleGetCreateMethods(boolean follow) {
029: return EJBMetafacadeUtils.getCreateMethods(this , follow);
030: }
031:
032: /**
033: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#getHomeInterfaceName()
034: */
035: protected java.lang.String handleGetHomeInterfaceName() {
036: return EJBMetafacadeUtils.getHomeInterfaceName(this );
037: }
038:
039: /**
040: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#getViewType()
041: */
042: protected java.lang.String handleGetViewType() {
043: return EJBMetafacadeUtils.getViewType(this );
044: }
045:
046: protected List handleGetInheritedInstanceAttributes() {
047: return EJBMetafacadeUtils.getInheritedInstanceAttributes(this );
048: }
049:
050: protected List handleGetAllInstanceAttributes() {
051: return EJBMetafacadeUtils.getAllInstanceAttributes(this );
052: }
053:
054: /**
055: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#getEnvironmentEntries(boolean)
056: */
057: protected Collection handleGetEnvironmentEntries(boolean follow) {
058: return EJBMetafacadeUtils.getEnvironmentEntries(this , follow);
059: }
060:
061: /**
062: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#getConstants(boolean)
063: */
064: protected Collection handleGetConstants(boolean follow) {
065: return EJBMetafacadeUtils.getConstants(this , follow);
066: }
067:
068: /**
069: * @see org.andromda.cartridges.ejb.metafacades.EJBSession#getJndiName()
070: */
071: protected java.lang.String handleGetJndiName() {
072: StringBuffer jndiName = new StringBuffer();
073: String jndiNamePrefix = StringUtils.trimToEmpty(this
074: .getJndiNamePrefix());
075: if (StringUtils.isNotEmpty(jndiNamePrefix)) {
076: jndiName.append(jndiNamePrefix);
077: jndiName.append("/");
078: }
079: jndiName.append("ejb/");
080: jndiName.append(this .getFullyQualifiedName());
081: return jndiName.toString();
082: }
083:
084: /**
085: * Gets the <code>jndiNamePrefix</code> for this EJB.
086: *
087: * @return the EJB Jndi name prefix.
088: */
089: protected String getJndiNamePrefix() {
090: String prefix = null;
091: if (this .isConfiguredProperty(EJBGlobals.JNDI_NAME_PREFIX)) {
092: prefix = (String) this
093: .getConfiguredProperty(EJBGlobals.JNDI_NAME_PREFIX);
094: }
095: return prefix;
096: }
097:
098: /**
099: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#isStateful()
100: */
101: protected boolean handleIsStateful() {
102: return !isStateless();
103: }
104:
105: /**
106: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacadeLogic#isStateless()
107: */
108: protected boolean handleIsStateless() {
109: return this .getAllInstanceAttributes() == null
110: || this .getAllInstanceAttributes().isEmpty();
111: }
112:
113: /**
114: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#getType()
115: */
116: protected String handleGetType() {
117: String type = "Stateful";
118: if (this .isStateless()) {
119: type = "Stateless";
120: }
121: return type;
122: }
123:
124: /**
125: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#allowSyntheticCreateMethod()
126: */
127: protected boolean handleIsSyntheticCreateMethodAllowed() {
128: return EJBMetafacadeUtils.allowSyntheticCreateMethod(this );
129: }
130:
131: /**
132: * @see org.andromda.metafacades.uml.EntityFacade#getBusinessOperations()
133: */
134: protected Collection handleGetBusinessOperations() {
135: Collection operations = super .getOperations();
136: CollectionUtils.filter(operations, new Predicate() {
137: public boolean evaluate(Object object) {
138: boolean businessOperation = false;
139: if (EJBOperationFacade.class.isAssignableFrom(object
140: .getClass())) {
141: businessOperation = ((EJBOperationFacade) object)
142: .isBusinessOperation();
143: }
144: return businessOperation;
145: }
146: });
147: return operations;
148: }
149:
150: /**
151: * @see org.andromda.cartridges.ejb.metafacades.EJBSessionFacade#getTransactionType()
152: */
153: protected java.lang.String handleGetTransactionType() {
154: String transactionType = (String) this
155: .findTaggedValue(EJBProfile.TAGGEDVALUE_EJB_TRANSACTION_TYPE);
156: if (StringUtils.isBlank(transactionType)) {
157: transactionType = transactionType = String
158: .valueOf(this
159: .getConfiguredProperty(EJBGlobals.TRANSACTION_TYPE));
160: }
161: return transactionType;
162: }
163: }
|