001package org.andromda.cartridges.hibernate.metafacades; 002 003import org.apache.commons.lang.ObjectUtils; 004import org.apache.commons.lang.StringUtils; 005 006/** 007 * MetafacadeLogic implementation for 008 * org.andromda.cartridges.hibernate.metafacades.HibernateService. 009 * 010 * @see org.andromda.cartridges.hibernate.metafacades.HibernateService 011 */ 012public class HibernateServiceLogicImpl 013 extends HibernateServiceLogic 014{ 015 private static final long serialVersionUID = 34L; 016 /** 017 * @param metaObject 018 * @param context 019 */ 020 public HibernateServiceLogicImpl( 021 Object metaObject, 022 String context) 023 { 024 super(metaObject, context); 025 } 026 027 /** 028 * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#getEjbJndiName() 029 */ 030 @Override 031 protected String handleGetEjbJndiName() 032 { 033 StringBuilder jndiName = new StringBuilder(); 034 String jndiNamePrefix = StringUtils.trimToEmpty(this.getEjbJndiNamePrefix()); 035 if (StringUtils.isNotBlank(jndiNamePrefix)) 036 { 037 jndiName.append(jndiNamePrefix); 038 jndiName.append('/'); 039 } 040 jndiName.append("ejb/"); 041 jndiName.append(this.getFullyQualifiedName()); 042 return jndiName.toString(); 043 } 044 045 /** 046 * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#getEjbViewType() 047 */ 048 @Override 049 protected String handleGetEjbViewType() 050 { 051 String defaultViewType = String.valueOf(this.getConfiguredProperty("ejbViewType")); 052 return HibernateMetafacadeUtils.getViewType(this, defaultViewType); 053 } 054 055 /** 056 * Gets the <code>ejbJndiNamePrefix</code> for this EJB. 057 * 058 * @return the EJB Jndi name prefix. 059 */ 060 protected String getEjbJndiNamePrefix() 061 { 062 final String property = "ejbJndiNamePrefix"; 063 return this.isConfiguredProperty(property) ? ObjectUtils.toString(this.getConfiguredProperty(property)) : null; 064 } 065 066 /** 067 * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#isEjbStateful() 068 */ 069 @Override 070 protected boolean handleIsEjbStateful() 071 { 072 return !this.getAttributes().isEmpty(); 073 } 074 075 /** 076 * The value used to indicate the interfaces for an EJB are remote. 077 */ 078 private static final String VIEW_TYPE_REMOTE = "remote"; 079 080 /** 081 * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#isEjbRemoteView() 082 */ 083 @Override 084 protected boolean handleIsEjbRemoteView() 085 { 086 return this.getEjbViewType().equalsIgnoreCase(VIEW_TYPE_REMOTE); 087 } 088}