Platform Explorer / Nuxeo Platform LTS 2017 9.10

Extension point adapters

Extension Point for registering new document adapters XML extensions may contain any number of 'adapter' elements of the form:

This means any document having the facet 'facet' can be adapted to a 'class' object using the factory 'factory'

The facet attribute is optional and serve to restrict the applicability of the adapter. If no facet is specified the adapter will be applicable on any document.

This is the main extension point for registring Adapters on your Documentmodels

To contribute an adpaters there are 3 simple steps :

  • Create your adapter implemention (you can also have several implementations having the same interface)
  • Create a Factory that will be responsible for creating your adapter object from a DocumentModel
  • Register your Factory, you can bind it to a specific document type or facet

One done you can simply access the adpater via DocumentModel.getAdapter(adapter.class)

Contribution Descriptor

Existing Contributions

  • nuxeo-invite-9.10.jar /OSGI-INF/user-registration-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.user.invite.RegistrationRules" factory="org.nuxeo.ecm.user.invite.RegistrationRulesFactory"/>
      </extension>
  • nuxeo-routing-core-9.10.jar /OSGI-INF/document-routing-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.routing.api.DocumentRoute" factory="org.nuxeo.ecm.platform.routing.core.adapter.DocumentRouteAdapterFactory"/>
        <adapter class="org.nuxeo.ecm.platform.routing.api.DocumentRouteStep" factory="org.nuxeo.ecm.platform.routing.core.adapter.DocumentRouteAdapterFactory"/>
        <adapter class="org.nuxeo.ecm.platform.routing.api.DocumentRouteElement" factory="org.nuxeo.ecm.platform.routing.core.adapter.DocumentRouteAdapterFactory"/>
        <adapter class="org.nuxeo.ecm.platform.routing.api.LockableDocumentRoute" factory="org.nuxeo.ecm.platform.routing.core.adapter.LockableDocumentAdapterFactory"/>
        <adapter class="org.nuxeo.ecm.platform.routing.core.impl.GraphRoute" factory="org.nuxeo.ecm.platform.routing.core.adapter.DocumentRouteAdapterFactory"/>
        <adapter class="org.nuxeo.ecm.platform.routing.core.impl.GraphNode" factory="org.nuxeo.ecm.platform.routing.core.adapter.DocumentRouteAdapterFactory"/>
      </extension>
  • nuxeo-theme-styling-9.10.jar /OSGI-INF/theme-local-configuration.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.theme.localconfiguration.LocalThemeConfig" factory="org.nuxeo.theme.localconfiguration.LocalThemeConfigAdapterFactory"/>
      </extension>
  • nuxeo-core-9.10.jar /OSGI-INF/versioning-document-adapter.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <documentation>
          Defines an adapter for documents having versioning
          info. The adapter
          interface is VersioningDocument and could be
          retrieved in a standard way
          from a document model with
          getAdapter(VersioningDocument.class)
        </documentation>
    
        <adapter class="org.nuxeo.ecm.core.api.facet.VersioningDocument" factory="org.nuxeo.ecm.core.versioning.VersioningDocumentAdapterFactory"/>
      </extension>
  • nuxeo-core-api-9.10.jar /OSGI-INF/blob-holder-adapters-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.core.api.blobholder.BlobHolder" factory="org.nuxeo.ecm.core.api.blobholder.BlobHolderAdapterFactory"/>
      </extension>
  • nuxeo-routing-dm-9.10.jar /OSGI-INF/dm-task-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.routing.dm.adapter.RoutingTask" factory="org.nuxeo.ecm.platform.routing.dm.adapter.RoutingTaskAdapterFactory"/>
        <adapter class="org.nuxeo.ecm.platform.routing.dm.adapter.TaskStep" factory="org.nuxeo.ecm.platform.routing.dm.adapter.TaskStepAdapterFactory"/>
      </extension>
  • nuxeo-diff-content-9.10.jar /OSGI-INF/content-diff-document-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.diff.content.ContentDiffAdapter" factory="org.nuxeo.ecm.diff.content.adapter.ContentDiffDocumentModelAdapterFactory"/>
      </extension>
  • nuxeo-search-ui-9.10.jar /OSGI-INF/search-local-configuration-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.search.ui.localconfiguration.SearchConfiguration" factory="org.nuxeo.search.ui.localconfiguration.SearchConfigurationFactory"/>
    
      </extension>
  • nuxeo-platform-collections-core-9.10.jar /OSGI-INF/collection-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.collections.core.adapter.Collection" factory="org.nuxeo.ecm.collections.core.adapter.CollectionAdapterFactory"/>
        <adapter class="org.nuxeo.ecm.collections.core.adapter.CollectionMember" factory="org.nuxeo.ecm.collections.core.adapter.CollectionMemberAdapterFactory"/>
      </extension>
  • nuxeo-preview-core-9.10.jar /OSGI-INF/document-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.preview.api.HtmlPreviewAdapter" factory="org.nuxeo.ecm.platform.preview.adapter.PreviewDocumentModelAdapterFactory"/>
      </extension>
  • nuxeo-drive-core-9.10.jar /OSGI-INF/nuxeodrive-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.drive.adapter.FileSystemItem" factory="org.nuxeo.drive.adapter.impl.FileSystemItemAdapterFactory"/>
    
      </extension>
  • nuxeo-core-api-9.10.jar /OSGI-INF/thumbnail-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.core.api.thumbnail.ThumbnailAdapter" factory="org.nuxeo.ecm.core.api.thumbnail.ThumbnailAdapterFactory"/>
      </extension>
  • nuxeo-template-rendering-core-9.10.jar /OSGI-INF/adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.template.api.adapters.TemplateBasedDocument" factory="org.nuxeo.template.adapters.TemplateAdapterFactory"/>
    
        <adapter class="org.nuxeo.template.api.adapters.TemplateSourceDocument" factory="org.nuxeo.template.adapters.TemplateAdapterFactory"/>
    
    
      </extension>
  • nuxeo-apidoc-repo-9.10.jar /OSGI-INF/adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.apidoc.api.BundleGroup" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXBundleGroup"/>
        <adapter class="org.nuxeo.apidoc.api.BundleInfo" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXBundle"/>
        <adapter class="org.nuxeo.apidoc.api.ComponentInfo" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXComponent"/>
        <adapter class="org.nuxeo.apidoc.api.ExtensionPointInfo" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXExtensionPoint"/>
        <adapter class="org.nuxeo.apidoc.api.ExtensionInfo" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXContribution"/>
        <adapter class="org.nuxeo.apidoc.api.ServiceInfo" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXService"/>
        <adapter class="org.nuxeo.apidoc.snapshot.DistributionSnapshot" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXDistribution"/>
        <adapter class="org.nuxeo.apidoc.api.DocumentationItem" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXDocumentation"/>
        <adapter class="org.nuxeo.apidoc.api.SeamComponentInfo" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXSeamComponent"/>
        <adapter class="org.nuxeo.apidoc.api.OperationInfo" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXOperation"/>
    
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXBundleGroup"/>
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXBundle"/>
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXComponent"/>
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXExtensionPoint"/>
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXContribution"/>
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXService"/>
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXSeamComponent"/>
        <adapter class="org.nuxeo.apidoc.api.NuxeoArtifact" factory="org.nuxeo.apidoc.adapters.AdapterFactory" type="NXOperation"/>
    
      </extension>
  • nuxeo-platform-usermanager-core-9.10.jar /OSGI-INF/user-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.usermanager.UserAdapter" factory="org.nuxeo.ecm.platform.usermanager.UserAdapterFactory"/>
      </extension>
  • nuxeo-localconf-simple-9.10.jar /OSGI-INF/simple-local-configuration.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.ecm.localconf.SimpleConfiguration" factory="org.nuxeo.ecm.localconf.SimpleConfigurationFactory"/>
    
      </extension>
  • nuxeo-platform-rendition-core-9.10.jar /OSGI-INF/rendition-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.rendition.Renderable" factory="org.nuxeo.ecm.platform.rendition.adapter.RenderableAdapterFactory"/>
      </extension>
  • nuxeo-platform-directory-core-9.10.jar /OSGI-INF/directory-local-configuration.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.directory.localconfiguration.DirectoryConfiguration" factory="org.nuxeo.ecm.directory.localconfiguration.DirectoryConfigurationFactory"/>
      </extension>
  • nuxeo-platform-3d-core-9.10.jar /OSGI-INF/adapters-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.threed.ThreeDDocument" factory="org.nuxeo.ecm.platform.threed.adapter.ThreeDDocumentAdapterFactory"/>
      </extension>
  • nuxeo-platform-task-core-9.10.jar /OSGI-INF/task-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.ecm.platform.task.Task" factory="org.nuxeo.ecm.platform.task.TaskAdapterFactory"/>
    
      </extension>
  • nuxeo-platform-imaging-api-9.10.jar /OSGI-INF/picture-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.picture.api.adapters.MultiviewPicture" factory="org.nuxeo.ecm.platform.picture.api.adapters.MultiviewPictureAdapterFactory"/>
    
        <adapter class="org.nuxeo.ecm.platform.picture.api.adapters.PictureResourceAdapter" factory="org.nuxeo.ecm.platform.picture.api.adapters.PictureResourceAdapterFactory"/>
      </extension>
  • nuxeo-platform-notification-core-9.10.jar /OSGI-INF/adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.ecm.platform.ec.notification.SubscriptionAdapter" factory="org.nuxeo.ecm.platform.ec.notification.SubscriptionAdapterFactory"/>
    
      </extension>
  • nuxeo-search-core-9.10.jar /OSGI-INF/savedsearch-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
    
        <adapter class="org.nuxeo.ecm.platform.search.core.SavedSearch" factory="org.nuxeo.ecm.platform.search.core.SavedSearchAdapterFactory"/>
    
      </extension>
  • nuxeo-platform-comment-api-9.10.jar /OSGI-INF/CommentableAdapter.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.comment.api.CommentableDocument" factory="org.nuxeo.ecm.platform.comment.impl.CommentableAdapterFactory"/>
      </extension>
  • nuxeo-platform-types-core-9.10.jar /OSGI-INF/contentview-local-configuration.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.types.localconfiguration.ContentViewConfiguration" factory="org.nuxeo.ecm.platform.types.localconfiguration.ContentViewConfigurationFactory"/>
      </extension>
  • nuxeo-platform-types-api-9.10.jar /OSGI-INF/nxtypes-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <documentation>
          Register the adapter for TypeInfo on DocumentModel
        </documentation>
        <adapter class="org.nuxeo.ecm.platform.types.adapter.TypeInfo" factory="org.nuxeo.ecm.platform.types.adapter.TypeInfoAdapterFactory"/>
      </extension>
  • nuxeo-platform-types-core-9.10.jar /OSGI-INF/ui-types-local-configuration.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
           <adapter class="org.nuxeo.ecm.platform.types.localconfiguration.UITypesConfiguration" factory="org.nuxeo.ecm.platform.types.localconfiguration.UITypesConfigurationFactory"/>
      </extension>
  • nuxeo-platform-video-core-9.10.jar /OSGI-INF/adapters-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
         <adapter class="org.nuxeo.ecm.platform.video.VideoDocument" factory="org.nuxeo.ecm.platform.video.adapter.VideoDocumentAdapterFactory"/>
      </extension>
  • nuxeo-platform-imaging-tiling-9.10.jar /OSGI-INF/pictures-tiles-adapter-contrib.xml
    <extension point="adapters" target="org.nuxeo.ecm.core.api.DocumentAdapterService">
        <adapter class="org.nuxeo.ecm.platform.pictures.tiles.api.adapter.PictureTilesAdapter" factory="org.nuxeo.ecm.platform.pictures.tiles.api.adapter.PictureTilesAdapterFactory"/>
      </extension>

Additional documentation

Code Sample   How To  
adpater Extension Point

This is the main extension point for registring Adapters on your Documentmodels

To contribute an adpaters there are 3 simple steps :

  • Create your adapter implemention (you can also have several implementations having the same interface)
  • Create a Factory that will be responsible for creating your adapter object from a DocumentModel
  • Register your Factory, you can bind it to a specific document type or facet

One done you can simply access the adpater via DocumentModel.getAdapter(adapter.class)

Coding the adapter Factory

For the Factory you need to implement org.nuxeo.ecm.core.api.adapter.DocumentAdapterFactory.

The implementation can be trivial and simply delagate the work to the constructor of the adpater class, or it can contains some filtering logic (based on the life-cycle of the DocumentModel, on schemas).

The factory can also choose the right implementation of the adpater depending on the schemas provided by the input DocumentModel.

Coding an Adapter

The first step is to create simple java class.

There is no required interface to implement, but it’s usually useful to add a method that allows to get the adpated DocumentModel from the adpater.

Register you adapter

Once you have created both the adapter and the factory you need to register them.

For that you will need to have :

  • the class or interface that will be used for the adapter
  • the class for the factory
  • the facet you want to use to filter document that can be adpated (optionnal)

Then you simply have to do an XML contribution to the adapter extension point.