-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
794 additions
and
28 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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/io/neonbee/internal/SharedDataAccessorFactory.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,36 @@ | ||
package io.neonbee.internal; | ||
|
||
import io.neonbee.NeonBee; | ||
import io.neonbee.config.NeonBeeConfig; | ||
import io.neonbee.internal.cluster.ClusterHelper; | ||
import io.neonbee.internal.hazelcast.ReplicatedDataAccessor; | ||
import io.vertx.core.Vertx; | ||
|
||
public class SharedDataAccessorFactory { | ||
private final NeonBee neonBee; | ||
|
||
public SharedDataAccessorFactory() { | ||
this.neonBee = NeonBee.get(); | ||
} | ||
|
||
public SharedDataAccessorFactory(Vertx vertx) { | ||
this.neonBee = NeonBee.get(vertx); | ||
} | ||
|
||
public SharedDataAccessorFactory(NeonBee neonBee) { | ||
this.neonBee = neonBee; | ||
} | ||
|
||
private boolean useHazelcastReplicatedMaps() { | ||
NeonBeeConfig config = neonBee.getConfig(); | ||
return config.isUseReplicatedMaps() && ClusterHelper.getHazelcastClusterManager(neonBee.getVertx()).isPresent(); | ||
} | ||
|
||
public SharedDataAccessor getSharedDataAccessor(Class<?> accessClass) { | ||
if (useHazelcastReplicatedMaps()) { | ||
return new ReplicatedDataAccessor(neonBee.getVertx(), accessClass); | ||
} else { | ||
return new SharedDataAccessor(neonBee.getVertx(), accessClass); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.