How to Setup an Eclipse Project for Tuner Development
Development environment used in this tutorial:
Lenovo W520 with 16GB RAM Windows 7 Professional x64 SP1
BBCA Tuner 8.2 with the following channels: 8.2 Channel Manager, Transmitter and Channel Copier Tuner install path: C:\dev_tools\bmc\BBCA Tuner workspace path: C:\dev_tools\bmc\BBCA\.marimba\BBCA_Target
Eclipse Java EE IDE for Web Developers : Version: Helios Service Release 2:Build id: 20110218-0911 Eclipse is running JVM: Java 64-Bit VM - 1.6.0_25-b06 Eclipse install path: C:\dev_tools\eclipse Eclipse workspace path: C:\Users\developer\Documents\Development\eclipsews
Assumptions The user of this document has experience with Java, Eclipse and BBCA/Marimba. Goals The goal of this tutorial is to demonstrate how to configure Eclipse so someone can use this IDE to produce and compile code that can be published to Transmitter and be consumed by a Tuner. The document will walk thru: opening Eclipse creating a new project adding the proper Tuner jar/zip files creating a simple channel publishing the simple channel testing the simple channel
1. Open Eclipse
NOTE: If it does not open in the Java Perspective (shown above) then click on Window -> Open Perspective -> Java
2. Create a Java Project
Call the project BBCA_Tutorial_01 and click Next
Click on the Libraries tab
Click on the "Add External JARS.." button Browse to the Tuner's lib directory and select the marimba.zip and tuner.zip files
Click the "Finish" button In the Package Explorer there will be a project named BBCA_Tutorial_01 with a triangle to the left of its name. Click on the triangle.
Click on the triangle to the left of "Referenced Libraries" and note that the two BBCA zip files have been added to the project's build path.
3. Create a Simple Channel Under the Package Explorer -> BBCA_Tutorial_01 RIGHT click on the src folder -> New ->Class
In the "Package" field enter: com.bmc.bbca.tutorial In the "Name" field enter: Tutorial01 Click the "Finish" button
Now copy the following code and replace the auto generated Java code.
package com.bmc.bbca.tutorial;
import com.marimba.intf.application.*;
public class Tutorial01 implements IApplication{
private IApplicationContext chCtx;
/* * This method is the entry point for a channel * @see com.marimba.intf.util.IObserver#notify(java.lang.Object, int, java.lang.Object) */ public void notify(Object sender, int msgId, Object args){ switch(msgId){ case(IApplication.APP_INIT):{ chCtx = (IApplicationContext) args; break; } case(IApplication.APP_START):{ log("Starting Channel: " + chCtx.getChannelURL()); log("Going to Stop Channel: " + chCtx.getChannelURL()); chCtx.stop(); break; } case(IApplication.APP_ARGV): { break; } case(IApplication.APP_STOP): { log("Stopping Channel: " + chCtx.getChannelURL()); break; } } }
/* * Logging for this tutorial will just be to Java's std out * Doing so not only keeps things simple but also demonstrates where/how * the tuner handles Java's std out calls like System.out.println * * The more advance tutorials will use the Tuner's logging API */ void log(String msg){ System.out.println(msg); } }
Under the Package Explorer -> BBCA_Tutorial_01 RIGHT click on the src folder -> New ->File
Select "src" as the parent folder and name the file properties.txt
Click the "Finish" button
Now copy the following and past it into the properties.txt file. author=Developer01 capabilities=all channel.version=1.0 classpath=. description=Simple Channel main=com.bmc.bbca.tutorial.Tutorial01 platform=any segment=any/any title=Tutorial01 type=Application
NOTE: The classpath value is '.' (dot) meaning the current directory (root of the channel directory, which in this case is the bin directory that Eclipse outputs the results of the compilation of the project. If a jar or zip file needs to be added to the channel, place them in the root directory. They can either be in the root or in subdirectories. Example: jarfile01.jar, ps/zipfile.zip; where ps is a directory. classpath=.:jarfile01.jar:ps/zipfile.zip
4. Publish to transmitter Start Channel Copier and create a new copy operation. As the source choose the bin directory where Eclipse outputs the compilation of the project. channel copy src - C:\Users\developer\Documents\Development\eclipsews\BBCA_Tutorial_01\bin channel copy dst - http://localhost:5282
Click the "Add/Close" button
Now modify the "Destination" URL to http://localhost:5282/Test/Tutorial01
Click the "Copy" button
5. Test the channel by subscribing to it NOTE: Since the channel is not signed be sure to add the transmitter to the trusted list (marimba.security.trusted.transmitters=localhost) otherwise the channel will not start and in the Tuner's stdout.log file there will be the line Error: Channel Tutorial01 requires capabilities, but it is not signed. When using Channel Manager to subscribe to the channel it automatically starts the channel for you.
You should see the following in the Tuner's stdout.log file: Starting Channel: http://localhost:5282/Test/Tutorial01 Going to Stop Channel: http://localhost:5282/Test/Tutorial01 Stopping Channel: http://localhost:5282/Test/Tutorial01
And in the channel's history log file: [12/Jul/2011:17:41:01 -0400] - info developer 1150 Channel instance started #Starting Channel: http://localhost:5282/Test/Tutorial01 #Going to Stop Channel: http://localhost:5282/Test/Tutorial01 #Stopping Channel: http://localhost:5282/Test/Tutorial01 [12/Jul/2011:17:41:01 -0400] - info developer 1152 Channel instance stopped