In this lesson, you create a Java service that writes trace information to the Unwired Orchestrator log file. Then you use the Java service in the business process service you created in previous tutorials to trace the logic.
Open the Service Development perspective.
Select File|New|Service from the WorkSpace main menu bar.
When the Create a Service wizard appears, select Java Service and click Next.
Select and expand MySybStore_Tutorials/Services/Java to populate the Enter or Select the Parent Folder field.
Enter MyDebugJavaService
in
the File Name field and click Next.
When the Service Summary window opens, click Next.
In the Implementation Type window, select From New Source File (.java) and click Next.
In the Java Class window, enter these values:
Source folder – MySybStore_Tutorials
Package – Services.Java
Name – debugClass
Superclass – java.lang.Object
Select the Inherited Abstract Methods option if it is not selected.
Click Finish.
The new service is created and opens in the Java Service Editor.
Select the Service Interface tab in the service editor.
Create an operation:
In the Java Service Interface diagram, right-click the Interface:debugClass operation box and select Add Operation|Create a New Method from the context menu.
Select the new operation1 method
in the diagram, then in the Properties pane,
enter printMyInt
in the Name field.
Add two parameters:
Select the new printMyInt method in the diagram, and click Add in the Operation Parameters section to add a new parameter to the operation.
In Operation Parameters table,
enter label
in the Name field.
In the Properties pane,
select Input
for the Style,
select Simple Type as the Datatype and
select String from the Data Type drop-down
list.
Select the new printMyInt method again in the Java Service Interface diagram and click Add in the Operation Parameters section to add a second parameter to the operation.
In Operation Parameters,
enter variable
in the Name field.
In the Properties pane
(below Operation Parameters), select Input
for
the Style, select Simple
Type as the Datatype and
select int from the Datatype drop-down
list.
Repeat steps 12 and 13 to create a second operation
called printMyString
to write
a label and the value of a string variable to standard output. Add
two parameters with these values:
Parameter 1:
Name – label
Datatype – Simple Type String
Parameter 2:
Name – variable
Datatype – Simple Type String
Modify the source code of the PrintInt method to carry out the service’s operation:
Select the Source tab in the Java Service Editor.
In the code window, select the line below public
static void printMyInt
that says “// TODO:
Complete method body
”.
Replace this line with the following code:
System.out.println(label); System.out.println(variable);
The method now reads as follows. See the following graphic for reference.
public static void printMyInt(String label, int variable) { System.out.println(label); System.out.println(variable);
Select File|Save from the WorkSpace main menu bar.
Build and deploy the package for MyDebugJavaService._svc_java.
In the WorkSpace Navigator, expand MySybStore_Tutorials/Services/Java, right-click MyDebugJavaService.svc_java, and select Create Sybase Services Package Profile from the context menu.
The new package is created and opens in the Sybase Services Package Profile Editor.
In the WorkSpace Navigator, right-click MyDebugJavaService.svcpkgdef and select Build Package from the context menu. This builds the actual package from the package profile you created earlier in the lesson.
If a message prompts whether you want to overwrite an
existing package file, click Yes to All.
The Console view opens and shows the progress of the operation.
When a message states that the package was successfully created, click OK.
If Unwired Orchestrator is not running, use the Windows taskbar and select Start|Programs|Sybase|Sybase WorkSpace|UO 5.1|Start UO.
In the WorkSpace Navigator, expand MySybStore_Tutorials/Services/Java, right-click MyDebugJavaService.svcpkgdef, and select Deploy Package from the context menu. In the Select Target Server dialog box, choose MyServiceContainer and click OK.
If a message prompts whether you want to overwrite an
existing package file, click Yes to All.
The Console shows the progress of the operation.
When a message states that the deployment was successful, click OK.
Close the Console view by clicking the “X” on the windows title tab.
Select File|Close to close the editor.
When this service runs in the context of the Unwired Orchestrator server, the data is written to the Unwired Orchestrator server log file. By default, this log file is found at %WS_INSTALL_DIR%\DevRuntimes\EAServer\bin\Jaguar.log.