Final message classes, removal of unneeded deps, initial pass over docs

This commit is contained in:
Chris Barratt 2022-10-17 17:01:27 +01:00
parent 8267ea597c
commit 8e6081875b
6 changed files with 11 additions and 59 deletions

View File

@ -45,36 +45,6 @@ cordapp {
}
}
/*
// Declare the set of Kotlin compiler options we need to build a CorDapp.
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
allWarningsAsErrors = false
// Specify the version of Kotlin that we are that we will be developing.
languageVersion = '1.7'
// Specify the Kotlin libraries that code is compatible with
apiVersion = '1.7'
// Note that we Need to use a version of Kotlin that will be compatible with the Corda API.
// Currently that is developed in Kotlin 1.7 so picking the same version ensures compatibility with that.
// Specify the version of Java to target.
jvmTarget = javaVersion
// Needed for reflection to work correctly.
javaParameters = true
// -Xjvm-default determines how Kotlin supports default methods.
// JetBrains currently recommends developers use -Xjvm-default=all
// https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-default/
freeCompilerArgs += [
"-Xjvm-default=all"
]
}
}
*/
// Declare the set of Kotlin compiler options we need to build a CorDapp.
tasks.withType(JavaCompile) {
@ -84,8 +54,6 @@ tasks.withType(JavaCompile) {
]
}
repositories {
// All dependencies are held in Maven Central
mavenCentral()
@ -95,13 +63,6 @@ repositories {
// A cordaProvided declaration is required for anything that we use that the Corda API provides.
// This is required to allow us to build CorDapp modules as OSGi bundles that CPI and CPB files are built on.
dependencies {
// We need a version of kotlin-stdlib-jdk8 built as an OSGi bundle, this is "kotlin-stdlib-jdk8-osgi".
// R3 builds kotlin-stdlib-jdk8-osgi from Kotlin's kotlin-stdlib-jdk8.
// NB:
// Kotlin's kotlin-osgi-bundle does not provide all of the Kotlin API that is required,
// There is no kotlin-stdlib-jdk11, but one is not needed even though we are targetting Java 11.
cordaProvided 'net.corda.kotlin:kotlin-stdlib-jdk8-osgi'
// Declare a "platform" so that we use the correct set of dependency versions for the version of the
// Corda API specified.
cordaProvided platform("net.corda:corda-api:$cordaApiVersion")
@ -135,9 +96,7 @@ dependencies {
// Optional but used by exmaple tests.
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion"
}

View File

@ -3,15 +3,15 @@ package com.r3.developers.csdetemplate;
import net.corda.v5.base.annotations.CordaSerializable;
import net.corda.v5.base.types.MemberX500Name;
// // A class which will contain a message, It must be marked with @CordaSerializable for Corda
//// to be able to send from one virtual node to another.
// A class which will contain a message, It must be marked with @CordaSerializable for Corda
// to be able to send from one virtual node to another.
@CordaSerializable
public class Message {
// public Message() {}
public Message(MemberX500Name sender, String message) {
this.sender = sender;
this.message = message;
}
public MemberX500Name getSender() {
return sender;
}

View File

@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
// MyFirstFlow is an initiating flow, it's corresponding responder flow is called MyFirstFlowResponder (defined below)
// to link the two sides of the flow together they need to have the same protocol.
@InitiatingFlow(protocol = "another-flow")
@InitiatingFlow(protocol = "my-first-flow")
// MyFirstFlow should inherit from RPCStartableFlow, which tells Corda it can be started via an RPC call
public class MyFirstFlow implements RPCStartableFlow {
@ -40,7 +40,7 @@ public class MyFirstFlow implements RPCStartableFlow {
public MyFirstFlow() {}
// When a flow is invoked it's call() method is called.
// When a flow is invoked its call() method is called.
// call() methods must be marked as @Suspendable, this allows Corda to pause mid-execution to wait
// for a response from the other flows and services
@NotNull

View File

@ -11,9 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// MyFirstFlowResponder is a responder flow, it's corresponding initiating flow is called MyFirstFlow (defined above)
// MyFirstFlowResponder is a responder flow, it's corresponding initiating flow is called MyFirstFlow (defined in MyFirstFlow.java)
// to link the two sides of the flow together they need to have the same protocol.
@InitiatedBy(protocol = "another-flow")
@InitiatedBy(protocol = "my-first-flow")
// Responder flows must inherit from ResponderFlow
public class MyFirstFlowResponder implements ResponderFlow {
@ -28,9 +28,9 @@ public class MyFirstFlowResponder implements ResponderFlow {
public MyFirstFlowResponder() {}
// Responder flows are invoked when an initiating flow makes a call via a session set up with the Virtual
// node hosting the Responder flow. When a responder flow is invoked it's call() method is called.
// node hosting the Responder flow. When a responder flow is invoked its call() method is called.
// call() methods must be marked as @Suspendable, this allows Corda to pause mid-execution to wait
// for a response from the other flows and services/
// for a response from the other flows and services.
// The Call method has the flow session passed in as a parameter by Corda so the session is available to
// responder flow code, you don't need to inject the FlowMessaging service.
@Suspendable

View File

@ -2,20 +2,14 @@ package com.r3.developers.csdetemplate;
import net.corda.v5.base.types.MemberX500Name;
// // A class to hold the arguments required to start the flow
//class MyFirstFlowStartArgs(val otherMember: MemberX500Name)
// A class to hold the arguments required to start the flow
public class MyFirstFlowStartArgs {
public MemberX500Name otherMember;
public MemberX500Name getOtherMember() {
return otherMember;
}
public MyFirstFlowStartArgs(MemberX500Name otherMember) {
this.otherMember = otherMember;
}
// Without the following we get
// "Cannot construct instance of `com.r3.developers.csdetemplate.MyFirstFlowStartArgs` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)\n at [Source: (String)\"{\"otherMember\":\"CN=Bob, OU=Test Dept, O=R3, L=London, C=GB\"}\"; line: 1, column: 2]"
// The JSON Marshalling Service, that handles serialisation, needs this constructor.
public MyFirstFlowStartArgs() {}
}

View File

@ -1,6 +1,5 @@
package com.r3.developers.csdetemplate;
import net.corda.simulator.HoldingIdentity;
import net.corda.simulator.RequestData;
import net.corda.simulator.SimulatedVirtualNode;