Step 3 – add the Java class
Now it is time to add a new Java class to the project. Choose the menu item “New -> File -> Class”:
Specify the class name “HelloWorld” and press the button “Add…” to add an implemented class interface. We are looking for the “ICustomEventHandler”:
Press “OK” and the IDE will generate the class:
Some code was added to demonstrate that the plugin works:
public void onPrePersist(List<ISecurityEvent> events) { for(Iterator<ISecurityEvent>i = events.iterator(); i.hasNext();) { ISecurityEvent event = i.next(); if(event.getName().startsWith("Hello!")) { event.setDeviceCustomString1("Hello world!"); } } }
Now do some cleanup: delete the Java class template (ServiceComponent.java) that was created automatically. The project should look like the picture below: