Redian新闻
>
spring creating objects depending on properties?
avatar
spring creating objects depending on properties?# Java - 爪哇娇娃
T*M
1
今天下午极其无聊,读文章的时候突然决定把放在硬盘里的老超女2005给挖出来再
~~~看一遍。
唉,一听到周笔畅的嗓子,俺就晕了。TNND,两年多了,这嗓音对我的杀伤力还是这么
强。人都是主观的,俺也没要求过别人象俺这样喜欢过小周,但是俺就是不懂,怎么可
以有人的嗓子这么好听呢???而且俺还不懂,为啥这么好听的嗓子就没被包装好,唱
过什么真正属于她自己的好歌呢???我听她唱其他人的歌可是比那些歌手自己唱的都
有感觉啊。一下午,心脏居然有被刺透的感觉。
其实我也有客观的地方,我能听出小周低音和高音的有时候不和谐的地方,但是她唱得
舒服的时候,我听得是真舒服啊。
本以为两年多没看05超女了应该新鲜一些,会有耐心听听别人的。结果发现还是拖着
鼠标,在小周同学处停一下听,或者拽回去再停一下。或者就是张靓影:这姐们自然嗓
音条件太好,跟其他人不是一个量级的。不过也就是因为如此,她老一开始老摆出一副
臭脸,好象跟这帮人一起唱多委屈了她,真让人对她喜欢不起来。直到5进3以后,才
放下架子,跟个小姑娘似地哭哭笑笑,唱什么也不太在意了,可爱了许多。老纪敏佳虽
然唱得好,太也太蛮,偶尔温柔一把就泯然众人了。
avatar
c*n
2
now in spring, as long as I write a in the .xml, it will be
created (lazily ??),
I wonder if there is a way to disable creating an bean depending on
properties settings, for example, my main bean is



let's say I decide that I won't give salary to employees in some cases, so
I don't need to use the salaryQueryer, is there a way to disable creating
the mySalaryQueryer at all? (without changing the .xml)
of course the design could be quite wrong, but I'm just thinking about
this particular problem now.
thanks
avatar
g*g
3
If you don't want to create mySalaryQueryer, don't put it
as a property of your Company bean.
You may dynamically get an instance using
BeanContext.getInstance().getCtx().getBean("mySalaryQueryer");
Make sure the queryer is lazy-init

【在 c******n 的大作中提到】
: now in spring, as long as I write a in the .xml, it will be
: created (lazily ??),
: I wonder if there is a way to disable creating an bean depending on
: properties settings, for example, my main bean is
:
:
:

: let's say I decide that I won't give salary to employees in some cases, so
: I don't need to use the salaryQueryer, is there a way to disable creating
: the mySalaryQueryer at all? (without changing the .xml)

avatar
w*s
4
means

Company company = new Company();
while means
company.setSalaryQueryer(mySalaryQueryer);

【在 c******n 的大作中提到】
: now in spring, as long as I write a in the .xml, it will be
: created (lazily ??),
: I wonder if there is a way to disable creating an bean depending on
: properties settings, for example, my main bean is
:
:
:

: let's say I decide that I won't give salary to employees in some cases, so
: I don't need to use the salaryQueryer, is there a way to disable creating
: the mySalaryQueryer at all? (without changing the .xml)

avatar
c*n
5
got it, essentially taking what is written in .xml form and put it in
.java code , which has the ability to dynamically construct members
based on property settings

【在 g*****g 的大作中提到】
: If you don't want to create mySalaryQueryer, don't put it
: as a property of your Company bean.
: You may dynamically get an instance using
: BeanContext.getInstance().getCtx().getBean("mySalaryQueryer");
: Make sure the queryer is lazy-init

avatar
r*l
6


【在 c******n 的大作中提到】
: now in spring, as long as I write a in the .xml, it will be
: created (lazily ??),
: I wonder if there is a way to disable creating an bean depending on
: properties settings, for example, my main bean is
:
:
:

: let's say I decide that I won't give salary to employees in some cases, so
: I don't need to use the salaryQueryer, is there a way to disable creating
: the mySalaryQueryer at all? (without changing the .xml)

avatar
r*l
7
You can use lookup method and put your switch there. If you queryer is not a
singleton, then this is not the expected use of lookup method though.

【在 c******n 的大作中提到】
: now in spring, as long as I write a in the .xml, it will be
: created (lazily ??),
: I wonder if there is a way to disable creating an bean depending on
: properties settings, for example, my main bean is
:
:
:

: let's say I decide that I won't give salary to employees in some cases, so
: I don't need to use the salaryQueryer, is there a way to disable creating
: the mySalaryQueryer at all? (without changing the .xml)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。