Skip to content

Developing on the service registry

mdutoo edited this page Apr 8, 2013 · 29 revisions

Development environment

Check out the EasySOA repository, do a mvn eclipse:eclipse at the root of the maven projects (in easysoa-registry/), import them all in Eclipse and you're ready to go !

In order to build and deploy the service registry plugins, you can either:

  • Use [Buildr](Development Environment) (recommended). Configure your Nuxeo location thanks to easysoa-distribution/build.yaml, then build and deploy by typing buildr nx_mvn nx_dist from the easysoa-distribution folder.
  • Build them using Maven (mvn clean install from the easysoa-registry folder), them move the easysoa-registry/target contents to your Nuxeo root folder.

About the "nuxeo-ecm" project

This pom project has only been set up to resolve compatibility issues between Nuxeo and Sonatype's M2Eclipse. You should keep this project open in your Eclipse workspace so that M2E refers to this projects pom.xml, and not to the "real one".

If you're having errors in the easysoa-registry-* projects, use M2Eclipse's "Update project configuration" option to update the dependencies references.

Quick reference

Debugging

To debug Nuxeo, in bin/nuxeo.conf uncomment or adapt the following line :

JAVA_OPTS=$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

Then restart the server, connect your debugging environment (ex. Eclipse > Debug configurations... > Remote Application) to said local port (here 8787), and start placing breakpoints. You can switch suspend=n to suspend=y if you want to monitor Nuxeo right from the start (Java will wait for you to connect with Eclipse before to start Nuxeo).

To get the Nuxeo code in Eclipse : if you're using working with the latest (HEAD) EasySOA code, do as Nuxeo says to get the source and you'll then be able to link to it from Eclipse. Otherwise if you're using a released version's source, check in Eclipse Preferences > Maven the "download sources" checkbox.

Testing

To test (with JUnit) Nuxeo developments, there must be a runnning Nuxeo server, or at least part of it. There are several ways :

Embedded Nuxeo using custom Feature annotations

Use a custom JUnit Feature, and annotations to configure an embedded Nuxeo deployment. Available features :

(older, obsolete) Embedded Nuxeo using Nuxeo helpers

Extend org.nuxeo.runtime.test.NXRuntimeTestCase, and use the deployBundle, deployContrib methods & others to configure an embedded Nuxeo deployment. Example : see org.nuxeo.ecm.core.storage.sql.SQLRepositoryTestCase

Full Nuxeo deployment

Write tests that interact remotely with a manually deployed Nuxeo by extending [NotificationTestCase] (https://github.com/easysoa/easysoa-model-demo/blob/master/plugins/easysoa-model-demo-rest/src/test/java/org/easysoa/test/rest/tools/NotificationTestCase.java), or using other remote interaction alternatives as described above.

Developing a new feature

Overview

Developing a new feature for the Service Registry implies one or more of :

  • Enriching the model
  • Displaying it in Nuxeo's JSF interface
  • Developing new services
  • Exposing them as REST using the Nuxeo Web Engine
  • External development using them

Developing custom UI's with web engine

JS FAQ:

  • There is a problem with Nuxeo 5.7 (maybe with earlier versions, not tested ..) and js files. When a script tag is included in a freemarker template in the web engine, Nuxeo returns the the path of the script instead of the script itself when the script name finish with '.js'. A solution, waiting for correction, is to rename the script with the extension '._js'.
  • To use Bootstrap, you have to add a script tag referencing JQuery before referencing the bootstrap.js file. Bootstrap is dependent of JQuery and if the JQuery script is not loaded before the bootstrap script, the bootstrap stuff will not work properly.

Freemarker FAQ:

  • to get a DocumentModel from a Nuxeo ID : see "how to create new objects" below and do service['session'].getDocument(new_f('org.nuxeo.ecm.core.api.IdRef', providerActor)). A better way would be to use customs methods on business adapters (InformationServiceAdapter...).
  • to create new objects (from there) : new_f('org.nuxeo.ecm.core.api.IdRef', providerActor) after having put in the freemarker context "new_f" as new freemarker.template.utility.ObjectConstructor()

Hot reload (for web development...)

As said in Hot reload doc, enable hot deploy & reload (of bundles, Seam & JSF UI, WebEngine...) by setting in nuxeo.conf (or in the Admin center) :

  org.nuxeo.dev=true

This can alternatively be done in Nuxeo Admin Center, or using the Nuxeo Studio Eclipse plugin. More info about hot reload without the plugin here.

Otherwise, also possible :

to reload WebEngine templates, copy their sources in your deployed Nuxeo server, ex. :

  cp -rf easysoa-registry-rest-server/src/main/resources/skin easysoa-registry-marketplace/target/nuxeo-cap-5.7-I20130111_0115-tomcat/nxserver/web/root.war/modules/org.easysoa.registry.rest.server/

then go to the Nuxeo site Admin page and hit "reload". More info about WebEngine hot reload here

Clone this wiki locally