Software Engineering

Custom Maven Plugin for BAM 12c

The newest version of BAM, BAM 12c, delivers some new components that didn’t exist in the previous version. Apart of the Business Objects and the Dashboards, there are now new elements like Business Queries and Logical Views. All these components can be exported and imported into new environments by using bamcommand, a standalone shell script that executes different administrative tasks based on the input arguments. Nevertheless, keeping various environments synchronised with several developers working in parallel can be very tricky. In those cases, integrating the BAM artifacts to a (existing) continuous integration system and a version control system may be desirable; automatised builds and version control of BAM artifacts are in some cases more than “nice to have” features. In this blog we are going to explain how to create a Maven Plugin to import and export these BAM artifacts.

The first thing to do is to generate a Maven Plugin Project. The “archetype:generate” command from maven creates the required elements and folder structure. For our plugin we are going to use it in the following way:

A directory named bam-deployment will be created and it will contain a basis folder structure within. It will also generate a basic pom, with some minor configurations and an “it” folder under “src” that contains some components to test the plugin. This „it“ folder can be deleted. The next step is to upload the required libraries into the maven repository and to declare them in the pom.xml as dependencies:

The BAM libraries can be found under <MIDDLEWARE_HOME>/soa/bam/lib.

Before implementing the plugin it is important to analyse how the actual bamcommand works. Oracle recommends having a BAM installation in the system that is going to run the command, but a quick look into the script shows that a class called oracle.beam.impexp.commandline.util ImportExportClient coordinates the whole process. This class has a main method that takes command line arguments and passes them to another method called execute. A first attempt would be to call this method from the ImportExportClient, but unfortunately it doesn’t allow the password to be sent as an argument. The bamcommand script also allows the definition of a configuration file called BAMCommandConfig.xml where parameters such as host, username and password are defined, but this alternative cannot be used in this scenario either; the ImportExportClient searches for the BAMCommandConfig.xml inside a directory called bin relative to the location of the its libraries, and in our plugin, those libraries are going to be placed inside the maven repository.

The solution is to invoke the method “process” from the ImportExportClient. It has only one argument and it is an instance of the class Options, which is only a container of Option instances. The plugin will have two classes, one for importing and one for exporting, and each one of this is going create an Options instance with the corresponding parameters.

The Import (or the Export) class can be divided into three parts. The first part declares the command line arguments that can be used for importing BAM artifacts. The second part is the building of the Options instance in order to pass it to the ImportExportClient and the third part is the invocation itself.

The above method -“execute”- references a custom class called BamImportExportClient.

The export class is similar. The only difference resides in the arguments it takes:

A good design for this plugin would define an abstract class that would contain the common code of the import and export classes.

The plugin can now be installed in the maven repository:

This plugin can be used in the same way as any other plugin. Here is a sample pom that uses the plugin:

This pom can extended with another maven plugin that extract the exported zip file in order to add the artifacts to a version control. The plugin is called twice because exporting BAM projects and enterprise messages differs in the arguments that can be used; therefore it is recommended to export this components separately. On the other hand, the import can contain both projects and enterprises messages, so all theses artifacts can be packed in one single zip file and imported at once.