Java Reference
In-Depth Information
<bean id="myGrid" class="org.gridgain.grid.GridSpringBean" scope="singleton">
<property name="configuration">
<bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter"
scope="singleton">
<property name="topologySpi">
<bean class="org.gridgain.grid.spi.topology.basic.GridBasicTopologySpi">
<property name="localNode" value="false"/>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="interceptor"
class="org.gridgain.grid.gridify.aop.spring.GridifySpringAspect"/>
<bean depends-on="myGrid" id="salutationService"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="autodetectInterfaces" value="false"/>
<property name="target">
<bean
class="com.apress.springenterpriserecipes.distributedspring.gridgain.SalutationServiceImpl"/
>
</property>
<property name="interceptorNames">
<list>
<value>interceptor</value>
</list>
</property>
</bean>
</beans>
Here, we use a plain, old-style AOP Proxy in conjunction with the GridGain aspect to proxy our
humble service class. I override topologySpi to set localNode to false , which has the effect of stopping
jobs from being run on the invoking node, which in this case is our service bean's node. The idea is that
this node is, locally, the front for application services, and it's inappropriate to run jobs on that virtual
machine, which may be handling highly transactional workloads. You might set the value to true if you
don't mind a node bearing the load of both handling the services and acting as a grid node. Because
you usually set up a Grid to offload work to some other node, this is usually not desirable. We know that
invoking that service will cause it to be farmed out. Here's a simple client. The parameter is the only
context we have and it's the only thing you can rely on being present on the node that's run. You can't,
if you're running the nodes via the startup script mentioned previously, rely on the Spring beans being
wired up. We'll explore this further. In the meantime, witness our client:
package com.apress.springenterpriserecipes.distributedspring.gridgain;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Locale;
public class Main {
Search WWH ::




Custom Search