« Back to General Discussion - All Versions

RE: New Message from Asher Schweigart in Customer Voice Portal (CVP) - Gene

Combination View Flat View Tree View
Threads [ Previous | Next ]
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.
Currently, what I do is create a second method (elementAction) that I call from doAction and pass it all the parameters I get from the element. That element returns an object containing all the values I want to return from the element.
This way for testing and developing, I can create a main method and call the same elementAction and pass it the same parameters, except instead of getting them from the element, I get them from the ant build file arguments. Then I can print out the return values in the main method, instead of saving them to element.
How do others structure their element classes to allow for testing from the command line/ant build file?

>>>>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

I like old school. I’ve been using Sublime Text 2 for a while now for web development, it’s my favorite editor, so I went to it for Java to, which it does nicely. It will even run an ant build file within the program. I just set up my first ant build file, so I still have some learning to do.
And I totally agree, no reason not to use a custom element. I’m doing the same thing you do right now, creating a custom element that I will only use in one app. Janine pushed us in class to do it this way, and I agree.

I’m surprised you use a test method and then copy it elsewhere. One of the reasons I wanted to write outside of studio is to make it easy to run the action without having to make any changes to the files. I know it’s only copy paste, but what I wanted to create is a system that would let me do everything automatically.
I have my ant build file configured with a task that will copy the appropriate files into the application I need it in within Studio, and of course the normal tasks for building and running the app, so I can do everything I need to from testing to deployment through Ant.

What do you think about creating a test class and instead of copying the doAction code, creating an instance of the element class and running doAction from the test class?
Also, the way I’m doing it, do you think there could be an issue leaving my main function in the class when I add it to Studio?

Why can you not use studio for java development, its’ eclipse. Though I myself use the EE version of eclipse separately. Use Junit for testing your classes. I use custom elements with discretion. I do not believe in converting every piece of functionality into custom element. My code ports with minimum changes from one CVP version to another and without any issues.
Hemal
From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Wednesday, November 14, 2012 10:26 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Asher Schweigart in Customer Voice Portal (CVP) - General Discussion - All Versions: RE: New Message from GEOFFREY THOMPSON in Customer Voice Portal (CVP) - Gen

Asher Schweigart has created a new message in the forum "General Discussion - All Versions": -------------------------------------------------------------- I like old school. I’ve been using Sublime Text 2 for a while now for web development, it’s my favorite editor, so I went to it for Java to, which it does nicely. It will even run an ant build file within the program. I just set up my first ant build file, so I still have some learning to do.
And I totally agree, no reason not to use a custom element. I’m doing the same thing you do right now, creating a custom element that I will only use in one app. Janine pushed us in class to do it this way, and I agree.

I’m surprised you use a test method and then copy it elsewhere. One of the reasons I wanted to write outside of studio is to make it easy to run the action without having to make any changes to the files. I know it’s only copy paste, but what I wanted to create is a system that would let me do everything automatically.
I have my ant build file configured with a task that will copy the appropriate files into the application I need it in within Studio, and of course the normal tasks for building and running the app, so I can do everything I need to from testing to deployment through Ant.

What do you think about creating a test class and instead of copying the doAction code, creating an instance of the element class and running doAction from the test class?
Also, the way I’m doing it, do you think there could be an issue leaving my main function in the class when I add it to Studio?
--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/8558680 or simply reply to this email.