GigaSpaces Plugin

advertisement
This document describes the features of
the IntelliJ IDEA 11 plugin for GigaSpaces
development. A plugin that supports
developers to write code for GigaSpaces
XAP, versions 7 up to 9.
GigaSpaces
Plugin
Description of features
Martijn Kooijman
Table of Contents
Introduction............................................................................................................................................. 2
Plugin installation .................................................................................................................................... 3
Plugin features......................................................................................................................................... 5
Code inspections ................................................................................................................................. 6
Code intentions ................................................................................................................................... 8
Processing Unit module type ............................................................................................................ 10
Usage marking ................................................................................................................................... 13
Introduction
This document describes the features of the IntelliJ IDEA plugin for developing GigaSpaces XAP
application code.
This plugin is created by Martijn Kooijman and can be used by developers to improve their code and
prevent errors that can be detected before actually running the code. The plugin does this by
extending the IntelliJ IDE, so that it shows errors on invalid code constructs and shows tooltips for
code improvements. The plugin also adds the ability to quickly create a new GigaSpaces processing
unit module by bundling and prefilling some of the required configuration files.
Plugin installation
Installing the plugin into IntelliJ IDEA currently requires some manual action. The plugin can be
installed simply by extracting its zip file to a folder located under the user profile.
For Windows users this location is:
/user/<user_name>/.IntelliJIdea11/config/plugins/
For Linux users this is:
/user.home/.IntelliJIdea11/config/plugins
Place the contents of the zip-file in this folder (including the ‘GigaSpacesPlugin ‘ subfolder).
The plugin can be used with both the Community Edition and the
Ultimate Edition of IntelliJ IDEA.
After copying the plugin to this folder and starting IntelliJ, you should notice a message in the topright corner of the IDE, in the plugins section:
This tells you that the plugin is properly installed and detected by the IDE.
Also, in the IDEA settings page you can now find a section for plugin-specific settings:
These include:



The inspection support level: determines what inspection messages to show based on the
given GigaSpaces version that should be supported.
The home folder to a GigaSpaces installation (to be used in a future release of the plugin)
The lookup group to use when detecting GigaSpaces components on the network (to be used
in a future release of the plugin)
Plugin features
The plugin consists of a number of features:




Code inspections & fixes
Code intentions
A new module type: GigaSpaces Processing Unit
Usage marking
On the following pages, each of these features will be described in more detail.
Code inspections
The IntelliJ IDEA static code analysis tool helps you maintain and clean up your code without actually
compiling or executing it. There are numerous automated Code Inspections that help you easily
detect different inconsistencies in your code. The GigaSpaces plugin will extend the default
inspections with many new ones to check for proper use of GigaSpaces annotations.
In the IntelliJ settings dialog you can see a list of all configured inspections, by opening the ‘Project
Settings -> Inspections -> GigaSpaces’ tree.
For each of them you can:



Read a description
Change the error/warning level
Enable/disable
The plugin adds inspections for the following categories:





Events
 e.g. usage of @EventDriven, @Polling, @Notify, @ExceptionHandler
Space filter
 e.g. usage of @BeforeWrite, @BeforeExecute, @AfterUpdate
Pojo’s
 e.g. usage of @SpaceId, @SpaceRouting, @SpacePersist , @SpaceVersion
Remoting
 e.g. usage of @Routing, @RemotingService
Tasks
 e.g. usage of @TaskGigaSpace , @AutowireTask
When writing Java code in the editor, the inspections added by the plugin will generate notifications
for lines that have an error:
And for many of the inspections, there are also available fixes:
Code intentions
IntelliJ IDEA helps you handle situations when you use classes that haven't been imported, or
methods that haven't been written etc., which can result in errors. When a possible problem is
suspected, IntelliJ IDEA can suggest a solution, and in certain cases can even implement this solution
(properly assign variables, create missing references and more).
The plugin adds some GigaSpaces related intentions. These can be found in the IntelliJ settings dialog
under ‘IDE Settings -> Intentions -> GigaSpaces’:
In the dialog you can see:



An intention description
An example situation before the intention has done its work
An example situation after the intention has done its work
When viewed in the editor, these intentions will result in a light bulb in some classes. Below is an
example popup that is displayed after pressing the light bulb:
After applying the intention fix, new code will be added or removed.
In our example, this results in:
Processing Unit module type
When adding a new module to an IntelliJ project, you have the option to select the type of module to
add.
Examples of module types are:




Java module
Groovy module
Maven module
Web module
The GigaSpaces plugin adds another type of module to this list: Processing Unit Module. This is
basically a Java module (and after adding, will be recognized as such), but it differs in the fact that it
automatically creates the correct Processing Unit folder structure and sets up some basic
configuration files.
The new type can be seen when selecting ‘New module’:
When selecting the GigaSpaces Processing Unit module type, the configuration settings can be finetuned by selecting a number of options:
Here the user can select some of the settings for the Processing Unit configuration file (pu.xml).
These include:





If a space proxy should be added
If so, what type of proxy?
If a transaction manager should be added
If so, what type of transaction manager?
If remoting service support should be added
Once the user has entered the correct settings, the new module is created in the current project,
with a default Processing Unit structure:
The following files can be found in this new module:
1. A pu.xml file (Processing Unit configuration) in the proper subfolder
2. A pom.xml file (Maven project file to build the module as a Processing Unit archive)
3. An assembly.xml file (Maven assembly file, needed to create the proper archive structure)
Usage marking
By default IntelliJ IDEA knows about a large number of annotations and marks the fields that they
annotate as ‘in use’. However, for annotation types unknown to IntelliJ, these links are not made and
therefore the annotated fields are marked as ‘not used’.
This can be really annoying and therefore the plugin fixes this for the GigaSpaces annotations, as you
can see in the next example:
Download