From ae349a88313eef023a59dfd3e2568c5b7130b05d Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Fri, 9 Dec 2016 14:30:52 +0000 Subject: [PATCH] Adds todos that will improve java interop. --- core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt | 4 ++++ core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt | 4 ++++ core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt | 3 +++ node/src/main/kotlin/net/corda/node/driver/Driver.kt | 3 +++ .../net/corda/node/services/messaging/CordaRPCClient.kt | 3 +++ 5 files changed, 17 insertions(+) diff --git a/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt b/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt index d1396f40e3..ce2dbea0b5 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt @@ -61,6 +61,8 @@ inline fun requireThat(body: Requirements.() -> R) = Requirements.body() //// Authenticated commands /////////////////////////////////////////////////////////////////////////////////////////// +// TODO: Provide a version of select that interops with Java + /** Filters the command list by type, party and public key all at once. */ inline fun Collection>.select(signer: CompositeKey? = null, party: Party? = null) = @@ -69,6 +71,8 @@ inline fun Collection filter { if (party == null) true else party in it.signingParties }. map { AuthenticatedObject(it.signers, it.signingParties, it.value as T) } +// TODO: Provide a version of select that interops with Java + /** Filters the command list by type, parties and public keys all at once. */ inline fun Collection>.select(signers: Collection?, parties: Collection?) = diff --git a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt index 3a9e7186b0..08f619797d 100644 --- a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt +++ b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt @@ -54,6 +54,8 @@ abstract class FlowLogic { return sendAndReceive(otherParty, payload, T::class.java) } + // TODO: Move the receiveType param to first position for readability + @Suspendable fun sendAndReceive(otherParty: Party, payload: Any, receiveType: Class): UntrustworthyData { return fsm.sendAndReceive(otherParty, payload, receiveType, sessionFlow) @@ -61,6 +63,8 @@ abstract class FlowLogic { inline fun receive(otherParty: Party): UntrustworthyData = receive(otherParty, T::class.java) + // TODO: Move the receiveType param to first position for readability + @Suspendable fun receive(otherParty: Party, receiveType: Class): UntrustworthyData { return fsm.receive(otherParty, receiveType, sessionFlow) diff --git a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt index 56f9384747..5b5b8ba8a6 100644 --- a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt +++ b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt @@ -31,6 +31,9 @@ sealed class StateMachineUpdate(val id: StateMachineRunId) { * RPC operations that the node exposes to clients using the Java client library. These can be called from * client apps and are implemented by the node in the [CordaRPCOpsImpl] class. */ + +// TODO: The use of Pairs throughout is unfriendly for Java interop. + interface CordaRPCOps : RPCOps { /** * Returns a pair of currently in-progress state machine infos and an observable of future state machine adds/removes. diff --git a/node/src/main/kotlin/net/corda/node/driver/Driver.kt b/node/src/main/kotlin/net/corda/node/driver/Driver.kt index 437a5b159c..b98e64f5f3 100644 --- a/node/src/main/kotlin/net/corda/node/driver/Driver.kt +++ b/node/src/main/kotlin/net/corda/node/driver/Driver.kt @@ -132,6 +132,9 @@ sealed class PortAllocation { * @param dsl The dsl itself. * @return The value returned in the [dsl] closure. */ + +// TODO: Add an @JvmOverloads annotation + fun driver( driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()), portAllocation: PortAllocation = PortAllocation.Incremental(10000), diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClient.kt b/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClient.kt index b5485a333c..e959406619 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClient.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClient.kt @@ -96,6 +96,9 @@ class CordaRPCClient(val host: HostAndPort, override val config: NodeSSLConfigur * * @throws RPCException if the server version is too low or if the server isn't reachable within the given time. */ + + // TODO: Add an @JvmOverloads annotation + @Throws(RPCException::class) fun proxy(timeout: Duration? = null, minVersion: Int = 0): CordaRPCOps { return state.locked {