/*
* LICENSE AGREEMENT
*
* GRIDGAIN 1.0 - GRID COMPUTING FOR JAVA.
* COPYRIGHT (C) 2005-2007 GRIDGAIN SYSTEMS. ALL RIGHTS RESERVED.
*
* THIS IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR
* MODIFY IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC
* LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; EITHER
* VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER
* VERSION.
*
* THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE
* GNU LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
*
* YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC
* LICENSE ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE
* SOFTWARE FOUNDATION, INC., 51 FRANKLIN ST, FIFTH FLOOR, BOSTON, MA
* 02110-1301 USA
*/
package org.gridgain.examples.helloworld.gridify.client;
import org.apache.log4j.*;
import org.gridgain.examples.helloworld.gridify.basic.*;
import org.gridgain.grid.*;
import org.gridgain.grid.connectors.ws.xfire.*;
import org.gridgain.grid.gridify.*;
import org.gridgain.grid.gridify.aop.spring.*;
/**
* Demonstrates {@link Gridify} annotation used with Ws-based connector client.
* This example will execute gridified method {@link #helloWorld(String)}
* on remote grid.
* <p>
* <h1 class="header">Jboss AOP</h1>
* The following configuration needs to be applied to enable JBoss byte code
* weaving.
* <ul>
* <li>
* The following JVM configuration must be present:
* <ul>
* <li><tt>-javaagent:[GRIDGAIN_HOME]/libs/jboss-aop-jdk50-4.0.4.jar</tt></li>
* <li><tt>-Djboss.aop.class.path=[path to gridgain.jar]</tt></li>
* <li><tt>-Djboss.aop.exclude=org,com -Djboss.aop.include=org.gridgain.examples</tt></li>
* </ul>
* </li>
* <li>
* The following JARs should be in a classpath:
* <ul>
* <li><tt>[GRIDGAIN_HOME]/libs/javassist-4.0.4.jar</tt></li>
* <li><tt>[GRIDGAIN_HOME]/libs/jboss-aop-jdk50-4.0.4.jar</tt></li>
* <li><tt>[GRIDGAIN_HOME]/libs/jboss-aspect-library-jdk50-4.0.4.jar</tt></li>
* <li><tt>[GRIDGAIN_HOME]/libs/jboss-common-4.0.4.jar</tt></li>
* <li><tt>[GRIDGAIN_HOME]/libs/trove-1.0.2.jar</tt></li>
* </ul>
* Note that these JARs are usually in classpath by default when using GridGain.
* </li>
* </ul>
* <p>
* <h1 class="header">Spring AOP</h1>
* 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 {@link GridifySpringEnhancer#enhance(Object)} for the object
* that has method with {@link Gridify} annotation.
* <p>
* Note that this method of weaving is rather inconvenient and AspectJ or JbossAOP is
* recommended over it. Spring AOP can be used in situation when code augmentation is
* undesired and cannot be used. It also allows for very fine grained control of what gets
* weaved.
* <p>
* <h1 class="header">AspectJ AOP</h1>
* The following configuration needs to be applied to enable AspectJ byte code
* weaving.
* <ul>
* <li>
* JVM configuration should include:
* <tt>-javaagent:[GRIDGAIN_HOME]/libs/aspectjweaver-1.5.3.jar</tt>
* </li>
* <li>
* Classpath should contain the <tt>[GRIDGAIN_HOME]/config/aop/aspectj</tt> folder.
* </li>
* </ul>
*
* @author 2005-2007 Copyright (C) GridGain Systems. All Rights Reserved.
* @version 1.0.0-07022007
*/
public final class GridifyHelloWorldWsClientExample {
/** Log4j logger. */
private static final Logger log = Logger.getLogger(GridifyHelloWorldBasicExample.class);
/**
* Ensure singleton.
*/
private GridifyHelloWorldWsClientExample() {
}
/**
* Method grid-enabled with {@link Gridify} annotation. Simply prints
* out the argument passed in.
* <p>
* Note that default <tt>Gridify</tt> configuration is used, so this method
* will be executed on remote grid with the same argument without split.
*
* @param arg String to print.
*/
@Gridify
public static void helloWorld(String arg) {
if (log.isInfoEnabled() == true) {
log.info(">>> Node " + GridFactory.getGrid().getLocalNode().getPhysicalAddress() + " is executing '" +
arg + "' <<<");
}
}
/**
* Sets default connector client to Web Services and executes
* {@link #helloWorld(String)} method.
*
* @param args Command line arguments, none required.
* @throws GridException If example failed.
*/
public static void main(String[] args) throws GridException {
GridifyClientManager.setDefaultClient(GridWsXfireConnectorClientFactory.getClient());
helloWorld("Hello, World!");
if (log.isInfoEnabled() == true) {
log.info(">>> Executed \"Hello, World!\" <<<");
}
}
}