mirror of
https://github.com/corda/corda.git
synced 2025-06-01 15:10:54 +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,64 +12,9 @@ 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
|
||||||
|
|
||||||
@InitiatingFlow
|
|
||||||
public class Initiator extends FlowLogic<String> {
|
|
||||||
private final Party otherSide;
|
|
||||||
|
|
||||||
public Initiator(Party otherSide) {
|
|
||||||
this.otherSide = otherSide;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String call() throws FlowException {
|
|
||||||
return initiateFlow(otherSide).receive(String.class).unwrap((it) -> it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@InitiatedBy(Initiator.class)
|
|
||||||
public class BaseResponder extends FlowLogic<Void> {
|
|
||||||
private FlowSession counterpartySession;
|
|
||||||
|
|
||||||
public BaseResponder(FlowSession counterpartySession) {
|
|
||||||
super();
|
|
||||||
this.counterpartySession = counterpartySession;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Void call() throws FlowException {
|
|
||||||
counterpartySession.send(getMessage());
|
|
||||||
return Void;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected String getMessage() {
|
|
||||||
return "This Is the Legacy Responder";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SubResponder extends BaseResponder {
|
|
||||||
|
|
||||||
public SubResponder(FlowSession counterpartySession) {
|
|
||||||
super(counterpartySession);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getMessage() {
|
|
||||||
return "This is the sub responder";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kotlin
|
|
||||||
~~~~~~
|
|
||||||
|
|
||||||
.. code-block:: kotlin
|
|
||||||
|
|
||||||
@InitiatedBy(Initiator::class)
|
@InitiatedBy(Initiator::class)
|
||||||
open class BaseResponder(internal val otherSideSession: FlowSession) : FlowLogic<Unit>() {
|
open class BaseResponder(internal val otherSideSession: FlowSession) : FlowLogic<Unit>() {
|
||||||
@ -87,8 +32,53 @@ kotlin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.. sourcecode:: java
|
||||||
|
|
||||||
|
@InitiatingFlow
|
||||||
|
public class Initiator extends FlowLogic<String> {
|
||||||
|
private final Party otherSide;
|
||||||
|
|
||||||
|
public Initiator(Party otherSide) {
|
||||||
|
this.otherSide = otherSide;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String call() throws FlowException {
|
||||||
|
return initiateFlow(otherSide).receive(String.class).unwrap((it) -> it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@InitiatedBy(Initiator.class)
|
||||||
|
public class BaseResponder extends FlowLogic<Void> {
|
||||||
|
private FlowSession counterpartySession;
|
||||||
|
|
||||||
|
public BaseResponder(FlowSession counterpartySession) {
|
||||||
|
super();
|
||||||
|
this.counterpartySession = counterpartySession;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void call() throws FlowException {
|
||||||
|
counterpartySession.send(getMessage());
|
||||||
|
return Void;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected String getMessage() {
|
||||||
|
return "This Is the Legacy Responder";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SubResponder extends BaseResponder {
|
||||||
|
public SubResponder(FlowSession counterpartySession) {
|
||||||
|
super(counterpartySession);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getMessage() {
|
||||||
|
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``.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user