-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserModule.java
54 lines (45 loc) · 1.79 KB
/
UserModule.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.thrive;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.thrive.ratelimit.ratelimitcache.RateLimitCache;
import com.thrive.ratelimit.ratelimitcache.Impl.RateLimitCacheImpl;
import com.thrive.client.cache.user.Impl.UserCacheImpl;
import com.thrive.client.cache.user.UserCache;
import com.thrive.db.UsersDB;
import com.thrive.db.impl.UsersDBImpl;
import com.thrive.model.config.CacheConfig;
import com.thrive.model.dao.StoredUser;
import com.thrive.services.UserService;
import com.thrive.services.impl.UserServiceImpl;
import io.appform.dropwizard.sharding.DBShardingBundle;
import io.appform.dropwizard.sharding.dao.RelationalDao;
import org.redisson.config.Config;
public class UserModule extends AbstractModule {
DBShardingBundle<UserServiceConfiguration> dbShardingBundle;
public UserModule(DBShardingBundle<UserServiceConfiguration> dbShardingBundle) {
this.dbShardingBundle = dbShardingBundle;
}
@Override
protected void configure() {
bind(UserService.class).to(UserServiceImpl.class);
bind(UsersDB.class).to(UsersDBImpl.class);
bind(UserCache.class).to(UserCacheImpl.class);
bind(RateLimitCache.class).to(RateLimitCacheImpl.class);
}
@Provides
@Singleton
public RelationalDao<StoredUser> baseRelationalDao() {
return dbShardingBundle.createRelatedObjectDao(StoredUser.class);
}
@Provides
@Singleton
public Config getRedisConfiguration(UserServiceConfiguration userServiceConfiguration) {
return userServiceConfiguration.getRedis();
}
@Provides
@Singleton
public CacheConfig getCacheConfiguration(UserServiceConfiguration userServiceConfiguration) {
return userServiceConfiguration.getCaches();
}
}