반응형

MANDATORY

Support a current transaction, throw an exception if none exists.

시작된 트랜잭션이 있으면 support, 없으면 예외 발생


NESTED

Execute within a nested transaction if a current transaction exists, behave like PROPAGATION_REQUIRED else.

시작된 트랜잭션이 있으면 중첩해서 트랜잭션을 실행한다. 


NEVER

Execute non-transactionally, throw an exception if a transaction exists.

트랜잭션이 있으면 예외 발생


NOT_SUPPORTED

Execute non-transactionally, suspend the current transaction if one exists.

시작된 트랜잭션이 있으면 보류한 후 트랜잭션 없이 진행한다.


REQUIRED

Support a current transaction, create a new one if none exists.

시작된 트랜잭션이 있으면 support, 없으면 새로운 트랜잭션을 생성한다.


REQUIRES_NEW

Create a new transaction, and suspend the current transaction if one exists.

이미 시작된 트랜잭션이 있으면 보류하고 새로운 트랜잭션을 생성해서 시작한다.


SUPPORTS

Support a current transaction, execute non-transactionally if none exists.

시작된 트랜잭션이 있으면 support, 없으면 없이 진행한다. 

728x90
반응형

'Development > Java' 카테고리의 다른 글

[SpringCloud]Spring Config..  (0) 2016.01.26
spring Cache  (0) 2015.12.05
[JPA]Persistence Context  (0) 2015.08.25
[JPA]Entity 생명주기  (0) 2015.08.12
Mybatis 동적쿼리 사용시 NuberFormatException:For input String 해결방법  (0) 2014.10.30
반응형

SpEL
- Expression Languege중 하나, 런타임시 특정 객체의 정보에 접근하거나 조작할수 있도록 지원.

1. XML 기반 Bean 정의시

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
        <property name="driverClassName" value="#{contextProperties.driver}"> 
        <property name="url" value="#{contextProperties.url}"> 
        <property name="username" value="#{contextProperties.username}"> 
        <property name="password" value="#{contextProperties.password}"> 
</property></property></property></property></bean>

classpath상에 존재하는 context.properties파일을 로드하여 bean으로 정의한 후 driver, url 등의 정보를 추출함.

2. Annotation 기반 Bean 정의시

  1. @Repository(“movieDao")
  2. public class MovieDao extends SimpleJdbcDaoSupport {
  3.  
  4.        @Value("#{contextProperties['pageSize'] ?: 10}")
  5.        int pageSize;
  6.        @Value("#{contextProperties['pageUnit'] ?: 10}")
  7.        int pageUnit;
  8.        @Inject
  9.        public void setJdbcDaoDataSource(DataSource dataSource) throws Exception {
  10.                  super.setDataSource(dataSource);
  11.        }
  12. }
@Value라는 Annotation과 함께 Expression정의 (값이 없을 경우 10으로 셋팅)

728x90
반응형

'Development > Java' 카테고리의 다른 글

파일 입출력.  (0) 2013.01.29
[Spring]Spring Annotation  (0) 2012.08.01
[Spring]Autowiring  (0) 2012.05.03
[Spring]AOP 주요 구성요소  (0) 2012.04.13
[Spring]Spring Bean Scope  (0) 2012.04.09
반응형

- Autowiring 이란
  Spirng container가 bean 간의 참조관계를 자동으로 연결해주는 기능

- 속성값
 1. no : 기본값
 2. byName : property 명과 동일한 id 또는 name을 가진 bean
 3. byType : 동일한 클래스타입,(같은 타입 여러개 존재시 exception 발생)
 4. constructor : byType과 비슷하나 생성자인자에 적용
 5. autodetect : constructor 모드 수행후 byType 모드 수행
 6. default : 최상위 태그인 <beans> 에 셋팅한 모드가 수행됨. (default-autowire 속성)


Setter Injection 사용시

  1. <bean id="firstBean" class="“org.anyframe.exercise.dependencies.FirstBean">
  2.     <property name="”secondBean”" ref="”secondBean”/"></property></bean>
  3.     <bean id="secondBean" class="“org.anyframe.exercise.dependencies.SecondBean/">
  4. </bean>
Autowire 사용시
  1. <bean id="firstBean" class="“org.anyframe.exercise.dependencies.FirstBean" autowire="byType">
  2.     <bean id="secondBean" class="“org.anyframe.exercise.dependencies.SecondBean/">
  3. </bean></bean>

특정 bean을 autowiring 제외시키려면

  1. <bean id="bean" class="“org.anyframe.test.TestBean”" autowire-candidate="false"> </bean>


728x90
반응형

'Development > Java' 카테고리의 다른 글

[Spring]Spring Annotation  (0) 2012.08.01
[Spring]SpEL(Spring Expression Language)  (0) 2012.07.31
[Spring]AOP 주요 구성요소  (0) 2012.04.13
[Spring]Spring Bean Scope  (0) 2012.04.09
[Spring]Dependency Injection  (0) 2012.03.21
반응형

1. Singleton Scope

- SpringContatiner는 해당 Bean에 대한 여러개의 요청이나 참조에 대해 하나의 Bean 인스턴스만 생성해서 제공함.

- 사용자의 요청시마다 유지해야할 data일 경우 Singleton Scope는 부적합.

- scope을 별도로 지정하지 않을경우 기본값은 Singleton Scope이다.


2. Prototype Scope

- SpringContainer는 요청시마다 새로운 인스턴스 생성하여 제공.


3. Request Scope

- Http Request마다 새로운 인스턴스 를 생성하여 제공


4. Session Scope

- Http Session마다 새로운 인스턴스 를 생성하여 제공

728x90
반응형

'Development > Java' 카테고리의 다른 글

[Spring]Autowiring  (0) 2012.05.03
[Spring]AOP 주요 구성요소  (0) 2012.04.13
[Spring]Dependency Injection  (0) 2012.03.21
[Spring in Action]DispatcherServlet 구성  (0) 2011.10.25
[Spring In Action]Spring MVC 요청의 생명주기  (0) 2011.10.17
반응형
Bean Definition 파일에 정의 한 dependency 관련 정보를 바탕으로 객체 사이의 의존 관계를 Container가 자동적으로 연결해주는것을 말한다. Container API 에 종속되는것을 줄일수 있다.
- Setter Injection : Setter 메소드 구현을 통해 해당 객체 초기화시 Container로 부터 참조관계에 놓인 특정 리소스를 할당받음.
- Constructor Injection : Constructor 구현을 통해 특정 객체 초기화 시 Contatiner로부터 참조 관계에 놓인 특정 리소스를 할당 받는 방법

-- Setter Injection 예
[속성 정의 파일 ] 
  1. <bean id="“movieService&quot;" class="….MovieServiceImpl">
  2.    <property name="“genreService&quot;" ref="“genreService&quot;/"></property></bean>
  3.    <bean id="”genreService”" class="”....GenreServiceImpl”/">
  4. </bean>
[구현클래스 ] 
  1. public class MovieServiceImpl implements MovieService{
  2.       DepBean genreService;
  3.       public void setGenreService(GenreService genreService) {
  4.             this.genreService = genreService;
  5.       }
  6. //중략
  7. }
-- Constructor Injection 예
  1. <bean id="“movieService" class="“org.anyframe.exercise.moviefinder.service.impl.MovieServiceImpl">
  2.      <constructor-arg ref="“movieDao/"></constructor-arg></bean>   
  3.      <bean id="movieDao" class="org.anyframe.exercise.moviefinder.service.impl.moviedao"/>
  4. </bean>
[구현클래스 ] 
  1. public class MovieServiceImpl implements MovieService {
  2.       private MovieDao movieDao;
  3.       public MovieServiceImpl(MovieDao movieDao) {
  4.            this.movieDao = movieDao;
  5.      }
  6. }
% Circular Dependencies
  1. <bean id="beanFirst" class="test.BeanFirst">
  2.       <constructor-arg ref="beanSecond"></constructor-arg>
  3. </bean>
  4. <bean id="beanSecond" class="test.BeanSecond">
  5.       <constructor-arg ref="beanFirst"></constructor-arg>
  6. </bean>
 두개의 서로다른 Bean이 constructor-arg 를 이용해 서로의 Bean을 참조하는 경우에 BeanCurrentlylnCreationException 발생


728x90
반응형

+ Recent posts