Developing Apama Applications > Developing Apama Applications in Java > Developing and Deploying Java Applications > Steps for developing Java applications in Apama Studio
Steps for developing Java applications in Apama Studio
The procedure for developing Apama Java applications in Apama Studio is as follows:
1. Add Apama Java support to a project.
To create a new project with Apama Java support:
a. Select File > New > Apama Project.
b. Enter a project name and click Next.
c. At the bottom of the dialog, select Add Apama Java support and click Finish.
To add Apama Java support to an existing project:
a. Right click the project in the Project Explorer panel.
b. Select Apama > Add Apama Java Nature.
When a project has Apama Java support, Apama Studio does the following:
*Uses ApamaJavaLibrary to add all necessary JAR files to the project’s Java build path.
*Creates and updates the jmon-jar.xml file. This is the deployment descriptor file required by each Apama Java application. Inside the correlator, the JVM processes the deployment descriptor file and uses it as a guide to the event types and monitor classes to load.
*Generates and maintains your application’s Apama Java JAR file in the project_name java application files folder of your project.
If you select Apama > Add Java Nature you are adding standard Eclipse Java support to your project. Selection of Add Apama Java Nature includes standard Eclipse Java support.
2. Create your application's source files.
Select File > New > Java Event or select File > New > Java Monitor.
Or, in the Project Explorer, right-click your project and select New > Java Event or select New > Java Monitor.
A wizard appears that lets you specify the event or monitor’s name, the package, a description, the Java source folder and Java package. Apama Studio automatically adds an entry for the event or monitor to the jmon-jar.xml deployment descriptor file and regenerates the Apama Java JAR file to include the new event or monitor.
If you want to build your JAR files manually, right-click your project and select Apama > Build JAR Files. This is useful if you unselected the Build jar files automatically option in the apama_java.xml file, which is in the config directory of your project. One reason you might not want to build the JAR files automatically is that the build takes too long. When Build jar files automatically is selected, Apama Studio builds the JAR files every time you modify an Apama Java file.
If there are events that you defined in Java and you refer to those events, or listen for those events in EPL code, then you must define those events in EPL as well as Java. If you do not also define the events in EPL, Apama Studio flags EPL references to those events as errors.
See also Creating new files for Apama Java applications in Using Apama Studio.
3. Create your application's launch configuration.
Apama Studio adds all Apama Java JAR files to the correlator initialization list and all non-Apama JAR files to the correlator class path.
If you want to build your project's files outside Apama Studio and Eclipse right-click your project and select Apama > Generate Ant Buildfiles. Apama Studio generates an ant build file (with the name build-project-name.xml), which you can use only to build your project’s Apama Java JAR files outside of the Eclipse environment. Note that this is unrelated to the Apama Studio feature for exporting an Ant build file that you can use for deployment.
See Defining custom launch configurations in Using Apama Studio.
4. Run and test your application.
See Launching Projects in Using Apama Studio.
5. Debug your application.
See Debugging Apama Java Applications in Using Apama Studio.
6. Deploy your application.
See Deploying Java applications.
Apama Studio generates your application’s Apama Java JAR file in the apama_java_config_name java application files folder of your project’s directory. By default, apama_java_config_name is the project name.
You can manage the content of the Apama Java JAR file and jmon-jar.xml file by using the Apama Studio editor to update the apama_java.xml file, which is located in the project’s config folder. You can use the Apama Studio editor to do the following:
*Set Apama Java metadata.
*Set the injection order of the events and monitors.
*Add non-Apama Java classes to the Apama Java JAR files.
*Add Apama Java classes that were not created by Apama Studio wizards to the Apama Java JAR file.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.