springの中でload time weaveの応用


これまではspringをjavaプログラム開発の枠組みとして利用してきましたが、springの様々な便利な機能を利用する過程で、spring管理のbeanの生成過程によって、いくつかの設計モードへの応用が制限されています.
   springは2.0以降のバージョンで、ロードtime weaveの概念を導入しました.springのプロファイルを利用してbeanの各種属性を管理できます.コードの中で@configrableタグを利用して配置の種類を表示して、後でコードの中で該当するbeanを生成すれば、二つの利点が得られます.
   一つはコードの中でbeanの生産過程を制御できます.第二に、springの構成と参照spring構成におけるbeanを利用することができる.
springの構成は以下の通りです.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
						http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
						http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">



	<context:annotation-config/>
	<context:load-time-weaver/>

	<bean id ="spel" class = "org.tkxing.spring.spel.SpelObject">
		<property name="data" ref ="dataConfiguration"></property>
	</bean>

	<bean id ="host" class = "org.tkxing.spring.spel.HostObject" abstract="true">
		<property name="spel" ref="spel"></property>
	</bean>

</beans>
 javaのclassの実現は以下の通りです.
import org.springframework.beans.factory.annotation.Configurable;


@Configurable("host")
public class HostObject {
	private String hello;
	private SpelObject spel;

	public String getHello() {
		return hello;
	}

	public void setHello(String hello) {
		this.hello = hello;
	}

	public SpelObject getSpel() {
		return spel;
	}

	public void setSpel(SpelObject spel) {
		this.spel = spel;
	}

}