Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Use a jndi configured infinispan cache instead of ehcahce.
Browse files Browse the repository at this point in the history
Need to add this to standalone.xml’s infinispan cache container:
jndi-name="java:jboss/infinispan/container/hibernate" start="EAGER"
  • Loading branch information
Carlos A. Munoz committed Aug 25, 2014
1 parent cb5413a commit 1956a1d
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 28 deletions.
10 changes: 5 additions & 5 deletions zanata-model/src/main/java/org/zanata/model/HAccount.java
Expand Up @@ -64,7 +64,7 @@
*
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "username"))
@Indexed
@Setter
Expand All @@ -86,21 +86,21 @@ public class HAccount extends ModelEntityBase implements Serializable {
private HAccount mergedInto;
private Map<String, HAccountOption> editorOptions;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY,
mappedBy = "account")
public HAccountActivationKey getAccountActivationKey() {
return accountActivationKey;
}

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY,
mappedBy = "account")
public HAccountResetPasswordKey getAccountResetPasswordKey() {
return accountResetPasswordKey;
}

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@OneToOne(mappedBy = "account", cascade = CascadeType.ALL)
public HPerson getPerson() {
return person;
Expand Down Expand Up @@ -134,7 +134,7 @@ public String getApiKey() {
return apiKey;
}

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@UserRoles
@ManyToMany(targetEntity = HAccountRole.class)
@JoinTable(name = "HAccountMembership", joinColumns = @JoinColumn(
Expand Down
Expand Up @@ -28,7 +28,7 @@
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class HAccountResetPasswordKey extends AccountKeyBase implements
Serializable {

Expand Down
Expand Up @@ -43,7 +43,7 @@
@Entity
@TypeDef(name = "conditionRuleAction",
typeClass = ConditionRuleActionType.class)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Setter
@NoArgsConstructor
@AllArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion zanata-model/src/main/java/org/zanata/model/HDocument.java
Expand Up @@ -82,7 +82,7 @@
*/
@Entity
@EntityListeners({HDocument.EntityListener.class})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@TypeDef(name = "contentType", typeClass = ContentTypeType.class)
@Setter
@NoArgsConstructor
Expand Down
Expand Up @@ -50,7 +50,7 @@
*
**/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Indexed
@Setter
@EqualsAndHashCode(callSuper = true, doNotUseGetters = true,
Expand Down
Expand Up @@ -59,7 +59,7 @@
*
**/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Indexed
@FullTextFilterDef(name = "glossaryLocaleFilter",
impl = LocaleFilterFactory.class,
Expand Down
4 changes: 2 additions & 2 deletions zanata-model/src/main/java/org/zanata/model/HLocale.java
Expand Up @@ -49,7 +49,7 @@
import com.ibm.icu.util.ULocale;

@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@TypeDef(name = "localeId", typeClass = LocaleIdType.class)
@Setter
@NoArgsConstructor
Expand Down Expand Up @@ -93,7 +93,7 @@ public void setEnabledByDefault(boolean enabledByDefault) {
}

@OneToMany(cascade = CascadeType.ALL, mappedBy = "id.supportedLanguage")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public Set<HLocaleMember> getMembers() {
if (this.members == null) {
this.members = new HashSet<HLocaleMember>();
Expand Down
2 changes: 1 addition & 1 deletion zanata-model/src/main/java/org/zanata/model/HPerson.java
Expand Up @@ -51,7 +51,7 @@
*
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Setter
@EqualsAndHashCode(callSuper = true, of = { "id", "email", "name" },
doNotUseGetters = true)
Expand Down
6 changes: 3 additions & 3 deletions zanata-model/src/main/java/org/zanata/model/HProject.java
Expand Up @@ -74,7 +74,7 @@
*
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Access(AccessType.FIELD)
@TypeDef(name = "entityStatus", typeClass = EntityStatusType.class)
@Restrict
Expand Down Expand Up @@ -128,7 +128,7 @@ public class HProject extends SlugEntityBase implements Serializable,
@JoinTable(name = "HProject_Maintainer", joinColumns = @JoinColumn(
name = "projectId"), inverseJoinColumns = @JoinColumn(
name = "personId"))
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
private Set<HPerson> maintainers = Sets.newHashSet();

@ManyToMany
Expand All @@ -145,7 +145,7 @@ public class HProject extends SlugEntityBase implements Serializable,
private Map<String, String> customizedValidations = Maps.newHashMap();

@OneToMany(mappedBy = "project")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
private List<HProjectIteration> projectIterations = Lists.newArrayList();

@Type(type = "entityStatus")
Expand Down
Expand Up @@ -75,7 +75,7 @@
import com.google.common.collect.Sets;

@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@TypeDef(name = "entityStatus", typeClass = EntityStatusType.class)
@Restrict
@EntityRestrict({ INSERT, UPDATE, DELETE })
Expand Down
Expand Up @@ -38,7 +38,7 @@
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Setter
@ToString(callSuper = true)
public class HRoleAssignmentRule extends ModelEntityBase {
Expand Down
Expand Up @@ -50,7 +50,7 @@
*/
@Entity
@EntityListeners({ HSimpleComment.EntityListener.class })
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@BatchSize(size = 20)
@Setter
@NoArgsConstructor
Expand Down
Expand Up @@ -45,7 +45,7 @@
*
**/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Setter
@NoArgsConstructor
@ToString(of = "comment")
Expand Down
4 changes: 2 additions & 2 deletions zanata-model/src/main/java/org/zanata/model/HTextFlow.java
Expand Up @@ -86,7 +86,7 @@
*/
@Entity
@EntityListeners({ HTextFlow.EntityListener.class })
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Setter
@NoArgsConstructor
@ToString(of = { "resId", "revision", "comment", "obsolete" })
Expand Down Expand Up @@ -376,7 +376,7 @@ public Map<Integer, HTextFlowHistory> getHistory() {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "textFlow")
@MapKeyColumn(name = "locale")
@BatchSize(size = 10)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public Map<Long, HTextFlowTarget> getTargets() {
if (targets == null) {
targets = new HashMap<Long, HTextFlowTarget>();
Expand Down
Expand Up @@ -83,7 +83,7 @@
*/
@Entity
@EntityListeners({ HTextFlowTarget.EntityListener.class })
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Indexed
@Setter
@NoArgsConstructor
Expand Down
Expand Up @@ -49,7 +49,7 @@
*/
@Entity
@Immutable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@BatchSize(size = 20)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Access(AccessType.FIELD)
Expand Down
Expand Up @@ -33,7 +33,7 @@
* @see org.zanata.rest.dto.extensions.gettext.PoHeader
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@ToString(callSuper = true)
public class HPoHeader extends PoHeaderBase {
private static final long serialVersionUID = 1L;
Expand Down
Expand Up @@ -39,7 +39,7 @@
* @see org.zanata.rest.dto.extensions.gettext.PoTargetHeader
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Setter
@ToString(callSuper = true, of = "targetLanguage")
public class HPoTargetHeader extends PoHeaderBase {
Expand Down
Expand Up @@ -47,7 +47,7 @@
* @see org.zanata.rest.dto.extensions.gettext.PotEntryHeader
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@BatchSize(size = 20)
@Setter
public class HPotEntryData implements Serializable {
Expand Down
Expand Up @@ -49,6 +49,8 @@
<class>org.zanata.model.tm.TransMemoryUnitVariant</class>
<class>org.zanata.model.tm.TransMemory</class>

<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>

<properties>
<!--
Binds the EntityManagerFactory to JNDI where Seam can look it up. This is only relevant when
Expand Down Expand Up @@ -104,7 +106,8 @@
See http://stackoverflow.com/a/8701914
-->
<property name="hibernate.cache.region.factory_class"
value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory" />
value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory" />
<property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/container/hibernate" />
<property name="hibernate.cache.region_prefix" value="" />

<!-- Default EHcache config location -->
Expand Down

0 comments on commit 1956a1d

Please sign in to comment.