This documentation relates to an old version of the Nuxeo Platform (5.5). You may want to check the latest technical documentation.
Skip to end of metadata
Go to start of metadata

Services and AMF

GraniteDS allows to expose different types of services, and you can use the GraniteDS configuration files to do so.
However, the Nuxeo Flex Connector contains a dedicated Component that is used to configure GraniteDS via the extension point system so that you don't have to update the GraniteDS configuration file.

You can use Nuxeo Platform Explorer to get more details about:

Using Nuxeo Runtime services

All the features of the Nuxeo platform are exposed as Services. You can access these services via the Flex Connector. For that you need to declare what services need to be available via AMF remoting.

Here is a simple example for exposing the SchemaManager service as a remotable:

  • class defines the service interface to be exposed,
  • id defines the name that will be used on the client side.

On the client side, you will use the services-config.xml to declare the remote service:

Using Seam beans

Although you can access to Nuxeo Runtime services, it make sense to use Seam beans:

  • because you may want to manage some states on the server side: Seam Context management is easy;
  • because you want Nuxeo to expose custom services that contains logic specific for your UI (having Seam beans as Controlers for your Flex UI);
  • because you want to reuse existing Nuxeo Seam Beans.

In order to make a Seam Bean accessible remotely from the Flex side you need to:

  1. declare the bean in the services extension point of NxGraniteConfigService,
  2. annotate the methods you want to call with Seam @WebRemote annotation.

Here is a simple example for exposing the 2 Seam beans as a remotable:

  • id is the name of the service on the client side;
  • source is the name of the Seam Component (defaults to id if unset).

On the client side, you will use the services-config.xml to declare the remote service:

Type Mapping and Marshaling

DocumenModel vs FlexDocumentModel

GraniteDS provides a simple and transparent mapping between Java Object and ActionScript objects. But this basic mapping only transfers the data and uses a simple one to one property mapping.

In some cases, this is not enough because you need a better control on the Marshaling.
For accessing Nuxeo services (Seam Bean or Runtime Service), we have this requirement for transmitting Documents (DocumentModel) over the wire between Flex and Java sides:

  • because a DocumentModel is a big object;
  • because you want to be able to update the Document on the client side: so you need methods;
  • because you want to be able to detect on the server side what part of the Document have been changed;
  • because you don't want Blobs to be sent as part of the Documents.

For this we have used GraniteDS Externalizer and InvocationListener to provide a mapping between the Java DocumentModel and an ActionScript FlexDocumentModel.
We also added support so that DocumentRef are serialized as Action Scripts strings.

Thanks to this mapping you can very easily call the existing Nuxeo services on most of the methods.

So for example:

Java signatures
ActionScript signatures

Advanced Marshaling

If for some custom objects you need more than what is provided by default in the Nuxeo Flex Connector, you can leverage GraniteDS to define some custom Marshaling.

  • Externalizer
    If you want to use Nuxeo API, you will need a mapping between Java Object and Action Script Object. GraniteDS provides a pluggable externalizer for your different Object. It aims to (de)serialize the different fields of your objects. For more information, see GraniteDS documentation.
  • InvocationListener
    You might need more control on mapping. For instance, the DocumentModel object in Nuxeo is rather complicated. So we have a FlexDocumentModel object which is a simplified version of DocumentModel. The mapping between those two Java objects is done in the NuxeoInvocationListener. It listens to each service invocation method call. Then we can switch from FlexDocumentModel to DocumentModel or the other way around. For more information on InvocationListener, see GraniteDS documentation.
Labels
  • None