= Mixees and Mixins

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


This section defines a number of "mixee" interfaces that define a contract for some framework-defined mixins.

[TIP]
====
See the xref:userguide:fun:overview.adoc#mixins[user guide] for a discussion of mixins.
====


[#java-lang-object]
== java.lang.Object

The framework provides a number of mixins that contributes to `java.lang.Object` (in other words, to every domain object):

* Layout
** xref:refguide:applib:index/mixins/layout/Object_downloadLayoutXml.adoc[Object_downloadLayoutXml]

* Metamodel
** xref:refguide:applib:index/mixins/metamodel/Object_downloadMetamodelXml.adoc[Object_downloadMetamodelXml]
** xref:refguide:applib:index/mixins/metamodel/Object_rebuildMetamodel.adoc[Object_rebuildMetamodel]
** xref:refguide:applib:index/mixins/metamodel/Object_logicalTypeName.adoc[Object_logicalTypeName] (property)
** xref:refguide:applib:index/mixins/metamodel/Object_objectIdentifier.adoc[Object_objectIdentifier] (property)

* Wicket viewer:
** xref:refguide:viewer:index/wicket/viewer/mixins/Object_clearHints.adoc[Object_clearHints]

* All viewers:
** xref:refguide:viewer:index/common/applib/mixins/Object_impersonate.adoc[Object_impersonate]
** xref:refguide:viewer:index/common/applib/mixins/Object_impersonateWithRoles.adoc[Object_impersonateWithRoles]
** xref:refguide:applib:index/mixins/rest/Object_openRestApi.adoc[Object_openRestApi]





[[Dto]]
== Dto

JAXB view models can optionally implement the xref:refguide:applib:index/mixins/dto/Dto.adoc[Dto] interface.
Two mixins contribute to this interface:

* xref:refguide:applib:index/mixins/dto/Dto_downloadXml.adoc[Dto_downloadXml]
* xref:refguide:applib:index/mixins/dto/Dto_downloadXsd.adoc[Dto_downloadXsd]

These allow the view model/DTO to be seriailized, respectively, as XML and as the XSD schema for said XML.


[[Persistable]]
== Persistable


All JDO domain entities implement the DataNucleus `Persistable` role interface as a result of the enhancer process (the fully qualified class name is `org.datanucleus.enhancement.Persistable`).

Using this, the following mixins (actions and properties) are available for all JDO entities:

* xref:refguide:persistence:index/jdo/datanucleus/mixins/Persistable_downloadJdoMetadata.adoc[Persistable_downloadJdoMetadata]

* xref:refguide:persistence:index/jdo/datanucleus/mixins/Persistable_datanucleusVersionLong.adoc[Persistable_datanucleusVersionLong] (property)
+
only visible if the entity is annotated with `javax.jdo.annotations.Version` and the `version` field introduced by enhancing can be cast to `Long`.

* xref:refguide:persistence:index/jdo/datanucleus/mixins/Persistable_datanucleusVersionTimestamp.adoc[Persistable_datanucleusVersionTimestamp] (property)
+
only visible if the entity is annotated with `javax.jdo.annotations.Version` and the `version` field introduced by enhancing can be cast to `java.sql.Timestamp`.

As a developer you do not need to write any code to obtain the mixins that contribute to this interface.

These mixin properties/actions are all associated with the "Metadata" fieldset.


== Security

Domain objects that are created, updated or otherwise associated with a user can implement the xref:refguide:applib:index/mixins/security/HasUsername.adoc[HasUsername] mixee interface.

A number of extension modules related to security, such as xref:security:secman:about.adoc[SecMan] module, contribute to this interface.


== System

Domain objects that are associated to an xref:refguide:applib:index/services/iactn/Interaction.adoc[Interaction] can express this relationship by implementing the xref:refguide:applib:index/mixins/system/HasInteractionId.adoc[HasInteractionId] interface.

Mixins that contribute to this mixee interface include:

* from the xref:userguide:commandlog:about.adoc[Command Log] extension:

** xref:refguide:extensions:index/commandlog/applib/contributions/Object_recentCommands.adoc[Object_recentCommands]
** xref:refguide:extensions:index/commandlog/applib/contributions/HasInteractionId_commandLogEntry.adoc[HasInteraction_commandLogEntry]
** xref:refguide:extensions:index/commandlog/applib/contributions/HasUsername_recentCommandsByUser.adoc[HasUsername_recentCommandsByUser]


* from the xref:userguide:executionlog:about.adoc[Execution Log] extension:

** xref:refguide:extensions:index/executionlog/applib/contributions/Object_recentExecutions.adoc[Object_recentExecutions]
** xref:refguide:extensions:index/executionlog/applib/contributions/HasInteractionId_executionLogEntries.adoc[HasInteractionId_executionLogEntries]

The closely related  xref:refguide:applib:index/mixins/system/HasInteractionIdAndSequence.adoc[HasInteractionIdAndSequence] (a subtype of xref:refguide:applib:index/mixins/system/HasInteractionId.adoc[HasInteractionId]) can be implemented by any objects representing events that could occur multiple times within within the outer xref:refguide:applib:index/services/iactn/Interaction.adoc[Interaction], most notably transactions..

The xref:refguide:applib:index/services/bookmark/HasTarget.adoc[HasTarget] is intended for domain objects representing commands, audit entries or executions (of action invocations/property edits).
Extension modules that provide these capabilities can implement this domain object to allow the user to navigate between these different but related cross-cutting concerns.

Mixins that contribute to this mixee interface include:

** xref:refguide:applib:index/mixins/system/HasTarget_openTargetObject.adoc[HasTarget_openTargetObject]
+
(provided by the core framework)




== Updates

The following interfaces define a contract for the framework to update:

* xref:refguide:applib:index/mixins/updates/OnUpdatedAt.adoc[OnUpdatedAt]
+
For domain entities that keep track of when they were last updated.

* xref:refguide:applib:index/mixins/updates/OnUpdatedBy.adoc[OnUpdatedBy]
+
For domain entities that keep track of which user last updated them.

* xref:refguide:applib:index/mixins/updates/OnUpdatedByAndAt.adoc[OnUpdatedByAndAt]
+
Simply a combination of xref:refguide:applib:index/mixins/updates/OnUpdatedAt.adoc[OnUpdatedAt] and xref:refguide:applib:index/mixins/updates/OnUpdatedBy.adoc[OnUpdatedBy]

Note that these are not quite the same thing as regular mixee interfaces, in that they do not expose getters to be leveraged by a mixin.
Rather, these expose callback such that the framework can populate them at the appropriate juncture.
