Multiple implementations and stubs

XINS can support multiple implementations for the same API. To add a new implementation for the API add in the xins-projects.xml an impl element with a name attribute to the api. For example

<project name="myprojects"
         domain="com.mycompany">
  <api name="allinone">
    <impl />
    <impl name="mystub" />
  </api>
</project>

New targets are created for this implementation. Only server side targets (war, javadoc-api, run, ...) are created for this new implementation. The other targets only depend on the specification which doesn't change. The new target syntax is <action>-<api name>-<implementation name>. For example to compile the new implementation of the example above execute xins classes-allinone-mystub.

Note

The list of the API names with the possible implementation is printed at the end of the execution of the xins help command.

Having the possibility to have more than one implementation is useful when you want to create a stub (fake API) so that other systems can test the API before being implemented.

XINS offers the possibility to generate a stub implementation of the API. The stub is generated based on the examples defined in the function specification.

To generate the stub implementation execute xins stub-<api name>-<implementation name>. Then the stub file are generated in the directory apis\<api name>\impl-<implementation name>\<package name>. You can also edit the generated code, for example to be more flexible with some input parameters or to return other values. Note that the stub target won't replace existing files.