You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ja...@apache.org on 2016/10/10 18:08:23 UTC
[1/2] incubator-geode git commit: GEODE-1972: Move Geode Hibernate
module to a feature branch
Repository: incubator-geode
Updated Branches:
refs/heads/release/1.0.0-incubating 82ae617c1 -> 38aa36f4e
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireEntityRegion.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireEntityRegion.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireEntityRegion.java
deleted file mode 100644
index 0f514a4..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireEntityRegion.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.access.AccessType;
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.geode.cache.Region;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.internal.cache.LocalRegion;
-import org.apache.geode.modules.hibernate.GemFireRegionFactory;
-import org.apache.geode.modules.util.ModuleStatistics;
-
-public class GemFireEntityRegion extends GemFireBaseRegion implements EntityRegion {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final boolean USE_JTA = Boolean.getBoolean("gemfiremodules.useJTA");
-
- /**
- * keys for which interest has been registered already
- */
- private ConcurrentMap<Object, Boolean> registeredKeys = new ConcurrentHashMap<Object, Boolean>();
-
- /**
- * map to store the entries that were pre-fetched when the underlying region has no local storage
- */
- protected ConcurrentMap<Object, EntityWrapper> preFetchMap = new ConcurrentHashMap<Object, EntityWrapper>();
-
- public GemFireEntityRegion(Region<Object, EntityWrapper> region,
- boolean isClient, CacheDataDescription metadata, GemFireRegionFactory regionFactory) {
- super(region, isClient, metadata, regionFactory);
- }
-
- @Override
- public boolean isTransactionAware() {
- // there are no colocation guarantees while using hibernate
- // so return false for a PartitionedRegion for now
- if (USE_JTA) {
- return true;
- }
- return false;
- }
-
- @Override
- public CacheDataDescription getCacheDataDescription() {
- return this.metadata;
- }
-
- @Override
- public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType)
- throws CacheException {
- if (AccessType.READ_ONLY.equals(accessType)) {
- log.info("creating read-only access for region: " + this.getName());
- return new ReadOnlyAccess(this);
- }
- else if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
- log.info("creating nonstrict-read-write access for region: "
- + this.getName());
- return new NonStrictReadWriteAccess(this);
- }
- else if (AccessType.READ_WRITE.equals(accessType)) {
- log.info("creating read-write access for region: "
- + this.getName());
- return new ReadWriteAccess(this);
- }
- else if (AccessType.TRANSACTIONAL.equals(accessType)) {
- log.info("creating transactional access for region: "
- + this.getName());
- return new TransactionalAccess(this);
- }
- throw new UnsupportedOperationException("Unknown access type: "
- + accessType);
- }
-
- /**
- * Should this region should register interest in keys.
- * @return true for client regions with storage
- */
- public boolean isRegisterInterestRequired() {
- return this.isClientRegion && this.region.getAttributes().getDataPolicy().withStorage();
- }
-
- /**
- * register interest in this key, if not already registered
- * @param key
- */
- public void registerInterest(Object key) {
- if (!this.registeredKeys.containsKey(key)) {
- this.region.registerInterest(key);
- this.registeredKeys.put(key, Boolean.TRUE);
- log.debug("registered interest in key{}", key);
- }
- }
-
- public void registerInterest(Collection<?> list) {
- // build a list of keys for which interest is not
- // already registered
- List<Object> interestList = new ArrayList<Object>();
- for (Object o : list) {
- if (!this.registeredKeys.containsKey(o)) {
- interestList.add(o);
- }
- }
- // register interest in this list
- this.region.registerInterest(interestList);
- log.debug("registered interest in {} keys", interestList.size());
- }
-
- /**
- * wraps the keys in {@link KeyWrapper} and calls getAll
- * on the underlying GemFire region. When the underlying region
- * is a proxy region, the fetched entries are stored in a local
- * map.
- * @param keys
- */
- public void getAll(Collection<?> keys) {
- Set<KeyWrapper> wrappedKeys = new HashSet<KeyWrapper>();
- for (Object o : keys) {
- wrappedKeys.add(new KeyWrapper(o));
- }
- if (isRegisterInterestRequired()) {
- registerInterest(wrappedKeys);
- } else {
- Map<Object, EntityWrapper> retVal = this.region.getAll(wrappedKeys);
- putInLocalMap(retVal);
- }
- }
-
- /**
- * if the underlying gemfire region does not have local storage, put
- * the pre-fetched entries in {@link #preFetchMap}
- * @param map map of prefetched entries
- */
- private void putInLocalMap(Map<Object, EntityWrapper> map) {
- if (!this.region.getAttributes().getDataPolicy().withStorage()) {
- // if the value is null, do not cache in preFetchMap
- for (Entry<Object, EntityWrapper> e : map.entrySet()) {
- if (e.getValue() != null) {
- this.preFetchMap.put(e.getKey(), e.getValue());
- log.debug("putting key: {} value: {} in local map", e.getKey(), e.getValue());
- }
- }
- }
- }
-
- /**
- * If this key was pre-fetched, get the entity.
- * @param key
- * @return the prefetched entity
- */
- public EntityWrapper get(Object key) {
- return this.preFetchMap.remove(key);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireQueryResultsRegion.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireQueryResultsRegion.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireQueryResultsRegion.java
deleted file mode 100644
index 28c9095..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireQueryResultsRegion.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.QueryResultsRegion;
-import org.hibernate.cache.Timestamper;
-import org.hibernate.cache.TimestampsRegion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.geode.cache.EntryNotFoundException;
-import org.apache.geode.cache.Region;
-
-public class GemFireQueryResultsRegion implements QueryResultsRegion, TimestampsRegion {
-
- private final Region region;
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- public GemFireQueryResultsRegion(Region region) {
- this.region = region;
- }
-
- @Override
- public Object get(Object key) throws CacheException {
- log.debug("get query results for {} ", key);
- return this.region.get(key);
- }
-
- @Override
- public void put(Object key, Object value) throws CacheException {
- log.debug("For key {} putting query results {} ", key, value);
- this.region.put(key, value);
- }
-
- @Override
- public void evict(Object key) throws CacheException {
- log.debug("removing query results for key {}", key);
- this.region.remove(key);
- }
-
- @Override
- public void evictAll() throws CacheException {
- log.debug("clearing the query cache");
- this.region.clear();
- }
-
- @Override
- public String getName() {
- return this.region.getName();
- }
-
- @Override
- public void destroy() throws CacheException {
- if (!this.region.isDestroyed()) {
- this.region.destroyRegion();
- }
- }
-
- @Override
- public boolean contains(Object key) {
- return this.region.containsKey(key);
- }
-
- @Override
- public long getSizeInMemory() {
- return -1;
- }
-
- @Override
- public long getElementCountInMemory() {
- return this.region.size();
- }
-
- @Override
- public long getElementCountOnDisk() {
- // TODO make this an overflow region
- return -1;
- }
-
- @Override
- public Map toMap() {
- return Collections.unmodifiableMap(this.region);
- }
-
- @Override
- public long nextTimestamp() {
- return Timestamper.next();
- }
-
- @Override
- public int getTimeout() {
- return 60*1000; // all other cache providers have same value
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/KeyWrapper.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/KeyWrapper.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/KeyWrapper.java
deleted file mode 100644
index dc8793f..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/KeyWrapper.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.hibernate.cache.CacheKey;
-
-import org.apache.geode.DataSerializable;
-import org.apache.geode.DataSerializer;
-
-/**
- * wraps {@link CacheKey}, and implements equals and
- * hashCode. This is required for register interest
- * operation/prefetching
- *
- */
-public class KeyWrapper implements DataSerializable {
-
- private Serializable key;
- private String entityName;
-
- private static final String separator = "#";
-
- public KeyWrapper() {
- }
-
- public KeyWrapper(Object p_key) {
- if (p_key instanceof String) {
- String stringKey = (String)p_key;
- this.key = stringKey.substring(stringKey.indexOf(separator)+1);
- this.entityName = stringKey.substring(0, stringKey.indexOf(separator));
- } else {
- CacheKey cacheKey = (CacheKey)p_key;
- this.key = cacheKey.getKey();
- this.entityName = cacheKey.getEntityOrRoleName();
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof KeyWrapper) {
- KeyWrapper other = (KeyWrapper)obj;
- if (this.key.toString().equals(other.key.toString())
- && this.entityName.equals(other.entityName)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this.key.toString().hashCode() + this.entityName.hashCode();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.entityName).append(separator).append(this.key);
- return sb.toString();
- }
-
- @Override
- public void toData(DataOutput out) throws IOException {
- DataSerializer.writeObject(this.key, out);
- out.writeUTF(this.entityName);
- }
-
- @Override
- public void fromData(DataInput in) throws IOException, ClassNotFoundException {
- this.key = DataSerializer.readObject(in);
- this.entityName = in.readUTF();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/NonStrictReadWriteAccess.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/NonStrictReadWriteAccess.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/NonStrictReadWriteAccess.java
deleted file mode 100644
index d6e9968..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/NonStrictReadWriteAccess.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.access.SoftLock;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NonStrictReadWriteAccess extends Access {
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- public NonStrictReadWriteAccess(GemFireEntityRegion region) {
- super(region);
- }
-
- @Override
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- log.debug("lock item called for key {}", key);
- return null;
- }
-
- @Override
- public boolean afterUpdate(Object key, Object value, Object currentVersion,
- Object previousVersion, SoftLock lock) throws CacheException {
- log.debug("after update called for key: {} value: {}", key, value);
- getGemFireRegion().put(getWrappedKey(key), new EntityWrapper(value, -1L));
- return true;
- }
-
- @Override
- public boolean update(Object key, Object value, Object currentVersion,
- Object previousVersion) throws CacheException {
- log.debug("updating key: {} value: {}", key, value);
- getGemFireRegion().put(getWrappedKey(key), new EntityWrapper(value, -1L));
- return true;
- }
-//
-// @Override
-// public boolean insert(Object key, Object value, Object version)
-// throws CacheException {
-// log.debug("inserting key:{} value:{}", key, value);
-// getGemFireRegion().put(key, new EntityWrapper(value, -1L));
-// return true;
-// }
-//
-// @Override
-// public boolean afterInsert(Object key, Object value, Object version)
-// throws CacheException {
-// log.debug("after insert called for key:{} value:{}", key, value);
-// getGemFireRegion().put(key, new EntityWrapper(value, -1L));
-// return true;
-// }
-//
- @Override
- public boolean putFromLoad(Object key, Object value, long txTimestamp,
- Object version) throws CacheException {
- return putFromLoad(key, value, txTimestamp, version, true);
- }
-
- @Override
- public boolean putFromLoad(Object key, Object value, long txTimestamp,
- Object version, boolean minimalPutOverride) throws CacheException {
- log.debug("putting a new entry from load key:{} value:{}", key, value);
- getGemFireRegion().put(getWrappedKey(key), new EntityWrapper(value, -1L));
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadOnlyAccess.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadOnlyAccess.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadOnlyAccess.java
deleted file mode 100644
index e99210f..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadOnlyAccess.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.access.SoftLock;
-
-public class ReadOnlyAccess extends Access {
-
- public ReadOnlyAccess(GemFireEntityRegion region) {
- super(region);
- }
-
- @Override
- public boolean insert(Object key, Object value, Object version)
- throws CacheException {
- throw new UnsupportedOperationException(
- "insert not supported on read only access");
- }
-
- @Override
- public boolean update(Object key, Object value, Object currentVersion,
- Object previousVersion) throws CacheException {
- throw new UnsupportedOperationException(
- "update not supported on read only access");
- }
-
- @Override
- public boolean afterInsert(Object key, Object value, Object version)
- throws CacheException {
- throw new UnsupportedOperationException(
- "insert not supported on read only access");
- }
-
- @Override
- public boolean afterUpdate(Object key, Object value, Object currentVersion,
- Object previousVersion, SoftLock lock) throws CacheException {
- throw new UnsupportedOperationException(
- "update not supported on read only access");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadWriteAccess.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadWriteAccess.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadWriteAccess.java
deleted file mode 100644
index 5597c97..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ReadWriteAccess.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.hibernate.cache.CacheException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReadWriteAccess extends Access {
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- public ReadWriteAccess(GemFireEntityRegion region) {
- super(region);
- }
-
- @Override
- public boolean update(Object key, Object value, Object currentVersion,
- Object previousVersion) throws CacheException {
- return super.update(key, value, currentVersion, previousVersion);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/RegionFactoryDelegate.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/RegionFactoryDelegate.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/RegionFactoryDelegate.java
deleted file mode 100644
index 1891528..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/RegionFactoryDelegate.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.apache.geode.cache.*;
-import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.modules.hibernate.GemFireCacheProvider;
-import org.apache.geode.modules.util.BootstrappingFunction;
-import org.apache.geode.modules.util.CreateRegionFunction;
-import org.apache.geode.modules.util.RegionConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-public class RegionFactoryDelegate {
-
- private static final String DEFAULT_REGION_TYPE = RegionShortcut.REPLICATE_HEAP_LRU.name();
-
- private static final String CLIENT_DEFAULT_REGION_TYPE = ClientRegionShortcut.PROXY.name();
-
- protected final Properties gemfireProperties;
- protected final Properties regionProperties;
-
- protected Logger log = LoggerFactory.getLogger(getClass());
-
- private Cache cache;
-
- public RegionFactoryDelegate(Properties gemfireProperties, Properties regionProperties) {
- this.gemfireProperties = gemfireProperties;
- this.regionProperties = regionProperties;
- }
-
- public GemFireCache startCache() {
- log.info("Creating a GemFire cache");
- checkExistingCache();
- cache = new CacheFactory(gemfireProperties).create();
- log.debug("GemFire cache creation completed");
- FunctionService.onMembers(this.cache.getDistributedSystem()).execute(new BootstrappingFunction()).getResult();
- FunctionService.registerFunction(new CreateRegionFunction(cache));
- return cache;
- }
-
- /**
- * When hibernate module is running within servlet container, we should
- * check if http module is being used and make sure that we use
- * same cache-xml and log-file properties.
- */
- protected void checkExistingCache() {
- Cache existingCache = GemFireCacheImpl.getInstance();
- if (existingCache == null) {
- return;
- }
- Properties existingProps = existingCache.getDistributedSystem().getProperties();
- String cacheXML = existingProps.getProperty(CACHE_XML_FILE);
- String logFile = existingProps.getProperty(LOG_FILE, "");
- this.gemfireProperties.setProperty(CACHE_XML_FILE, cacheXML);
- this.gemfireProperties.setProperty(LOG_FILE, logFile);
- log.info("Existing GemFire cache detected. Using same "+CACHE_XML_FILE+":"+cacheXML+
- " and "+LOG_FILE+":"+logFile+" as existing cache");
- }
-
- public Region<Object, EntityWrapper> createRegion(String regionName) {
- Region<Object, EntityWrapper> r = cache.getRegion(regionName);
- if (r != null) {
- // for the peer-to-peer case, for now we assume that
- // cache.xml will be the same for all peers
- // TODO validate regions without this assumption
- return r;
- }
- String regionType = getRegionType(regionName);
- boolean isLocalRegion = regionType.contains("LOCAL") ? true : false;
- RegionConfiguration regionConfig = new RegionConfiguration();
- regionConfig.setRegionName(regionName);
- regionConfig.setRegionAttributesId(regionType);
- regionConfig.setCacheWriterName(EntityRegionWriter.class.getCanonicalName());
- org.apache.geode.cache.RegionFactory<Object, EntityWrapper> rFactory = this.cache
- .createRegionFactory(RegionShortcut.valueOf(regionType));
- rFactory.setCacheWriter(new EntityRegionWriter());
- if (isLocalRegion) {
- rFactory.setDataPolicy(DataPolicy.REPLICATE);
- }
- r = rFactory.create(regionName);
- // create same region on peers
- if (!isLocalRegion) {
- FunctionService.onMembers(this.cache.getDistributedSystem())
- .withArgs(regionConfig).execute(CreateRegionFunction.ID).getResult();
- }
- return r;
- }
-
- /**
- * returns the type of region to create by consulting the properties specified
- * in hibernate.cfg.xml
- *
- * @see #createRegion(String)
- * @param regionName
- * @return string representation of {@link RegionShortcut}
- * @see GemFireCacheProvider
- */
- protected String getRegionType(String regionName) {
- String rType = getOverridenRegionType(regionName);
- if (rType != null) {
- return rType.toUpperCase();
- }
- rType = regionProperties
- .getProperty(DistributionConfig.GEMFIRE_PREFIX + "default-region-attributes-id");
- if (rType == null) {
- rType = DEFAULT_REGION_TYPE;
- }
- return rType.toUpperCase();
- }
-
- private String getOverridenRegionType(String regionName) {
- String rType = null;
- Iterator<Object> it = regionProperties.keySet().iterator();
- while (it.hasNext()) {
- String current = (String)it.next();
- if (current.contains(regionName)) {
- rType = regionProperties.getProperty(current);
- break;
- }
- }
- return rType;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/TransactionalAccess.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/TransactionalAccess.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/TransactionalAccess.java
deleted file mode 100644
index c8ec670..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/TransactionalAccess.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.geode.modules.hibernate.internal;
-
-public class TransactionalAccess extends Access {
-
- public TransactionalAccess(GemFireEntityRegion region) {
- super(region);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Event.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Event.java b/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Event.java
deleted file mode 100644
index 39eec22..0000000
--- a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Event.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules;
-
-import java.util.Date;
-
-public class Event {
- private Long id;
-
- private String title;
- private Date date;
- private int i;
-
- public Event() {}
-
- public Long getId() {
- return id;
- }
-
- private void setId(Long id) {
- this.id = id;
- }
-
- public Date getDate() {
- return date;
- }
-
- public Integer getVersion() {
- return i;
- }
-
- public void setVersion(int i) {
- this.i = i;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder();
- b.append("Event:id:"+id+" title:"+title+" date:"+date);
- return b.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/HibernateJUnitTest.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/HibernateJUnitTest.java b/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/HibernateJUnitTest.java
deleted file mode 100644
index a9d6c64..0000000
--- a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/HibernateJUnitTest.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules;
-
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Region.Entry;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.modules.Owner.Status;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Configuration;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.assertEquals;
-
-@Category(IntegrationTest.class)
-public class HibernateJUnitTest {
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- //private static final String jdbcURL = "jdbc:hsqldb:hsql://localhost/test";
- private static final String jdbcURL = "jdbc:hsqldb:mem:test";
-
- static File tmpDir;
-
- static String gemfireLog;
-
- @Before
- public void setUp() throws Exception {
- // Create a per-user scratch directory
- tmpDir = new File(System.getProperty("java.io.tmpdir"),
- "gemfire_modules-" + System.getProperty("user.name"));
- tmpDir.mkdirs();
- tmpDir.deleteOnExit();
-
- gemfireLog = tmpDir.getPath() +
- System.getProperty("file.separator") + "gemfire_modules.log";
- }
-
- public static SessionFactory getSessionFactory(Properties overrideProps) {
- System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "home", "GEMFIREHOME");
- Configuration cfg = new Configuration();
- cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
- cfg.setProperty("hibernate.connection.driver_class",
- "org.hsqldb.jdbcDriver");
- // cfg.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test");
- cfg.setProperty("hibernate.connection.url", jdbcURL);
- cfg.setProperty("hibernate.connection.username", "sa");
- cfg.setProperty("hibernate.connection.password", "");
- cfg.setProperty("hibernate.connection.pool_size", "1");
- cfg.setProperty("hibernate.connection.autocommit", "true");
- cfg.setProperty("hibernate.hbm2ddl.auto", "update");
-
- cfg.setProperty("hibernate.cache.region.factory_class",
- "org.apache.geode.modules.hibernate.GemFireRegionFactory");
- cfg.setProperty("hibernate.show_sql", "true");
- cfg.setProperty("hibernate.cache.use_query_cache", "true");
- //cfg.setProperty("gemfire.mcast-port", AvailablePort.getRandomAvailablePort(AvailablePort.JGROUPS)+"");
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + MCAST_PORT, "0");
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + STATISTIC_SAMPLING_ENABLED, "true");
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + LOG_FILE, gemfireLog);
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + "writable-working-dir", tmpDir.getPath());
- //cfg.setProperty("gemfire.statistic-archive-file", "plugin-stats-file.gfs");
- //cfg.setProperty("gemfire.default-client-region-attributes-id", "CACHING_PROXY");
- //cfg.setProperty("gemfire.cache-topology", "client-server");
- //cfg.setProperty("gemfire.locators", "localhost[5432]");
- //cfg.setProperty("gemfire.log-level", "fine");
- // cfg.setProperty("", "");
- cfg.addClass(Person.class);
- cfg.addClass(Event.class);
- if (overrideProps != null) {
- Iterator it = overrideProps.keySet().iterator();
- while (it.hasNext()) {
- String key = (String) it.next();
- cfg.setProperty(key, overrideProps.getProperty(key));
- }
- }
- return cfg.buildSessionFactory();
- }
-
- @Test
- public void testpreload() {
- log.info("SWAP:creating session factory In hibernateTestCase");
-
- Session session = getSessionFactory(null).openSession();
- log.info("SWAP:session opened");
- session.beginTransaction();
- Event theEvent = new Event();
- theEvent.setTitle("title");
- theEvent.setDate(new Date());
- session.save(theEvent);
- Long id = theEvent.getId();
- session.getTransaction().commit();
- session.beginTransaction();
- Event ev = (Event) session.get(Event.class, id);
- log.info("SWAP:load complete: " + ev);
- session.getTransaction().commit();
- }
-
- @Test
- public void testSomething() throws Exception {
- java.util.logging.Logger.getLogger("org.hibernate").setLevel(Level.ALL);
- log.info("SWAP:creating session factory In hibernateTestCase");
-
- Session session = getSessionFactory(null).openSession();
- log.info("SWAP:session opened");
- // session.setFlushMode(FlushMode.COMMIT);
- session.beginTransaction();
- Event theEvent = new Event();
- theEvent.setTitle("title");
- theEvent.setDate(new Date());
- //session.save(theEvent);
- session.persist(theEvent);
- Long id = theEvent.getId();
- session.getTransaction().commit();
- log.info("commit complete...doing load");
- session.beginTransaction();
- Event ev = (Event) session.load(Event.class, id);
- log.info("load complete: " + ev);
- log.trace("SWAP");
- ev.setTitle("newTitle");
- session.save(ev);
- log.info("commit");
- session.getTransaction().commit();
- log.info("save complete " + ev);
-
- session.beginTransaction();
- ev = (Event) session.load(Event.class, id);
- log.info("load complete: " + ev);
- ev.setTitle("newTitle2");
- session.save(ev);
- log.info("commit");
- session.getTransaction().commit();
- log.info("save complete " + ev);
-
- ev = (Event) session.load(Event.class, id);
- log.info("second load " + ev);
- session.flush();
- session.close();
- log.info("flush complete session:" + session);
-
- for (int i = 0; i < 5; i++) {
- session = getSessionFactory(null).openSession();
- log.info("doing get " + id);
- // ev = (Event) session.load(Event.class, id);
- ev = (Event) session.get(Event.class, id);
- log.info("third load " + ev);
- }
- printExistingDB();
- Iterator it = GemFireCacheImpl.getInstance().rootRegions().iterator();
- while (it.hasNext()) {
- Region r = (Region) it.next();
- System.out.println("Region:" + r);
- Iterator enIt = r.entrySet().iterator();
- while (enIt.hasNext()) {
- Region.Entry re = (Entry) enIt.next();
- System.out.println("key:" + re.getKey() + " value:" + re.getValue());
- }
- }
- Thread.sleep(3000);
- //System.in.read();
- // try direct data
-
- }
-
- @Ignore
- @Test
- public void testInvalidation() {
- Session s = getSessionFactory(null).openSession();
- }
-
- static Long personId;
-
- @Test
- public void testRelationship() throws Exception {
- //java.util.logging.Logger.getLogger("org.hibernate").setLevel(Level.ALL);
- Properties props = new Properties();
- props.put(DistributionConfig.GEMFIRE_PREFIX + "topology", "client-server");
- Session session = getSessionFactory(null).openSession();
- session.beginTransaction();
-
- Person thePerson = new Person();
- thePerson.setFirstname("foo");
- thePerson.setLastname("bar");
- thePerson.setAge(1);
- thePerson.setId(99L);
- session.save(thePerson);
- personId = thePerson.getId();
- log.info("person saved");
-
- Event theEvent = new Event();
- theEvent.setTitle("title");
- theEvent.setDate(new Date());
- session.save(theEvent);
- Long eventId = theEvent.getId();
- log.info("event saved");
-
- Event theEvent2 = new Event();
- theEvent2.setTitle("title2");
- theEvent2.setDate(new Date());
- session.save(theEvent2);
- Long eventId2 = theEvent2.getId();
- log.info("event2 saved");
- session.getTransaction().commit();
-
- session.beginTransaction();
- Person aPerson = (Person) session.load(Person.class, personId);
- Event anEvent = (Event) session.load(Event.class, eventId);
- Event anEvent2 = (Event) session.load(Event.class, eventId2);
- log.info("adding event to person");
- aPerson.getE().add(anEvent);
- aPerson.getE().add(anEvent2);
- log.info("calling commit");
-
- session.getTransaction().commit();
- log.info("commit complete");
- session.close();
- log.info("opening new session");
- session = getSessionFactory(null).openSession();
- log.info("SWAP:loading person");
- aPerson = (Person) session.load(Person.class, personId);
- log.info("loading events");
- Iterator<Event> e = aPerson.getE().iterator();
- while (e.hasNext()) {
- e.next();
- }
- session.close();
- log.info("opening new session");
- session = getSessionFactory(null).openSession();
- log.info("SWAP:loading person");
- aPerson = (Person) session.load(Person.class, personId);
- log.info("loading events");
- e = aPerson.getE().iterator();
- while (e.hasNext()) {
- e.next();
- }
-
- log.info(aPerson.getE() + "");
- session.close();
- //System.in.read();
- // log.info("opening third session");
- // session = getSessionFactory().openSession();
- // log.info("loading person");
- // aPerson = (Person)session.load(Person.class, personId);
- // log.info("loading events");
- // log.info(aPerson.getEvents()+"");
- }
-
- @Ignore
- @Test
- public void testQueryCache() throws Exception {
- Session session = getSessionFactory(null).openSession();
- Query q = session.createQuery("from Event");
- q.setCacheable(true);
- List l = q.list();
- log.info("list:" + l);
- // log.info("Sleeping for 10 seconds");
- // Thread.sleep(10000);
- l = q.list();
- log.info("list2:" + l);
- log.info("updating an event");
- session.beginTransaction();
- Event e = (Event) l.get(0);
- e.setDate(new Date());
- session.saveOrUpdate(e);
- session.getTransaction().commit();
- l = q.list();
- log.info("list3:" + l);
- }
-
- @Test
- public void testInsert() {
- Session session = getSessionFactory(null).openSession();
- Region r = GemFireCacheImpl.getExisting().getRegion(Person.class.getCanonicalName());
- int initSize = r.size();
- session.beginTransaction();
- log.info("SWAP: Saving Person");
- Person p = new Person();
- p.setId(10L);
- p.setFirstname("foo");
- p.setLastname("bar");
- session.saveOrUpdate("Person", p);
- session.getTransaction().commit();
- assertEquals(1, session.getStatistics().getEntityCount());
- assertEquals(initSize + 1, r.size());
-
- session.beginTransaction();
- p.setAge(1);
- session.saveOrUpdate(p);
- session.getTransaction().commit();
- assertEquals(1, session.getStatistics().getEntityCount());
- }
-
- @Test
- public void testNormalRegion() {
- Properties props = new Properties();
- props.setProperty(DistributionConfig.GEMFIRE_PREFIX + "default-region-attributes-id", "LOCAL");
- Session session = getSessionFactory(props).openSession();
- session.beginTransaction();
- Event theEvent = new Event();
- theEvent.setTitle("title");
- theEvent.setDate(new Date());
- session.save(theEvent);
- Long id = theEvent.getId();
- session.getTransaction().commit();
- session.beginTransaction();
- Event ev = (Event) session.load(Event.class, id);
- ev.setTitle("newTitle");
- session.save(ev);
- session.getTransaction().commit();
- }
-
- private void printExistingDB() throws SQLException {
- try {
- Class.forName("org.hsqldb.jdbc.JDBCDriver");
- } catch (Exception e) {
- System.err.println("ERROR: failed to load HSQLDB JDBC driver.");
- e.printStackTrace();
- return;
- }
-
- Connection c = DriverManager.getConnection(jdbcURL, "SA", "");
- log.info("issuing query...");
- ResultSet rs = c.createStatement().executeQuery("select * from events");
- int col = rs.getMetaData().getColumnCount();
- while (rs.next()) {
- StringBuilder b = new StringBuilder();
- for (int i = 1; i <= col; i++) {
- b.append(" col:" + i + ":" + rs.getString(i));
- }
- log.info("Query result:" + b.toString());
- }
- }
-
- @Test
- public void testEnum() {
- AnnotationConfiguration cfg = new AnnotationConfiguration();
- cfg.addAnnotatedClass(Owner.class);
- cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
- cfg.setProperty("hibernate.connection.driver_class",
- "org.hsqldb.jdbcDriver");
- cfg.setProperty("hibernate.connection.url", jdbcURL);
- cfg.setProperty("hibernate.connection.username", "sa");
- cfg.setProperty("hibernate.connection.password", "");
- cfg.setProperty("hibernate.connection.pool_size", "1");
- cfg.setProperty("hibernate.connection.autocommit", "true");
- cfg.setProperty("hibernate.hbm2ddl.auto", "update");
-
- cfg.setProperty("hibernate.cache.region.factory_class",
- "org.apache.geode.modules.hibernate.GemFireRegionFactory");
- cfg.setProperty("hibernate.show_sql", "true");
- cfg.setProperty("hibernate.cache.use_query_cache", "true");
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + STATISTIC_SAMPLING_ENABLED, "true");
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + LOG_FILE, gemfireLog);
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + "writable-working-dir", tmpDir.getPath());
- cfg.setProperty(DistributionConfig.GEMFIRE_PREFIX + MCAST_PORT, "0");
- //cfg.setProperty("gemfire.cache-topology", "client-server");
-
- SessionFactory sf = cfg.buildSessionFactory();
- Session session = sf.openSession();
- session.beginTransaction();
- Owner o = new Owner();
- o.setAddress("addr");
- o.setCity("pdx");
- o.setStatus(Status.PREMIUM);
- session.save(o);
- long id = o.getId();
- log.info("testEnum:commiting tx");
- session.getTransaction().commit();
- session.close();
-
- session = sf.openSession();
- Owner o1 = (Owner) session.load(Owner.class, id);
- log.info("loaded:" + o);
- assertEquals(o.getAddress(), o1.getAddress());
- assertEquals(o.getCity(), o1.getCity());
- assertEquals(o.getStatus(), o1.getStatus());
- o1.setAddress("address2");
- session.save(o1);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Owner.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Owner.java b/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Owner.java
deleted file mode 100644
index 772f131..0000000
--- a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Owner.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
-* Copyright 2002-2013 the original author or authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.Column;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-import org.hibernate.annotations.Entity;
-
-
-/**
- * Simple JavaBean domain object representing an owner.
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- * @author Sam Brannen
- */
-@javax.persistence.Entity
-@Entity
-public class Owner {
- private static final long serialVersionUID = 4315791692556052565L;
-
- @Column(name="address")
- private String address;
-
- private String city;
-
- private String telephone;
-
-// private Set<Pet> pets;
- @Id
- @GeneratedValue
- private Long id;
-
- private long versionNum = -1;
-
- public enum Status {
- NORMAL, PREMIUM
- };
-
- @Enumerated
- private Status status = Status.NORMAL;
-
- private void setId(Long id) {
- this.id = id;
- }
-
- public Long getId() {
- return id;
- }
-
- public String getAddress() {
- return this.address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public String getCity() {
- return this.city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getTelephone() {
- return this.telephone;
- }
-
- public void setTelephone(String telephone) {
- this.telephone = telephone;
- }
-
- public long getVersionNum() {
- return versionNum;
- }
-
- public void setVersionNum(long versionNum) {
- this.versionNum = versionNum;
- }
-
- public Status getStatus() {
- return this.status;
- }
-
- public void setStatus(Status state) {
- if (state != null) {
- this.status = state;
- }
- }
-
-// protected void setPetsInternal(Set<Pet> pets) {
-// this.pets = pets;
-// }
-//
-// protected Set<Pet> getPetsInternal() {
-// if (this.pets == null) {
-// this.pets = new HashSet<Pet>();
-// }
-// return this.pets;
-// }
-//
-// public List<Pet> getPets() {
-// List<Pet> sortedPets = new ArrayList<Pet>(getPetsInternal());
-// PropertyComparator.sort(sortedPets, new MutableSortDefinition("name",
-// true, true));
-// return Collections.unmodifiableList(sortedPets);
-// }
-//
-// public void addPet(Pet pet) {
-// getPetsInternal().add(pet);
-// pet.setOwner(this);
-// }
-//
-// /**
-// * Return the Pet with the given name, or null if none found for this Owner.
-// *
-// * @param name
-// * to test
-// * @return true if pet name is already in use
-// */
-// public Pet getPet(String name) {
-// return getPet(name, false);
-// }
-//
-// /**
-// * Return the Pet with the given name, or null if none found for this Owner.
-// *
-// * @param name
-// * to test
-// * @return true if pet name is already in use
-// */
-// public Pet getPet(String name, boolean ignoreNew) {
-// name = name.toLowerCase();
-// for (Pet pet : getPetsInternal()) {
-// if (!ignoreNew || !pet.isNew()) {
-// String compName = pet.getName();
-// compName = compName.toLowerCase();
-// if (compName.equals(name)) {
-// return pet;
-// }
-// }
-// }
-// return null;
-// }
-//
-// @Override
-// public String toString() {
-// return new ToStringCreator(this).append("id", this.getId())
-// .append("new", this.isNew())
-// .append("lastName", this.getLastName())
-// .append("firstName", this.getFirstName())
-// .append("address", this.address).append("city", this.city)
-// .append("telephone", this.telephone)
-// .append("version", this.versionNum)
-// .append("status", this.status)
-//
-// .toString();
-// }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Person.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Person.java b/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Person.java
deleted file mode 100644
index c98bb81..0000000
--- a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/Person.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class Person {
- private Long id;
- private int age;
- private String firstname;
- private String lastname;
-
- private Set<Event> e = new HashSet<Event>();
-
- public Person() {}
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
-
- public String getFirstname() {
- return firstname;
- }
-
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
-
- public String getLastname() {
- return lastname;
- }
-
- public void setE(Set<Event> events) {
- this.e = events;
- }
-
- public Set<Event> getE() {
- return e;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/SecondVMTest.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/SecondVMTest.java b/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/SecondVMTest.java
deleted file mode 100644
index cdc8e07..0000000
--- a/extensions/geode-modules-hibernate/src/test/java/org/apache/geode/modules/SecondVMTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import org.hibernate.Session;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.GemFireCache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Region.Entry;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-
-@Category(IntegrationTest.class)
-@Ignore("Can this test be deleted?")
-public class SecondVMTest {
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- @Ignore
- @Test
- public void testStartEmptyVM() throws IOException {
- Properties gemfireProperties = new Properties();
- gemfireProperties.setProperty(MCAST_PORT, "5555");
- gemfireProperties.setProperty(LOG_LEVEL, "fine");
- Cache cache = new CacheFactory(gemfireProperties).create();
- System.in.read();
- Iterator it = cache.rootRegions().iterator();
- while (it.hasNext()) {
- Region r = (Region)it.next();
- System.out.println("Region:"+r);
- Iterator enIt = r.entrySet().iterator();
- while (enIt.hasNext()) {
- Region.Entry re = (Entry)enIt.next();
- System.out.println("key:"+re.getKey()+" value:"+re.getValue());
- }
- }
- }
-
- @Ignore
- @Test
- public void testStartVM() throws Exception {
- java.util.logging.Logger.getLogger("org.hibernate").setLevel(Level.ALL);
- Session session = HibernateJUnitTest.getSessionFactory(null).openSession();
- log.info("SWAP:new session open");
- long id = 1;
- log.info("loading new person:"+(id));
- GemFireCache cache = GemFireCacheImpl.getInstance();
- Iterator<Region<?, ?>> rSet = cache.rootRegions().iterator();
- while (rSet.hasNext()) {
- Region<?, ?> r = rSet.next();
- log.info("SWAP:Region "+r);
- Iterator<?> keySet = r.keySet().iterator();
- while (keySet.hasNext()) {
- log.info("key:"+keySet.next());
- }
- }
- log.info("loading new person:"+(id));
- session.beginTransaction();
- Person p = (Person)session.load(Person.class, id);
- p.setFirstname("SecondVMfirstname"+id);
- log.info("loading events");
- log.info(p.getE()+"");
- session.getTransaction().commit();
- //System.in.read();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/resources/log4j.properties b/extensions/geode-modules-hibernate/src/test/resources/log4j.properties
deleted file mode 100644
index c136990..0000000
--- a/extensions/geode-modules-hibernate/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
-# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
-#log4j.rootLogger=DEBUG, stdout, logfile
-log4j.rootLogger=DEBUG, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
-
-#log4j.appender.logfile=org.apache.log4j.RollingFileAppender
-#log4j.appender.logfile.MaxFileSize=512KB
-## Keep three backup files.
-#log4j.appender.logfile.MaxBackupIndex=3
-## Pattern to output: date priority [category] - message
-#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
-#log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Event.hbm.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Event.hbm.xml b/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Event.hbm.xml
deleted file mode 100644
index 2473641..0000000
--- a/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Event.hbm.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.apache.geode.modules">
- <class name="Event" table="EVENTS">
- <cache usage="read-write"/>
- <id name="id" column="EVENT_ID">
- <generator class="native"/>
- </id>
- <version name="version"/>
- <property name="date" type="timestamp" column="EVENT_DATE"/>
- <property name="title"/>
- </class>
-</hibernate-mapping>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Person.hbm.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Person.hbm.xml b/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Person.hbm.xml
deleted file mode 100644
index 2105b1d..0000000
--- a/extensions/geode-modules-hibernate/src/test/resources/org/apache/geode/modules/Person.hbm.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.apache.geode.modules">
- <class name="Person" table="PERSON">
- <cache usage="read-write"/>
- <id name="id" column="PERSON_ID">
- </id>
- <property name="age"/>
- <property name="firstname"/>
- <property name="lastname"/>
- <set name="e" table="PERSON_EVENT">
- <cache usage="read-write"/>
- <key column="PERSON_ID"/>
- <many-to-many column="EVENT_ID" class="Event"/>
- </set>
- </class>
-</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/gradle/sonar.gradle
----------------------------------------------------------------------
diff --git a/gradle/sonar.gradle b/gradle/sonar.gradle
index 33140d3..45bb772 100644
--- a/gradle/sonar.gradle
+++ b/gradle/sonar.gradle
@@ -42,12 +42,6 @@ project("extensions/geode-modules-assembly") {
}
}
-project("extensions/geode-modules-hibernate") {
- sonarqube {
- skipProject = true
- }
-}
-
project("extensions/geode-modules-session") {
sonarqube {
skipProject = true
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index 0b7002b..5aaa17a 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -32,7 +32,6 @@ include 'geode-cq'
include 'extensions/geode-modules'
include 'extensions/geode-modules-tomcat7'
include 'extensions/geode-modules-tomcat8'
-include 'extensions/geode-modules-hibernate'
include 'extensions/geode-modules-session-internal'
include 'extensions/geode-modules-session'
include 'extensions/geode-modules-assembly'
[2/2] incubator-geode git commit: GEODE-1972: Move Geode Hibernate
module to a feature branch
Posted by ja...@apache.org.
GEODE-1972: Move Geode Hibernate module to a feature branch
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/38aa36f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/38aa36f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/38aa36f4
Branch: refs/heads/release/1.0.0-incubating
Commit: 38aa36f4eb4df61333e17dab4abf9952baf2000b
Parents: 82ae617
Author: Jason Huynh <hu...@gmail.com>
Authored: Mon Oct 10 10:37:34 2016 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Mon Oct 10 10:37:34 2016 -0700
----------------------------------------------------------------------
extensions/geode-modules-assembly/build.gradle | 12 +-
extensions/geode-modules-hibernate/build.gradle | 42 --
.../geode/modules/hibernate/EnumType.java | 57 ---
.../geode/modules/hibernate/GemFireCache.java | 238 -----------
.../modules/hibernate/GemFireCacheListener.java | 54 ---
.../modules/hibernate/GemFireCacheProvider.java | 200 ---------
.../hibernate/GemFireQueryCacheFactory.java | 39 --
.../modules/hibernate/GemFireRegionFactory.java | 221 ----------
.../modules/hibernate/internal/Access.java | 257 ------------
.../ClientServerRegionFactoryDelegate.java | 201 ---------
.../hibernate/internal/CollectionAccess.java | 224 ----------
.../hibernate/internal/EntityRegionWriter.java | 87 ----
.../hibernate/internal/EntityVersion.java | 27 --
.../hibernate/internal/EntityVersionImpl.java | 50 ---
.../hibernate/internal/EntityWrapper.java | 89 ----
.../hibernate/internal/GemFireBaseRegion.java | 166 --------
.../internal/GemFireCollectionRegion.java | 59 ---
.../hibernate/internal/GemFireEntityRegion.java | 187 ---------
.../internal/GemFireQueryResultsRegion.java | 113 -----
.../modules/hibernate/internal/KeyWrapper.java | 92 ----
.../internal/NonStrictReadWriteAccess.java | 83 ----
.../hibernate/internal/ReadOnlyAccess.java | 55 ---
.../hibernate/internal/ReadWriteAccess.java | 36 --
.../internal/RegionFactoryDelegate.java | 146 -------
.../hibernate/internal/TransactionalAccess.java | 25 --
.../java/org/apache/geode/modules/Event.java | 67 ---
.../geode/modules/HibernateJUnitTest.java | 416 -------------------
.../java/org/apache/geode/modules/Owner.java | 185 ---------
.../java/org/apache/geode/modules/Person.java | 72 ----
.../org/apache/geode/modules/SecondVMTest.java | 95 -----
.../src/test/resources/log4j.properties | 16 -
.../org/apache/geode/modules/Event.hbm.xml | 32 --
.../org/apache/geode/modules/Person.hbm.xml | 36 --
gradle/sonar.gradle | 6 -
settings.gradle | 1 -
35 files changed, 1 insertion(+), 3685 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/build.gradle b/extensions/geode-modules-assembly/build.gradle
index f037aad..5604e12 100644
--- a/extensions/geode-modules-assembly/build.gradle
+++ b/extensions/geode-modules-assembly/build.gradle
@@ -154,15 +154,6 @@ task distTomcat(type: Zip, dependsOn: ':extensions/geode-modules:assemble') {
}
}
-task distHibernate(type: Zip, dependsOn: ':extensions/geode-modules-hibernate:assemble') {
- archiveName = "Apache_Geode_Modules-${version}-Hibernate.zip"
-
- into('lib') {
- from getJarArtifact(':extensions/geode-modules')
- from getJarArtifact(':extensions/geode-modules-hibernate')
- }
-}
-
task distAppServer(type: Zip, dependsOn: ':extensions/geode-modules-session:assemble') {
archiveName = "Apache_Geode_Modules-${version}-AppServer.zip"
@@ -204,11 +195,10 @@ task distTcServer30(type: Zip, dependsOn: [':extensions/geode-modules:assemble',
dependencies {
moduleDistOutputs distTcServer.outputs.files
moduleDistOutputs distTcServer30.outputs.files
- moduleDistOutputs distHibernate.outputs.files
moduleDistOutputs distAppServer.outputs.files
moduleDistOutputs distTomcat.outputs.files
}
-task dist(type: Task, dependsOn: ['distTcServer', 'distTcServer30', 'distTomcat', 'distHibernate', 'distAppServer'])
+task dist(type: Task, dependsOn: ['distTcServer', 'distTcServer30', 'distTomcat', 'distAppServer'])
build.dependsOn dist
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/build.gradle b/extensions/geode-modules-hibernate/build.gradle
deleted file mode 100644
index 5169b04..0000000
--- a/extensions/geode-modules-hibernate/build.gradle
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-dependencies {
- compile project(':extensions/geode-modules')
- compile ('org.hibernate:hibernate-annotations:' + project.'hibernate.version') {
- //TODO - do we want these extensions, especially since the show up in testruntime?
- //If they were needed by our tests, doesn't that mean they will be needed in production?
- exclude module: 'commons-collections'
- exclude module: 'dom4j'
- exclude module: 'hibernate-commons-annotations'
- exclude module: 'hibernate-jpa-2.0-api'
- exclude module: 'jta'
- }
- compile 'org.eclipse.persistence:javax.persistence:' + project.'javax.persistence-api.version'
-
- runtime ('dom4j:dom4j:' + project.'dom4j.version') {
- exclude module: 'xml-apis'
- }
-
- testRuntime 'commons-collections:commons-collections:' + project.'commons-collections.version'
- testRuntime 'org.hibernate:hibernate-commons-annotations:' + project.'hibernate-commons-annotations.version'
- testRuntime 'org.slf4j:slf4j-jdk14:' + project.'slf4j-api.version'
- testRuntime 'org.hsqldb:hsqldb:' + project.'hsqldb.version'
- testRuntime 'org.javassist:javassist:' + project.'javassist.version'
-
- testCompile project(path: ':geode-junit')
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/EnumType.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/EnumType.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/EnumType.java
deleted file mode 100644
index 0a8218e..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/EnumType.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate;
-
-import java.io.Serializable;
-
-import org.hibernate.HibernateException;
-
-/**
- * Extends {@link org.hibernate.type.EnumType} so as to
- * override methods responsible for cached representation
- * of enums in hibernate.
- * This class must be used in place of {@link org.hibernate.type.EnumType}
- * in client-server topology when the application classes are
- * not available on the server.
- * e.g. a typical enum configuration should look like this:
- * <pre>
- * <property name="myEnum">
- * <type name="<b>org.apache.geode.modules.hibernate.EnumType</b>">
- * <param name="enumClass">com.mycompany.MyEntity$MyEnum</param>
- * <param name="type">12</param>
- * </type>
- * </property>
- * </pre>
- */
-public class EnumType extends org.hibernate.type.EnumType {
-
- private static final long serialVersionUID = 3414902482639744676L;
-
- @Override
- public Object assemble(Serializable cached, Object owner)
- throws HibernateException {
- String name = (String) cached;
- Class<? extends Enum> clazz = returnedClass();
- return Enum.valueOf(clazz, name);
- }
-
- @Override
- public Serializable disassemble(Object value) throws HibernateException {
- return ((Enum)value).name();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCache.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCache.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCache.java
deleted file mode 100644
index 134bbf6..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCache.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate;
-
-import java.util.Map;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.Timestamper;
-
-import org.apache.geode.cache.EntryNotFoundException;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.distributed.DistributedLockService;
-import org.apache.geode.internal.cache.LocalRegion;
-
-public class GemFireCache implements Cache {
- private Region region;
-
- private boolean clientRegion = false;
-
- private final DistributedLockService distributedLockService;
-
- public GemFireCache(Region region, DistributedLockService lockService) {
- this.region = region;
- this.distributedLockService = lockService;
- this.clientRegion = isClient(region);
- }
-
- private boolean isClient(Region region) {
- return region.getAttributes().getPoolName() != null;
- }
-
- /**
- * Clear the cache
- */
- public void clear() throws CacheException {
- GemFireCacheProvider.getLogger().info("GemFireCache: clear called");
- region.clear();
- }
-
- /**
- * Clean up
- */
- public void destroy() throws CacheException {
- GemFireCacheProvider.getLogger().info("GemFireCache: destroy called");
- region.localDestroyRegion();
- }
-
- /**
- * Get an item from the cache
- *
- * @param key
- * @return the cached object or <tt>null</tt>
- * @throws CacheException
- */
- public Object get(Object key) throws CacheException {
- GemFireCacheProvider.getLogger().debug(
- "GemFireCache: get called for: " + key);
- try {
- Object value = region.get(key);
- GemFireCacheProvider.getLogger().debug(
- "GemFireCache: retrieved: " + key + "-->" + value);
- return value;
- }
- catch (org.apache.geode.cache.CacheException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * The count of entries currently contained in the regions in-memory store.
- *
- * @return The count of entries in memory; -1 if unknown or unsupported.
- */
- public long getElementCountInMemory() {
- return ((LocalRegion)region).entryCount();
- }
-
- /**
- * The count of entries currently contained in the regions disk store.
- *
- * @return The count of entries on disk; -1 if unknown or unsupported.
- */
- public long getElementCountOnDisk() {
- return -1;
- }
-
- /**
- * Get the name of the cache region
- */
- public String getRegionName() {
- return region.getName();
- }
-
- /**
- * The number of bytes is this cache region currently consuming in memory.
- *
- * @return The number of bytes consumed by this region; -1 if unknown or
- * unsupported.
- */
- public long getSizeInMemory() {
- return -1;
- }
-
- /**
- * Return the lock timeout for this cache.
- */
- public int getTimeout() {
- GemFireCacheProvider.getLogger().debug("GemFireCache: getTimeout");
- return Timestamper.ONE_MS * 60000;
- }
-
- /**
- * If this is a clustered cache, lock the item
- */
- public void lock(Object key) throws CacheException {
- GemFireCacheProvider.getLogger().info(
- "GemFireCache: lock called for: " + key);
-
- if (!clientRegion) {
- // If we're using GLOBAL scope, we don't have to worry about
- // locking.
- if (!Scope.GLOBAL.equals(region.getAttributes().getScope())) {
- this.distributedLockService.lock(key, -1, -1);
- }
- }
- else {
- // We assume the server region is GLOBAL for now. Else, use command
- // pattern to acquire lock on the server
- GemFireCacheProvider.getLogger().info(
- "GemFireCache: client region, ignoring lock : " + key);
- }
- }
-
- /**
- * Generate the next timestamp
- */
- public long nextTimestamp() {
- GemFireCacheProvider.getLogger().debug("GemFireCache: nextTimestamp called");
- // TODO : Need a counter, cache-wide
- return Timestamper.next();
- }
-
- /**
- * Add an item to the cache
- *
- * @param key
- * @param value
- * @throws CacheException
- */
- public void put(Object key, Object value) throws CacheException {
- GemFireCacheProvider.getLogger().debug(
- "GemFireCache: put called for key: " + key + "value: " + value);
- try {
- region.put(key, value);
- GemFireCacheProvider.getLogger().debug(
- "GemFireCache: put " + key + "-->" + value);
- }
- catch (org.apache.geode.cache.CacheException e) {
- throw new CacheException(e);
- }
- }
-
- public Object read(Object key) throws CacheException {
- GemFireCacheProvider.getLogger().info(
- "GemFireCache: read called for: " + key);
- return region.get(key);
- }
-
- /**
- * Remove an item from the cache
- */
- public void remove(Object key) throws CacheException {
- GemFireCacheProvider.getLogger().debug(
- "GemFireCache: remove called for: " + key);
- try {
- region.destroy(key);
- GemFireCacheProvider.getLogger().debug("GemFireCache: removed: " + key);
- }
- catch (EntryNotFoundException e) {
- // We can silently ignore this
- }
- catch (org.apache.geode.cache.CacheException e) {
- throw new CacheException(e);
- }
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Hibernate cache on GemFire region: ");
- buffer.append(region);
- return buffer.toString();
- }
-
- /**
- * If this is a clustered cache, unlock the item
- */
- public void unlock(Object key) throws CacheException {
- GemFireCacheProvider.getLogger().info(
- "GemFireCache: unlock called for: " + key);
-
- if (!clientRegion) {
- // If we're using GLOBAL scope, we don't have to worry about locking.
- if (!Scope.GLOBAL.equals(region.getAttributes().getScope())) {
- this.distributedLockService.unlock(key);
- }
- }
- else {
- GemFireCacheProvider.getLogger().info(
- "GemFireCache: client region, ignoring lock : " + key);
- }
- }
-
- public void update(Object key, Object value) throws CacheException {
- GemFireCacheProvider.getLogger().info(
- "GemFireCache: update called for: " + key);
- this.region.put(key, value);
- }
-
- public Map<?, ?> toMap() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheListener.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheListener.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheListener.java
deleted file mode 100644
index 0738f36..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate;
-
-import java.util.Properties;
-
-import org.apache.geode.cache.Declarable;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.util.CacheListenerAdapter;
-
-public class GemFireCacheListener extends CacheListenerAdapter implements
- Declarable {
-
- @Override
- public void afterCreate(EntryEvent event) {
- System.out.println("Create : " + event.getKey() + " / "
- + event.getNewValue());
- }
-
- @Override
- public void afterDestroy(EntryEvent event) {
- System.out.println("Destroy : " + event.getKey());
- }
-
- @Override
- public void afterInvalidate(EntryEvent event) {
- System.out.println("Invalidate : " + event.getKey());
- }
-
- @Override
- public void afterUpdate(EntryEvent event) {
- System.out.println("Update : " + event.getKey() + " / "
- + event.getNewValue());
- }
-
- public void init(Properties props) {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheProvider.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheProvider.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheProvider.java
deleted file mode 100644
index 2ccb5c0..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireCacheProvider.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate;
-
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.distributed.DistributedLockService;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.modules.util.CreateRegionFunction;
-import org.apache.geode.modules.util.RegionConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheProvider;
-import org.hibernate.cache.Timestamper;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-@SuppressWarnings("deprecation")
-public class GemFireCacheProvider implements CacheProvider {
-
- private static final Logger logger = LogService.getLogger();
-
- protected org.apache.geode.cache.Cache _cache;
-
- private DistributedLockService distributedLockService;
-
- private Properties regionAttributes = new Properties();
-
- private final String DEFAULT_REGION_TYPE = RegionShortcut.REPLICATE_HEAP_LRU
- .name();
-
- private final String HIBERNATE_DLOCK_SERVICE_NAME = "hibernate-cache-lock-service";
- /**
- * Configure the cache
- *
- * @param regionName
- * the name of the cache region
- * @param properties
- * configuration settings
- * @throws CacheException
- */
- public Cache buildCache(String regionName, Properties properties)
- throws CacheException {
- logger.info("GemFireCacheProvider: Creating cache: " + regionName);
- Region region = retrieveOrCreateRegion(regionName);
- Cache cache = null;
- if (region == null) {
- // Doh, blow up
- throw new RuntimeException("Couldn't find cache region : " + regionName);
- }
- else {
- cache = new GemFireCache(region, this.distributedLockService);
- }
- logger.info("GemFireCacheProvider: Created cache: " + regionName + "->" + cache);
- return cache;
- }
-
- public boolean isMinimalPutsEnabledByDefault() {
- return false;
- }
-
- /**
- * Generate a timestamp
- */
- public long nextTimestamp() {
- return Timestamper.next();
- }
-
- /**
- * Returns the region if already created, otherwise first tries to create it
- * from cache.xml, if not specified in cache.xml, create the region from the
- * properties specified in hibernate.cfg.xml. Two types of properties can be
- * specified in hibernate.cfg.xml
- * <ol>
- * <li>gemfire.default-region-attributes-id: the default region type to
- * create. (default value for this is REPLICATE)
- * <li>gemfire.region-attributes-for:fullyQualifiedRegionName when a region
- * wants to override the default region type
- * </ol>
- *
- * @param regionName
- * @return the region
- */
- protected Region retrieveOrCreateRegion(String regionName) {
- // TODO client regions
- Region r = _cache.getRegion(regionName);
- if (r == null) {
- String regionType = getRegionType(regionName);
- r = _cache.createRegionFactory(RegionShortcut.valueOf(regionType))
- .create(regionName);
- RegionConfiguration regionConfig = new RegionConfiguration();
- regionConfig.setRegionName(regionName);
- regionConfig.setRegionAttributesId(regionType);
- FunctionService.onMembers(_cache.getDistributedSystem())
- .withArgs(regionConfig).execute(CreateRegionFunction.ID).getResult();
- }
- return r;
- }
-
- /**
- * returns the type of region to create by consulting the properties specified
- * in hibernate.cfg.xml
- *
- * @see #retrieveOrCreateRegion(String)
- * @param regionName
- * @return string representation of {@link RegionShortcut}
- */
- private String getRegionType(String regionName) {
- String rType = regionAttributes
- .getProperty(DistributionConfig.GEMFIRE_PREFIX + "default-region-attributes-id");
- if (rType == null) {
- rType = DEFAULT_REGION_TYPE;
- }
- // iterate to find overridden property for a region
- Iterator<Object> it = regionAttributes.keySet().iterator();
- while (it.hasNext()) {
- String current = (String)it.next();
- if (current.contains(regionName)) {
- rType = regionAttributes.getProperty(current);
- break;
- }
- }
- return rType.toUpperCase();
- }
-
- /**
- * Callback to perform any necessary initialization of the underlying cache
- * implementation during SessionFactory construction.
- *
- * @param properties
- * current configuration settings.
- */
- public void start(Properties properties) throws CacheException {
- logger.info("GemFireCacheProvider: Creating cache provider");
-
- // We have to strip out any unknown properties, do so here
- Properties gemfireOnlyProperties = new Properties();
- for (Object keyObj : properties.keySet()) {
- String key = (String)keyObj;
- if (key.contains("region-attributes")) {
- regionAttributes.put(key, properties.get(key));
- } else if (key.startsWith(DistributionConfig.GEMFIRE_PREFIX)) {
- gemfireOnlyProperties.setProperty(key.replace(DistributionConfig.GEMFIRE_PREFIX, ""),
- properties.getProperty(key));
- }
- }
-
- // Create cache and d-lock service
- try {
- _cache = new CacheFactory(gemfireOnlyProperties).create();
- DistributedLockService existing = DistributedLockService.getServiceNamed(HIBERNATE_DLOCK_SERVICE_NAME);
- if (existing == null) {
- this.distributedLockService = DistributedLockService.create(
- HIBERNATE_DLOCK_SERVICE_NAME, _cache.getDistributedSystem());
- } else {
- this.distributedLockService = existing;
- }
- }
- catch (org.apache.geode.cache.CacheException e) {
- throw new CacheException(e);
- }
-
- FunctionService.registerFunction(new CreateRegionFunction());
-
- logger.info("GemFireCacheProvider: Done creating cache provider");
- }
-
- /**
- * Callback to perform any necessary cleanup of the underlying cache
- * implementation during SessionFactory.close().
- */
- public void stop() {
- logger.info("GemFireCacheProvider: Stopping");
- _cache.close();
- logger.info("GemFireCacheProvider: Stopped");
- }
-
- public static Logger getLogger() {
- return logger;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireQueryCacheFactory.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireQueryCacheFactory.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireQueryCacheFactory.java
deleted file mode 100644
index fba1d9f..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireQueryCacheFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate;
-
-import java.util.Properties;
-
-import org.hibernate.HibernateException;
-import org.hibernate.cache.QueryCache;
-import org.hibernate.cache.QueryCacheFactory;
-import org.hibernate.cache.UpdateTimestampsCache;
-import org.hibernate.cfg.Settings;
-
-/**
- * Defines a factory for query cache instances. These factories are responsible
- * for creating individual QueryCache instances.
- *
- */
-public class GemFireQueryCacheFactory implements QueryCacheFactory {
- public QueryCache getQueryCache(String regionName,
- UpdateTimestampsCache updateTimestampsCache, Settings settings,
- Properties props) throws HibernateException {
- return new org.hibernate.cache.StandardQueryCache(settings, props,
- updateTimestampsCache, regionName);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireRegionFactory.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireRegionFactory.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireRegionFactory.java
deleted file mode 100644
index 088d0b1..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/GemFireRegionFactory.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.GemFireCache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.client.ClientCache;
-import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
-import org.apache.geode.modules.hibernate.internal.*;
-import org.apache.geode.modules.util.Banner;
-import org.hibernate.cache.*;
-import org.hibernate.cache.access.AccessType;
-import org.hibernate.cfg.Settings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class GemFireRegionFactory implements RegionFactory {
-
- private static final String GEMFIRE_QUERY_RESULTS_REGION_NAME = DistributionConfig.GEMFIRE_PREFIX + "hibernateQueryResults";
-
- private static final String GEMFIRE_TIMESTAMPS_REGION_NAME = DistributionConfig.GEMFIRE_PREFIX + "hibernateTimestamps";
-
- private GemFireCache _cache;
-
- private RegionFactoryDelegate delegate;
-
- // TODO get rid of this
- private boolean isClient;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final ExecutorService executorService = Executors.newSingleThreadExecutor();
-
- private Set<String> gemfireAttributes;
-
- /**
- * maps the entity to the region that stores it.
- */
- private ConcurrentMap<String, GemFireEntityRegion> entityRegionMap = new ConcurrentHashMap<String, GemFireEntityRegion>();
-
- public GemFireRegionFactory(Properties props) {
- log.debug("props:" + props);
- }
-
- public ExecutorService getExecutorService() {
- return this.executorService;
- }
-
- @Override
- public void start(Settings settings, Properties properties)
- throws CacheException {
- log.info("Initializing " + Banner.getString());
- extractGemFireProperties(properties);
- _cache = delegate.startCache();
- }
-
- private void extractGemFireProperties(Properties properties) {
- // We have to strip out any unknown properties, do so here
- Properties gemfireProperties = new Properties();
- Properties regionProperties = new Properties();
- for (Object keyObj : properties.keySet()) {
- String key = (String)keyObj;
- if (key.contains("region-attributes")) {
- regionProperties.put(key, properties.get(key));
- } else if (key.equals(DistributionConfig.GEMFIRE_PREFIX + "cache-topology")) {
- if (properties.getProperty(key).trim()
- .equalsIgnoreCase("client-server")) {
- isClient = true;
- }
- } else if (key.startsWith(DistributionConfig.GEMFIRE_PREFIX) && isGemFireAttribute(key)) {
- gemfireProperties.setProperty(key.replace(DistributionConfig.GEMFIRE_PREFIX, ""),
- properties.getProperty(key));
- }
- }
- if (isClient) {
- delegate = new ClientServerRegionFactoryDelegate(gemfireProperties, regionProperties);
- } else {
- delegate = new RegionFactoryDelegate(gemfireProperties, regionProperties);
- }
- }
-
- private boolean isGemFireAttribute(String key) {
- String gfKey = key.replace(DistributionConfig.GEMFIRE_PREFIX, "");
- Set<String> gemfireAttributes = getGemFireAttributesNames();
- return gemfireAttributes.contains(gfKey);
- }
-
- private Set<String> getGemFireAttributesNames() {
- if (this.gemfireAttributes == null) {
- //used only to get the list of all gemfire properties
- DistributionConfig dConfig = new DistributionConfigImpl(new Properties());
- String[] gemfireAttributeNames = dConfig.getAttributeNames();
- gemfireAttributes = new HashSet<String>();
- for (String attrName : gemfireAttributeNames) {
- gemfireAttributes.add(attrName);
- }
- }
- return gemfireAttributes;
- }
-
- @Override
- public void stop() {
- // we do not want to close the cache, as there may be other
- // applications/webapps
- // using this cache. TODO do we want to close the regions that are created
- // by this application?
- }
-
- @Override
- public boolean isMinimalPutsEnabledByDefault() {
- // minimal puts is better for clustered cache
- return true;
- }
-
- @Override
- public AccessType getDefaultAccessType() {
- return AccessType.NONSTRICT_READ_WRITE;
- }
-
- @Override
- public long nextTimestamp() {
- log.debug("nextTimestamp called");
- // TODO use gemfire cache time here. (which tries to minimize clock skews)
- return Timestamper.next();
- }
-
- @Override
- public EntityRegion buildEntityRegion(String regionName,
- Properties properties, CacheDataDescription metadata)
- throws CacheException {
- // create the backing region
- log.debug("creating Entity region {} ", regionName);
- Region<Object, EntityWrapper> region = delegate.createRegion(regionName);
- GemFireEntityRegion r = new GemFireEntityRegion(region, isClient, metadata, this);
- this.entityRegionMap.put(regionName, r);
- return r;
- }
-
- @Override
- public CollectionRegion buildCollectionRegion(String regionName,
- Properties properties, CacheDataDescription metadata)
- throws CacheException {
- log.debug("creating collection region {}",regionName);
- Region<Object, EntityWrapper> region = delegate.createRegion(regionName);
- return new GemFireCollectionRegion(region, isClient, metadata, this);
- }
-
- @Override
- public QueryResultsRegion buildQueryResultsRegion(String regionName,
- Properties properties) throws CacheException {
- log.debug("Creating a query results region");
- Region region = getLocalRegionForQueryCache();
- return new GemFireQueryResultsRegion(region);
- }
-
- private Region getLocalRegionForQueryCache() {
- return getLocalRegion(GEMFIRE_QUERY_RESULTS_REGION_NAME);
- }
-
- private Region getLocalRegionForTimestampsCache() {
- return getLocalRegion(GEMFIRE_TIMESTAMPS_REGION_NAME);
- }
-
- private Region getLocalRegion(String regionName) {
- Region region = _cache.getRegion(regionName);
- if (region != null) {
- return region;
- }
- if (isClient) {
- ClientCache cc = (ClientCache)_cache;
- region = cc.createClientRegionFactory(ClientRegionShortcut.LOCAL_HEAP_LRU).create(regionName);
- } else {
- Cache c = (Cache)_cache;
- region = c.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU).create(regionName);
- }
- return region;
- }
-
- @Override
- public TimestampsRegion buildTimestampsRegion(String regionName,
- Properties properties) throws CacheException {
- Region region = getLocalRegionForTimestampsCache();
- return new GemFireQueryResultsRegion(region);
- }
-
- /**
- * Given an entity name, gets the region used to store
- * that entity.
- * @param name name of the entity
- * @return the entity region for the given entity name
- */
- public GemFireEntityRegion getEntityRegion(String name) {
- return this.entityRegionMap.get(name);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/Access.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/Access.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/Access.java
deleted file mode 100644
index a14f7ac..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/Access.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.apache.geode.cache.CacheWriterException;
-import org.apache.geode.cache.EntryExistsException;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.client.ServerOperationException;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.access.SoftLock;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public abstract class Access implements EntityRegionAccessStrategy {
-
- private final GemFireEntityRegion region;
-
- /**Thread local to remember the status of insert, which can be returned in afterInsert*/
- private ThreadLocal<Map<Object, Boolean>> createStatus = new ThreadLocal<Map<Object, Boolean>>() {
- @Override
- protected Map<Object, Boolean> initialValue() {
- return new HashMap<Object, Boolean>();
- }
- };
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- public Access(GemFireEntityRegion region) {
- this.region = region;
- }
-
- @Override
- public EntityRegion getRegion() {
- return this.region;
- }
-
- @Override
- public Object get(Object key, long txTimestamp) throws CacheException {
- KeyWrapper wKey = getWrappedKey(key);
- if (this.region.isRegisterInterestRequired()) {
- this.region.registerInterest(wKey);
- }
- // first check to see if we have pre-fetched this entity
- EntityWrapper wrapper = this.region.get(wKey);
- if (wrapper == null) {
- wrapper = this.region.getGemFireRegion().get(wKey);
- }
- if (wrapper == null) {
- this.region.getStats().incCacheMiss();
- log.debug("Cache miss for {} count: {}",wKey, this.region.getStats().getCacheMiss());
- return null;
- } else {
- this.region.getStats().incCacheHit();
- log.debug("cache hit {} count: {} ", wKey, this.region.getStats().getCacheHits());
- }
- return wrapper.getEntity();
- }
-
- @Override
- public boolean putFromLoad(Object key, Object value, long txTimestamp,
- Object version) throws CacheException {
- return putFromLoad(key, value, txTimestamp, version, true);
- }
-
- @Override
- public boolean putFromLoad(Object key, Object value, long txTimestamp,
- Object version, boolean minimalPutOverride) throws CacheException {
- return create(key, value);
- }
-
- private boolean create(Object key, Object value) {
- KeyWrapper wKey = getWrappedKey(key);
- EntityWrapper wrapper = new EntityWrapper(value, 1L);
- log.debug("putting a new entry from load {} value: {}",wKey, wrapper);
- boolean remove = false;
- try {
- this.region.getGemFireRegion().create(wKey, wrapper);
- } catch (EntryExistsException ee) {
- log.debug("key {} exists in the cache already, destroying", wKey);
- remove = true;
- } catch (CacheWriterException writerEx) {
- this.region.getStats().incHibernateDestroyJobsScheduled();
- log.debug("caught a CacheWriterException {} ",writerEx.getMessage());
- remove = true;
- } catch (ServerOperationException serverEx) {
- if (serverEx.getCause() instanceof CacheWriterException) {
- this.region.getStats().incHibernateDestroyJobsScheduled();
- log.debug("caught a ServerOperationException caused by CacheWriterException {} ",serverEx.getMessage());
- } else {
- throw serverEx;
- }
- remove = true;
- }
- if (remove) {
- this.region.getGemFireRegion().remove(wKey);
- return false;
- }
- return true;
- }
-
- @Override
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- KeyWrapper wKey = getWrappedKey(key);
- EntityWrapper wrapper = this.region.getGemFireRegion().get(wKey);
- Long ver = wrapper == null ? 0L : wrapper.getVersion();
- log.debug("lockItem:key: {} entityVersion: {}", new Object[] { wKey, ver });
- return new EntityVersionImpl(ver);
- }
-
- @Override
- public SoftLock lockRegion() throws CacheException {
- return null;
- }
-
- @Override
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- log.debug("unlockItem:key:" + key + " lock:" + lock);
- }
-
- @Override
- public void unlockRegion(SoftLock lock) throws CacheException {
- }
-
- @Override
- public boolean insert(Object key, Object value, Object version)
- throws CacheException {
- log.debug("insert:key:{} value:{} version:{}",
- new Object[]{key, value, version});
- boolean retVal = create(key, value);
- createStatus.get().put(key, retVal);
- return retVal;
- }
-
- @Override
- public boolean afterInsert(Object key, Object value, Object version)
- throws CacheException {
- log.info("afterInsert:key:{} value:{} version:{}",
- new Object[]{key, value, version});
- return createStatus.get().remove(key);
- }
-
- @Override
- public boolean update(Object key, Object value, Object currentVersion,
- Object previousVersion) throws CacheException {
- KeyWrapper wKey = getWrappedKey(key);
- EntityWrapper oldWrapper = this.region.getGemFireRegion().get(wKey);
- Long version = oldWrapper == null ? 1L : oldWrapper.getVersion() + 1;
- EntityWrapper wrapper = new EntityWrapper(value, version);
- log.debug("put:key:{} value:{} version:{}", new Object[] { wKey, value,
- version });
- boolean remove = false;
- try {
- if (oldWrapper == null) {
- remove = this.region.getGemFireRegion().putIfAbsent(wKey, wrapper) != null;
- } else {
- remove = !this.region.getGemFireRegion().replace(wKey, oldWrapper, wrapper);
- }
- } catch (CacheWriterException writerEx) {
- this.region.getStats().incHibernateDestroyJobsScheduled();
- log.debug("caught a CacheWriterException {} ",writerEx.getMessage());
- remove = true;
- } catch (ServerOperationException serverEx) {
- if (serverEx.getCause() instanceof CacheWriterException) {
- this.region.getStats().incHibernateDestroyJobsScheduled();
- log.debug("caught a ServerOperationException caused by CacheWriterException {} ",serverEx.getMessage());
- remove = true;
- } else {
- throw serverEx;
- }
- }
- if (remove) {
- this.region.getGemFireRegion().remove(wKey);
- return false;
- }
- log.debug("put for key {} succeded", wKey);
- return true;
- }
-
- @Override
- public boolean afterUpdate(Object key, Object value, Object currentVersion,
- Object previousVersion, SoftLock lock) throws CacheException {
- log.debug("afterUpdate:key:{} value:{} currVersion:{} previousVersion:{}",
- new Object[] {key, value, currentVersion, previousVersion});
- KeyWrapper wKey = getWrappedKey(key);
- EntityWrapper wrapper = this.region.getGemFireRegion().get(wKey);
- if (wrapper == null) {
- // this entry was destroyed during update
- return false;
- }
- Long version = wrapper.getVersion();
- Long expectedVersion = ((EntityVersion)lock).getVersion() + 1;
- log.debug("afterPut:key:{} value:{} version:{} expected: {}",
- new Object[] { wKey, value, version, expectedVersion });
- if (wrapper.getVersion() != expectedVersion) {
- log.debug(
- "for key {} expected version to be {} but was {}, so destroying the key",
- new Object[] { wKey, expectedVersion, version });
- this.region.getGemFireRegion().remove(wKey);
- return false;
- }
- return true;
- }
-
- @Override
- public void remove(Object key) throws CacheException {
- log.debug("removing key {} ",key);
- this.region.getGemFireRegion().remove(getWrappedKey(key));
- }
-
- @Override
- public void removeAll() throws CacheException {
- log.debug("removing all keys");
- this.region.getGemFireRegion().clear();
- }
-
- @Override
- public void evict(Object key) throws CacheException {
- // TODO we should implement a method on Region to evict
- // a particular entry, destroying is inefficient
- log.debug("removing key {} ",key);
- this.region.getGemFireRegion().remove(getWrappedKey(key));
- }
-
- @Override
- public void evictAll() throws CacheException {
- log.debug("removing all keys");
- this.region.getGemFireRegion().clear();
- }
-
- protected Region<Object, EntityWrapper> getGemFireRegion() {
- return this.region.getGemFireRegion();
- }
-
- protected KeyWrapper getWrappedKey(Object key) {
- return new KeyWrapper(key);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ClientServerRegionFactoryDelegate.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ClientServerRegionFactoryDelegate.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ClientServerRegionFactoryDelegate.java
deleted file mode 100644
index bbe3917..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/ClientServerRegionFactoryDelegate.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.apache.geode.cache.GemFireCache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.client.ClientCache;
-import org.apache.geode.cache.client.ClientCacheFactory;
-import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.modules.util.BootstrappingFunction;
-import org.apache.geode.modules.util.CreateRegionFunction;
-import org.apache.geode.modules.util.RegionConfiguration;
-
-import java.util.*;
-
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-
-public class ClientServerRegionFactoryDelegate extends RegionFactoryDelegate {
-
- private static final String DEFAULT_SERVER_REGION_TYPE = RegionShortcut.PARTITION.name();
-
- private static final String DEFAULT_CLIENT_REGION_TYPE = ClientRegionShortcut.PROXY.name();
-
- private ClientCache clientCache;
-
- public ClientServerRegionFactoryDelegate(Properties gemfireProperties,
- Properties regionProperties) {
- super(gemfireProperties, regionProperties);
- }
-
- @Override
- public GemFireCache startCache() {
- log.info("Creating a GemFire client cache");
- String locatorsString = (String) gemfireProperties.remove(LOCATORS);
- checkExistingCache();
- ClientCacheFactory ccf = new ClientCacheFactory(gemfireProperties).setPoolSubscriptionEnabled(true);
- List<LocatorHolder> locators = getLocatorsMap(locatorsString);
- for (LocatorHolder locHolder : locators) {
- log.debug("adding pool locator with host {} port {}", locHolder.host, locHolder.port);
- ccf.addPoolLocator(locHolder.host, locHolder.port);
- }
- this.clientCache = ccf.create();
-
- log.debug("GemFire client cache creation completed");
- // bootstrap the servers
- FunctionService.onServers(this.clientCache).execute(new BootstrappingFunction()).getResult();
- FunctionService.registerFunction(new CreateRegionFunction(this.clientCache));
- return this.clientCache;
- }
-
- private List<LocatorHolder> getLocatorsMap(String locatorsString) {
- List<LocatorHolder> retval = new ArrayList<LocatorHolder>();
- if (locatorsString == null || locatorsString.isEmpty()) {
- return retval;
- }
- StringTokenizer st = new StringTokenizer(locatorsString, ",");
- while (st.hasMoreTokens()) {
- String locator = st.nextToken();
- int portIndex = locator.indexOf('[');
- if (portIndex < 1) {
- portIndex = locator.lastIndexOf(':');
- }
- // starting in 5.1.0.4 we allow '@' as the bind-addr separator
- // to let people use IPv6 numeric addresses (which contain colons)
- int bindAddrIdx = locator.lastIndexOf('@', portIndex - 1);
-
- if (bindAddrIdx < 0) {
- bindAddrIdx = locator.lastIndexOf(':', portIndex - 1);
- }
-
- String host = locator.substring(0,
- bindAddrIdx > -1 ? bindAddrIdx : portIndex);
-
- if (host.indexOf(':') >= 0) {
- bindAddrIdx = locator.lastIndexOf('@');
- host = locator.substring(0, bindAddrIdx > -1 ? bindAddrIdx : portIndex);
- }
- int lastIndex = locator.lastIndexOf(']');
- if (lastIndex == -1) {
- if (locator.indexOf('[') >= 0) {
- throw new IllegalArgumentException("Invalid locator");
- } else {
- // Using host:port syntax
- lastIndex = locator.length();
- }
- }
- String port = locator.substring(portIndex + 1, lastIndex);
- int portVal = 0;
- try {
- portVal = Integer.parseInt(port);
- if (portVal < 1 || portVal > 65535) {
- throw new IllegalArgumentException("port should be grater than zero and less than 65536");
- }
- } catch (NumberFormatException ex) {
- throw new IllegalArgumentException("Invalid Locator");
- }
- retval.add(new LocatorHolder(host, portVal));
- }
- return retval;
- }
-
- @Override
- public Region<Object, EntityWrapper> createRegion(String regionName) {
- // first create the region on the server
- String serverRegionType = getServerRegionType(regionName);
- RegionConfiguration regionConfig = new RegionConfiguration();
- regionConfig.setRegionName(regionName);
- regionConfig.setRegionAttributesId(serverRegionType);
- regionConfig.setCacheWriterName(EntityRegionWriter.class.getCanonicalName());
- FunctionService.onServer(this.clientCache).withArgs(regionConfig)
- .execute(CreateRegionFunction.ID).getResult();
- // now create region on the client
- Region<Object, EntityWrapper> r = this.clientCache.getRegion(regionName);
- if (r != null) {
- return r;
- }
- String clientRegionType = getClientRegionType(regionName);
- ClientRegionFactory<Object, EntityWrapper> rf = this.clientCache
- .createClientRegionFactory(ClientRegionShortcut
- .valueOf(clientRegionType));
- r = rf.create(regionName);
- return r;
- }
-
- private String getClientRegionType(String regionName) {
- String rType = getOverridenClientRegionType(regionName);
- if (rType != null) {
- return rType.toUpperCase();
- }
- rType = regionProperties.getProperty(DistributionConfig.GEMFIRE_PREFIX + "default-client-region-attributes-id");
- if (rType == null) {
- rType = DEFAULT_CLIENT_REGION_TYPE;
- }
- return rType.toUpperCase();
- }
-
- private String getServerRegionType(String regionName) {
- String rType = getOverridenServerRegionType(regionName);
- if (rType != null) {
- return rType.toUpperCase();
- }
- rType = regionProperties.getProperty(DistributionConfig.GEMFIRE_PREFIX + "default-region-attributes-id");
- if (rType == null) {
- rType = DEFAULT_SERVER_REGION_TYPE;
- }
- return rType.toUpperCase();
- }
-
- private String getOverridenServerRegionType(String regionName) {
- String rType = null;
- Iterator<Object> it = regionProperties.keySet().iterator();
- while (it.hasNext()) {
- String current = (String)it.next();
- if (current.contains(regionName) && !current.contains("client")) {
- rType = regionProperties.getProperty(current);
- break;
- }
- }
- return rType;
- }
-
- private String getOverridenClientRegionType(String regionName) {
- String rType = null;
- Iterator<Object> it = regionProperties.keySet().iterator();
- while (it.hasNext()) {
- String current = (String)it.next();
- if (current.contains(regionName) && current.contains("client")) {
- rType = regionProperties.getProperty(current);
- break;
- }
- }
- return rType;
- }
-
- private static class LocatorHolder {
- private String host;
- private int port;
- private LocatorHolder(String host, int port) {
- this.host = host;
- this.port = port;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/CollectionAccess.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/CollectionAccess.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/CollectionAccess.java
deleted file mode 100644
index d921ade..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/CollectionAccess.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.access.SoftLock;
-import org.hibernate.cache.entry.CollectionCacheEntry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.geode.cache.CacheWriterException;
-import org.apache.geode.cache.EntryExistsException;
-import org.apache.geode.cache.EntryNotFoundException;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.client.ServerOperationException;
-
-public class CollectionAccess implements
- CollectionRegionAccessStrategy {
-
- private final GemFireCollectionRegion region;
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * if we know the entity whose ids are stored in this
- * collection, we can prefetch those entities using
- * getAll. This field stores that child entity name.
- */
- private String childEntityName;
-
- public CollectionAccess(GemFireCollectionRegion region) {
- this.region = region;
- String regionName = this.region.getGemFireRegion().getName().trim();
- regionName = regionName.replace("\\/", "");
- int lastPeriod = regionName.lastIndexOf('.');
- if (lastPeriod < 0) {
- log.info("Eager prefetching disabled for region: {}", this.region.getName());
- return;
- }
- String entityName = regionName.substring(0, lastPeriod);
- String collectionFieldName = regionName.substring(lastPeriod+1);
- log.debug("entity name: {}, collectionFieldName: {}", entityName, collectionFieldName);
- try {
- Class parentClass = Class.forName(entityName);
- Field[] fields = parentClass.getDeclaredFields();
- for (Field field : fields) {
- log.debug("genericType: {}", field.getGenericType());
- if (field.getName().equals(collectionFieldName)) {
- String genericString = field.toGenericString();
- log.debug("genericType: for required field name: {}", field.toGenericString());
- int startDependentEntityIndex = genericString.indexOf("<");
- if (startDependentEntityIndex != -1 &&
- genericString.indexOf("<", startDependentEntityIndex+1) == -1) {
- int childDependentEntityIndex = genericString.indexOf(">");
- this.childEntityName = genericString.substring(startDependentEntityIndex+1, childDependentEntityIndex);
- log.debug("For Collection {} using child entity: {}", this.region.getGemFireRegion().getName(), this.childEntityName);
- }
- }
- }
- }
- catch (ClassNotFoundException e) {
- //ok to ignore, we will not use pre-fetching
- }
- if (this.childEntityName == null) {
- log.info("Eager prefetching disabled for region: {}", this.region.getName());
- }
- }
-
- @Override
- public CollectionRegion getRegion() {
- return this.region;
- }
-
- @Override
- public Object get(Object key, long txTimestamp) throws CacheException {
- EntityWrapper wrapper = this.region.getGemFireRegion().get(key);
- if (wrapper == null) {
- this.region.getStats().incCacheMiss();
- log.debug("Cache miss for {} ts: {}",key, txTimestamp);
- return null;
- } else {
- this.region.getStats().incCacheHit();
- log.debug("cache hit {} count: {} ", key, this.region.getStats().getCacheHits());
- // do pre-fetching
- if (isPrefetchPossible()) {
- log.debug("for key: {} prefetching entries: {}", key, wrapper.getEntity());
- prefetchKeys((CollectionCacheEntry)wrapper.getEntity());
- }
- }
- return wrapper.getEntity();
- }
-
- private void prefetchKeys(CollectionCacheEntry entry) {
- StringBuilder builder = new StringBuilder(this.childEntityName+"#");
- Serializable[] childEntityKeys = entry.getState();
- Set<String> getAllSet = new HashSet<String>();
- for (Serializable id : childEntityKeys) {
- String key = builder.append(id).toString();
- log.debug("adding key {} to getAll set", key);
- getAllSet.add(key);
- }
- GemFireEntityRegion childRegion = this.region.regionFactory.getEntityRegion(this.childEntityName);
- log.debug("prefetching {} keys", getAllSet.size());
- if (!getAllSet.isEmpty() && childRegion != null) {
- childRegion.getAll(getAllSet);
- }
- }
-
- private boolean isPrefetchPossible() {
- return this.childEntityName != null;
- }
-
- private void printRegionContents(Region<Object, EntityWrapper> r) {
- log.debug("printing contents of {} ",r);
- for (Object k : r.keySet()) {
- log.debug("key {} value {} ",k,r.get(k));
- }
- }
-
- @Override
- public boolean putFromLoad(Object key, Object value, long txTimestamp,
- Object version) throws CacheException {
- return putFromLoad(key, value, txTimestamp, version, true);
- }
-
- @Override
- public boolean putFromLoad(Object key, Object value, long txTimestamp,
- Object version, boolean minimalPutOverride) throws CacheException {
- EntityWrapper wrapper = new EntityWrapper(value, 1L);
- log.debug("putting a new collection entry from load {} value: {}",key, wrapper);
- boolean remove = false;
- try {
- this.region.getGemFireRegion().create(key, wrapper);
- } catch (EntryExistsException ee) {
- log.debug("key {} exists in the cache already, destroying", key);
- remove = true;
- } catch (CacheWriterException writerEx) {
- this.region.getStats().incHibernateDestroyJobsScheduled();
- log.debug("caught a CacheWriterException {} ",writerEx.getMessage());
- remove = true;
- } catch (ServerOperationException serverEx) {
- if (serverEx.getCause() instanceof CacheWriterException) {
- this.region.getStats().incHibernateDestroyJobsScheduled();
- log.debug("caught a ServerOperationException caused by CacheWriterException {} ",serverEx.getMessage());
- } else {
- throw serverEx;
- }
- remove = true;
- }
- if (remove) {
- this.region.getGemFireRegion().remove(key);
- return false;
- }
- return true;
- }
-
- @Override
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- // there are no updates to the collectionCache,
- // so no need to lock/version
- return null;
- }
-
- @Override
- public SoftLock lockRegion() throws CacheException {
- return null;
- }
-
- @Override
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- }
-
- @Override
- public void unlockRegion(SoftLock lock) throws CacheException {
- }
-
- @Override
- public void remove(Object key) throws CacheException {
- log.debug("removing key {}",key);
- this.region.getGemFireRegion().remove(key);
- }
-
- @Override
- public void removeAll() throws CacheException {
- log.debug("removing all keys");
- this.region.getGemFireRegion().clear();
- }
-
- @Override
- public void evict(Object key) throws CacheException {
- // TODO we should implement a method on Region to evict
- // a particular entry, destroying is inefficient
- log.debug("removing key {}", key);
- this.region.getGemFireRegion().remove(key);
- }
-
- @Override
- public void evictAll() throws CacheException {
- log.debug("removing all keys");
- this.region.getGemFireRegion().clear();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityRegionWriter.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityRegionWriter.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityRegionWriter.java
deleted file mode 100644
index d4f6f2f..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityRegionWriter.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.geode.cache.CacheWriterException;
-import org.apache.geode.cache.Declarable;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.util.CacheWriterAdapter;
-
-public class EntityRegionWriter extends CacheWriterAdapter implements Declarable {
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
-// @Override
-// public void beforeCreate(EntryEvent event) {
-// event.getRegion().getCache().getLogger().info("GFE:Writer invoked for beforeCreate:"+event);
-// final Object key = event.getKey();
-// EntityWrapper val = (EntityWrapper)event.getNewValue();
-// EntityWrapper oldVal = (EntityWrapper)event.getOldValue();
-// log.debug("beforeCreate: key:"+key+" val:"+val.getEntity()+" ver:"+val.getVersion()+" region:"+event.getRegion().getName()+" oldVal:"+oldVal+" this:"+System.identityHashCode(this));
-// }
-
- @Override
- public void beforeUpdate(EntryEvent event) {
- log.debug("Writer invoked for beforeUpdate:{}",event);
- final Object key = event.getKey();
- EntityWrapper val = (EntityWrapper)event.getNewValue();
- if (val.getVersion() < 0) {
- // no need for version check for NonStrictReadWrite
- // this is needed because CacheEntry does not implement equals
- return;
- }
- EntityWrapper oldVal = (EntityWrapper)event.getOldValue();
- // if same entity was loaded from two different VMs,
- // i.e. version same and entity equal then no need to destroy
- //
- if (oldVal.getVersion() == val.getVersion()) {
- if (val.getEntity().equals(oldVal.getEntity())) {
- // since CacheEntry does not override equals
- // this check is probably of no use
- return;
- }
- } else if (oldVal.getVersion() < val.getVersion()) {
- return;
- }
- log.debug("For key {} old version was {} new version was {}", new Object[] {key, oldVal.getVersion(), val.getVersion()});
- throw new CacheWriterException("key "+key+" had a newer version");
- }
-
- @Override
- public boolean equals(Object obj) {
- // This method is only implemented so that RegionCreator.validateRegion works properly.
- // The CacheWriter comparison fails because two of these instances are not equal.
- if (this == obj) {
- return true;
- }
-
- if (obj == null || !(obj instanceof EntityRegionWriter)) {
- return false;
- }
- return true;
- }
-
- @Override
- public void init(Properties arg0) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersion.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersion.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersion.java
deleted file mode 100644
index 9851d29..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersion.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.hibernate.cache.access.SoftLock;
-
-/**
- *
- */
-public interface EntityVersion extends SoftLock {
-
- public Long getVersion();
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersionImpl.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersionImpl.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersionImpl.java
deleted file mode 100644
index ad866a6..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityVersionImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-/**
- *
- */
-public class EntityVersionImpl implements EntityVersion {
-
- private final Long version;
-
- public EntityVersionImpl(Long version) {
- this.version = version;
- }
-
- @Override
- public Long getVersion() {
- return this.version;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EntityVersionImpl) {
- EntityVersionImpl other = (EntityVersionImpl)obj;
- if (this.version.equals(other.version)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this.version.hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityWrapper.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityWrapper.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityWrapper.java
deleted file mode 100644
index a829de6..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/EntityWrapper.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.geode.DataSerializable;
-import org.apache.geode.DataSerializer;
-
-public class EntityWrapper implements DataSerializable {
-
- private static final long serialVersionUID = 8616754027252339041L;
-
- private Object entity;
-
- private long version;
-
- public EntityWrapper(Object entity, long version) {
- this.entity = entity;
- this.version = version;
- }
-
- /**
- * for {@link DataSerializer}
- */
- public EntityWrapper() {
- }
-
- public long getVersion() {
- return version;
- }
-
- public Object getEntity() {
- return entity;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EntityWrapper) {
- EntityWrapper other = (EntityWrapper)obj;
- if (this.version == other.version) {
- //CacheEntry does not override equals, hence cannot be used in this comparison
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Long.valueOf(this.version).hashCode();
- }
-
- @Override
- public String toString() {
- return new StringBuilder()
- .append("EntityWrapper@" + System.identityHashCode(this))
- .append(" Entity:" + this.entity).append(" version:" + this.version)
- .toString();
- }
-
- @Override
- public void toData(DataOutput out) throws IOException {
- out.writeLong(this.version);
- DataSerializer.writeObject(this.entity, out);
- }
-
- @Override
- public void fromData(DataInput in) throws IOException, ClassNotFoundException {
- this.version = in.readLong();
- this.entity = DataSerializer.readObject(in);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireBaseRegion.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireBaseRegion.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireBaseRegion.java
deleted file mode 100644
index 022187a..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireBaseRegion.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.Region;
-import org.hibernate.cache.Timestamper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.internal.cache.LocalRegion;
-import org.apache.geode.modules.hibernate.GemFireRegionFactory;
-import org.apache.geode.modules.util.ModuleStatistics;
-
-public class GemFireBaseRegion implements Region {
-
- /**
- * the backing region
- */
- protected final org.apache.geode.cache.Region<Object, EntityWrapper> region;
-
- /**
- * to determine if the operation should be forwarded to server
- */
- protected final boolean isClientRegion;
-
- protected final CacheDataDescription metadata;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- protected final GemFireRegionFactory regionFactory;
-
- protected final ModuleStatistics stats;
-
- public GemFireBaseRegion(org.apache.geode.cache.Region<Object, EntityWrapper> region,
- boolean isClient, CacheDataDescription metadata, GemFireRegionFactory regionFactory) {
- this.region = region;
- this.isClientRegion = isClient;
- this.metadata = metadata;
- this.regionFactory = regionFactory;
- DistributedSystem system = ((LocalRegion)region).getSystem();
- this.stats = ModuleStatistics.getInstance(system);
-
- }
-
- public org.apache.geode.cache.Region<Object, EntityWrapper> getGemFireRegion() {
- return this.region;
- }
-
- public ModuleStatistics getStats() {
- return this.stats;
- }
-
- public ExecutorService getExecutorService() {
- return this.regionFactory.getExecutorService();
- }
-
- @Override
- public String getName() {
- return this.region.getName();
- }
-
- @Override
- public void destroy() throws CacheException {
- if (!this.region.isDestroyed()) {
- this.region.localDestroyRegion();
- }
- }
-
- /*
- * I did not see any useful callers from hibernate-core
- */
- @Override
- public boolean contains(Object key) {
- log.debug("contains key called for :" + key);
- if (isClientRegion) {
- // TODO should this be done?
- return this.region.containsKeyOnServer(key);
- }
- return this.region.containsKey(key);
- }
-
- @Override
- public long getSizeInMemory() {
- return 0;
- }
-
- @Override
- public long getElementCountInMemory() {
- return this.region.size();
- }
-
- @Override
- public long getElementCountOnDisk() {
- LocalRegion lr = (LocalRegion)this.region;
- if (lr.getDiskRegion() != null) {
- return lr.getDiskRegion().getNumOverflowOnDisk();
- }
- return 0;
- }
-
- @Override
- public Map<Object, EntityWrapper> toMap() {
- return Collections.unmodifiableMap(this.region);
- }
-
- /*
- * only used by updateTimestamps cache
- */
- @Override
- public long nextTimestamp() {
- log.debug("nextTimestamp called");
- return Timestamper.next();
- }
-
- /*
- * this is used by updateTimestamps cache only
- */
- @Override
- public int getTimeout() {
- return 60*1000; // all other cache providers have same value
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof GemFireBaseRegion) {
- GemFireBaseRegion other = (GemFireBaseRegion)obj;
- if (this.region.getName().equals(other.region.getName())
- && this.isClientRegion == other.isClientRegion) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this.region.hashCode() + (this.isClientRegion ? 1 : 0);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/38aa36f4/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireCollectionRegion.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireCollectionRegion.java b/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireCollectionRegion.java
deleted file mode 100644
index 5cb53ea..0000000
--- a/extensions/geode-modules-hibernate/src/main/java/org/apache/geode/modules/hibernate/internal/GemFireCollectionRegion.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.geode.modules.hibernate.internal;
-
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.access.AccessType;
-import org.hibernate.cache.access.CollectionRegionAccessStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.geode.cache.Region;
-import org.apache.geode.modules.hibernate.GemFireRegionFactory;
-
-public class GemFireCollectionRegion extends GemFireBaseRegion implements CollectionRegion {
-
- private Logger log = LoggerFactory.getLogger(getClass());
-
- public GemFireCollectionRegion(Region<Object, EntityWrapper> region,
- boolean isClient, CacheDataDescription metadata,
- GemFireRegionFactory regionFactory) {
- super(region, isClient, metadata, regionFactory);
- }
-
- @Override
- public boolean isTransactionAware() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public CacheDataDescription getCacheDataDescription() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public CollectionRegionAccessStrategy buildAccessStrategy(
- AccessType accessType) throws CacheException {
- log.debug("creating collection access for region:"+this.region.getName());
- return new CollectionAccess(this);
- }
-
-}