We showed this in our Beans/Plugins session at ServoyWorld. This plugin allows you to to take any utility jar downloaded from the internet, drop it in the Plugins/ClassWrapper folder, and then it is a plugin. Its that simple.
For those of you who wern’t there, here is a brief outline..
DESCRIPTION
The ClassWrapper plugin reads all of the jars inside of the
Servoy/Plugins/ClassWrapper folder, and then reads all of the
classes insider of each jar. It then shows each class under the
ClassWrapper plugin. Use the packages statement to get a new
instance of the class, and then use any of the visible methods
available under the class.
INSTALL INSTRUCTIONS
Put the ddc_classwrapper.jar and the ClassWrapper folder in your
Servoy/Plugins folder. The ClassWrapper folder has the pf.jar in
it as an example. pf.jar is for the Programmers Friend API.
Available at http://www.programmers-friend.org
Any, or multiple, utility jar may be dropped in
the ClassWrapper folder, and each class within the jars will be
shown alphabetically under the ClassWrapper plugin.
EXAMPLE USAGE
To use the utility jars in the ClassWrapper folder, you must first
use the Packages statement to get a new instance of the object.
The statement depends on the jar that you are using. An example
for the pf.jar to get in instance of the StringUtil class is
//get a new instance of StringUtil from Servoys Package loader
var myObject = Packages.org.pf.text.StringUtil.current()
//use the plugin to show methods in StringUtil
var isNull = myObject.isNullOrEmpty(“test”)
You’ll need to look at the API of the utility jar that you are
workig with. However, most will probably use .newInstance().
ex Packages.org.pf.text.StringUtil.newInstance()
I just used the programmer’s friend jar as an example. There is no real extension of their code in the plugin. It is actually a very simple plugin that loops through the jars, and then returns an instance of each class in the getAllReturnTypes() function that is part of Servoy’s plugin API.
You can put any jar you want in the ClassWrapper folder and it should do the same thing…or even mulitple jars in the folder.
Scott this looks very very handy! I can see the benefits of having your methods exposed in a plugin. I only wish this was around 6 months ago!
Can you tell me, from a functional point of view, is there a difference between the ClassWrapper and putting the JARs in the Servoy/lib folder & accessing them with a Packages statement
var result = Packages.com.hic.client.api.Eclaim.getInstance().createSession()
There is no difference at all. Think of this plugin as just a way to view the API listing of the Jar inside of Servoy.
If you were to do all of your coding with the ClassWrapper plugin, and then delete the ClassWrapper plugin, everything would still work. The ClassWrapper plugin doesn’t actually add any functionality…it just shows the Classes and methods of the Jar inside of Servoy.
For example, on your App Server, you could put your Jar in the Lib Folder, and then in your Developer, you could put it in your plugins folder with the ClassWrapper plugin…and it would not make any difference.
Scott, Are we supposed to see the jar contents in the Outline pane of the Editor window? I have PF.jar in the Servoy\Plugins\ClassWrapper folder and restarted Servoy. I can call it, but only because I know that the StringUtil exists.
This is with Servoy Developer
Version 3.0-build 371
Java version 1.5.0_06-b05 (Windows XP)
Thanks again Scott! It works perfectly here with Servoy 3.0.2, on a WIN XP box. Very grateful for your contribution!
A thought - in the tree under the DDC_ClassWrapper node, would it make sense to show the JARs in the ClassWrapper folder, then the classes within that JAR? It’s a means of verifying which jar file you’d need to have available on the server for the methods to work. Also easier to find the class you want when there are lots of them.
It’s just a thought - I think it’s fine how it is, and very useful.
A thought - in the tree under the DDC_ClassWrapper node, would it make sense to show the JARs in the ClassWrapper folder, then the classes within that JAR? It’s a means of verifying which jar file you’d need to have available on the server for the methods to work. Also easier to find the class you want when there are lots of them.
I tried to do that, but haven’t seen where it is possible to do in the Servoy API…so, currently all of the classes are just sorted alphabetically