Creating Your First Service
Creating Your First Service
Creating your own services is not difficult. Here are the necessary steps:
- Create service Java class.
- Add workflow rule definition to the database.
- Create a view to call the new workflow rule.
As an exercise, let's create a simple service.
Step 1: Create service Java class
-
Select the
com.archibus.app.solution.logiccookbook
package in the Package Explorer window.
-
Right-click on the package name and select
New --> Other
menu item:
-
Select
Java --> Class
and click on the
Next
button:
-
Type "MyTestService" in the
Name
field, and click on the
Finish
button:
-
Eclipse will open the MyTestService.java in the editor:
-
Add a new method that returns an information message to the view:
-
Press CTRL+S to save the file.
Step 2: Add workflow rule definition to the database
Note: You only need to add new workflow rule definitions to the database when you create a new event-handler class. You can create additional event-handler methods in the same class later without adding workflow rule definitions to the database.
-
Start the application server.
-
Select
System Administration --> Add-In Manager--> Workflow Rules
task.
-
Select
AbSolutionsLogicAddIns
application.
-
Click on the
Add New
button in the
Workfow Rules
grid panel.
-
Enter the following values in the
Workflow Rule
form:
- Active? : Yes
- Rule Name : MyTestService
-
Rule Class
:com.archibus.app.solution.logiccookbook.MyTestService
-
Click on the
Save
button.
- Restart the application server to load the new workflow rule definition.
Step 3: Create a view to call the new workflow rule
- Select the schema\ab-products\solutions\logic-cookbook folder in the Package Explorer window.
-
Right click and select
New --> File
menu item:
-
Type the view name (ab-my-test.axvw) and click on the
Finish
button:
-
Eclipse will open the view file in the editor. Add the following text to the view file:
- Navigate to the test view: http://localhost:8080/archibus/schema/ab-products/solutions/logic-cookbook/ab-my-test.axvw .
-
Click on the
Test
button. The service result will be displayed: