-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Made it possible to change hazelcast instance factory. Fixes #21. This is better because many third-party db libraries assume that properties in Properties are Strings, not objects.
- Loading branch information
1 parent
5d9da9b
commit b57a0d5
Showing
7 changed files
with
83 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...-hibernate5/src/main/java/com/hazelcast/hibernate/instance/IHazelcastInstanceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* 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 com.hazelcast.hibernate.instance; | ||
|
||
import org.hibernate.cache.CacheException; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* A hookable factory class to build up implementations of {@link com.hazelcast.hibernate.instance.IHazelcastInstanceLoader} | ||
*/ | ||
public interface IHazelcastInstanceFactory { | ||
IHazelcastInstanceLoader createInstanceLoader(final Properties props) throws CacheException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...bernate5/src/test/java/com/hazelcast/hibernate/instance/HazelcastMockInstanceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.hazelcast.hibernate.instance; | ||
|
||
import org.hibernate.cache.CacheException; | ||
|
||
import java.util.Properties; | ||
|
||
public class HazelcastMockInstanceFactory implements IHazelcastInstanceFactory | ||
{ | ||
private static ThreadLocal<IHazelcastInstanceLoader> loaders = new ThreadLocal<IHazelcastInstanceLoader>(); | ||
|
||
public static void setThreadLocalLoader(IHazelcastInstanceLoader loader) | ||
{ | ||
loaders.set(loader); | ||
} | ||
|
||
@Override | ||
public IHazelcastInstanceLoader createInstanceLoader(Properties props) throws CacheException | ||
{ | ||
return loaders.get(); | ||
} | ||
} |