Minor: auto-format of module: client

This commit is contained in:
Mike Hearn 2017-04-11 12:38:31 +02:00
parent d9391b3d29
commit 6f200562b3
10 changed files with 22 additions and 18 deletions

View File

@ -39,11 +39,13 @@ object JacksonSupport {
override fun partyFromName(partyName: String): Party? = rpc.partyFromName(partyName)
override fun partyFromKey(owningKey: CompositeKey): Party? = rpc.partyFromKey(owningKey)
}
class IdentityObjectMapper(val identityService: IdentityService, factory: JsonFactory) : PartyObjectMapper, ObjectMapper(factory) {
override fun partyFromName(partyName: String): Party? = identityService.partyFromName(partyName)
override fun partyFromKey(owningKey: CompositeKey): Party? = identityService.partyFromKey(owningKey)
}
class NoPartyObjectMapper(factory: JsonFactory): PartyObjectMapper, ObjectMapper(factory) {
class NoPartyObjectMapper(factory: JsonFactory) : PartyObjectMapper, ObjectMapper(factory) {
override fun partyFromName(partyName: String): Party? = throw UnsupportedOperationException()
override fun partyFromKey(owningKey: CompositeKey): Party? = throw UnsupportedOperationException()
}

View File

@ -52,7 +52,7 @@ class NodeMonitorModel {
* TODO provide an unsubscribe mechanism
*/
fun register(nodeHostAndPort: HostAndPort, username: String, password: String) {
val client = CordaRPCClient(nodeHostAndPort){
val client = CordaRPCClient(nodeHostAndPort) {
maxRetryInterval = 10.seconds.toMillis()
}
client.start(username, password)

View File

@ -4,7 +4,6 @@ import javafx.collections.FXCollections
import javafx.collections.ListChangeListener
import javafx.collections.ObservableList
import javafx.collections.transformation.TransformationList
import kotlin.comparisons.compareValues
/**
* Given an [ObservableList]<[E]> and a grouping key [K], [AggregatedList] groups the elements by the key into a fresh

View File

@ -13,7 +13,7 @@ import java.util.stream.Collectors
* Utility bindings for the [Amount] type, similar in spirit to [Bindings]
*/
object AmountBindings {
fun <T: Any> sum(amounts: ObservableList<Amount<T>>, token: T) = EasyBind.map(
fun <T : Any> sum(amounts: ObservableList<Amount<T>>, token: T) = EasyBind.map(
Bindings.createLongBinding({
amounts.stream().collect(Collectors.summingLong {
require(it.token == token)

View File

@ -5,7 +5,6 @@ import javafx.collections.ListChangeListener
import javafx.collections.ObservableList
import javafx.collections.transformation.TransformationList
import java.util.*
import kotlin.comparisons.compareValues
/**
* [ConcatenatedList] takes a list of lists and concatenates them. Any change to the underlying lists or the outer list

View File

@ -4,7 +4,6 @@ import javafx.collections.FXCollections
import javafx.collections.MapChangeListener
import javafx.collections.ObservableList
import javafx.collections.ObservableMap
import kotlin.comparisons.compareValues
/**
* [MapValuesList] takes an [ObservableMap] and returns its values as an [ObservableList].

View File

@ -25,8 +25,8 @@ import kotlin.test.assertTrue
class CordaRPCClientTest : NodeBasedTest() {
private val rpcUser = User("user1", "test", permissions = setOf(
startFlowPermission<CashIssueFlow>(),
startFlowPermission<CashPaymentFlow>()
startFlowPermission<CashIssueFlow>(),
startFlowPermission<CashPaymentFlow>()
))
private lateinit var node: Node
private lateinit var client: CordaRPCClient
@ -100,8 +100,8 @@ class CordaRPCClientTest : NodeBasedTest() {
assertTrue(startCash.isEmpty(), "Should not start with any cash")
val flowHandle = proxy.startFlow(::CashIssueFlow,
123.DOLLARS, OpaqueBytes.of(0),
node.info.legalIdentity, node.info.legalIdentity
123.DOLLARS, OpaqueBytes.of(0),
node.info.legalIdentity, node.info.legalIdentity
)
println("Started issuing cash, waiting on result")
flowHandle.progress.subscribe {

View File

@ -318,13 +318,13 @@ class CordaRPCClientImpl(private val session: ClientSession,
* return observationsSubject
*/
private fun refCountUp() {
if(referenceCount.andIncrement == 0) {
if (referenceCount.andIncrement == 0) {
hardReferencesToQueuedObservables.add(this)
}
}
private fun refCountDown() {
if(referenceCount.decrementAndGet() == 0) {
if (referenceCount.decrementAndGet() == 0) {
hardReferencesToQueuedObservables.remove(this)
}
}
@ -354,7 +354,9 @@ class CordaRPCClientImpl(private val session: ClientSession,
private fun deliver(msg: ClientMessage) {
sessionLock.withLock { msg.acknowledge() }
val kryo = createRPCKryoForDeserialization(this@CordaRPCClientImpl, qName, rpcName, rpcLocation)
val received: MarshalledObservation = try { msg.deserialize(kryo) } finally {
val received: MarshalledObservation = try {
msg.deserialize(kryo)
} finally {
releaseRPCKryoForDeserialization(kryo)
}
rpcLog.debug { "<- Observable [$rpcName] <- Received $received" }

View File

@ -68,7 +68,7 @@ abstract class AbstractClientRPC {
serverThread.shutdownNow()
}
fun <T: RPCOps> rpcProxyFor(rpcUser: User, rpcImpl: T, type: Class<T>): T {
fun <T : RPCOps> rpcProxyFor(rpcUser: User, rpcImpl: T, type: Class<T>): T {
val userService = object : RPCUserService {
override fun getUser(username: String): User? = if (username == rpcUser.username) rpcUser else null
override val users: List<User> get() = listOf(rpcUser)
@ -93,5 +93,8 @@ abstract class AbstractClientRPC {
return CordaRPCClientImpl(clientSession, ReentrantLock(), rpcUser.username).proxyFor(type)
}
fun safeClose(obj: Any) = try { (obj as AutoCloseable).close() } catch (e: Exception) {}
fun safeClose(obj: Any) = try {
(obj as AutoCloseable).close()
} catch (e: Exception) {
}
}

View File

@ -1,12 +1,12 @@
package net.corda.client.rpc
import net.corda.core.messaging.RPCOps
import net.corda.node.services.messaging.*
import net.corda.node.services.messaging.requirePermission
import net.corda.nodeapi.PermissionException
import net.corda.nodeapi.User
import org.junit.After
import org.junit.Test
import kotlin.test.*
import kotlin.test.assertFailsWith
class RPCPermissionsTest : AbstractClientRPC() {
companion object {
@ -74,7 +74,7 @@ class RPCPermissionsTest : AbstractClientRPC() {
}
@Test
fun `check ALL is implemented the correct way round` () {
fun `check ALL is implemented the correct way round`() {
val joeUser = userOf("joe", setOf(DUMMY_FLOW))
proxy = proxyFor(joeUser)
assertFailsWith(PermissionException::class,