forked from alibaba/QLExpress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQLExecuteService.java
More file actions
26 lines (20 loc) · 947 Bytes
/
QLExecuteService.java
File metadata and controls
26 lines (20 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.alibaba.qlexpress4.spring;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import com.alibaba.qlexpress4.Express4Runner;
import com.alibaba.qlexpress4.InitOptions;
import com.alibaba.qlexpress4.QLOptions;
import com.alibaba.qlexpress4.security.QLSecurityStrategy;
@Service
public class QLExecuteService {
private final Express4Runner runner =
new Express4Runner(InitOptions.builder().securityStrategy(QLSecurityStrategy.open()).build());
@Autowired
private ApplicationContext applicationContext;
public Object execute(String script, Map<String, Object> context) {
QLSpringContext springContext = new QLSpringContext(context, applicationContext);
return runner.execute(script, springContext, QLOptions.DEFAULT_OPTIONS).getResult();
}
}