Skip to content

Commit

Permalink
add spring el expression
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdi committed Jul 6, 2018
1 parent 65af2c5 commit 2bb190c
Show file tree
Hide file tree
Showing 7 changed files with 589 additions and 0 deletions.
42 changes: 42 additions & 0 deletions learn-springel/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http:https://maven.apache.org/POM/4.0.0"
xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>daydayup</artifactId>
<groupId>com.github.landyking</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>learn-springel</artifactId>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package springel;

import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericApplicationContext;

/**
* Created by landy on 2018/7/5.
*/
public class ApplicationContextFactory {
public static ApplicationContext createInstance() {
GenericApplicationContext app = new GenericApplicationContext();
app.registerBeanDefinition("SpElUtil", new RootBeanDefinition(SpElUtil.class));
app.refresh();
return app;
}
}
40 changes: 40 additions & 0 deletions learn-springel/src/test/java/springel/Date2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package springel;

/**
* Created by landy on 2018/7/5.
*/
public class Date2 {
private int year;
private int month;
private int day;

public int getYear() {
return year;
}

public void setYear(int year) {
this.year = year;
}

public int getMonth() {
return month;
}

public void setMonth(int month) {
this.month = month;
}

public int getDay() {
return day;
}

public void setDay(int day) {
this.day = day;
}

public Date2(int year, int month, int day) {
this.year=year;
this.month=month;
this.day=day;
}
}
68 changes: 68 additions & 0 deletions learn-springel/src/test/java/springel/SpElUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package springel;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by landy on 2018/7/5.
*/
public class SpElUtil {
private String name;
private SpelTestInnerClass innerClass;
private Date2 time;
private Map<String, Object> maps = new HashMap<String, Object>();
private List<Integer> numbers;

public SpElUtil() {
maps.put("key", Arrays.asList(1, 3, 4));
maps.put("1", "string1");
this.time = new Date2(111, 1, 2);
innerClass = new SpelTestInnerClass();
}

public List<Integer> getNumbers() {
return numbers;
}

public void setNumbers(List<Integer> integers) {
this.numbers=integers;
}

public SpelTestInnerClass getInnerClass() {
return innerClass;
}

public Map<String, Object> getMaps() {
return maps;
}

public void setMaps(Map<String, Object> maps) {
this.maps = maps;
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setTime(Date2 time) {
this.time = time;
}

public Date2 getTime() {
return time;
}

public static int len(String name) {
return name.length();
}

public void setInnerClass(SpelTestInnerClass innerClass) {
this.innerClass = innerClass;
}
}
Loading

0 comments on commit 2bb190c

Please sign in to comment.