Creating and Installing a Velocity Java Module

I’d like to create and install an extension to add custom functionality to my Velocity templates… I’m not sure, but this is what I’ve got so far:

It looks like I’ll need to add somethign like this to my Extensions\Handlers\Java\8\Extensions.xml file:

   <Extension categorystring="" context="global/percussion/user/"
              deprecated="no" handler="Java"
              name="[b]myPackageName[/b]" restoreRequestParamsOnError="no">
      <initParam name="com.percussion.user.description">[b]Something informative.[/b]</initParam>
      <initParam name="com.percussion.extension.version">1</initParam>
      <initParam name="com.percussion.extension.reentrant">yes</initParam>
      <initParam name="className">[b]my.class.Name[/b]</initParam>
      <interface name="com.percussion.extension.IPSJexlExpression"/>
      <suppliedResources/>
   </Extension>

Does anyone have any more information on this? maybe an API for the IPSJexlExpression interface? Or know where I can find the documentation for this sort of thing?

Thanks.

Update:

I figured out that what I said before is essentially correct, with the additional caveats:

  1. The java class needs to be a subclass of com.percussion.extension.PSJexlUtilBase and needs to implement the interface com.percussion.extension.IPSJexlExpression
  2. You need to create the folder Extensions\Handlers\Java\8\global\percussion\user[i]myPackageName[/i]\1

However, this does not add the methods of the new package to the popup for auto-complete in the workbench… still working on that.

Anyone have any suggestions?

You don’t need to edit extensions.xml directly or create folder structures. You should use the workbench to add the exit. This will do all the necessary work. If you submit the class file w/ the registration, the code becomes available immediately. However, if you submit the code w/ the registration, you will need to submit it each time you change the registration.

If you add a jar to the lib dir, the server will have to be restarted each time the jar is modified. I usually use the former method while developing an exit to save on rebooting the server.

You don’t ‘have’ to extend PSJexlUtilBase, that is a convenience. You either extend that class, or implement IPSJexlExpression (which PSJexlUtilBase implements.)

[QUOTE=Rushing;16024]Update:

I figured out that what I said before is essentially correct, with the additional caveats:

  1. The java class needs to be a subclass of com.percussion.extension.PSJexlUtilBase and needs to implement the interface com.percussion.extension.IPSJexlExpression
  2. You need to create the folder Extensions\Handlers\Java\8\global\percussion\user[i]myPackageName[/i]\1

However, this does not add the methods of the new package to the popup for auto-complete in the workbench… still working on that.

Anyone have any suggestions?[/QUOTE]

You also need to have the correct Annotations. Use @IPSJexlMethod to annotate each method that you want to have appear in the dropdowns. The parameters to this method must be annotated with @IPSJexlParam. Look back at some of the tutorials I have posted earlier, I believe they contain examples of those annotations.

As for the installation method, you can use either the “Extensions.xml” and PSExtensionInstallTool method or the “Workbench” method (look at the deploy.xml that comes with the PSOToolkit for an example of how to do this). I strongly recommend you create a JAR rather than attempting to deploy class files.

As Paul points out, the Workbench method has some advantages for development.

The “Extensions.xml” method has the advantage that it can be automated, which the workbench method cannot.

In 6.7 and later, you can also use the Package Builder and Package Installer to move extensions from system to system, but this option is not available in prior versions. This method is not quite as straightforward as using the Extensions.xml and PSExtensionInstallTool method

Dave

Thanks for the replies.

Dave, I’m assuming you are talking about this thread. Am I correct?

Anyway, I’ll take a look at that and see what I can apply to my system.

Worked like a charm. I’ve posted my finished JEXL extension on the Code repository forum.