This tutorial walks you through the steps for developing application code using the Symphony plug-in for the Eclipse IDE. It then guides you through the process of building, packaging, and deploying the associated service. This tutorial was prepared for users that are already familiar with the Eclipse IDE.
For instructions on installing the Symphony plug-in into Eclipse, refer to the Symphony Plug-in for Eclipse topic in the Application Development Guide.
The Symphony plug-in for Eclipse is an all-in-one tool package that eases the task of Symphony application development and package deployment.
The plug-in generates a framework of code that provides a foundation for Symphony application development. This framework of basic code is typically common to all Symphony applications. All you need to do is add your own logic to it. One of the key components of the plug-in is the Symphony project wizard, which guides you through the development process and prompts you for application-specific information.
The plug-in also facilitates service package deployment and application registration. This is achieved by combining multiple tasks into single operations through the Symphony DE Platform Management Console, which is integrated with the plug-in.
This section describes the steps for creating a new Symphony Java application (with generated code) using the Symphony project wizard in Eclipse.
We will review the client, message, and service code that is generated by the Symphony plug-in for Eclipse and discuss what you need to do to complete the application coding.
Since you need to create an instance of the message class in your client class, you must import the message class. Add the following import statement to the generated code for the client class:
A connection establishes a context for your client and workload. When you connect to an application:
The application name in the connection must match that defined in the application profile. This name was assigned when you created the new project using the wizard.
The default security callback encapsulates the callback for the user name and password. In Symphony DE, there is no security checking and login credentials are ignored —you can specify any user name and password. However, when using your client on the grid with Platform Symphony, you need a valid user name and password.
The generated code for connecting to the application is complete and does not require any additional code to make it functional.
The creation and usage of the connection object is scoped in a try-finally block. The finally block, with the connection.close() method, ensures that the connection is always closed whether exceptional behavior occurs or not. Failure to close the connection causes the connection to continue to occupy system resources.
A session is a way of logically grouping tasks that are sent to a service for execution.
When creating a session, you need to specify the session attributes by using the SessionCreationAttributes object. The generated code sets four parameters in the SessionCreationAttributes object.
The first parameter is the session name. This is optional. The session name can be any descriptive name you want to assign to your session. It is for informational purposes, such as in the command line interface.
The second parameter is the session type. The session type is optional. You can leave this parameter blank and system default values are used for your session.
The third parameter is the session flag, which the code generator specified as Session.PARTIAL_ASYNC. This flag setting was determined by the client type specified in the project wizard. This indicates to Symphony that the client expects to receive messages asynchronously.
The fourth parameter is the callback object. This object is used by Symphony to call back to the client when the results are ready to be received.
The attributes object is passed to the createSession() method, which returns the created session.
Similar to the connection object, the creation and usage of the session (sending and receiving data) is scoped in a try-finally block. The finally block, with the session.close() method, ensures that the session is always closed, whether exceptional behavior occurs or not. Failure to close the session causes the session to continue to occupy system resources.
In this step, you create 10 input messages to be processed by the service. When a message is sent, a task input handle is returned. This task input handle contains the ID for the task that was created for this input message. The part of the code that is missing is shown by the TODO comments. To make this code functional, you must create an input message and attach it to the TaskSubmissionAttributes object, which is subsequently sent to the Symphony middleware.
The following code snippet shows an example of the completed code for creating the message and attaching it to the TaskSubmissionAttributes object. In this case, we are inserting a simple string and task ID into the input message.
This step is performed after sending the input data to be processed.
Since our client is asynchronous, we need to synchronize the controlling thread and the callback thread. In the generated code, the controlling thread blocks until all replies have come back.
The MyInput class represents the data input to the service, and the MyOutput class represents the data output from the service. These classes implement methods to set and access the data, such as the message string and task ID.
The code that is generated uses Symphony’s API to serialize the MyInput and MyOutput objects. Symphony serialization is achieved by deriving from the SOAM Message object and implementing the appropriate serialization handlers, i.e., onSerialize() and onDeserialize().
The following code was generated for the MyInput class:
When the client type is set to asynchronous in the project wizard, it generates a callback class that extends the SessionCallback class.
Since you need to create an instance of the message class in your callback class, you must import the message class. Add the following import statement to the generated code for the callback class:
This class contains the onResponse() method to retrieve the output for each input message that is sent. To make the generated code complete, you need to add code to the onResponse() method, as indicated by the TODO comments.
onResponse() is called every time a task completes and output is returned to the client. The task output handle allows the client code to manipulate the output.
The following code example shows the completed code for the onResponse() method. If there is output to retrieve, populateTaskOutput() gets the output. Once results return, print them to standard output and return.
Since you need to create an instance of the message class in your service class, you must import the message class. Add the following import statement to the generated code for the service class:
Symphony calls onInvoke() on the service container once per task. This is where the calculation is performed.
To gain access to the data set from the client, you call the populateTaskInput() method on the taskContext. The Symphony middleware is responsible for placing the input into the taskContext object.
The task context contains all information and functionality that is available to the service during an onInvoke() call in relation to the task that is being processed.
The following code was generated by the Symphony plug-in. What is missing, as identified by the TODO comment, is your service logic for the onInvoke() method.
The following code example shows the onInvoke() method with the service logic. The input message is simply echoed back to the client by creating a string in the output message and passing it to the setTaskOutput() method.
Every sample includes a .classpath file sufficient for building the project within Eclipse. Consequently, there is no need to import the project by importing the existing Ant build file.
You cannot pre-load information about message code that was generated outside the Eclipse plug-in since the code generation wizard is not aware of message code that has been created or modified externally. For example, if you define new message classes for an imported project using the code generation wizard, the existing message classes from the imported project will not appear in the Message Definition dialog.
In this section, we will import the SampleApp sample that is included with Symphony DE and deploy its service. The Java samples are located at:
For more information about the SampleApp code sample or any other sample included with Symphony DE, refer to the appropriate tutorial or readme in the Knowledge Center.