Add Store and Js5MasterIndex providers

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent a3cca0e6c3
commit 65b3e1315a
  1. 9
      cache/src/main/kotlin/org/openrs2/cache/CacheModule.kt
  2. 12
      cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndexProvider.kt
  3. 14
      cache/src/main/kotlin/org/openrs2/cache/StoreProvider.kt

@ -1,6 +1,7 @@
package org.openrs2.cache
import com.google.inject.AbstractModule
import com.google.inject.Scopes
import org.openrs2.buffer.BufferModule
import org.openrs2.crypto.CryptoModule
@ -8,5 +9,13 @@ public object CacheModule : AbstractModule() {
override fun configure() {
install(BufferModule)
install(CryptoModule)
bind(Store::class.java)
.toProvider(StoreProvider::class.java)
.`in`(Scopes.SINGLETON)
bind(Js5MasterIndex::class.java)
.toProvider(Js5MasterIndexProvider::class.java)
.`in`(Scopes.SINGLETON)
}
}

@ -0,0 +1,12 @@
package org.openrs2.cache
import javax.inject.Inject
import javax.inject.Provider
public class Js5MasterIndexProvider @Inject constructor(
private val store: Store
) : Provider<Js5MasterIndex> {
override fun get(): Js5MasterIndex {
return Js5MasterIndex.create(store)
}
}

@ -0,0 +1,14 @@
package org.openrs2.cache
import io.netty.buffer.ByteBufAllocator
import java.nio.file.Path
import javax.inject.Inject
import javax.inject.Provider
public class StoreProvider @Inject constructor(
private val alloc: ByteBufAllocator
) : Provider<Store> {
override fun get(): Store {
return Store.open(Path.of("nonfree/share/cache"), alloc)
}
}
Loading…
Cancel
Save