GEOFFREY THOMPSON | >>>>I've recently begun developing more custom elements for my applications, and I am curious to know how other Java developers develop for call studio, specifically with ant or another external compiler.
I have been building fairly complex Custom Action Elements and Custom Decision Elements for more than 7 years, and developed a technique way back then that I still use. The way that CVP 3.0 worked is not the same as CVP 9.0 works, so if I were to start today, I may not do it this way.
First off, I hate any in-line Java code in Studio and don’t use it. Never used it. I don’t like the opaqueness of it, and will make a custom action element with defined Settings even if I just use it once.
I typically build two classes – the custom Action Element and a test class.
The test class is a stand-alone class with a main() method that takes command-line params, does NOT include any Audium JARs, and then has an internal method to do the heavy lifting. The main() wrapper passes the cmd args to the method. In contrast, the custom action element gets the values from the Settings array and passes them to the same method.
To return variables I use a Java inner class, as that’s the way Audium told us to do it years ago – because of multi-threading issues. When returning more than 1 value from a method, you need to instantiate an object of the inner class and set various values on this object.
The test class prints out the variables from the inner class so I can see what happened. The Custom Action Element will probably set session variables to the values of variables on the inner class so that the application can use them.
By constructing it this way, my method that does all the heavy lifting (for example: talking to SAP, talking to a database, talking to a Web service using Apache Axis or JAXB, talking over a socket protocol) can be lifted WITH NO CHANGE from the test class to the Action Element. I do complete testing in the test class, and when everything checks out, copy the method into the custom Action Element.
Each of my really complex class files has logging in the heavy-lifting method.
Whether it’s writing this low-level trace or not is controlled by a Boolean in the Settings (in the test class it may come from the CMD line or just be permanently set to TRUE). This way I can write very detailed trace to my own file and not bother looking through Activity Logs; but when ready for production, I can just turn off the low level trace through the Studio app.
There will be sufficient custom logging in Audium outside the method that does the heavy lifting – but none inside it. As I noted, the method can live in a stand-alone class with a main() method that does not include ANY Audium JARs.
I write and compile completely outside Studio. I use Apache ant to help with the makefile scripts. I edit with GVIM. I use Java docs to understand classes, rather than letting a Dev Builder show me; that way I learn the class and the methods.
Old school – I know.
Regards, Geoff |