You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Denis Koblov (JIRA)" <ji...@apache.org> on 2017/10/10 09:18:00 UTC
[jira] [Created] (IGNITE-6586) Spring bean as ignite service
Denis Koblov created IGNITE-6586:
------------------------------------
Summary: Spring bean as ignite service
Key: IGNITE-6586
URL: https://issues.apache.org/jira/browse/IGNITE-6586
Project: Ignite
Issue Type: Wish
Reporter: Denis Koblov
Hello.
I use a spring-ignite in my application. When using ServiceGrid I noticed a feature.
I created the following class for the ServiceGrid:
{code:java}
public class SimpleService implements Service, ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
@Override
public void init(ServiceContext serviceContext) throws Exception {
if (applicationContext == null) {
System.out.println("ApplicationContext is null");
}
}
@Override
public void execute(ServiceContext serviceContext) throws Exception {
}
@Override
public void cancel(ServiceContext serviceContext) {
}
}
{code}
{code:java}
<bean id="igniteSpringBean" class="org.apache.ignite.IgniteSpringBean">
<property name="configuration">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Enabling the peer-class loading feature. -->
<property name="peerClassLoadingEnabled" value="false"/>
<property name="gridLogger">
<bean class="org.apache.ignite.logger.slf4j.Slf4jLogger"/>
</property>
<property name="userAttributes">
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="simpleservice" value="true" value-type="java.lang.Boolean"/>
</map>
</property>
<property name="serviceConfiguration">
<list>
<bean class="org.apache.ignite.services.ServiceConfiguration">
<!-- Unique service name -->
<property name="name" value="SimpleService"/>
<!-- Service implementation's class -->
<property name="service" >
<bean class="com.myapp.SimpleService"/>
</property>
<property name="nodeFilter">
<bean class="com.myapp.ServiceNodeFilter">
<constructor-arg name="serviceName" value="simpleservice"/>
</bean>
</property>
</bean>
</list>
</property>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="joinTimeout" value="60000"/>
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses" value="#{'${ignite.addresses.discovery}'.split(',')}"/>
</bean>
</property>
</bean>
</property>
<!-- see https://issues.apache.org/jira/browse/IGNITE-4377 -->
<property name="binaryConfiguration">
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="false"/>
</bean>
</property>
</bean>
</property>
{code}
After start the application i see following text on the output console:
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)