1 package org.andromda.cartridges.hibernate.metafacades;
2
3 import org.andromda.cartridges.hibernate.HibernateProfile;
4 import org.apache.commons.lang.StringUtils;
5
6
7
8
9
10
11
12 public class HibernateAssociationLogicImpl
13 extends HibernateAssociationLogic
14 {
15 private static final long serialVersionUID = 34L;
16
17
18
19
20
21 public HibernateAssociationLogicImpl(
22 Object metaObject,
23 String context)
24 {
25 super(metaObject, context);
26 }
27
28
29
30
31 private static final String HIBERNATE_ASSOCIATION_CACHE = "hibernateAssociationCache";
32
33
34
35
36 @Override
37 protected String handleGetHibernateCacheType()
38 {
39 String cacheType = (String)findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_ASSOCIATION_CACHE);
40 if (StringUtils.isBlank(cacheType))
41 {
42 cacheType = String.valueOf(this.getConfiguredProperty(HIBERNATE_ASSOCIATION_CACHE));
43 }
44 return StringUtils.trimToEmpty(cacheType);
45 }
46
47
48
49
50 @Override
51 protected int handleGetEhCacheMaxElementsInMemory()
52 {
53 String maxElements = null;
54 maxElements = (String)this.findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_MAX_ELEMENTS);
55 if (StringUtils.isBlank(maxElements))
56 {
57 maxElements = (String)this.getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_MAX_ELEMENTS);
58 }
59 return Integer.parseInt(maxElements);
60 }
61
62
63
64
65 @Override
66 protected boolean handleIsEhCacheEternal()
67 {
68 String eternal = (String)this.findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_ETERNAL);
69 if (StringUtils.isBlank(eternal))
70 {
71 eternal = (String)this.getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_ETERNAL);
72 }
73 return Boolean.valueOf(eternal).booleanValue();
74 }
75
76
77
78
79 @Override
80 protected int handleGetEhCacheTimeToIdleSeconds()
81 {
82 String timeToIdle = null;
83 timeToIdle = (String)this.findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_TIME_TO_IDLE);
84 if (StringUtils.isBlank(timeToIdle))
85 {
86 timeToIdle = (String)this.getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_TIME_TO_IDLE);
87 }
88 return Integer.parseInt(timeToIdle);
89 }
90
91
92
93
94 @Override
95 protected int handleGetEhCacheTimeToLiveSeconds()
96 {
97 String timeToLive = null;
98 timeToLive = (String)this.findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_TIME_TO_LIVE);
99 if (StringUtils.isBlank(timeToLive))
100 {
101 timeToLive = (String)this.getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_TIME_TO_LIVE);
102 }
103 return Integer.parseInt(timeToLive);
104 }
105
106
107
108
109 @Override
110 protected boolean handleIsEhCacheOverflowToDisk()
111 {
112 String eternal = (String)this.findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_EHCACHE_OVERFLOW_TO_DISK);
113 if (StringUtils.isBlank(eternal))
114 {
115 eternal = (String)this.getConfiguredProperty(HibernateGlobals.HIBERNATE_EHCACHE_OVERFLOW_TO_DISK);
116 }
117 return Boolean.valueOf(eternal).booleanValue();
118 }
119
120
121
122
123 @Override
124 protected boolean handleIsHibernateCacheDistributed()
125 {
126 {
127 String distributed = (String)this.getConfiguredProperty(HibernateGlobals.HIBERNATE_ENTITYCACHE_DISTRIBUTED);
128 boolean distributedCachingEnabled = Boolean.valueOf(StringUtils.trimToEmpty(distributed)).booleanValue();
129
130 if (distributedCachingEnabled)
131 {
132 String entityCacheDistributed =
133 (String)this.findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_ASSOCIATIONCACHE_DISTRIBUTED);
134 return Boolean.valueOf(StringUtils.trimToEmpty(entityCacheDistributed)).booleanValue();
135 }
136 return false;
137 }
138 }
139 }