Oracle Coherence A Netbeans Plug-in

Recently I have been working with the Oracle Coherence product and noticed that when using the, recommended, POF Serialization functionality I seem to be writing a lot of similar code. When using POF Serialization you need to implement the PortableObject interface and write a readExternal and a writeExternal method which deserialize and serialize the class properties respectively.

Now this can become a bit tedious so to improve my NetBeans development environment I decided to implement a some auto generation functionality to take away the need to manually create these methods. In addition to the generation of the POF methods I also implemented an alternative that generates an Inner Serializer class and its associated methods, as defined in Alek Soevic's book "Oracle Coherence 3.5", the final part of the plug-in is the ability to create and run Coherence cluster nodes from within NetBeans.  At the moment I have built this plugin within NetBeans 6.9, but it runs fine on 6.10, and it can be downloaded from the NetBean Plugin Portal.

The rest of this blog entry will describe the functionality provided and how to create and configure a Coherence instance within Netbeans.

The Coherence Plugin

The Netbeans Coherence Plugin provides 3 key piece of functionality:

  1. Auto Generation of POF Serializer methods through an addition "Insert Code" Menu Option.
  2. Auto Generation of PofSerializer Inner Class through an addition "Insert Code" Menu Option.
  3. Ability to Create / Configure / Run Coherence Nodes through the NetBeans Services Tab.

Using the Auto Generation from the "Insert Code" menu assumes you have manually added the appropriate coherence.jar file to the projects lib path through the normal NetBeans Methods whilst creating a new server needs the user to define the Coherence Classpath property. The functionality was implemented this way because I needed to create and run bothe Coherence 3.5 and 3.6 nodes.

Insert Code Extensions

The insert code funtionality can be access by right-clicking on the java code and following the installation of the plugin you will see a menu something like the one below.

Insert Menu

You will notice that their are now two Coherence Menu Items at the top of the list (although sometimes you get one at the top and one at the bottom) and I will briefly describe each and what effect they have on the following same code.

Coherence POF Serializer Inner Class

On executing this menu option the lines 42 - 141 in the code example below will be generated. The generated code implements a PofSerializer, as an Inner Class, for the NewClass Class and this can be inserted / references in the pof-config as defined by the example in line 69 - 81.

  • Line 43 : Create a com.tangosol.util.Binary variable that will be used to retrieve and write the remainder information from the and This is added to prevent data loss in the case where the class has been manually edited elsewhere and additional information is being Serialized.
  • Lines 57 - 67 : This new constructor is used to create an instance of the NewClass based on the deserialized information retrieved during a call the Inner Classes deserialize method.
  • Lines 82 - 141 : Inner Serializer Class which is referenced from the pof-config file. This class defines a property (84 - 93) for all properties in the NewClass that are not defined as transient, final or static because given their nature these properties do not need to be serialized. The serialise method, required by PofSerializer interface, can be seen in line 101 - 112 and simply takes the object passed in and accesses the appropriate properties and writes then to the PofWriter. The deserialization is done within the deserialize method defined in line 128 - 139 and it can be seen that the properties are read into the local variables before the NewClass constructor, defined in 57 - 67, is executed to return a new object. Rather then use Magic number I have genrated a series of constants, 114 - 121, for each of the fields to be serialized.

All these lines of code will be removed and regenerated if the method is called again.

Coherence PortableObject Methods

Executing this functionality will generate the Simple POF Methods define in lines 42 - 81 of the code below. In addition you can see that the implements, line 21, has been extended to use the

  • Line 21 : Add / append the
  • Lines  47 - 56 : Simple readExternal, as mandated by PortableObject, which reads the lines from the PofReader and then assigns them to the appropriate properties. Again only the properties that need to be serialized and deserialized are used.
  • Lines 58 - 65 : Index Constants.
  • Lines 72 - 82 : Simple writeExternal method that takes the local properties and serializes them using the PofWriter.

Coherence Server

Coherence Servers can be added to the new "Coherence Server" node within the NetBeans Services Tab. This is done simply by right-clicking on the node and selecting add server. At present this will allow the user to simple name the server and then select ok. Once the server has been created it will appear below the "Coherence Servers" Node as  can be seen in the image below. At this point the user should select the properties for the new server and edit them to fit their requirements. In this version the user has access to all the available coherence properties and an additional to properties have been added (Coherence Classpath and Additional Classpath) so that the user can specify the locations of all appropriate jar files.

  • Coherence Classpath : Intended to be used to specify the location of all the require Coherence jars
  • Additional Classpath : Used to specify the location to any project specific jar files.
  • Java Flags : Allows the user to specify additional Java flag, such as -Xms128m, that will written to the beginning of the run command.
  • Custom Properties : This field allows the user to add custom command line properties that will be written at the end of the command line before the reference to the DefaultServer.

Coherence Server

Once the server has been configured the new node provides a number of options as part of the Right-Click Context Menu:

  1. Start : You can simply run it by selecting the Start menu option on the servers context menu and its output will be written to the NetBeans Output window (below).
  2. Stop : This is only available for a running server and simplys stops its execution.
  3. Clone Server : Takes the current servers configuration and clones it allowing the user to specify a new name.
  4. Delete : Deletes the current server.
  5. Properties : Displays the server properties.
  6. Reset Coherence Properties : Resets all the coherence Specific Properties for this server. That is all properties that start tangosol..



<script type="text/javascript"> $(document).ready(function(){ $("#historydiv").load("../resource/coherence/CoherenceNetbeansPluginHistory.html"); }); </script>

Very nice.

Posted by Ashish on November 21, 2010 at 11:06 PM GMT #

Hi Dante, thanks for the extremely useful plugin. I did not see it in the list of available plugins under NetBeans' Tools, Plugin menu even when I have the Plugin Portal repository added in the Settings. When will it be added to the repository? Also, in the Services tab, I tried setting the properties for tangosol.coherence.ttl=0 for single machine mode, however it did not allow that as a valid value and keeps going back to default (4), but the GUI says -1.


Posted by Phil Chung on November 25, 2010 at 04:06 PM GMT #

The Services properties also need tangosol.pof.enabled=[true|fase] and tangosol.pof.config=<filename>. It probably needs a way to add a custom property too.

Posted by Phil Chung on November 25, 2010 at 04:27 PM GMT #


I've added the two missing properties and will upload it to the plug-in site as soon as it will let me. You'll notice the version will be updated to 1.3. To add it to the repository I think I'll have to get it approved which I'll have a go at when I've managed to update it.

Posted by Andrew on November 29, 2010 at 06:12 AM GMT #


Still having trouble uploading the nbm to the Netbean Plugin site so I have added a download link to the top of the page. Essentially the new version resolves the features ;-) you highlighted.

Posted by Andrew on November 30, 2010 at 02:09 AM GMT #

Thanks Andrew, works great. Also wanted to know if we could easily add/duplicate/run multiple DefaultCacheServer entries in the Services tab with the same properties as one already defined. This way a developer could easily see the effects of adding another DefaultCacheServer. Thanks.

Posted by Phil on November 30, 2010 at 07:23 PM GMT #


I'll take a look the starting part should be easy it's the listing the running ones so you can stop them I'll need to think about.

Posted by Andrew on December 01, 2010 at 06:27 AM GMT #

Hello Andrew,

Any chance to get access to the source code of this plugin for collaborative / community improvement ?



Posted by Sébastien Stormacq on December 10, 2010 at 05:05 AM GMT #


I'll see what I can do about getting it on Project Kenai and I'll let you know.


Posted by Andrew on December 10, 2010 at 06:58 AM GMT #

New release posted to the Netbeans Pluin Portal

Posted by Andrew on December 14, 2010 at 08:47 AM GMT #

Post a Comment:
Comments are closed for this entry.

As a member of the Oracle A-Team we specialise in enabling and supporting the Oracle Fusion Middleware communities.


« July 2016