group persistence modules (#2890)
* move security content from spring-security-rest-full * swagger update * move query language to new module * rename spring-security-rest-full to spring-rest-full * group persistence modules
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
dbeb5f8ba4
commit
26c50909be
+16
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.spring.data.gemfire.function;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.gemfire.function.annotation.FunctionId;
|
||||
import org.springframework.data.gemfire.function.annotation.OnRegion;
|
||||
import org.springframework.data.gemfire.function.annotation.RegionData;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@OnRegion(region="employee")
|
||||
public interface FunctionExecution {
|
||||
@FunctionId("greeting")
|
||||
public void execute(String message);
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.spring.data.gemfire.function;
|
||||
|
||||
import org.springframework.data.gemfire.function.annotation.GemfireFunction;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FunctionImpl {
|
||||
|
||||
@GemfireFunction
|
||||
public void greeting(String message){
|
||||
System.out.println("Message "+message);
|
||||
}
|
||||
|
||||
@GemfireFunction
|
||||
public String sayHello(String message){
|
||||
return "Hello "+message;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.baeldung.spring.data.gemfire.function;
|
||||
|
||||
import com.baeldung.spring.data.gemfire.model.Employee;
|
||||
import com.baeldung.spring.data.gemfire.repository.EmployeeRepository;
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.LocalRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.function.config.EnableGemfireFunctionExecutions;
|
||||
import org.springframework.data.gemfire.function.config.EnableGemfireFunctions;
|
||||
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableGemfireRepositories(basePackages = "com.baeldung.spring.data.gemfire.repository")
|
||||
@EnableGemfireFunctions
|
||||
@EnableGemfireFunctionExecutions(basePackages = "com.baeldung.spring.data.gemfire.function")
|
||||
public class GemfireConfiguration {
|
||||
|
||||
@Autowired
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
FunctionExecution functionExecution;
|
||||
|
||||
|
||||
@Bean
|
||||
Properties gemfireProperties() {
|
||||
Properties gemfireProperties = new Properties();
|
||||
gemfireProperties.setProperty("name", "SpringDataGemFireApplication");
|
||||
gemfireProperties.setProperty("mcast-port", "0");
|
||||
gemfireProperties.setProperty("log-level", "config");
|
||||
return gemfireProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Autowired
|
||||
CacheFactoryBean gemfireCache() {
|
||||
CacheFactoryBean gemfireCache = new CacheFactoryBean();
|
||||
gemfireCache.setClose(true);
|
||||
gemfireCache.setProperties(gemfireProperties());
|
||||
return gemfireCache;
|
||||
}
|
||||
|
||||
|
||||
@Bean(name="employee")
|
||||
@Autowired
|
||||
LocalRegionFactoryBean<String, Employee> getEmployee(final GemFireCache cache) {
|
||||
LocalRegionFactoryBean<String, Employee> employeeRegion = new LocalRegionFactoryBean<String, Employee>();
|
||||
employeeRegion.setCache(cache);
|
||||
employeeRegion.setClose(false);
|
||||
employeeRegion.setName("employee");
|
||||
employeeRegion.setPersistent(false);
|
||||
employeeRegion.setDataPolicy(DataPolicy.PRELOADED);
|
||||
return employeeRegion;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.baeldung.spring.data.gemfire.model;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.PersistenceConstructor;
|
||||
import org.springframework.data.gemfire.mapping.Region;
|
||||
|
||||
|
||||
@Region("employee")
|
||||
public class Employee {
|
||||
|
||||
@Id
|
||||
public String name;
|
||||
public double salary;
|
||||
|
||||
@PersistenceConstructor
|
||||
public Employee(String name, double salary) {
|
||||
this.name = name;
|
||||
this.salary = salary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " is " + salary + " years old.";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public double getSalary() {
|
||||
return salary;
|
||||
}
|
||||
|
||||
public void setSalary(int salary) {
|
||||
this.salary = salary;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.spring.data.gemfire.repository;
|
||||
|
||||
import com.baeldung.spring.data.gemfire.model.Employee;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends CrudRepository<Employee, String> {
|
||||
|
||||
Employee findByName(String name);
|
||||
|
||||
Iterable<Employee> findBySalaryGreaterThan(double salary);
|
||||
|
||||
Iterable<Employee> findBySalaryLessThan(double salary);
|
||||
|
||||
Iterable<Employee> findBySalaryGreaterThanAndSalaryLessThan(double salary1, double salary2);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:gfe-data="http://www.springframework.org/schema/data/gemfire"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/data/gemfire http://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
|
||||
|
||||
<context:component-scan base-package="com.baeldung.spring.data.gemfire"></context:component-scan>
|
||||
|
||||
<gfe:annotation-driven/>
|
||||
<gfe-data:function-executions base-package="com.baeldung.spring.data.gemfire.function"/>
|
||||
<!-- Declare GemFire Cache -->
|
||||
<gfe:cache/>
|
||||
<!-- Local region for being used by the Message -->
|
||||
<gfe:local-region id="employee" value-constraint="com.baeldung.spring.data.gemfire.model.Employee" data-policy="PRELOADED"/>
|
||||
<!-- Search for GemFire repositories -->
|
||||
<gfe-data:repositories base-package="com.baeldung.spring.data.gemfire.repository"/>
|
||||
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user