: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.

The `executionPublishing` element specifies that the editing of an object property should be published to registered implementation(s) of link:https://isis.apache.org/refguide/2.0.0-M5/applib-svc/ExecutionSubscriber.html#spi[`ExecutionSubscriber` SPI].

This is performed _after_ the property has been changed.

The publishing from the framework to the SPI is in-memory.
A typical SPI implementation would then publish over the network, or perhaps store in a database.
(Note that the framework provides an link:https://isis.apache.org/mappings/2.0.0-M3/outbox-publisher/about.html[out-of-the-box implementation] of the link:https://microservices.io/patterns/data/transactional-outbox.html[outbox pattern]).

The element can be specified using either the `@Property` annotation, or through a meta-annotation.

NOTE: The demo shows publishing of entities, as this is much more common use case than publishing a view model.


== Annotated

The `executionPublishing` element can be specified explicitly using an annotation through `@Property#executionPublishing()`:

[source,java,indent=0]
----
include::PropertyExecutionPublishingJdo.java[tags=annotation]
----
<.> explicitly specifies that modifying the property should be published.

The annotation could also be applied to a mixin, but would have little effect because mixin properties are always read-only.

== Meta-annotated

The `executionPublishing` element can also be specified using a custom meta-annotation:

* the meta-annotation is defined as:
+
[source,java]
----
include::../PropertyExecutionPublishingEnabledMetaAnnotation.java[tags=class]
----
<.> annotated for a property
<.> annotation can be applied to a property (either its getter or the field directly)

* and can be applied to a property:
+
[source,java,indent=0]
----
include::PropertyExecutionPublishingJdo.java[tags=meta-annotated]
----
<.> semantic is inherited from the meta-annotation



=== Meta-annotated Overridden

The meta-annotation can itself be overridden:

* in a property:
+
[source,java,indent=0]
----
include::PropertyExecutionPublishingJdo.java[tags=meta-annotated-overridden]
----
<.> semantic from meta-annotation ...
<.> \... is overridden by the `@Property` annotation


== ExecutionSubscriber

The demo provides a simple implementation of `PublisherService` that just stores the DTOs in memory:

[source,java]
----
include::spiimpl/PublisherServiceSpiForProperties.java[tags=class]
----
<.> serializes to `InteractionDto`, as defined by the link:https://isis.apache.org/refguide/2.0.0-M3/schema/ixn.html[Apache Isis schema].

The demo implementation also provides a way to query these executions:

[source,java,indent=0]
----
include::spiimpl/PublisherServiceSpiForProperties.java[tags=demo]
----

Supporting mixins surface this list as contributions on the object:

* `interactionExecutions` collection:
+
[source,java,indent=0]
----
include::spiimpl/PropertyPublishingJdo_interactionExecutions.java[tags=class]
----

* `clearInteractionExecutions` action:
+
[source,java,indent=0]
----
include::spiimpl/PropertyPublishingJdo_clearInteractionExecutions.java[tags=class]
----



== Configuration

By default, publishing of property edits is disabled.
This can be configured globally:

[source,yaml]
.application.yml
----
isis:
  applib:
    annotation:
      property:
        publishing: none
----
