In the following example, we will use the Component Library feature to include a developed component that uses an external API.
For more information about this possibility, refer back to the main article.
What you need to do in Bizagi
To use the Component library feature, these steps are carried out:
1. Building your component (a compiled output).
2. Registering the component in Bizagi.
3. Creating the business rule which invokes the component.
When developing a component for the JEE edition, you need to ensure that this component is compiled under the supported framework used by Bizagi (the same version or a lower one).
In Bizagi 11.x versions, the framework used by the JEE solution is JDK 7.
In addition to this, if your component invokes a SOAP Web service, make sure that your JEE Application Server supports the standard under which that Web service was built.
Otherwise, additional configuration steps may be required at the server if it relies on a different library or framework to run specific components (such as when generating a proxy for Web services, in which cases a server may use a different SOAP compliance).
We will illustrate this through a sample Credit Request Process.
Notice that this is a simplified example, in which we will validate that the Applicant is not reported in a central Black List in the service task called “Verify Blacklist”.
In this service task, we will create a business rules that accesses our developed component to make use of that given API. Through this API, we invoke a method that returns whether or not the applicant's id is listed in the Blacklist (true or false).
We will illustrate how to use the Component library feature for an JEE project.
Build your component (a compiled output)
Our first step is to develop the component as a Java class library project.
In our sample component called “MyCreditBureauComponent”, we make use of a “CreditBureau.jar”, which represent an example API.
We include the .jar into our project library.
For the JEE edition, we build the class library project as a jar file.
Notice that our package name is called com.creditbcomponent, and notice that our Class is public (called “Class1”). The method we will use in this example is called “IsCustomerInBlackList”.
It is very important that the developed component does not include the API within the output file.
Even though it references the API, it should not build an output containing it.
Registering the component in Bizagi
Having built the component’s jar file in our previous step, we will use this output (“MyCreditBureauComponent.jar”) to register the component in Bizagi's component library.
To do this, we go to Bizagi Studio’s Tools and add a new component:
Find the .jar file and then click on open, we upload the MyCreditBureauComponent.jar assembly:
Once the component is added, give a Display name and a Description.
Given that this component references and uses another jar library (the API), we need to register and include this API into our component library as well.
Therefore, we repeat the steps to add a component, but this time we do it for the CreditBureau.jar reference.
For our CreditBureau API, we enter the required information and upload the corresponding jar file:
Click on Ok.
In this example, no additional configuration is required mainly because our CreditBureau.jar API does not use any other additional jar files and because this API is not already included in JBoss.
There are some considerations (specially in JBoss) for the components configurations when either of the previous scenarios is present which are described at Special considerations with components.
In the end, we need to have registered our 2 jars as 2 separate components:
Creating the business rule which invokes the component
Now that we have registered our component in the Component library, we proceed to create a business rule which invokes the component’s method.
For the sake of simplicity, the following example shows how to call this component from directly within a business rule.
However, as a best practice in terms of maintainability of your solution, it is recommended to create a global rule (a library rule) that receives input parameters, invokes the component and returns output parameters.
This way, business rules call this global rule, and you have a single point in Bizagi coupled to your component.
Members of your team working on the same project just need to know which global rule to use.
For more information about global rules (library rules), refer to Reusing business rules.
To do this, we go to the Activity Actions view from our Process wizard, and select the “Verify black list” service task. We include a business rule in this point in the Process:
In the expression, we invoke our MyCreditBureauComponent’s method with the following syntax:
Notice that our Class is not defined as a static class, and therefore we can previously create an instance of it, to invoke its methods. In our example, the complete expression invokes the IsCustomerInBlackList method by:
•Sending out the Applicant’s id.
•Storing the method’s result in the CreditRequest.InBlackList Boolean-type attribute.
This is the expression’s content:
var temp = new Class1();
When saving the business rule invoking a Component's method (as in this example), the rule will be saved with warnings and errors shown in Bizagi's compilation. For this case, these messages can be ignored (it will work Ok on execution).
At this point, we are set using a custom developed component with the Component library feature in Bizagi!.
To see this example working, we execute our Process in Bizagi's Work Portal by clicking in the “Run Process” option:
We can see that after the “Verify black list” service task, our next Activity will show the result of our component’s method invocation:
If you wish to enable the development's debug mode, then you will need to edit the console-configuration properties file for the JEE Console Manager (found by default as C:\BizagiJEE\BizagiConsoleManagerJEE\config\console-configuration.properties).
Make sure it includes this line:
Keep in mind the following:
2. JBoss service is started by Bizagi as a javax.exe process, in which you may see its executed command line having the environment variables set and used by Bizagi: