-
1. Re: Unique Bean mapkey for ZK Skope attribute Map
alin.heyoulin.qq.com Feb 5, 2010 4:24 PM (in response to oberinspector)private String createMapKey(Bean bean) {
if(bean instanceof RIBean)
return (RIBean)bean.getId();
else
throw Exception(not a RIBean
);
} -
2. Re: Unique Bean mapkey for ZK Skope attribute Map
pmuir Feb 5, 2010 6:06 PM (in response to oberinspector)There is no generic ID function suitable for all beans. I'm also unaware of any generally unique way of identifying all beans.
-
3. Re: Unique Bean mapkey for ZK Skope attribute Map
alin.heyoulin.qq.com Feb 5, 2010 6:20 PM (in response to oberinspector)Yes
where i want to store Weld created ManagedBeansThomas Müller Just get ManagedBeans :-)
-
4. Re: Unique Bean mapkey for ZK Skope attribute Map
pmuir Feb 5, 2010 6:41 PM (in response to oberinspector)I assumed he really meant all beans, as storing just managed beans would be an odd thing to do.
-
5. Re: Unique Bean mapkey for ZK Skope attribute Map
oberinspector Feb 7, 2010 8:16 PM (in response to oberinspector)yes... i mean all beans... i just started with weld and i probably misused the therms... ;)
I want to programm against the CDI API... RIBean.getId() is weld spcific and not portable.I need to ensure equity only for the configured Skope... so a combination of the most significant type and the Qualifier OR the name in case of @Named beans should be sufficient to build a key.
Or do i miss something?
/Thomas
-
6. Re: Unique Bean mapkey for ZK Skope attribute Map
swd847 Feb 8, 2010 3:03 AM (in response to oberinspector)Theoretically no, although in practice this is probably fine. Using the spec it is possible to add beans that have the exact same bean type and qualifiers, so these would end up with the same key.
This is not actually as useless as it sounds, as these beans can have producer methods that produce different stuff. e.g. using the seam xml extension you can do:
<test:SomeBean> <test:someField> <Produces/> <test:ProducerQualifier value="1" /> <value>1</value> </test:someField> </test:SomeBean> <test:SomeBean> <test:someField> <Produces/> <test:ProducerQualifier value="2" /> <value>2</value> </test:someField> </test:SomeBean>
This will mean you end up with three different beans with the same bean type and qualifiers (as the original bean will still be installed), however they produce different stuff.
-
7. Re: Unique Bean mapkey for ZK Skope attribute Map
ashishlin Feb 9, 2010 7:21 AM (in response to oberinspector)Seems to me you need a (Contextual,Key) mapping. In your createMapKey() you need a way to keep track of whether or not a contextual was created before. If not generate a unique key yourself. Take a look at AbstractMapContext class that comes with weld.