GridGain comes with a set of examples. Examples' source code, necessary configuration and Javadoc are located in ${GRIDGAIN_HOME}/examples folder. All examples come with fully documented source code.
All examples can be easily imported into Java IDE such as IDEA, Eclipse or NetBeans. Following short instruction will guide you through a setup for IDEA 6.0 on Windows XP:
- Create the new single-module project, name it "Examples"
- Specify source code directory as %GRIDGAIN_HOME%\examples\src
- Add necessary libraries:
- Add all libraries from %GRIDGAIN_HOME%\libs
- Add main GridGain JAR located at %GRIDGAIN_HOME%\gridgain-x.x.x.jar
- Make sure to select Java 5 or Java 6 JDK


Once you have setup the project, follow the instructions in Javadoc on how to run example. Note that examples that use AOP-based grid enabling will require additional configuration for their AOP frameworks. All instructions for AOP configuration are available in the Javadoc.
Running Grid Node
All examples will need some (one or more) remote nodes to be running. To start a remote node open the terminal window on Linux/Mac OS X or Command Prompt on Windows, change directory to ${GRIDGAIN_HOME}/bin and run the gridgain.{sh|bat} script. It takes 2-3 seconds for grid node to start and if everything worked fine you should see starting log ending with successful start acknowledgment:

IP-Multicast
Note that default configuration for discovery SPI uses IP-multicast. Depending on operating system IP-multicast can be disabled. Check your firewall settings to make sure that IP-multicast is enabled.
| IP-multicast IP-multicast should be enabled in order for default configuration to work properly. Refer to Troubleshooting section for help with IP multicast. We also advise you to Google |
AOP Configuration
In order to use annotation based @Gridify ![]()
JBoss AOP
Note that GridGain is not shipped with JBoss and doesn't include necessary JBoss libraries. We assume that if you choose to use JBoss AOP you would have these libraries anyways. The following configuration needs to be applied to enable JBoss byte code weaving:
- The following JVM configuration must be present:
- -javaagent:[path to jboss-aop-jdk50-4.x.x.jar]
- -Djboss.aop.class.path=[path to gridgain.jar]
- -Djboss.aop.exclude=org,com -Djboss.aop.include=org.gridgain.examples
- The following JARs should be in a classpath:
- javassist-4.x.x.jar
- jboss-aop-jdk50-4.x.x.jar
- jboss-aspect-library-jdk50-4.x.x.jar
- jboss-common-4.x.x.jar
- trove-1.0.x.jar
AspectJ AOP
The following configuration needs to be applied to enable AspectJ byte code weaving.
- JVM configuration should include: -javaagent:[GRIDGAIN_HOME]/libs/aspectjweaver-1.5.3.jar
- Classpath should contain the [GRIDGAIN_HOME]/config/aop/aspectj folder.
Spring AOP
Spring AOP framework is based on dynamic proxy implementation and doesn't require any specific runtime parameters for online weaving. All weaving is on-demand and should be performed by calling method GridifySpringEnhancer.enhance(Object) ![]()
Note that since this method of weaving requires manual enhancing of participating classes, it is rather inconvenient in most cases, and AspectJ or JbossAOP are recommended over it. Spring AOP can be used in situations when code augmentation is undesired and cannot be used. It also allows for very fine grained control of what gets weaved.
