@Component public class GlueJpaActivity extends GlueActivity<GlueContext>
- store : @Repository가 붙은 컴포넌트 - repository : org.springframework.data.repository.Repository 를 extends 한 컴포넌트 - method : store나 repository에 해당하는 컴포넌트의 method 이름 - param-count : method의 parameter 수 - param# : key::type 형태. type 누락시 java.lang.String 으로 함. - result-key : Activity의 수행 결과에 대한 key 값다음은 activity 사용 예시입니다.
<activity name="Find" class="com.poscoict.glueframework.biz.activity.GlueJpaActivity">
<transition name="success" value="end" />
<property name="store" value="sample.posco.domain.DeptStore" />
<property name="method" value="retrieveByDeptno" />
<property name="param-count" value="1" />
<property name="param1" value="deptno::int" />
<property name="result-key" value="dept" />
</activity>
<activity name="Find" class="com.poscoict.glueframework.biz.activity.GlueJpaActivity">
<transition name="success" value="end" />
<property name="store" value="sample.posco.domain.DeptStore" />
<property name="method" value="retrieve" />
<property name="param-count" value="1" />
<property name="param1" value="uuid" />
<property name="result-key" value="dept" />
</activity>
<activity name="Find" class="com.poscoict.glueframework.biz.activity.GlueJpaActivity">
<transition name="success" value="end" />
<property name="repository" value="sample.posco.store.repository.DeptRepository" />
<property name="method" value="findByDeptno" />
<property name="param-count" value="1" />
<property name="param1" value="deptno::int" />
<property name="result-key" value="dept" />
</activity>
activity 사용 예와 관련된 sample.posco.domain.DeptStore 인터페이스와 구현클래스 입니다.
package sample.posco.domain; public interface DeptStore { void create( Dept entity ); Dept retrieve( String uuid ); Dept retrieveByDeptno( int deptno ); }
package sample.posco.store; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import sample.posco.domain.Dept; import sample.posco.domain.DeptStore; import sample.posco.store.jpo.DeptJpo; import sample.posco.store.repository.DeptRepository; @Repository public class DeptJpaStore implements DeptStore { @Autowired private DeptRepository deptRepository; @Override public void create( Dept entity ) { deptRepository.save( new DeptJpo( entity ) ); } @Override public Dept retrieve( String uuid ) { Optional<DeptJpo> value = deptRepository.findById( uuid ); if ( value.isPresent() ) { return value.get().toDomain(); } return null; } @Override public Dept retrieveByDeptno( int deptno ) { Optional<DeptJpo> value = deptRepository.findByDeptno( deptno ); if ( value.isPresent() ) { return value.get().toDomain(); } return null; } }activity 사용 예와 관련된 posco.store.repository.DeptRepository 입니다.
package sample.posco.store.repository; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import sample.posco.store.jpo.DeptJpo; public interface DeptRepository extends JpaRepository{ { Optional<DeptJpo> findByDeptno( int deptno ); }
package sample.posco.store.jpo; import javax.persistence.Entity; import javax.persistence.Id; import org.springframework.beans.BeanUtils; import sample.posco.domain.Dept; @Entity public class DeptJpo { @Id private String id; private int deptno; private String dname; private String loc; public DeptJpo( Dept entity ) { this.id = entity.getId(); BeanUtils.copyProperties( entity, this ); } // 중략 .. }
package sample.posco.domain; import java.io.Serializable; import javax.persistence.Id; import javax.persistence.MappedSuperclass; @MappedSuperclass public class Dept implements Serializable { @Id private final String id; private int deptno; private String dname; private String loc; // 중략 .. }
Modifier and Type | Field and Description |
---|---|
protected static String |
METHOD
property : method
|
protected static String |
PARAM_COUNT
property : param-count
|
protected static String |
REPOSITORY
property : repository
|
protected static String |
STORE
property : store
|
applicationContext, FAILURE, logger, RESULT_KEY, RESULT_KEY_POSTFIX, SUCCESS
Constructor and Description |
---|
GlueJpaActivity() |
Modifier and Type | Method and Description |
---|---|
String |
runActivity(GlueContext ctx)
abstract method.
|
checkMethodName, destroy, getMethod, getParamCount, getRequiredType, getResultKey, init, makeMethodParamTypes
protected static final String STORE
protected static final String REPOSITORY
protected static final String METHOD
protected static final String PARAM_COUNT
public String runActivity(GlueContext ctx)
GlueActivity
runActivity
in class GlueActivity<GlueContext>
Copyright © 2019 POSCOICT. All rights reserved.