From: Vance K. <va...@us...> - 2006-06-14 05:04:05
|
User: vancek Date: 06/06/13 22:04:04 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3SessionOperationFacadeLogicImpl.java EJB3SessionFacadeLogicImpl.java Log: fixed JIRA EJB-27 for getting view type of session bean and bean operations for mixed local and remote types Revision Changes Path 1.12 +134 -0 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3SessionOperationFacadeLogicImpl.java Index: EJB3SessionOperationFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3SessionOperationFacadeLogicImpl.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -r1.11 -r1.12 --- EJB3SessionOperationFacadeLogicImpl.java 30 Apr 2006 01:54:47 -0000 1.11 +++ EJB3SessionOperationFacadeLogicImpl.java 14 Jun 2006 05:04:03 -0000 1.12 @@ -96,6 +96,103 @@ } /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleIsViewTypeStrictlyLocal() + */ + protected boolean handleIsViewTypeStrictlyLocal() + { + boolean isViewTypeStrictlyLocal = false; + String viewType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE); + if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_LOCAL) || this.isViewTypeStrictlyBoth()) + { + isViewTypeStrictlyLocal = true; + } + return isViewTypeStrictlyLocal; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleIsViewTypeStrictlyRemote() + */ + protected boolean handleIsViewTypeStrictlyRemote() + { + boolean isViewTypeStrictlyRemote = false; + String viewType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE); + if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_REMOTE) || this.isViewTypeStrictlyBoth()) + { + isViewTypeStrictlyRemote = true; + } + return isViewTypeStrictlyRemote; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleIsViewTypeStrictlyBoth() + */ + protected boolean handleIsViewTypeStrictlyBoth() + { + boolean isViewTypeStrictlyBoth = false; + String viewType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE); + if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_BOTH)) + { + isViewTypeStrictlyBoth = true; + } + return isViewTypeStrictlyBoth; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleIsViewTypeAbsoluteLocal() + */ + protected boolean handleIsViewTypeAbsoluteLocal() + { + boolean isViewTypeAsbolutelyLocal = false; + EJB3SessionFacade session = (EJB3SessionFacade)this.getOwner(); + if (!this.isLifecycleCallback() && + StringUtils.equalsIgnoreCase(this.getVisibility(), "public") && + ((session.isViewTypeBoth() && + ((session.isViewTypeStrictlyRemote() && this.isViewTypeStrictlyLocal()) || + ((session.isViewTypeStrictlyLocal() || session.isViewTypeStrictlyBoth()) && + !this.isViewTypeStrictlyRemote()))) || + (session.isViewTypeStrictlyLocal() && !this.isViewTypeStrictlyRemote()) || + this.isViewTypeStrictlyBoth())) + { + isViewTypeAsbolutelyLocal = true; + } + return isViewTypeAsbolutelyLocal; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleIsViewTypeAbsoluteRemote() + */ + protected boolean handleIsViewTypeAbsoluteRemote() + { + boolean isViewTypeAsbolutelyRemote = false; + EJB3SessionFacade session = (EJB3SessionFacade)this.getOwner(); + if (!this.isLifecycleCallback() && + StringUtils.equalsIgnoreCase(this.getVisibility(), "public") && + ((session.isViewTypeBoth() && + ((session.isViewTypeStrictlyLocal() && this.isViewTypeStrictlyRemote()) || + ((session.isViewTypeStrictlyRemote() || session.isViewTypeStrictlyBoth()) && + !this.isViewTypeStrictlyLocal()))) || + (session.isViewTypeStrictlyRemote() && !this.isViewTypeStrictlyLocal()) || + this.isViewTypeStrictlyBoth())) + { + isViewTypeAsbolutelyRemote = true; + } + return isViewTypeAsbolutelyRemote; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleIsViewTypeAbsoluteBoth() + */ + protected boolean handleIsViewTypeAbsoluteBoth() + { + boolean isViewTypeAbsolutelyBoth = false; + if (this.isViewTypeAbsoluteLocal() && this.isViewTypeAbsoluteRemote()) + { + isViewTypeAbsolutelyBoth = true; + } + return isViewTypeAbsolutelyBoth; + } + + /** * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleGetTransactionType() */ protected String handleGetTransactionType() @@ -429,4 +526,41 @@ { return this.isPostConstruct() || this.isPreDestroy() || this.isPostActivate() || this.isPrePassivate(); } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleIsSeamValidationValidator() + */ + protected boolean handleIsSeamValidationValidator() + { + boolean isSeamValidorMethod = false; + if (this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_VALIDATION_VALIDATOR)) + { + isSeamValidorMethod = true; + } + return isSeamValidorMethod; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic#handleGetSeamValidationOutcome() + */ + protected String handleGetSeamValidationOutcome() + { + String validationOutcome = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_VALIDATION_OUTCOME); + if (StringUtils.isNotBlank(validationOutcome) && + !StringUtils.equals(validationOutcome, "org.jboss.seam.annotations.Outcome.REDISPLAY")) + { + validationOutcome = "\"" + validationOutcome + "\""; + } + return validationOutcome; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionOperationFacadeLogic# + * handleIsSeamValidationRefreshEntities() + */ + protected boolean handleIsSeamValidationRefreshEntities() + { + return BooleanUtils.toBoolean( + (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_VALIDATION_REFRESH_ENTITIES)); + } } \ No newline at end of file 1.17 +158 -6 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3SessionFacadeLogicImpl.java Index: EJB3SessionFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3SessionFacadeLogicImpl.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -r1.16 -r1.17 --- EJB3SessionFacadeLogicImpl.java 11 Apr 2006 16:11:34 -0000 1.16 +++ EJB3SessionFacadeLogicImpl.java 14 Jun 2006 05:04:03 -0000 1.17 @@ -227,8 +227,15 @@ String sessionType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_SESSION_TYPE); if (StringUtils.isBlank(sessionType)) { + if (this.isSeamComponent()) + { + isStateless = true; + } + else + { isStateless = this.getAllInstanceAttributes() == null || this.getAllInstanceAttributes().isEmpty(); } + } else { isStateless = sessionType.equalsIgnoreCase(EJB3Globals.SERVICE_TYPE_STATELESS); @@ -258,8 +265,69 @@ */ protected java.lang.String handleGetViewType() { - return EJB3MetafacadeUtils.getViewType(this, + String viewType = EJB3MetafacadeUtils.getViewType(this, String.valueOf(this.getConfiguredProperty(SERVICE_DEFAULT_VIEW_TYPE))); + + /** + * Check all session bean operations. + * If session view type is remote, check for operations with view type local and return both. + * If session view type is local, check for operations with view type remote and return both. + * Otherwise session view type is both, return both. + * + * NOTE: do not invoke viewType on EJB3SessionOperationFacade to avoid cyclic dependency and throwing + * StackOverFlowError. + */ + if (viewType.equalsIgnoreCase(EJB3Globals.VIEW_TYPE_LOCAL)) + { + boolean operationWithRemoteViewExists = + CollectionUtils.exists( + this.getBusinessOperations(), + new Predicate() + { + public boolean evaluate(Object object) + { + EJB3SessionOperationFacade operation = (EJB3SessionOperationFacade)object; + String operationViewType = + String.valueOf(operation.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE)); + if (operationViewType.equalsIgnoreCase(EJB3Globals.VIEW_TYPE_REMOTE) || + operationViewType.equalsIgnoreCase(EJB3Globals.VIEW_TYPE_BOTH)) + { + return true; + } + else + { + return false; + } + } + }); + viewType = (operationWithRemoteViewExists ? EJB3Globals.VIEW_TYPE_BOTH : viewType); + } + else if (viewType.equalsIgnoreCase(EJB3Globals.VIEW_TYPE_REMOTE)) + { + boolean operationWithLocalViewExists = + CollectionUtils.exists( + this.getBusinessOperations(), + new Predicate() + { + public boolean evaluate(Object object) + { + EJB3SessionOperationFacade operation = (EJB3SessionOperationFacade)object; + String operationViewType = + String.valueOf(operation.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE)); + if (operationViewType.equalsIgnoreCase(EJB3Globals.VIEW_TYPE_LOCAL) || + operationViewType.equalsIgnoreCase(EJB3Globals.VIEW_TYPE_BOTH)) + { + return true; + } + else + { + return false; + } + } + }); + viewType = (operationWithLocalViewExists ? EJB3Globals.VIEW_TYPE_BOTH : viewType); + } + return viewType; } /** @@ -268,8 +336,8 @@ protected boolean handleIsViewTypeLocal() { boolean isLocal = false; - if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_LOCAL) || - this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_BOTH)) + if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_LOCAL) || this.isViewTypeBoth() || + this.isSeamComponent()) { isLocal = true; } @@ -282,8 +350,7 @@ protected boolean handleIsViewTypeRemote() { boolean isRemote = false; - if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_REMOTE) || - this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_BOTH)) + if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_REMOTE) || this.isViewTypeBoth()) { isRemote = true; } @@ -291,6 +358,67 @@ } /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacadeLogic#handleIsViewTypeBoth() + */ + protected boolean handleIsViewTypeBoth() + { + boolean isBoth = false; + if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_BOTH)) + { + isBoth = true; + } + return isBoth; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacadeLogic#handleIsViewTypeStrictlyLocal() + */ + protected boolean handleIsViewTypeStrictlyLocal() + { + + boolean isViewTypeStrictlyLocal = false; + String viewType = EJB3MetafacadeUtils.getViewType(this, + String.valueOf(this.getConfiguredProperty(SERVICE_DEFAULT_VIEW_TYPE))); + if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_LOCAL) || + StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_BOTH)) + { + isViewTypeStrictlyLocal = true; + } + return isViewTypeStrictlyLocal; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacadeLogic#handleIsViewTypeStrictlyRemote() + */ + protected boolean handleIsViewTypeStrictlyRemote() + { + boolean isViewTypeStrictlyRemote = false; + String viewType = EJB3MetafacadeUtils.getViewType(this, + String.valueOf(this.getConfiguredProperty(SERVICE_DEFAULT_VIEW_TYPE))); + if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_REMOTE) || + StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_BOTH)) + { + isViewTypeStrictlyRemote = true; + } + return isViewTypeStrictlyRemote; + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacadeLogic#handleIsViewTypeStrictlyBoth() + */ + protected boolean handleIsViewTypeStrictlyBoth() + { + boolean isViewTypeStrictlyBoth = false; + String viewType = EJB3MetafacadeUtils.getViewType(this, + String.valueOf(this.getConfiguredProperty(SERVICE_DEFAULT_VIEW_TYPE))); + if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_BOTH)) + { + isViewTypeStrictlyBoth = true; + } + return isViewTypeStrictlyBoth; + } + + /** * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacade#getHomeInterfaceName() */ protected java.lang.String handleGetHomeInterfaceName() @@ -1004,4 +1132,28 @@ } }) != null; } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacadeLogic#handleIsSeamComponent() + */ + protected boolean handleIsSeamComponent() + { + return EJB3MetafacadeUtils.isSeamComponent(this); + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacadeLogic#handleGetSeamComponentScopeType() + */ + protected String handleGetSeamComponentScopeType() + { + return EJB3MetafacadeUtils.getSeamComponentScopeType(this, this.isStateless()); + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3SessionFacadeLogic#handleGetSeamComponentName() + */ + protected String handleGetSeamComponentName() + { + return EJB3MetafacadeUtils.getSeamComponentName(this); + } } \ No newline at end of file |