mirror of
https://github.com/corda/corda.git
synced 2025-05-31 06:31:08 +00:00
[CORDA-2408]: Formatting on Flow Overriding page wrong - code not rendering correctly (fixed). (#4533)
This commit is contained in:
parent
d33cb16c5e
commit
dd6a007ff2
@ -12,10 +12,27 @@ Subclassing a Flow
|
|||||||
If you have a workflow which is mostly common, but also requires slight alterations in specific situations, most developers would be familiar
|
If you have a workflow which is mostly common, but also requires slight alterations in specific situations, most developers would be familiar
|
||||||
with refactoring into `Base` and `Sub` classes. A simple example is shown below.
|
with refactoring into `Base` and `Sub` classes. A simple example is shown below.
|
||||||
|
|
||||||
java
|
.. container:: codeset
|
||||||
~~~~
|
|
||||||
|
|
||||||
.. code-block:: java
|
.. sourcecode:: kotlin
|
||||||
|
|
||||||
|
@InitiatedBy(Initiator::class)
|
||||||
|
open class BaseResponder(internal val otherSideSession: FlowSession) : FlowLogic<Unit>() {
|
||||||
|
@Suspendable
|
||||||
|
override fun call() {
|
||||||
|
otherSideSession.send(getMessage())
|
||||||
|
}
|
||||||
|
protected open fun getMessage() = "This Is the Legacy Responder"
|
||||||
|
}
|
||||||
|
|
||||||
|
@InitiatedBy(Initiator::class)
|
||||||
|
class SubResponder(otherSideSession: FlowSession) : BaseResponder(otherSideSession) {
|
||||||
|
override fun getMessage(): String {
|
||||||
|
return "This is the sub responder"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.. sourcecode:: java
|
||||||
|
|
||||||
@InitiatingFlow
|
@InitiatingFlow
|
||||||
public class Initiator extends FlowLogic<String> {
|
public class Initiator extends FlowLogic<String> {
|
||||||
@ -53,7 +70,6 @@ java
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class SubResponder extends BaseResponder {
|
public class SubResponder extends BaseResponder {
|
||||||
|
|
||||||
public SubResponder(FlowSession counterpartySession) {
|
public SubResponder(FlowSession counterpartySession) {
|
||||||
super(counterpartySession);
|
super(counterpartySession);
|
||||||
}
|
}
|
||||||
@ -65,32 +81,6 @@ java
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kotlin
|
|
||||||
~~~~~~
|
|
||||||
|
|
||||||
.. code-block:: kotlin
|
|
||||||
|
|
||||||
@InitiatedBy(Initiator::class)
|
|
||||||
open class BaseResponder(internal val otherSideSession: FlowSession) : FlowLogic<Unit>() {
|
|
||||||
@Suspendable
|
|
||||||
override fun call() {
|
|
||||||
otherSideSession.send(getMessage())
|
|
||||||
}
|
|
||||||
protected open fun getMessage() = "This Is the Legacy Responder"
|
|
||||||
}
|
|
||||||
|
|
||||||
@InitiatedBy(Initiator::class)
|
|
||||||
class SubResponder(otherSideSession: FlowSession) : BaseResponder(otherSideSession) {
|
|
||||||
override fun getMessage(): String {
|
|
||||||
return "This is the sub responder"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Corda would detect that both ``BaseResponder`` and ``SubResponder`` are configured for responding to ``Initiator``.
|
Corda would detect that both ``BaseResponder`` and ``SubResponder`` are configured for responding to ``Initiator``.
|
||||||
Corda will then calculate the hops to ``FlowLogic`` and select the implementation which is furthest distance, ie: the most subclassed implementation.
|
Corda will then calculate the hops to ``FlowLogic`` and select the implementation which is furthest distance, ie: the most subclassed implementation.
|
||||||
In the above example, ``SubResponder`` would be selected as the default responder for ``Initiator``
|
In the above example, ``SubResponder`` would be selected as the default responder for ``Initiator``
|
||||||
|
Loading…
x
Reference in New Issue
Block a user