001: package org.andromda.cartridges.hibernate.metafacades;
002:
003: import org.andromda.cartridges.hibernate.HibernateProfile;
004: import org.apache.commons.lang.StringUtils;
005:
006: /**
007: * MetafacadeLogic implementation for
008: * org.andromda.cartridges.hibernate.metafacades.HibernateAssociation.
009: *
010: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation
011: */
012: public class HibernateAssociationLogicImpl extends
013: HibernateAssociationLogic {
014: // ---------------- constructor -------------------------------
015: public HibernateAssociationLogicImpl(Object metaObject,
016: String context) {
017: super (metaObject, context);
018: }
019:
020: /**
021: * Stores the default cache strategy for associations.
022: */
023: private static final String HIBERNATE_ASSOCIATION_CACHE = "hibernateAssociationCache";
024:
025: /**
026: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation#getHibernateCacheType()
027: */
028: protected java.lang.String handleGetHibernateCacheType() {
029: String cacheType = (String) findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_ASSOCIATION_CACHE);
030: if (cacheType == null) {
031: cacheType = String
032: .valueOf(this
033: .getConfiguredProperty(HIBERNATE_ASSOCIATION_CACHE));
034: }
035: return StringUtils.trimToEmpty(cacheType);
036: }
037:
038: /**
039: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation#getEhCacheMaxElementsInMemory()
040: */
041: protected int handleGetEhCacheMaxElementsInMemory() {
042: String maxElements = null;
043: maxElements = (String) this
044: .findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_MAX_ELEMENTS);
045: if (StringUtils.isBlank(maxElements)) {
046: maxElements = (String) this
047: .getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_MAX_ELEMENTS);
048: }
049: return Integer.parseInt(maxElements);
050: }
051:
052: /**
053: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation#isEhCacheEternal()
054: */
055: protected boolean handleIsEhCacheEternal() {
056: String eternal = (String) this
057: .findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_ETERNAL);
058: if (eternal == null) {
059: eternal = (String) this
060: .getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_ETERNAL);
061: }
062: return Boolean.valueOf(eternal).booleanValue();
063: }
064:
065: /**
066: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation#getEhCacheTimeToIdleSeconds()
067: */
068: protected int handleGetEhCacheTimeToIdleSeconds() {
069: String timeToIdle = null;
070: timeToIdle = (String) this
071: .findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_TIME_TO_IDLE);
072: if (StringUtils.isBlank(timeToIdle)) {
073: timeToIdle = (String) this
074: .getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_TIME_TO_IDLE);
075: }
076: return Integer.parseInt(timeToIdle);
077: }
078:
079: /**
080: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation#getEhCacheTimeToLiveSeconds()
081: */
082: protected int handleGetEhCacheTimeToLiveSeconds() {
083: String timeToLive = null;
084: timeToLive = (String) this
085: .findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_TIME_TO_LIVE);
086: if (StringUtils.isBlank(timeToLive)) {
087: timeToLive = (String) this
088: .getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_TIME_TO_LIVE);
089: }
090: return Integer.parseInt(timeToLive);
091: }
092:
093: /**
094: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation#isEhCacheOverflowToDisk()
095: */
096: protected boolean handleIsEhCacheOverflowToDisk() {
097: String eternal = (String) this
098: .findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_OVERFLOW_TO_DISK);
099: if (eternal == null) {
100: eternal = (String) this
101: .getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_OVERFLOW_TO_DISK);
102: }
103: return Boolean.valueOf(eternal).booleanValue();
104: }
105:
106: /**
107: * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociation#isHibernateCacheDistributed()
108: */
109: protected boolean handleIsHibernateCacheDistributed() {
110: {
111: String distributed = (String) this
112: .getConfiguredProperty(HibernateGlobals.HIBERNATE_ENTITYCACHE_DISTRIBUTED);
113: boolean distributedCachingEnabled = Boolean.valueOf(
114: StringUtils.trimToEmpty(distributed))
115: .booleanValue();
116:
117: if (distributedCachingEnabled) {
118: String entityCacheDistributed = (String) this
119: .findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_ASSOCIATIONCACHE_DISTRIBUTED);
120: return Boolean
121: .valueOf(
122: StringUtils
123: .trimToEmpty(entityCacheDistributed))
124: .booleanValue();
125: }
126: return false;
127: }
128: }
129: }
|