I have 2 budles in project. When first bundle is start second bundle use services from it. But How can I use service in service inside bundle?
<service ref="EMUtilService" interface="domain.access.EMUtil"/>
<bean id="EMUtilService" class="domain.access.impl.EMUtilImpl" scope="singleton">
<jpa:context unitname="access" property="entityManager"/>
<tx:transaction method="*" value="RequiresNew"/>
</bean>
<service ref="userService" interface="domain.access.UserService"/>
<bean id="userService" class="domain.access.impl.UserServiceImpl" scope="singleton">
</bean>
I want use EMUtilService
in userService
or in another simple classes.
my EMUtilService
public class EMUtilImpl implements EMUtil {
private EntityManager entityManager;
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
@Override
public EntityManager getEntityManager() {
return entityManager;
}
}
I wan init EntityManager
in this service and use it in another classes.
Blueprint is largely inspired by Spring (it's the successor of Spring DM) and as such, it supports the same syntax for injecting beans/services into other beans. You can put an id on a bean definition, and inject this bean into a property of another bean :
<bean id="mybean" class="my.package.MyClass"/>
<bean id="myService" class="my.package.MyService">
<property name="myProperty" ref="mybean"/>
</bean>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.