We're all familiar with the steps:
- Navigate to where ever the IA resides
- Open the integration.js file in a text editor.
- Find some nice piece of code that works fine.
- "improve" it.
- Navigate back to the IA/bin directory or find the service on windows
- Restart the agent
- Watch the log spit out a stack trace or
- Login to the management system
- Find a ticket
- Enter stuff
- Watch the log spit out a stack trace
- Repeat 1-7 until you find a big hammer or you have a stress induced ulcer
Yes, fun as this is, I have a better way!
Some of us remember the days of the dreaded JavaClient and programming in Java. Java is a very powerful language and you can build some really cool stuff with it. (I know a great notification platform) However, not terribly friendly for those without (or with!) Computer Science degrees.
Ok, so why do I care and how is this going to help my blood pressure?
Well, what if I told you it is possible to get an interactive java script command environment? What if I told you it used the exact same Java and Rhino versions the IA uses?
Wow, so much violence in this post, I won't make it a habit.
Anyway, the goods. All you need is to run this command:
*Edited: This code below just gets you the raw environment. However, trying importing any useful IA Classes results in the need for more head bashing... see the second entry for a more realistic use case.
[user@tree bin]$ cd $IAHOME
[user@tree integrationagent-5.0.7]$ ./jre/bin/java -jar ./lib/mule-1.4.3/lib/user/js.jar
Rhino 1.6 release 5 2006 11 18
Throw this into a rhino.sh file and set the execute flag (chmod +x rhino.sh) and save to the IAHOME/bin directory
# Set the base install directory. This basically just gets the current working directory, then goes up one level
INSTALL_DIR=$( cd "$( dirname "$0" )" && pwd )/..
# Here we set the class path, first to include the js.jar (rhino shell), then the IA jar files
# Finally, call java and pass the class path we created above. Then we invoke the Main method of the Rhino shell, stored in js.jar
Windows Batch file:
rem Keep environment variables local to this script (not supported in all versions of Windows)
IF (%OS%) == (Windows_NT) SETLOCAL
rem Get SFN path to install directory.
rem A bug in some versions of Windows makes %~dsp0 append the filename, so use this workaround.
rem Note: correct to append .. instead of \ since %~dsp0 ends with \
for %%i in (%~sf0) do set INSTALL_DIR=%%~dspi..
I just managed to figure this out, so I just had to share. I hope you all like it!
Blog- Originally created by Travis Depuy