Skip to content
Merged

Dev #197

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.44</version>
<version>3.4.45</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
</parent>

<name>springboot-starter-data-authorization</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-fast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.44</version>
<version>3.4.45</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ScriptMapping(String mapping, ScriptMethod scriptMethod, String script) {

@ResponseBody
Response execute() {
Object result = ScriptRuntime.running(script);
Object result = ScriptRuntime.getInstance().running(script);
if (result instanceof List || result.getClass().isArray()) {
return SingleResponse.of(result);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,36 @@
import com.codingapi.springboot.fast.jdbc.JdbcQueryContext;
import com.codingapi.springboot.fast.jpa.JpaQuery;
import com.codingapi.springboot.fast.jpa.JpaQueryContext;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import com.codingapi.springboot.framework.script.GroovyScriptRunner;
import com.codingapi.springboot.framework.script.request.GroovyBindObjectBuilder;
import lombok.Getter;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;


public class ScriptRuntime {

static Object running(String script) {
Binding binding = new Binding();

@Getter
private final static ScriptRuntime instance = new ScriptRuntime();

private final GroovyScriptRunner scriptRunner;

private ScriptRuntime(){
this.scriptRunner = new GroovyScriptRunner(1000);
}

Object running(String script) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
ScriptRequest request = new ScriptRequest(attributes.getRequest());
JdbcQuery jdbcQuery = JdbcQueryContext.getInstance().getJdbcQuery();
JpaQuery jpaQuery = JpaQueryContext.getInstance().getJpaQuery();

binding.setVariable("$request", request);
binding.setVariable("$jpa", jpaQuery);
binding.setVariable("$jdbc", jdbcQuery);
GroovyBindObjectBuilder bindBuilder = GroovyBindObjectBuilder.builder();
bindBuilder.add("$request", request);
bindBuilder.add("$jpa", jpaQuery);
bindBuilder.add("$jdbc", jdbcQuery);

GroovyShell groovyShell = new GroovyShell(binding);
Script userScript = groovyShell.parse(script);
return userScript.run();
return this.scriptRunner.run(script,Object.class,bindBuilder.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ScriptRuntimeTest {

@Test
void running() {
Object res = ScriptRuntime.running("return 1");
Object res = ScriptRuntime.getInstance().running("return 1");
assertEquals(1, res);
}
}
2 changes: 1 addition & 1 deletion springboot-starter-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.44</version>
<version>3.4.45</version>
</parent>

<name>springboot-starter-flow</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.codingapi.springboot.flow.script;

import com.codingapi.springboot.framework.script.GroovyScriptRunningContext;
import com.codingapi.springboot.framework.script.GroovyScriptRunner;
import lombok.Getter;

public class GroovyShellContext {
Expand All @@ -11,25 +11,25 @@ public class GroovyShellContext {
@Getter
private final static GroovyShellContext instance = new GroovyShellContext();

private final GroovyScriptRunner scriptRunner;


private GroovyShellContext() {
if(GroovyScriptRunningContext.getInstance().getMaxCacheSize()!=MAX_CACHE_SIZE) {
GroovyScriptRunningContext.getInstance().setMaxCacheSize(MAX_CACHE_SIZE);
}
scriptRunner = new GroovyScriptRunner(MAX_CACHE_SIZE);
}


public <T> T run(String script, Class<T> returnType, Object... args) {
return GroovyScriptRunningContext.getInstance().run("run", script, returnType, args);
return scriptRunner.invoke("run", script, returnType, args);
}


public int size(){
return GroovyScriptRunningContext.getInstance().cacheSize();
public int size() {
return scriptRunner.cacheSize();
}

public void clear(){
GroovyScriptRunningContext.getInstance().clearCache();
public void clear() {
scriptRunner.clearCache();
}

}
2 changes: 1 addition & 1 deletion springboot-starter-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.44</version>
<version>3.4.45</version>
</parent>

<artifactId>springboot-starter-security</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.44</version>
<version>3.4.45</version>
</parent>
<artifactId>springboot-starter</artifactId>

Expand Down
Loading