= CommandExecutorService
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Provides a mechanism to execute a xref:refguide:applib:index/services/command/Command.adoc[Command] .

== API

[source,java]
.CommandExecutorService.java
----
interface CommandExecutorService {
  Try<Bookmark> executeCommand(InteractionContextPolicy interactionContextPolicy, Command command)     // <.>
  Try<Bookmark> executeCommand(InteractionContextPolicy interactionContextPolicy, CommandDto commandDto)     // <.>
  Try<Bookmark> executeCommand(Command command)     // <.>
  Try<Bookmark> executeCommand(CommandDto commandDto)     // <.>
}
----

<.> xref:#executeCommand_InteractionContextPolicy_Command[executeCommand(InteractionContextPolicy, Command)]
+
--
Executes the specified xref:refguide:applib:index/services/command/Command.adoc[Command] using the required _InteractionContextPolicy_ , updating the Command (or its persistent equivalent) afterwards (for example, setting its _Command#getCommandDto() commandDto_ field.
--
<.> xref:#executeCommand_InteractionContextPolicy_CommandDto[executeCommand(InteractionContextPolicy, CommandDto)]
+
--
Executes the specified command (represented as a _CommandDto_ using the required _InteractionContextPolicy_ .
--
<.> xref:#executeCommand_Command[executeCommand(Command)]
+
--
As per _#executeCommand(InteractionContextPolicy, Command)_ , with a policy of _InteractionContextPolicy#NO_SWITCH no switch_ .
--
<.> xref:#executeCommand_CommandDto[executeCommand(CommandDto)]
+
--
As per _#executeCommand(InteractionContextPolicy, CommandDto)_ , with a policy of _InteractionContextPolicy#NO_SWITCH no switch_ .
--

== Members

[#executeCommand_InteractionContextPolicy_Command]
=== executeCommand(InteractionContextPolicy, Command)

Executes the specified xref:refguide:applib:index/services/command/Command.adoc[Command] using the required _InteractionContextPolicy_ , updating the Command (or its persistent equivalent) afterwards (for example, setting its _Command#getCommandDto() commandDto_ field.

[#executeCommand_InteractionContextPolicy_CommandDto]
=== executeCommand(InteractionContextPolicy, CommandDto)

Executes the specified command (represented as a _CommandDto_ using the required _InteractionContextPolicy_ .

IMPORTANT: THIS METHOD HAS SIGNIFICANT SIDE-EFFECTS. Specifically, the xref:refguide:applib:index/services/command/Command.adoc[Command] of the executing thread (obtained using _org.apache.causeway.applib.services.iactn.InteractionProvider_ to obtain the xref:refguide:applib:index/services/iactn/Interaction.adoc[Interaction] , and then _Interaction#getCommand()_ to obtain the xref:refguide:applib:index/services/command/Command.adoc[Command] ) will be UPDATED to hold the _CommandDto_ passed in.

[#executeCommand_Command]
=== executeCommand(Command)

As per _#executeCommand(InteractionContextPolicy, Command)_ , with a policy of _InteractionContextPolicy#NO_SWITCH no switch_ .

Note that this method updates the Command as a side-effect.

[#executeCommand_CommandDto]
=== executeCommand(CommandDto)

As per _#executeCommand(InteractionContextPolicy, CommandDto)_ , with a policy of _InteractionContextPolicy#NO_SWITCH no switch_ .

IMPORTANT: THIS METHOD HAS SIGNIFICANT SIDE-EFFECTS. Specifically, the xref:refguide:applib:index/services/command/Command.adoc[Command] of the executing thread (obtained using _org.apache.causeway.applib.services.iactn.InteractionProvider_ to obtain the xref:refguide:applib:index/services/iactn/Interaction.adoc[Interaction] , and then _Interaction#getCommand()_ to obtain the xref:refguide:applib:index/services/command/Command.adoc[Command] ) will be UPDATED to hold the _CommandDto_ passed in.

include::hooks/CommandExecutorService_010-implementation.adoc[]

include::hooks/CommandExecutorService_020-examples-and-usage.adoc[]
