. . .

Migrate from JAR-based modules to Git-based modules

Before ApiOmat version 2.1.0 there was only the possibility to create JAR-based Native Modules. Since then the possibility to create Git-based Native Modules was added.

These Git-based modules have some advantages:

  • They're easier to maintain

  • As with every Git repository it's much easier to work on it with multiple developers at the same time

  • The performance when working with references is higher

  • You can use constructors when creating new objects

So if you already have some existing modules that are currently still JAR-based you might want to change them to the new format.

To change/update the module from JAR to Git there are a few steps to follow:

1) Download the current version of the JAR-based Native Module with the Ant script (build.xml) or cURL


cURL
curl -X GET %URL%/yambas/rest/modules/%YOUR_MODULENAME%/sdk -u %AUTH% > %YOUR_MODULENAME%.zip

2) Delete the chosen Native Module in yambas using the ApiOmat Dashboard or cURL

images/download/attachments/10715398/DeleteModule.jpg

cURL
curl -X DELETE %URL%/yambas/rest/modules/%YOUR_MODULENAME%/sdk -u %AUTH% > %YOUR_MODULENAME%.zip

3) Create a new Git repository and paste the downloaded Data into it. You can include the whole old module code.

4) Create the new native module in the Dashboard and choose the Git-based option. Fill in the needed information and the URL for the repository.

images/wiki.apiomat.com/download/attachments/7831695/image2016-5-25-13_39_16.png

The Git URL for cloning the repository looks like the following:

You can also create a Git-based Native Module via request to the REST endpoint /modules/{moduleName}/gitinit. See https://apiomat.yourcompany.com/apidocs/index.html#!/modules/initNativeModuleGit.

For more information about creating Git Native Modules, see Creating a new module via Git.

5) Change the Native Module's code

The Native Module is now Git-based and should work right away, but you might want to take advantage of its feature to use constructors when creating new objects.

To do so, delete the old project in your IDE and import the new one from the Git repository (for more information see Download / Checkout and Import).

Former code when using JAR-based Native Modules

When using JAR-based Native Modules, you have to create objects of arbitrary types with the createObject method:

MyModule.AOM.createObject( String appName, String moduleName, String className, Request r );

The return value is of type IModel<?> and needs to be cast to the type you're creating.

Example:


User user = (User) MyModule.AOM.createObject(appName, "Basics", "User", r);
user.setUserName("joe");
user.setPassword("123456");
user.save();

New code when using Git-based Native Modules

When using Git-based Native Modules, you can create objects with the createObject method as well, but also use constructors.

Example:


User user = new User();
user.setUserName("joe");
user.setPassword("123456");
user.save();

6) Finally make a Git push and then pull the data with the button in the ApiOmat Dashboard. The Git-based Native Module should work properly now.

* link only available in Enterprise Documentation