If you have configured Spring to allow annotation-based injection, then you will be able to inject Tapestry services into your Spring Beans.
This feature is only available when Spring ApplicationContext is not configured and loaded externally.
Inside your Spring beans, you may use @Inject and @Autowired annotations.
Simply add these two annotations on top the field you want to inject in your Spring bean.
{code:language=java} @Inject
@Autowired
private MyService myService;{code}
or use @Inject on top of arguments in @Autowired bean constructor methods{code:language=java} private final MyService myService;
@Autowired
public UserDAOImpl(@Inject MyService myService)
{
this.myService = myService;
}
{code}h3. Configuring Spring with Tapestry Symbols
This is accomplished by a BeanFactoryPostProcessors that resolves the values of 'placeholders' from symbol values. In the following example the value of the Bean's property 'productionMode' is the value of the Tapestry's symbol [tapestry.production-mode|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/SymbolConstants.html#PRODUCTION_MODE]
{code:language=xml}
<bean id="myBean" class="org.example.MyBean">
<property name="productionMode" value="${tapestry.production-mode}"/>
</bean>
{code}
Non-singleton beans are not handled properly. Tapestry will request the beans from the application context in a manner unsuitable for their life cycle. For the moment, you should consider the non-singleton beans to be not injectable. Instead, inject the ApplicationContext service and obtain the non-singleton beans as needed.
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-32014-2.html
因为你们检测的根本就不是小米的产品