@functions for SSJS
The code directly inside a database and the commands is available inside this database?
Here is an example on how to create a control, inside an NSF (http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Creating_a_Java_Control_in_an_NSF). So it should also be possible to include the plugin code in an NSF.