@Component public class GlueRestClientActivity extends GlueActivity<GlueContext>
- uri : Spring REST API - method : HTTP method. GET,POST,PUT,DELETE - data : key - param-count : parameter 수. - param# : key - result-key : Activity의 수행 결과에 대한 key 값다음은 activity 사용 예시입니다.
<activity name="Get" class="com.poscoict.glueframework.biz.activity.GlueRestClientActivity">
<transition name="success" value="end" />
<property name="uri" value="uri-key" />
<property name="method" value="GET" />
<property name="result-key" value="deptList" />
</activity>
<activity name="POST" class="com.poscoict.glueframework.biz.activity.GlueRestClientActivity">
<transition name="success" value="end" />
<property name="uri" value="uri-key" />
<property name="method" value="POST" />
<property name="data" value="dept" />
</activity>
<activity name="PUT" class="com.poscoict.glueframework.biz.activity.GlueRestClientActivity">
<transition name="success" value="end" />
<property name="uri" value="uri-key" />
<property name="method" value="PUT" />
<property name="data" value="dept" />
<property name="param-count" value="1" />
<property name="param1" value="deptno" />
</activity>
<activity name="DELETE" class="com.poscoict.glueframework.biz.activity.GlueRestClientActivity">
<transition name="success" value="end" />
<property name="uri" value="uri-key" />
<property name="method" value="DELETE" />
<property name="param-count" value="1" />
<property name="param1" value="deptno" />
</activity>
다음은 Spring REST API 예시입니다.
@RestController(value = "dept")
public class DeptController
{
@GetMapping
public List getDeptList(){
...
return ..;
}
@PostMapping
public void addDept(@RequestBody Dept dept){
...
}
@PutMapping(path="{deptno}")
public void updateDept(@PathVariable String deptno, @RequestBody Dept dept){
...
}
@DeleteMapping(path="{deptno}")
public void deleteDept(@PathVariable String deptno){
...
}
}
다음은 테스트 코드 일부입니다.
@Bean
public CommandLineRunner run( GlueRestClientActivity activity )
{
return ( args -> {
String uri = "http://localhost:8080/dept";
Map props = new HashMap<>();
props.put( "uri", "uri-key" );
props.put( "method", "GET" );
props.put( "result-key", "result" );
GlueDefaultContext ctx = new GlueDefaultContext( "no-service" );
ctx.setActivityProperties( GlueRestClientActivity.class, props );
ctx.put( "uri-key", uri );
activity.runActivity( ctx );
System.out.println( ctx.get( "result" ) );
} );
}
| Modifier and Type | Field and Description |
|---|---|
protected static String |
DATA
property : param
|
protected static String |
METHOD
property : method
|
protected static String |
PARAM_COUNT
property : param-count
|
protected static String |
URI
property : url
|
applicationContext, FAILURE, logger, RESULT_KEY, RESULT_KEY_POSTFIX, SUCCESS| Constructor and Description |
|---|
GlueRestClientActivity() |
| Modifier and Type | Method and Description |
|---|---|
String |
runActivity(GlueContext ctx)
abstract method.
|
checkMethodName, destroy, getMethod, getParamCount, getRequiredType, getResultKey, init, makeMethodParamTypesprotected static final String URI
protected static final String METHOD
protected static final String DATA
protected static final String PARAM_COUNT
public String runActivity(GlueContext ctx)
GlueActivityrunActivity in class GlueActivity<GlueContext>Copyright © 2019 POSCOICT. All rights reserved.