Child pages
  • Creating Client Plugins

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Plugins can be developed in any Java development environment, like Eclipse for example. 

Preliminary Settings

  • Create a new Java Project.
  • Add a set of needed Servoy libraries.

    The minimal set of libraries may be found in /{servoyInstall}/application_server/lib/ folder, and is the following:
    - j2db.jar
    - j2dbdev.jar
    - js.jar
    - wicket.jar

    Info

    A 'User Library' can be defined in Window > Preferences which will be available for all future relevant projects. Name it 'Servoy', for example.


...

Before starting coding, do study these interfaces on api docs.

Example

This example shows the implementation of a component which will query a whois server and retrieve whois information about a domain.

...

Since the class which implements the IServerPlugin, ISmartClientPlugin or IClientPlugin is one file among many inside the jar, it's advised indicate which file is the plugin entry point.

From 2022.09 this is mandatory to have

The plugin jar can use Java Service Provider to expose Servoy Plugin classes. There should be a file inside the plugin jar at the path: META-INF/services/com.servoy.j2db.plugins.IPlugin which contains a line for each class in the jar that  implements IPlugin (IClientPlugin or IServerPlugin). The plugin should also have a default constructor (with no parameters). If file com.servoy.j2db.plugins.IPlugin is missing or contains invalid entries Servoy will automatically scan the jar for all classes that implement interface IPlugin. NOTE: This automatic scanning will not happen anymore from 2022.09 on.

An example of file content (for whois plugin) is:

...

Code Block
var domainName = "";
var result = "";

function onQueryWhois()
{
	if (domainName != null && domainName.length > 0) {
		result = plugins.whois.query(domainName, "whois.internic.net");
	}
}

Running Smart Client