Spring Data REST + GemFire + AngularJS Integration

This tutorial explains the integration between Spring Data REST, GemFire and AngularJS frameworks. We are going to develop a REST service which returns the JSON response and that will be accessed by the AngularJS web page.

  1. Tools Required

We’ve developed this tutorial by using the following tools:

JDK 1.6.
Tomcat 7.
Maven 3.
GemFire 7.0.1.
AngularJS
2. Project Structure

Here is the project structure used for this tutorial.

Spring REST - GemFire - Eclipse Project Directory
3. Business Domain

Message is the persistence object used for storing the data in GemFire’s in-memory storage. We are using only this entity for this tutorial. If you look at the below code, the entity imports the org.springframework.data.gemfire.mapping.Region which is equivalent to the table in the relational database. This Region class used as the segment in in-memory and allocate the storage for the data.

Message.java

package net.javabeat.springdata.data;

import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.gemfire.mapping.Region;

@Region(“messages”)
public class Message {
@Id
private String messageId;
private String message;

public Message() {
}

@PersistenceConstructor
public Message(String id, String message) {
this.messageId = id;
this.message = message;
}

public String getMessageId() {
return messageId;
}

public void setMessageId(String messageId) {
this.messageId = messageId;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
}
4. Spring Data Repository

It’s the repositories that enable the CRUD operations against the business domain. In our previous tutorial I have explained theSpring Dataand how the repositories used for the CRUD operations.

MessageReposirory.java

package net.javabeat.springdata.repo;

import net.javabeat.springdata.data.Message;

import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

@RepositoryRestResource(collectionResourceRel=”messages”,path=”messages”)
public interface MessageRepository extends CrudRepository

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值