[case study] transaction types

¢£abs
commit or rollback??

¢£env+conditions
¢¢operation flow

opeA¢ªopeB¢ªopeC

ParentBean#test(){
¡¡opeA;
¡¡ParentBean.childBean.test();
¡¡opeC;¢ªEXCEPTION!!!
}
ChildBean#test(){ opeB }

¢¢relations

childBean -DI¢ª parentBean

¢¢bean def file

<'bean id="parentBean" class="ParentBean">
¡¡<'property name="childBean" ref="childBean"/>
<'/bean>
<'bean id="childBean" class="ChildBean"/>

¢¢bean def file (transaction)

¡¡<'bean id="applyTransactionAttribute"
¡¡¡¡¡¡¡¡class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
¡¡¡¡<'property name="properties">
¡¡¡¡<'props>
¡¡¡¡¡¡<'prop key="test">PROPAGATION_REQUIRED<'/prop>¡ú
¡¡¡¡<'/props>
¡¡<'/property>
¡¡<'/bean>

¡¡<'bean id="autoProxy"
¡¡¡¡class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
¡¡¡¡<'property name="interceptorNames">
¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡<'value>applyInterceptor<'/value>
¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
¡¡¡¡<'property name="beanNames">
¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡<'value>parentBean<'/value>
¡¡¡¡¡¡¡¡<'value>childBean<'/value>
¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
¡¡<'/bean>

¢£case study
¢¢PROPAGATION_REQUIRED¡½´û¸¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òήÍÑ
¡¡opeA: ¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤òÀ¸À®
¡¡opeB: ´û¸¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤¬¤¢¤ë¤Î¤Ç ¤½¤¤¤Ä¤òήÍÑ
¡¡opeC: opeA»þ¤ËÀ¸À®¤µ¤ì¤¿¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤ò¤½¤Î¤Þ¤Þ»ÈÍÑ
¡¡¢­
¡¡opeC¤ÇEXCEPTION¤¬È¯À¸¤·¤¿¾ì¹ç
¡¡opeA¤âopeB¤â¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ë¡£

¢¢PROPAGATION_REQUIRES_NEW¡½¾ï¤Ë¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥ó
¡¡opeA: ¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤òÀ¸À®
¡¡opeB: ¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥óB¤òÀ¸À®
¡¡¡¡¡¡¡¡¤³¤Î»þ ¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤Ï¾Ã¤¨¤ë
¡¡opeC: ¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥óC¤òÀ¸À®
¡¡¡¡¡¡¡¡¤³¤Î»þ ¥È¥é¥ó¥¶¥¯¥·¥ç¥óC¤Ï¾Ã¤¨¤ë
¡¡¢­
¡¡opeC¤ÇEXCEPTION¤¬È¯À¸¤·¤¿¾ì¹ç
¡¡opeA¤Ï ¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤¬¥³¥ß¥Ã¥È¤µ¤ì¤ëÁ°¤Ë¾Ã¤µ¤ì¤ë¤Î¤Ç ¥³¥ß¥Ã¥È¤µ¤ì¤Ê¤¤
¡¡opeB¤Ï ¥È¥é¥ó¥¶¥¯¥·¥ç¥óB¤¬Ìµ»ö½ªÎ»¤¹¤ë¤Î¤Ç¥³¥ß¥Ã¥È¤µ¤ì¤ë
¡¡opeC¤Ï ÉáÄÌ¤Ë¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ë
¡¡
¢¢PPROPAGATION_NESTED¡½»Ò¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÍøÍÑ
¡¡[bean def file (transaction)]¤òÊѹ¹¤· childBean¤Ë¤ÏPPROPAGATION_NESTED¤ò»ØÄê
¡¡opeA: ¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤òÀ¸À®
¡¡opeB: ¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥óB¤òÀ¸À®
¡¡¡¡¡¡¡¡¤³¤Î»þ ¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤Ï¾Ã¤¨¤ë
¡¡opeC: ¿·µ¬¥È¥é¥ó¥¶¥¯¥·¥ç¥óC¤òÀ¸À®¡Ê¤¿¤Ö¤ó¡Ë
¡¡¡¡¡¡¡¡¤³¤Î»þ ¥È¥é¥ó¥¶¥¯¥·¥ç¥óC¤Ï¾Ã¤¨¤ë
¡¡¢­
¡¡opeC¤ÇEXCEPTION¤¬È¯À¸¤·¤¿¾ì¹ç
¡¡opeA¤Ï ¥È¥é¥ó¥¶¥¯¥·¥ç¥óA¤¬¥³¥ß¥Ã¥È¤µ¤ì¤ëÁ°¤Ë¾Ã¤µ¤ì¤ë¤Î¤Ç ¥³¥ß¥Ã¥È¤µ¤ì¤Ê¤¤
¡¡opeB¤Ï ¥È¥é¥ó¥¶¥¯¥·¥ç¥óB¤¬Ìµ»ö½ªÎ»¤¹¤ë¤Î¤Ç¥³¥ß¥Ã¥È¤µ¤ì¤ë
¡¡opeC¤Ï ÉáÄÌ¤Ë¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ë



ref:
http://8318.blog100.fc2.com/blog-entry-225.html

Spring Framework: Best Programming Practices Part 2

¥Ù¥¹¥È¥×¥é¥¯¥Æ¥£¥¹¤½¤Î£²¡ª
¤½¤Î£²¤âSpring¥³¥¢¥Ñ¥Ã¥±¡¼¥¸¤È¤½¤ÎÂ¾ÊØÍø¥Ñ¥Ã¥±¡¼¥¸¤Ë¥Õ¥©¡¼¥«¥¹¡£
¤½¤Î£±¡Á£µ¤â»²¹Í¤Ë¤É¤¦¤¾¡£
¤¢¡¢´Ö°ã¤Ã¤Æ¤¿¤é¶µ¤¨¤Æ¡£
(This is the second part of Spring Best Practices series as per Best practices introduction post. This second part is also related with the best practices when using Spring¡Çs Core classes and other utilities. You can refer the other four posts through this links¡Ä Part 1, Part 3, Part 4 and Part 5. I am expecting the corrections (if any)as well as the new best ways from my readers.)
--------------------------------------------------------------------------------
* °Û¤Ê¤ë¥í¥±¡¼¥·¥ç¥ó¤Ç¤ÎApplicationContext¤ÎÀßÄê
* Configuring Spring Application context for different locations:
--------------------------------------------------------------------------------
³«È¯¥Þ¥·¥ó°Ê³°¤Î´Ä¶­ÀßÄ꤬Ʊ¤¸¤Ê¤é¡¢°ã¤¦¤ä¤Ä¤À¤±¤òÄêµÁ¤·¤¿ÊÌÀßÄê¥Õ¥¡¥¤¥ë¤òÍѰա£
(If the configuration is the same for all the environments except for the developer¡Çs machine,
then make (a) separate configuration file(s) with the configuration that is different. )

¤Ç¡¢°ã¤¦¤ä¤Ä¤ÎÀßÄê¤Ç¡¢¶¦Ä̤Τä¤Ä¤ò¾å½ñ¤­¤¹¤ë¤è¤¦¤ÊÄêµÁ¤ò¤¹¤ë¡£
(Let this different configuration overwrite the definition(s) in the original file(s).)
Ãí°Õ¡§¾å½ñ¤­¤·¤¿ÀßÄê¤Ï¡¢¿ÆÀßÄê¤ò»²¾È¤·¤ÆÂ¾¤ÎÅÛ¤é¤Ë¤â±Æ¶Á¤¹¤ë¤«¤é¤Í¡£
Make sure this different configuration will never be placed in the other environments!!!
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
Example of how to achieve this if you use the org.springframework.context.support.ClassPathXmlApplicationContext:
¢¨Êص¹¾å¡¢Bean¤Ë¤ÏÁ´Éô¥æ¥Ë¡¼¥¯¤ÊID¤ò³ä¤ê¿¶¤êÃæ¡£¸å¤ÇRef¤·°×¤¤¤è¤¦¤Ë¡£
(Note: I give every example file below a unique name, so I can easily refer to it.Contents of beanRefContext.xml:)
<'beans>
¡¡¡¡<'bean
¡¡¡¡¡¡¡¡id=¡ÉaBeanId¡Éclass=¡Éorg.springframework.context.support.ClassPathXmlApplicationContext¡É>
¡¡¡¡¡¡¡¡<'constructor-arg>
¡¡¡¡¡¡¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡<'value>
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡/spring/applicationContext-forAllTheEnvironments.xml
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡<'/value>
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡<'value>/spring/applicationContext-local.xml<'/value>
¡¡¡¡¡¡¡¡¡¡¡¡<'/list>
¡¡¡¡¡¡¡¡<'/constructor-arg>
¡¡¡¡¡¡¡¡<'constructor-arg>
¡¡¡¡¡¡¡¡¡¡¡¡ref bean=¡ÉframeworkApplicationContextId¡É/>
¡¡¡¡¡¡¡¡<'/constructor-arg>
¡¡¡¡<'/bean>
<'/beans>
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
configLocations¡Ê£±¤Ã¤³¤á¤Î¥³¥ó¥¹¥È¥é¥¯¥¿°ú¿ô¡Ë¤ËÄêµÁ¤·¤¿Bean¤Ç¡¢applicationContext¡Ê£²¤³¤á¤Î¥³¥ó¥¹¥È¥é¥¯¥¿°ú¿ô¡Ë¤ËÄêµÁ¤·¤¿Bean¤ò¾å½ñ¤­¡£
(Beans defined in the config locations (first constructor-arg) overwrite the beans in the parent application context (second constructor-arg).)
¤³¤Î¥¯¥é¥¹¤ÎJavaDoc¤Ë¤è¤ì¤Ð¡¢Ê£¿ô¤ÎcouficLocation¤¬¤¢¤ë¾ì¹ç¡¢¸å¤ËÄêµÁ¤µ¤ì¤¿Bean¤¬¡¢Àè¤ËÄêµÁ¤µ¤ì¤¿¤â¤Î¤ò¾å½ñ¤¯¡£Â¾¤ÎXML¥Õ¥¡¥¤¥ë¤ò·Ðͳ¤·¤¿Bean¤Ç¤â¾å½ñ¤­²Äǽ¡£
(Quote from the JavaDoc of this class ¡ÈIn case of multiple config locations, later bean definitions will override ones defined in earlier loaded files.
This can be leveraged to deliberately override certain bean definitions via an extra XML file.¡É

--------------------------------------------------------------------------------
* ưŪ¥Ý¥¤¥ó¥È¥«¥Ã¥È¤è¤êÀÅŪ¥Ý¥¤¥ó¥È¥«¥Ã¥È
* Prefer static pointcut over dynamic point cut :
--------------------------------------------------------------------------------
TODO
In Spring¡Çs book of definitions static point cut refers to a pointcut that can be evaluated when a proxy is created.
Criteria for static point cuts can not changed afterwards.
Dynamic point cuts depend on runtime information such as arguement values or call stack.
Dynamic pointcuts are slower to evaluate than static pointcuts and allow less potential for optimization.
It¡Çs always necessary to evaluate them on each invocation.


--------------------------------------------------------------------------------
* Use regular expression advisors to fine tune interceptor scope
--------------------------------------------------------------------------------
TODO
Instead of using broad method point cuts and filtering target methods in interceptor,
use more sophisticated and elegant regular expression at the application context level.
Spring supports three types of regex method point cuts:
¡¦ org.springframework.aop.support.JdkRegexpMethodPointcut : Java 1.4 regular expression for the fully-qualified method names to match.
¡¦ org.springframework.aop.support.Perl5RegexpMethodPointcut : Perl5 regular expression for the fully-qualified method names to match
¡¦ org.springframework.aop.support.RegexpMethodPointcutAdvisor : Convenient class for regexp method pointcuts that hold an Advice, making them an Advisor.
By default, JdkRegexpMethodPointcut will be used on JDK 1.4+, falling back to Perl5RegexpMethodPointcut on JDK 1.3 (requiring Jakarta ORO on the classpath).

ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
Example:
<'bean id=¡ÉcrudInterceptor¡É class=¡Écom.mycompany.CrudInterceptor¡É />
<'bean
¡¡¡¡id=¡Écrud¡Éclass=¡Éorg.springframework.aop.support.RegexpMethodPointcutAdvisor¡É>
¡¡¡¡<'property name=¡Éadvice¡É>
¡¡¡¡¡¡¡¡<'ref local=¡É crudInterceptor ¡È />
¡¡¡¡<'/property>
¡¡¡¡<'property name=¡Épatterns¡É>
¡¡¡¡¡¡¡¡<'value>.*create.*,.*destroy.*,.*get.*,.*update.*<'/value>
¡¡¡¡<'/property>
<'/bean>
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
--------------------------------------------------------------------------------
* Â礭¤¤¥¢¥×¥ê¤Ë¤Ï¥ª¡¼¥È¥×¥í¥­¥·¤¬Í­¸ú
* Use autoproxying for large applications
--------------------------------------------------------------------------------
ProxyFactoryBean¤Ï¡¢¾®¤µ¤¤¥¢¥×¥ê¤Ë¤Ï¤è¤¤¤¬¡¢ÀßÄ꤬¤¯¤É¤¤¡£
¥³¥ó¥È¥í¡¼¥é¤´¤È¤Ë°ã¤Ã¤¿¥×¥í¥­¥·¤ÎÀßÄ꤬²Äǽ¡£
¥×¥í¥­¥·¤Ç¥³¡¼¥É·Ú¸º¡ª
Spring¤ÎTransactionProxyFactoryBean¤ä LocalStatelessSessionProxyFactoryBean¤Ç¡¢ProxyFactoryBean¤¬³Ú¤Ë»È¤¨¤ë¡£
(ProxyFactoryBean works well for small application but it requires more verbose configuration.
It allows control over every aspect of the proxy.
Spring ease the use of ProxyFactoryBean by providing dedicated proxies such as TransactionProxyFactoryBean and LocalStatelessSessionProxyFactoryBean.
Proxies also saves code duplication in configurations.)

ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
Example:
<'bean id=¡ÉmyProxy¡É
¡¡¡¡class=¡Éorg.springframework.aop.framework.ProxyFactoryBean¡É
¡¡¡¡abstract=¡Étrue¡É>
¡¡¡¡<'property name=¡ÉinterceptorNames¡É>
¡¡¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡¡¡¡¡<'value>interceptor1<'/value>
¡¡¡¡¡¡¡¡¡¡¡¡<'value>interceptor2<'/value>
¡¡¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
<'/bean>
<'bean id=¡Émybean¡É parent=¡ÉmyProxy¡É>
¡¡¡¡<'property name=¡ÉproxyInterfaces¡É>
¡¡¡¡¡¡¡¡<'value>com.mycompany.mybean<'/value>
¡¡¡¡<'/property>
¡¡¡¡<'property name=¡Étarget¡É>
¡¡¡¡¡¡¡¡<'bean class=¡Écom.mycompany.MyBeanImpl¡É>
¡¡¡¡¡¡¡¡¡¡¡¡<'property name=¡Éname¡É>
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡<'value>Dave<'/value>
¡¡¡¡¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡¡¡¡¡¡¡¡¡<'property name=¡Édescription¡É>
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡<'value>Good Boy<'/value>
¡¡¡¡¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡¡¡¡¡<'/bean>
¡¡¡¡<'/property>
<'/bean>
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
¾åµ­¤ß¤¿¤¤¤Ë»Ò¶¡Bean¤ÎÄêµÁ¤Ï¡¢myProxy¤Î¤è¤¦¤ÊÆÃÄê¤ÎÄêµÁ¤ò·Ñ¾µ¤Ç¤­¤ë¡£»Ò¶¡Bean¤Ë¤Ï¡¢¤µ¤é¤Ë¥×¥í¥Ñ¥Æ¥£¤ò­¤¹¤Î¤¬ÉáÄÌ¡£proxy interfaces¤ß¤¿¤¤¤Ë¡£
(Here number of child bean definitions can ¡Èextend¡É the myProxy definition, specifying a target, usually inner bean.
They can optionally add further properties, such as proxy interfaces. )


¥ª¡¼¥È¥×¥í¥­¥·¤Ã¤ÆÍפϡ¢ÀßÄ꼡Âè¤Ç¡¢Ê£¿ô¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥×¥í¥­¥·¤·¤Á¤ã¤¦¤â¤Î¤Ç¡¢BeanNameAutoProxyCreator¤«DefaultAdvisorAutoProxyCreator¤ÇºîÀ®²Äǽ¡£
(Autoproxying means that depending on some configuration, proxying is applied consistently to a number of objects.
Autoproxy can be created using BeanNameAutoProxyCreator or DefaultAdvisorAutoProxyCreator. )

BeanNameAutoProxyCreator¤Ï¡¢Ê£¿ô¸Ä¤ÎProxyFactoryBean¤ÎÂå¤ï¤ê¤Ë»È¤¦¤ó¤ËÎɤ¯¤Æ¡¢DefaultAdvisorAutoProxyCreator¤Ï¡¢¥Ñ¥ï¥Õ¥ë¡£
(BeanNameAutoProxyCreator is good for replacing several ProxyFactoryBean. DefaultAdvisorAutoProxyCreator is powerful. )
DefaultAdvisorAutoProxyCreator¤Ï¡¢¥³¥ó¥Æ¥­¥¹¥È¤ËÄêµÁ¤·¤¿Ä̤ê¤Ë¡¢¥¿¡¼¥²¥Ã¥È¥ª¥Ö¥¸¥§¥¯¥È¤È¹çÃפ¹¤ë¥Ý¥¤¥ó¥È¥«¥Ã¥È¥á¥½¥Ã¥É¤¬¤¢¤ë¤«¡¢Á´¥¢¥É¥Ð¥¤¥¶¡¼¤ò´Æ»ë¡£BeanNameAutoProxyCreator¤Î¥¤¥ó¥¿¥»¥×¥¿¤Î¥ê¥¹¥È¤Ë¡¢¥¢¥É¥Ð¥¤¥¶¤È¥¢¥É¥Ð¥¤¥¹¡£ DefaultAdvisorAutoProxyCreator¤Ë¤Ï¡¢¥¢¥É¥Ð¥¤¥¶¡£
(It examines all advisors defined in current context for mathcing pointcut methods on target object. Both advisor and advices and be used in BeanNameAutoProxyCreator interceptor list. DefaultAdvisorAutoProxyCreator strictly requires Advisors. )
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
Examples:BeanNameAutoProxyCreator :
<'bean id=¡ÉbnProxyCreator¡É
¡¡¡¡class=¡Éorg.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator¡É>
¡¡¡¡<'property name=¡ÉbeanNames¡É>
¡¡¡¡¡¡¡¡<'value>bean1,mybean*<'/value>
¡¡¡¡<'/property>
¡¡¡¡<'property name=¡ÉinterceptorNames¡É>
¡¡¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡¡¡¡¡<'value>advisor1<'/value>
¡¡¡¡¡¡¡¡¡¡¡¡<'value>interceptor1<'/value>
¡¡¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
<'/bean>
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
Examples:DefaultAdvisorAutoProxyCreator :
<'bean id=¡ÉdaaProxyCreator¡É
¡¡¡¡class=¡Éorg.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator¡É />
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
¥ª¡¼¥È¥×¥í¥­¥·¤Îcreator¤ÎBean¤ÎÄêµÁ¤Ï¡¢¥¢¥×¥ê¤Î¥³¡¼¥É¤ä¾¤ÎFW¤Î¥ª¥Ö¥¸¥§¥¯¥È¤«¤é¤Î¥¢¥¯¥»¥¹¤Ë¤Ï´Ø·¸¤Ê¤¯¡¢Â¾¤ÎBeanÄêµÁ¤Î¸úǽ¤òº¸±¦¤¹¤ë¤â¤Î¡£
¥ª¡¼¥È¥×¥í¥­¥·¤Ï¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥óÄêµÁ¤Ë¤â»È¤¨¤ë¡£
(An autoproxy creator bean definition is intended to change the effect of other bean definitions,
not for access by application code or other framework objects. Autoproxy can be used to define transactions as well.)
¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î¥í¡¼¥ë¥Ð¥Ã¥¯¤Ë¤Ä¤¤¤Æ
¥Ç¥Õ¥©¥ë¥È¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï¡¢¥é¥ó¥¿¥¤¥àÎã³°»þ¤Î¤ß¥í¡¼¥ë¥Ð¥Ã¥¯¤·¤Æ¡¢¥Á¥§¥Ã¥¯¤·¤¿Îã³°¤Ç¤Ï¤·¤Ê¤¤¡£
¤¬¡¢É¬Íפ˱þ¤¸¤Æ¡¢¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤»¤¿¤¤Îã³°¤ò¥Á¥§¥Ã¥¯¤·¤Æ¶È̳¥í¥¸¥Ã¥¯¤ò¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤»¤ë¤è¤¦¤Ë¤¹¤ë¤Î¤â¥è¥¤Îý½¬¡£
Îã³°¤Ë¥Þ¥¤¥Ê¥¹µ­¹æ¤ò¤Ä¤±¤ì¤Ð¡¢¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ë¡£
(15. Specify Transaction Rollback:
By default transactions are rolled back only on runtime exceptions and not on checked exceptions.
However it is a good practice to choose specific checked exceptions where you want the transaction to be rolled back based on business needs. Exceptions marked with negative (-) sign cause transaction to be rolled back.)

ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
Example:
<'bean id=¡ÉbusinessBean¡É
¡¡¡¡class=¡Éorg.springframework.transaction.interceptor.NameMatchTransactionAttributeSource¡É>
¡¡¡¡<'props>
¡¡¡¡¡¡¡¡<'prop key=¡ÉbusinessMethod1¡í>
¡¡¡¡¡¡¡¡¡¡¡¡PROPAGATION_REQUIRES_NEW,ISOLATION_REPEATABLE_READ,-RollBackBusinessException
¡¡¡¡¡¡¡¡<'/prop>
¡¡¡¡<'/props>
¡¡¡¡<'/property>
<'/bean>
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
¥í¡¼¥ë¥Ð¥Ã¥¯¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¥é¥ó¥¿¥¤¥àÎã³°¤òÀßÄꤹ¤ë¤Î¤â²Ä¤À¤¬¡¢°Õ¤Ë±è¤ï¤Ê¤¤Æ°¤­¤ò¤·¤Æ¤Þ¤ï¤Ê¤¤¤è¤¦Í×Ãí°Õ¡£
(You can even mark runtime exceptions as positive to prevent rollbacks but be careful while doing so as it could have adverse affects.)

--------------------------------------------------------------------------------
* Aware of thread safe issues with AOP advice
--------------------------------------------------------------------------------
¥¢¥É¥Ð¥¤¥¹¥¤¥ó¥¹¥¿¥ó¥¹¤ÏÊ£¿ô¥¹¥ì¥Ã¥É¤Ç¤è¤¦Î®ÍѤµ¤ì¤ë¤«¤é¡¢¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤«¤ËÃí°Õ¤¹¤Ù¤·¡£
Î㤨¤Ð¡¢¥á¥½¥Ã¥É¥¤¥ó¥¿¥»¥×¥¿¤¬¡¢¥æ¥Ë¡¼¥¯¤ÊID¤ä¥«¥¦¥ó¥È¤ËÂбþ¤·¤¿¤â¤Î¤Ê¤é¡¢¥«¥¦¥ó¥È¤ò¥¤¥ó¥¯¥ê¥á¥ó¥È¤¹¤ë¤¿¤á¤Ë¡¢¥·¥ó¥¯¥í¥Ê¥¤¥º¥É¤µ¤ì¤¿¥á¥½¥Ã¥ÉÊÑ¿ô¤ò¥¹¥ì¥Ã¥É¥í¡¼¥«¥ë¤ËÍѰդ¹¤ë¡£
(Advice instances are most often shared among threads, so we need to consider thread safety issues. For example if the method interceptor is responsible for generating unique id or count, then consider using ThreadLocal variable with synchronized method for incrementing the count.)
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ
Example:
public class CountingMethodAdvice implements MethodInterceptor {// The next serial number to be assigned
¡¡private static long nextSerialNum = 0;
¡¡private static ThreadLocal serialNum = new ThreadLocal() {
¡¡¡¡protected synchronized Object initialValue() {
¡¡¡¡¡¡return new Long(nextSerialNum++);
¡¡¡¡}
¡¡};
¡¡private static long getCount() {
¡¡¡¡if(serialNum!=null){
¡¡¡¡¡¡return ((Long) (serialNum.get())).longValue();
¡¡¡¡}
¡¡}
¡¡public Object invoke(MethodInvocation methodInvocation) throws Throwable {
¡¡¡¡System.out.println(¡ÉThis method is called ¡É + getCount + ¡É times¡É);
¡¡}
}
ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ


Lijin¡Çs Localhost
http://lijinjoseji.wordpress.com/2007/09/27/spring-framework-best-programming-practices-part-2/

AOP

¢¢Proxy
Proxy¤ÎÀ¸À®ÊýË¡
­¡ProxyFactoryBean¤ò»È¤¦
­¢autoproxy¤ò»È¤¦
¡¡¢ª¥³¥ó¥Æ¥Ê¤¬¥í¡¼¥É¤µ¤ì¤¿»þ¤Ë¼«Æ°Åª¤ËAOP Proxy¤¬ºîÀ®¤µ¤ì¤ë
¡¡¡¡»Å³Ý¤±
¡¡¡¡¥³¥ó¥Æ¥Ê¤¬Bean¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òºî¤ë¤¿¤Ó¤Ë¥³¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ëBeanPostProcessor¤Î¥á¥½¥Ã¥É¤òÍøÍÑ
¡¡¡¡¤½¤³¤ÇBean¤ò¤¤¤í¤¤¤í¤ÈºÙ¹©¢ªProxyFactory¤Ë¿©¤ï¤»¤Æ¤ë¡©

¢¢autoproxy
autoproxy¤Î»ÈÍÑÊýË¡
­¡autoproxy createor¤ò»È¤¦
­¢¥½¡¼¥¹¥ì¥Ù¥ë¤Î¥á¥¿¥Ç¡¼¥¿¤ò»È¤¦

¢¢autoproxy creator
autoproxy creator¤Î»ÈÍÑÊýË¡
autoproxy¡ÊAbstractAutoProxyCreator¡Ë¤Î¼ÂÁõ¥¯¥é¥¹£²¤Ä¤¢¤ê
­¡BeanNameAutoProxyCreator
¡¡»ØÄꤵ¤ì¤¿Ì¾Á°¡ÊÍ×ÁǤÎid°À­¤äname°À­¡Ë¤ÎBean¤ËÂФ·¤ÆAspect¤òWeaving¤·¤Æ¤¯¤ì¤ëautoproxy creator
¡¡¢ªÂ¿¿ô¤ÎBean¤ËÂФ·¤Æ£±¤Ä°Ê¾å¤ÎmethodInterceptor¤òŬÍѤǤ­¤ë
¡¡ProxyFactoryBeanƱÍÍ¡¢interceptorNames¤È¤¤¤¦property¤Ë ŬÍѤµ¤»¤ëAspect¡Êinterceptor/advice¡Ë¤ò»ØÄꤹ¤ë

­¢DefaultAdvisorAutoProxyCreator
¡¡eXtream¤Çpowerful¤Êautoproxy creator
¡¡Bean¤Ë¥Þ¥Ã¥Á¤¹¤ëPointcut¤òÊÒ¤Ãü¤«¤éŬÍѤ¹¤ë
¡¡¥Þ¥Ã¥Á¤¹¤ë¤â¤Î¤¬Ìµ¤¤¾ì¹ç target¤ÎBean¤Ï¥×¥í¥­¥·¤µ¤ì¤Ê¤¤
¡¡# Spring¤ÎPointcut¤Ï¡¢ClassFilter¤ÈMethodMatcher¤«¤é¹½À®¤µ¤ì¤ë¤«¤é¤Ç¤­¤ë¤³¤È
¡¡¢ªtargetËè¤ËÍ×ÀßÄê¡©
¡¡¢¨DefaultAdvisorProxyCreator¤ÇŬÍѤǤ­¤ë¤Î¤ÏAdvisor¤À¤±¤Ç Interceptor¤Ï¥À¥á¡ª
¡¡¡ÊInterceptor¤ÏAroundAdvice¤ÇPointcut¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¤«¤é¡Ë


ref:
http://d.hatena.ne.jp/koichik/20040413

AOP SAMPLE

¢£Sample
¢¢composition
/autoproxy
|-/bin
|-/src
| |-/samplepackage
| | |- HelloOne.java
| | |- HelloTwo.java
| | |- HelloThree.java
| | |- HelloAdvice.java
| | |- Practitioner.java
|-/conf ¡¦¡¦¡¦ ÀßÄê¥Õ¥¡¥¤¥ë³ÊǼ¥Õ¥©¥ë¥À
| |- applicationContext.xml
| |- log4j.xml
|-/lib ¡¦¡¦¡¦ ¥é¥¤¥Ö¥é¥ê(³°ÉôJAR)¥Õ¥©¥ë¥À
| |- asm-attrs.jar
| |- cglib-2.1.3.jar
| |- commons-logging-1.0.4.jar
| |- log4j-1.2.11.jar
| |- spring-aop.jar
| |- spring-beans.jar
| |- spring-context.jar
| |- spring-core.jar

<'!-- ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ -->
¢¢Step01
AOP¤ò¤«¤±¤ëÂоݥ¯¥é¥¹¤òºîÀ®¤¹¤ë¡£
Âоݥ¯¥é¥¹
¡¦HelloOne.java
¡¦HelloTwo.java
¡¦HelloThree.java

¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
package samplepackage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* HelloOne¥¯¥é¥¹.
*/
public class HelloOne {

¡¡¡¡/** ¥í¥®¥ó¥° */
¡¡¡¡private Log logger = LogFactory.getLog(HelloOne.class);
¡¡¡¡/** ¥á¥Ã¥»¡¼¥¸ */
¡¡¡¡private String message;

¡¡¡¡/**
¡¡¡¡ * @return message ¤òÌ᤹¡£
¡¡¡¡ */
¡¡¡¡public String getMessage() {
¡¡¡¡¡¡¡¡return message;
¡¡¡¡}

¡¡¡¡/**
¡¡¡¡ * @param message message ¤òÀßÄꤹ¤ë¡£
¡¡¡¡ */
¡¡¡¡public void setMessage(String message) {
¡¡¡¡¡¡¡¡this.message = message;
¡¡¡¡}

¡¡¡¡/**
¡¡¡¡ * message¤ò½ÐÎϤ¹¤ë.
¡¡¡¡ */
¡¡¡¡public void message() {
¡¡¡¡¡¡¡¡logger.info(this.message);
¡¡¡¡}
}

¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
package samplepackage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* HelloTwo¥¯¥é¥¹.
*/
public class HelloTwo {

¡¡¡¡/** ¥í¥®¥ó¥° */
¡¡¡¡private Log logger = LogFactory.getLog(HelloTwo.class);
¡¡¡¡/** ¥á¥Ã¥»¡¼¥¸ */
¡¡¡¡private String message;

¡¡¡¡/**
¡¡¡¡ * @return message ¤òÌ᤹¡£
¡¡¡¡ */
¡¡¡¡public String getMessage() {
¡¡¡¡¡¡¡¡return message;
¡¡¡¡}

¡¡¡¡/**
¡¡¡¡ * @param message message ¤òÀßÄꤹ¤ë¡£
¡¡¡¡ */
¡¡¡¡public void setMessage(String message) {
¡¡¡¡¡¡¡¡this.message = message;
¡¡¡¡}

¡¡¡¡/**
¡¡¡¡ * message¤ò½ÐÎϤ¹¤ë.
¡¡¡¡ */
¡¡¡¡public void message() {
¡¡¡¡¡¡¡¡logger.info(this.message);
¡¡¡¡}
}
¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
package samplepackage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* HelloThree¥¯¥é¥¹.
*/
public class HelloThree {

¡¡¡¡/** ¥í¥®¥ó¥° */
¡¡¡¡private Log logger = LogFactory.getLog(HelloThree.class);
¡¡¡¡/** ¥á¥Ã¥»¡¼¥¸ */
¡¡¡¡private String message;

¡¡¡¡/**
¡¡¡¡ * @return message ¤òÌ᤹¡£
¡¡¡¡ */
¡¡¡¡public String getMessage() {
¡¡¡¡¡¡¡¡return message;
¡¡¡¡}

¡¡¡¡/**
¡¡¡¡ * @param message message ¤òÀßÄꤹ¤ë¡£
¡¡¡¡ */
¡¡¡¡public void setMessage(String message) {
¡¡¡¡¡¡¡¡this.message = message;
¡¡¡¡}

¡¡¡¡/**
¡¡¡¡ * message¤ò½ÐÎϤ¹¤ë.
¡¡¡¡ */
¡¡¡¡public void message() {
¡¡¡¡¡¡¡¡logger.info(this.message);
¡¡¡¡}
}

<'!-- ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ -->
¢¢Step02
AOP¤Ë»ÈÍѤ¹¤ë¥¢¥É¥Ð¥¤¥¹¥¯¥é¥¹¤òºîÀ®¤¹¤ë¡£
¡¦HelloAdvice.java
AOP¤ò¥á¥½¥Ã¥É¤ÎÁ°¸å¤Ë¤«¤±¤ëAroundAdvice¤ò»ÈÍѤ¹¤ë¾ì¹ç¡¢¥¢¥É¥Ð¥¤¥¹¥¯¥é¥¹¤ÏMethodInteceptor¤ò¼ÂÁõ¤·¤ÆºîÀ®¤¹¤ë¡£

¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
package samplepackage;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* HelloAdvice¥¯¥é¥¹.
*/
public class HelloAdvice implements MethodInterceptor {

¡¡¡¡/** ¥í¥®¥ó¥° */
¡¡¡¡private Log logger = LogFactory.getLog(HelloAdvice.class);

¡¡¡¡/* (Èó Javadoc)
¡¡¡¡ * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
¡¡¡¡ */
¡¡¡¡public Object invoke(MethodInvocation invocation) throws Throwable {
//¡¡¡¡¡¡¡¡joinpoint¤ÎÁ°½èÍý
¡¡¡¡¡¡¡¡logger.info("Á°½èÍý");
//¡¡¡¡¡¡¡¡´ÉÍý¤¹¤ë¥¯¥é¥¹¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹
¡¡¡¡¡¡¡¡Object result = invocation.proceed();
//¡¡¡¡¡¡¡¡joinpoint¤Î¸å½èÍý
¡¡¡¡¡¡¡¡logger.info("¸å½èÍý");

¡¡¡¡¡¡¡¡return result;
¡¡¡¡}
}

<'!-- ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ -->
¢¢Step03
ÄêµÁ¥Õ¥¡¥¤¥ë¤ËÄêµÁ¤¹¤ë¡£
¡¦applicationContext.xml

¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
<'?xml version="1.0" encoding="UTF-8"?>
<'!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

<'beans>
¡¡¡¡<'!--AutoProxyBean
¡¡¡¡¡¡¡¡<'bean
¡¡¡¡¡¡¡¡id="defaultAdvisorAutoProxy"
¡¡¡¡¡¡¡¡class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
¡¡¡¡¡¡¡¡<'property name="proxyTargetClass">
¡¡¡¡¡¡¡¡<'value>true<'/value>
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡¡¡¡¡<'/bean>
¡¡¡¡-->
¡¡¡¡<'!-- AutoProxyBean -->
¡¡¡¡<'!-- ¢¨interceptorNames¡¢beanNames°À­¤Ë¡¢ref»ØÄê¤ÏÉԲġ£¡ÊBean¤Ç¤Ê¤¯¡¢Bean̾¤òÅϤ¹¡£¡Ë -->
¡¡¡¡<'bean id="beanNameAutoProxy"
¡¡¡¡¡¡¡¡class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
¡¡¡¡¡¡¡¡<'property name="beanNames">
¡¡¡¡¡¡¡¡¡¡¡¡<'value>*e<'/value>
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡¡¡¡¡<'property name="interceptorNames">
¡¡¡¡¡¡¡¡¡¡¡¡<'value>helloAdvisor<'/value>
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡<'/bean>

¡¡¡¡<'!-- "AOP¤¹¤ë¥¢¥É¥Ð¥¤¥¹¥¯¥é¥¹"¤ò"AOPÂоݥ¯¥é¥¹"¤Ë¹çÂΤµ¤»¤ë¥¢¥É¥Ð¥¤¥¶¡¼¥¯¥é¥¹ -->
¡¡¡¡<'!-- ¤É¤Î¥¯¥é¥¹¤Ë¡¢¤É¤¦¤æ¤¦¥ë¡¼¥ë¤Ç¡¢¤É¤Î¥¢¥É¥Ð¥¤¥¹¤ò¹çÂΤµ¤»¤ë¤«Åù¤Î¾ðÊó¤òÊÝ»ý¤·¤Æ¤¤¤ë¡£ -->
¡¡¡¡<'bean id="helloAdvisor"
¡¡¡¡¡¡¡¡class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
¡¡¡¡¡¡¡¡<'property name="advice">
¡¡¡¡¡¡¡¡¡¡¡¡<'ref local="helloAdvice" />
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡¡¡¡¡<'property name="mappedName">
¡¡¡¡¡¡¡¡¡¡¡¡<'value>*message<'/value>
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡<'/bean>

¡¡¡¡<'!-- AOP¤¹¤ë¥¢¥É¥Ð¥¤¥¹¥¯¥é¥¹ -->
¡¡¡¡<'bean id="helloAdvice"
¡¡¡¡¡¡¡¡class="samplepackage.HelloAdvice" />

¡¡¡¡<'!-- AOPÂоݥ¯¥é¥¹ -->
¡¡¡¡<'bean id="helloOne"
¡¡¡¡¡¡¡¡class="samplepackage.HelloOne">
¡¡¡¡¡¡¡¡<'property name="message">
¡¡¡¡¡¡¡¡¡¡¡¡<'value>Hello,AOP!! one<'/value>
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡<'/bean>

¡¡¡¡<'bean id="helloTwo"
¡¡¡¡¡¡¡¡class="samplepackage.HelloTwo">
¡¡¡¡¡¡¡¡<'property name="message">
¡¡¡¡¡¡¡¡¡¡¡¡<'value>Hello,AOP!! two<'/value>
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡<'/bean>

¡¡¡¡<'bean id="helloThree"
¡¡¡¡¡¡¡¡class="samplepackage.HelloThree">
¡¡¡¡¡¡¡¡<'property name="message">
¡¡¡¡¡¡¡¡¡¡¡¡<'value>Hello,AOP!! three<'/value>
¡¡¡¡¡¡¡¡<'/property>
¡¡¡¡<'/bean>
<'/beans>

<'!-- ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ -->
¢¢Step04
¼ÂÁ©¥¯¥é¥¹¤òºîÀ®¤¹¤ë¡£Íפϥᥤ¥ó¥¯¥é¥¹¡£
¡¦Practitioner.java

¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
package samplepackage;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
* Practitioner¥¯¥é¥¹.
*
*/
public class Practitioner {
¡¡¡¡public static void main(String args[]) {
¡¡¡¡¡¡¡¡try {
¡¡¡¡¡¡¡¡¡¡¡¡ApplicationContext context = new ClassPathXmlApplicationContext(
¡¡¡¡¡¡¡¡¡¡¡¡"applicationContext.xml");
¡¡¡¡¡¡¡¡¡¡¡¡HelloOne helloOne = (HelloOne) context.getBean("helloOne");
¡¡¡¡¡¡¡¡¡¡¡¡HelloTwo helloTwo = (HelloTwo) context.getBean("helloTwo");
¡¡¡¡¡¡¡¡¡¡¡¡HelloThree helloThree = (HelloThree) context.getBean("helloThree");

¡¡¡¡¡¡¡¡¡¡¡¡helloOne.message();
¡¡¡¡¡¡¡¡¡¡¡¡helloTwo.message();
¡¡¡¡¡¡¡¡¡¡¡¡helloThree.message();
¡¡¡¡¡¡¡¡} catch (Exception e) {
¡¡¡¡¡¡¡¡¡¡¡¡e.printStackTrace();
¡¡¡¡¡¡¡¡}
¡¡¡¡}
}
<'!-- ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ -->
¢¢Step5
·ë²Ì¤ò³Îǧ¤¹¤ë¡£

¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
core.CollectionFactory:66 - JDK 1.4+ collections available
xml.XmlBeanDefinitionReader:163 - Loading XML bean definitions from class path resource [applicationContext.xml]
support.AbstractRefreshableApplicationContext:92 - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;has hCode=9142687]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [beanNameAutoProxy,helloAdvisor,helloAdvice,helloOne,helloT wo,helloThree]; root of BeanFactory hierarchy
support.AbstractApplicationContext:290 - 6 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=91 42687]
framework.DefaultAopProxyFactory:59 - CGLIB2 available: proxyTargetClass feature enabled
support.AbstractApplicationContext$BeanPostProcessorChecker:738 - Bean 'beanNameAutoProxy' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
support.AbstractApplicationContext:432 - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.Delegatin gMessageSource@a4e2e3]
support.AbstractApplicationContext:454 - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframewo rk.context.event.SimpleApplicationEventMulticaster@fd68b1]
support.DefaultListableBeanFactory:268 - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [beanNameAutoProxy,helloAdvisor,helloAdvice,helloOne,helloTwo,helloThree]; root of BeanFactory hierarchy]
autoproxy.HelloAdvice:26 - Á°½èÍý
autoproxy.HelloOne:39 - Hello,AOP!! one
autoproxy.HelloAdvice:30 - ¸å½èÍý
autoproxy.HelloTwo:39 - Hello,AOP!! two
autoproxy.HelloAdvice:26 - Á°½èÍý
autoproxy.HelloThree:39 - Hello,AOP!! three
autoproxy.HelloAdvice:30 - ¸å½èÍý

<'!-- ޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥޥ -->


ref:
Spring/AOP ÍøÍÑÎã/Auto Proxy
http://www.system-trust.com/pukiwiki/?Spring%2FAOP%20%CD%F8%CD%D1%CE%E3%2FAuto%20Proxy

transaction manager

==error==
javax.transaction.RollbackException

==reason==
the error when try to use two different type datasources, non-xa and xa, in a same transaction.

==log==
[08/04/07 13:37:10:118 JST] 0000009f RegisteredRes E WTRN0063E: ´û¸¤Î 2 ¥Õ¥§¡¼¥º²Äǽ¥ê¥½¡¼¥¹¤È°ì½ï¤Ë 1 ¥Õ¥§¡¼¥º²Äǽ¥ê¥½¡¼¥¹¤ò¥³¥ß¥Ã¥È¤·¤è¤¦¤È¤¹¤ëÉÔÀµ¤Ê»î¤ß¤¬¹Ô¤ï¤ì¤Þ¤·¤¿¡£
[08/04/07 13:37:10:118 JST] 0000009f RegisteredRes E WTRN0086I: ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó 00000119272C12AC00000001000000141958447DBC1C067F7CE14BF65756462CF8FF57FB00000119272C12AC00000001000000141958447DBC1C067F7CE14BF65756462CF8FF57FB00000001 ¤Î½àÈ÷¥Õ¥§¡¼¥º¤Ç XAException ¤¬¸¡½Ð¤µ¤ì¤Þ¤·¤¿¡£ ¥í¡¼¥«¥ë¡¦¥ê¥½¡¼¥¹¤¬¤³¤Î¸å¤Ë³¤­¤Þ¤¹¡£
[08/04/07 13:37:10:134 JST] 0000009f RegisteredRes E WTRN0089I: XATransactionWrapper@ 62826282 XAResource: com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@627a627a enlisted: true mcWrapper.hashCode()1639866814: ɾÄê: commit
[08/04/07 13:37:10:134 JST] 0000009f RegisteredRes E WTRN0089I: XATransactionWrapper@ 56425642 XAResource: com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@55f655f6 enlisted: true mcWrapper.hashCode()2008446902: ɾÄê: commit
[08/04/07 13:37:10:134 JST] 0000009f RegisteredRes E WTRN0089I: LocalTransactionWrapper@:33a433a4 localTransaction:com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl@3e123e12 enlisted:true registeredForSynctruemcWrapper.hashcode()1597136690: ɾÄê: none
[08/04/07 13:37:10:150 JST] 0000009f SystemOut O 2008/04/07 13:37:10 DEBUG TransactionSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@26602660] for key [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@4d648f94] from thread [WebContainer : 4]
[08/04/07 13:37:10:197 JST] 0000009f SystemOut O 2008/04/07 13:37:10 DEBUG TransactionSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@2e4e2e4e] for key [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@61200ee3] from thread [WebContainer : 4]
[08/04/07 13:37:10:212 JST] 0000009f SystemOut O 2008/04/07 13:37:10 DEBUG TransactionSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@36483648] for key [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@28d9d69d] from thread [WebContainer : 4]
[08/04/07 13:37:10:244 JST] 0000009f SystemOut O 2008/04/07 13:37:10 DEBUG TransactionSynchronizationManager - Clearing transaction synchronization
[08/04/07 13:37:10:337 JST] 0000009f SystemOut O 2008/04/07 13:37:10 ERROR SimpleMappingExceptionResolverEx - Handled the following exception.
org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException
javax.transaction.RollbackException
at com.ibm.ws.Transaction.JTA.TransactionImpl.stage3CommitProcessing(TransactionImpl.java:1811)
at com.ibm.ws.Transaction.JTA.TransactionImpl.processCommit(TransactionImpl.java:1590)
at com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1512)
at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:237)
at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:162)
at com.ibm.ws.Transaction.JTA.UserTransactionImpl.commit(UserTransactionImpl.java:285)
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:787)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:500)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:473)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:267)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy59.handleRequest(Unknown Source)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:723)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:358)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:907)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at ......

autoProxy¤ÎʬÎöÊýË¡

Ä̾ï¤Î¥Ç¡¼¥¿¥½¡¼¥¹ÍѤΥȥé¥ó¥¶¥¯¥·¥ç¥ó¥¤¥ó¥¿¥»¥×¥¿¤È
2PC¡Ê2Áꥳ¥ß¥Ã¥È¡Ë¤Î¥Ç¡¼¥¿¥½¡¼¥¹ÍѤΥȥé¥ó¥¶¥¯¥·¥ç¥ó¥¤¥ó¥¿¥»¥×¥¿¤òƱ»þÄêµÁ¤¹¤ëÊýË¡¡£

¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦
<'?xml version="1.0" encoding="UTF-8"?>

<'!DOCTYPE beans
¡¡¡¡PUBLIC "-//SPRING//DTD BEAN//EN"
¡¡¡¡"http://www.springframework.org/dtd/spring-beans.dtd">

<'beans>

¡¡<'!-- autoProxy -->
¡¡<'bean id="autoProxy"
¡¡¡¡¡¡class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator" abstract="true">
¡¡<'/bean>
¡¡
¡¡<'!-- autoProxy for two phase commit -->
¡¡<'bean id="autoProxy.xa" parent="autoProxy">
¡¡¡¡<'property name="interceptorNames">
¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡<'idref bean="transactionInterceptorJTA"/>
¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
¡¡¡¡<'property name="beanNames">
¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡<'value>*0XAController<'/value>
¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
¡¡<'/bean>
¡¡
¡¡<'!-- autoProxy for one phase commit -->
¡¡<'bean id="autoProxy.tx" parent="autoProxy">
¡¡¡¡<'property name="interceptorNames">
¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡<'idref bean="transactionInterceptor"/>
¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
¡¡¡¡<'property name="beanNames">
¡¡¡¡¡¡<'list>
¡¡¡¡¡¡¡¡<'value>*Controller<'/value>
¡¡¡¡¡¡<'/list>
¡¡¡¡<'/property>
¡¡<'/bean>
¡¡
<'/beans>

ref:
S_a_k_U¤ÎÆüµ­¤ß¤¿¤¤¤ÊDB¡¡¡Á¥µ¥¯¥¥¡¼¤È¸Æ¤Ð¤Ê¤¤¤Ç¡Á
http://d.hatena.ne.jp/S_a_k_U/20070617/p3

tag

JSTL/core
<'c:choose>
¡¡Â¿´ôʬ´ô
<'c:forEach>
¡¡·«¤êÊÖ¤·½èÍý
<'c:forTokens>
¡¡Ê¸»úÎóʬ³ä
<'c:if>
¡¡Ã±½ãʬ´ô
<'c:import>
¡¡³°Éô¥Õ¥¡¥¤¥ë¤Î¥¤¥ó¥Ý¡¼¥È
<'c:out>
¡¡ÊÑ¿ô½ÐÎÏ
<'c:redirect>
¡¡¥Ú¡¼¥¸¥ê¥À¥¤¥ì¥¯¥È
<'c:remove>
¡¡¥¹¥³¡¼¥×¤ÎÊÑ¿ôºï½ü
<'c:set>
¡¡¥¹¥³¡¼¥×¤Ø¤ÎÊÑ¿ôÀßÄê
<'c:url>
¡¡URL¥¨¥ó¥³¡¼¥É

Jakarta/Common Lang
<'str:wordWrap>
¡¡¥ï¡¼¥É¥é¥Ã¥×À©¸æ

JSTL/I18n
<'fmt:formatDate>
¡¡ÆüÉեǡ¼¥¿À°·Á
<'fmt:formatNumber>
¡¡¿ôÃͥǡ¼¥¿À°·Á
<'fmt:parseDate>
¡¡Ê¸»úÎ󤫤éÆüÉեǡ¼¥¿¤Ø¤ÎÊÑ´¹
<'fmt:parseNumber>
¡¡Ê¸»úÎ󤫤é¿ôÃͥǡ¼¥¿¤Ø¤ÎÊÑ´¹

Spring Framework/JSP/Form
<'form:checkbox>
¡¡¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹À¸À®
<'form:errors>
¡¡¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò°Ï¤ó¤ÀHTML span¥¿¥°¤ÎÀ¸À®
<'form:form>
¡¡HTML form¥¿¥°¤ÎÀ¸À®
<'form:hidden>
¡¡HTML hidden¥¿¥°¤ÎÀ¸À®
<'form:input>
¡¡¥Æ¥­¥¹¥È¥Ü¥Ã¥¯¥¹¤ÎÀ¸À®
<'form:label>
¡¡HTML label¥¿¥°¤ÎÀ¸À®
<'form:option>
¡¡HTML option¥¿¥°¤ÎÀ¸À®
<'form:options>
¡¡HTML option¥¿¥°¤ò¥ê¥¹¥È¤ÇÀ¸À®
<'form:password>
¡¡¥Ñ¥¹¥ï¡¼¥ÉÆþÎÏÍó¤ÎÀ¸À®
<'form:radiobutton>
¡¡¥é¥¸¥ª¥Ü¥¿¥ó¤ÎÀ¸À®
<'form:select>
¡¡¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎÀ¸À®
<'form:textarea>
¡¡¥Æ¥­¥¹¥È¥¨¥ê¥¢¤ÎÀ¸À®

Spring Framework/JSP
<'spring:bind>
¡¡¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥ÈÃͤÎÊÑ¿ô¤Ø¤Î¥Ð¥¤¥ó¥É
<'spring:escapeBody>
¡¡HTML/JavaScript¥¨¥¹¥±¡¼¥×
<'spring:hasBindErrors>
¡¡¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥ÈÃͤΥХ¤¥ó¥É¥¨¥é¡¼É½¼¨
<'spring:message>
¡¡¥á¥Ã¥»¡¼¥¸É½¼¨
<'spring:nestedPath>
¡¡¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ¹¤ë¥Í¥¹¥È¤·¤¿¥Ñ¥¹¤Îµö²Ä

Spring Module/Commons Validator
<'validator: javascript>
ÆþÎÏÃÍ¥Á¥§¥Ã¥¯ÍѤÎJavaScriptÀ¸À®

Acegi Security/Authorization
<'authz:authorize>
¡¡²èÌ̤´¤È¤Îǧ¾Ú
<'authz:authentication>
¡¡¸¢¸Â¤Ë¤è¤ë²èÌ̹àÌܤÎɽ¼¨/Èóɽ¼¨À©¸æ

tlds

tlds
--------------------------------------------------
for
<'%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<'%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
goto
http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
select
1.1.2.zip
get
jakarta/taglibs/standard-1.1.2/tld/c.tld
jakarta/taglibs/standard-1.1.2/tld/fmt.tld

--------------------------------------------------
for
<'%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<'%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
download
spring-framework-2.0.6
get
spring-framework-2.0.6/dist/resources/spring.tld
spring-framework-2.0.6/dist/resources/spring-form.tld

--------------------------------------------------
for
<'%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
goto
http://fisheye1.cenqua.com/browse/springframework/spring/sandbox/src/org/springframework/validation/commons

--------------------------------------------------
for
<'%@ taglib prefix="authz" uri="http://acegisecurity.org/authz" %>
goto
http://www.koders.com/noncode/fid5A4BB79C08CC912E95988E14CC3216A8BC8C221F.aspx
get
authz.tld

--------------------------------------------------
goal is
<'web-app>
...
<'jsp-config>
<'!-- ¥¿¥°¥é¥¤¥Ö¥é¥ê -->
<'taglib>
<'taglib-uri>http://java.sun.com/jsp/jstl/core<'/taglib-uri>
<'taglib-location>/WEB-INF/tld/c.tld<'/taglib-location>
<'/taglib>
<'taglib>
<'taglib-uri>http://java.sun.com/jsp/jstl/fmt<'/taglib-uri>
<'taglib-location>/WEB-INF/tld/fmt.tld<'/taglib-location>
<'/taglib>
<'taglib>
<'taglib-uri>http://www.springframework.org/tags<'/taglib-uri>
<'taglib-location>/WEB-INF/tld/spring.tld<'/taglib-location>
<'/taglib>
<'taglib>
<'taglib-uri>http://www.springframework.org/tags/form<'/taglib-uri>
<'taglib-location>/WEB-INF/tld/spring-form.tld<'/taglib-location>
<'/taglib>
<'taglib>
<'taglib-uri>http://www.springmodules.org/tags/commons-validator<'/taglib-uri>
<'taglib-location>/WEB-INF/tld/spring-common-validation.tld<'/taglib-location>
<'/taglib>
<'taglib>
<'taglib-uri>http://acegisecurity.org/authz<'/taglib-uri>
<'taglib-location>/WEB-INF/tld/authz.tld<'/taglib-location>
<'/taglib>
<'/jsp-config>
<'/web-app>

transaction types

¢£PROPAGATION_REQUIRED
¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È
¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤·¤Ê¾ì¹ç¡§¿·¤·¤¤¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òºîÀ®

¢£PROPAGATION_SUPPORTS
¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È
¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¡§Èó¥È¥é¥ó¥¶¥¯¥·¥ç¥óŪ¤Ë¼Â¹Ô

¢£PROPAGATION_MANDATORY
¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È
¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¡§Îã³°¤òÁ÷½Ð

¢£PROPAGATION_REQUIRES_NEW
¿·¤·¤¤¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òºîÀ®
¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤¹¤ë¾ì¹ç¡§¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò°ì»þÄä»ß

¢£PROPAGATION_NOT_SUPPORTED
Èó¥È¥é¥ó¥¶¥¯¥·¥ç¥óŪ¤Ë¼Â¹Ô
¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤¹¤ë¾ì¹ç¡§¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò°ì»þÄä»ß

¢£PROPAGATION_NEVER
Èó¥È¥é¥ó¥¶¥¯¥·¥ç¥óŪ¤Ë¼Â¹Ô
¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤¹¤ë¾ì¹ç¡§Îã³°¤òÁ÷½Ð

¢£PROPAGATION_NESTED
¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤¹¤ë¾ì¹ç¡§¥Í¥¹¥È¤µ¤ì¤¿¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ÎÆâÉô¤Ç¼Â¹Ô
¸½ºß¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¡§PROPAGATION_REQUIRED¤ÈƱÍÍ¤ËÆ°ºî

spring web flow quick start

Á°Äó
Spring Web Flow 1.0¤ÈSpring Framework¤¬¥À¥¦¥ó¥í¡¼¥ÉºÑ¤ß
Spring¡¢HTML¡¢JSP/JSTL¤Î´ðÁÃÃμ±
finite state machines¤ÈUML state diagrams¤Î´ðÁÃÃμ±¡©

­¡¡¡½àÈ÷
spring-webflow-1.0.jar¤Èsoring-binding-1.0.jar¤ò¥¯¥é¥¹¥Ñ¥¹¤ËÄ̤¹¡£
spring.jar¤â¡£

­¢¡¡flow¤ÎÀß·×
ºîÀ®¤¹¤ëflow¡§
i.
¥¹¥¿¡¼¥È¥¢¥Ã¥×¤Ç¥Ö¥é¥¦¥¶¤Ë¥Õ¥©¡¼¥à¥Ó¥å¡¼¤òɽ¼¨¡£
ii.
¥µ¥Ö¥ß¥Ã¥È¤Ç¥Õ¥©¡¼¥à¤ËÆþÎϤµ¤ì¤¿¥Ç¡¼¥¿¤ò΢Êý¤Î¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥Ð¥¤¥ó¥É¤·¤Æ¥Ð¥ê¥Ç¡¼¥·¥ç¥ó¡£
¥¨¥é¡¼¢ª¥Õ¥©¡¼¥à¥Ó¥å¡¼¤ËÌá¤ë¡£
£Ï£Ë¢ª¥µ¥Ö¥ß¥Ã¥È¥¢¥¯¥·¥ç¥ó¤ò¼Â¹Ô¡£

­£¡¡flow¤Î¼ÂÁõ
XML¤Î½ñ¤­Êý
==myFlow.xml==
<'?xml version="1.0" encoding="UTF-8"?>
<'!DOCTYPE flow PUBLIC "-//SPRING//DTD WEBFLOW 1.0//EN"
"http://www.springframework.org/dtd/spring-webflow-1.0.dtd">

<'flow start-state="displayForm">

<'view-state id="displayForm" view="form">
<'entry-actions>
<'action bean="formAction" method="setupForm"/>
<'/entry-actions>
<'transition on="submit" to="processSubmit">
<'action bean="formAction" method="bindAndValidate"/>
<'/transition>
<'/view-state>

<'action-state id="processSubmit">
<'action bean="formAction" method="processSubmit"/>
<'transition on="success" to="finish"/>
<'/action-state>

<'end-state id="finish" view="success"/>

<'/flow>
==============

­¤¡¡¥¢¥¯¥·¥ç¥ó¤Î¼ÂÁõ
»È¤¦¤Î¤ÏFormAction¡£
FormAction¤Ï¡¢¥Õ¥©¡¼¥à¤Î¥»¥Ã¥È¥¢¥Ã¥×¡¢¥Ð¥¤¥ó¥É¡¢¥Ð¥ê¥Ç¡¼¥È¡¢¥µ¥Ö¥ß¥Ã¥È¥í¥¸¥Ã¥¯¤«¤éÀ®¤ë¡£
==MyFormAction.java==
public class MyFormAction extends FormAction {
public MyFormAction() {
setFormObjectClass(FormObject.class);
}

public static class FormObject implements Serializable {
private String data;

public String getData() {
return data;
}

public void setData(String data) {
this.data = data;
}
}

/**
* A "submit" hook: an action execute method, called after
* binding and validation.
*/
public Event processSubmit(RequestContext context) throws Exception {
FormObject formObject = (FormObject)getFormObject(context);
// do submit logic
return success();
}

}
=====================

­¥¡¡flow¤ò¥Ç¥×¥í¥¤
Spring Application Cotext»È¤Ã¤Æ¥Ç¥×¥í¥¤¡£
XmlFlowRegistryFactoryBean¤ò»ÈÍÑ¡£
XmlFlowRegistryFactoryBean¤Ï¡¢­£¤Îxml¤ò¸µ¤Ë¤òflow¤òÅÐÏ¿¡£
¥Õ¥©¡¼¥à¥¢¥¯¥·¥ç¥ó¤ò²¿½è¤Ë¥Ç¥×¥í¥¤¤·¤¿¤«¤âÌÀ¼¨¡£
==dispatcher-servlet.xml==
<'bean id="flowRegistry" class="org.springframework.webflow.registry.XmlFlowRegistryFactoryBean">
<'property name="flowLocations" value="/WEB-INF/flows/myflow.xml"/>
<'/bean>

<'bean id="formAction" class="example.MyFormAction"/>
==========================

­¦¡¡flow¤Î½àÈ÷
¹¥¤­¤Êweb framework¤Çflow¤ò»È¤¦½àÈ÷¡£
SpringMVC¤ò»È¤¦¾ì¹ç¤Ï¡¢FlowController¤ÈViewResolver¤ò¢­¤Ê´¶¤¸¤ÇÄêµÁ¡£
==dispatcher-servlet.xml==
<'bean name="/myApp.htm" class="org.springframework.webflow.executor.mvc.FlowController">
<'property name="flowLocator" ref="flowRegistry"/>
<'/bean>

<'!-- Maps flow view-state view names to JSP templates with JSTL support -->
<'bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<'property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<'property name="prefix" value="/WEB-INF/jsp/"/>
<'property name="suffix" value=".jsp"/>
<'/bean>
==========================
¢¬/myApp.htm¤Î»þ¤ËFlowController¤ò»ÈÍÑ¡¢¤ÈÄêµÁ¤·¤Æ¤ë¡£
£±¤³¤Î¥³¥ó¥È¥í¡¼¥é¤¬°ìÈÌŪ¤Ë¤³¤Î¥¢¥×¥ê¤ÎÁ´Éôflow¤Î¼Â¹Ô¤ò´ÉÍý¡£
¥Ó¥å¡¼¤Ç¥Ñ¥é¥á¡¼¥¿_flowId¤Ç»ØÄꤷ¤¿flow¥³¥ó¥È¥í¡¼¥é¤Ç¿·¤·¤¤flow¤ò¼Â¹Ô¤¦¤ó¤Ì¤ó¤Ì¤ó¡Ä¡£

­§¡¡¥Ó¥å¡¼¤Î¼ÂÁõ
==/WEB-INF/jsp/form.jsp==
<'html>
<'head>
<'title>My Form<'/title>
<'/head>
<'body>
<'p>
<'table>
<'form action="myApp.htm">
<'tr>
<'td>Field:<'/td>
<'td><'input type="text" name="data" size="25"/><'/td>
<'/tr>
<'tr>
<'td colspan="2" align="right">
<'input name="_eventId_submit" type="submit">
<'input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<'/td>
<'/tr>
<'/form>
<'/table>
<'/p>
<'/body>
<'/html>
=========================

¢¨ ¥Ñ¥é¥á¡¼¥¿_flowExecutionKey
flow¤Ï¥¹¥Æ¡¼¥È¥Õ¥ë¡£
¢ªflow¤Ç»È¤¦¥Ó¥å¡¼¤Ï¡¢É¬¤º¥Ñ¥é¥á¡¼¥¿_flowExecutionKey¤ò¥µ¥Ö¥ß¥Ã¥È¤Ç¥µ¡¼¥Ð¤ËÊÖ¤¹¤³¤È¡£

¢¨ ¥Ñ¥é¥á¡¼¥¿_eventId
¥Ó¥å¡¼¤Ç¡¢É¬¤º¥¤¥Ù¥ó¥È¤ò¼±Ê̤¹¤ë¤¿¤á¤Î¥Ñ¥é¥á¡¼¥¿_eventId¤ò¥µ¥Ö¥ß¥Ã¥È¥Ü¥¿¥ó¤Ë­¤¹¤³¤È¡£

­¨¡¡¥¢¥¯¥»¥¹
¢­¤Ë¥¢¥¯¥»¥¹¡£
/myApp.htm?_flowId=myFlow
¥¢¥¯¥»¥¹¤¹¤ë¤È¡¢¿·¤·¤¯myFlow¤¬À¸À®¤µ¤ì¡¢start-state¤ËÁ«°Ü¤µ¤ì¤ë¡£
¤½¤Î¸å¤Îή¤ì¤Ï¢­ÆÉ¤ó¤Ç¡£

ref:
Spring Web Flow QuickStart
http://opensource.atlassian.com/confluence/spring/display/WEBFLOW/Quick+Start?decorator=printable

Top|Next »

HOME

09 | 2008/10 | 11
Æü ·î ²Ð ¿å ÌÚ ¶â ÅÚ
- - - 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 -

QR

name:
mail:
title:
body:

N/A