[jboss-user] [Microcontainer] - Re: Injecting a field value
Sure. I never said this was _not_ pseudo code. :-) But I think you get my drift. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193894#4193894 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193894 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
Ah, I get it. One thing though - shouldn't the class be loaded from the classloader of the deployment? If you have just one ConstantsProvider for all deployements and it's just using its own classloader, one would think there might be problems when it is used by another deployment. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193881#4193881 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193881 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
"[EMAIL PROTECTED]" wrote : The most obvious mechanism to me is a ValueMetaData that is comprised of a class and a field name. The most obvious is value-factory: | | | org.jboss.demos.ioc.access.IConstants | | | | | | | | public class ConstantsProvider | { |private KernelConfigurator configurator; |private String className; |private ClassInfo classInfo; | |public ConstantsProvider(String className) |{ | this.className = className; |} | |@Inject(bean = KernelConstants.KERNEL_CONFIGURATOR_NAME) |public void setConfigurator(KernelConfigurator configurator) |{ | this.configurator = configurator; |} | |public void create() throws Throwable |{ | if (configurator == null) | throw new IllegalArgumentException("Null configurator"); | | if (className != null) | classInfo = configurator.getClassInfo(className, getClass().getClassLoader()); |} | |public Object getConstant(String constantName) throws Throwable |{ | return getConstant(classInfo, constantName); |} | |public Object getConstant(String className, String constantName) throws Throwable |{ | ClassInfo classInfo = configurator.getClassInfo(className, getClass().getClassLoader()); | return getConstant(classInfo, constantName); |} | |protected Object getConstant(ClassInfo classInfo, String constantName) throws Throwable |{ | FieldInfo field = classInfo.getDeclaredField(constantName); | return field.get(null); |} | } | I can add this as part of Kernel, probably next to BeanMetaDataBuilder. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193805#4193805 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193805 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
Exactly... View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193795#4193795 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193795 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
A simpler use case would be constants in an interface. ;-) View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193793#4193793 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193793 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
Consider the case where a constructor takes an enum or an enum-like object - object identity is significant, but there may or may not be a way to get the value from a factory method. The object would be known publicly only because it is declared as a public constant. The most obvious mechanism to me is a ValueMetaData that is comprised of a class and a field name. Make sense? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193771#4193771 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193771 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
"alesj" wrote : | We don't have any special static handling (via xml or BMDB). | Apart from constructor::factory. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193756#4193756 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193756 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
"[EMAIL PROTECTED]" wrote : Unless access-mode="FIELDS" implicitly grabs the class instead? Grabs class how? We don't have any special static handling (via xml or BMDB). OO != static. ;-) And I don't see why we should have any special treatment, the example I provided you is not a huge penalty. But you can do all this static mojo via BeanInfo. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193752#4193752 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193752 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
It just seems a little odd - I want to pull a static field so why do I need an object instance? Unless access-mode="FIELDS" implicitly grabs the class instead? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193743#4193743 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193743 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
"[EMAIL PROTECTED]" wrote : So does that mean that any bean which I want to pull constants from has to be managed? It's all about beans. Unless we had special constants treatment, how else do you expect us to pull stuff from? :-) But I guess this can be done generic: - simply add constants handling bean - value-factory usage - use similar mechanism we use for field access. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193740#4193740 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193740 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
Ah, I see why it wasn't obvious at first. So does that mean that any bean which I want to pull constants from has to be managed? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193736#4193736 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193736 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
"[EMAIL PROTECTED]" wrote : Though I am starting to suspect that there is no support for this currently. You would be wrong. ;-) I might even be offended as you doubt us. :-) See constants usage: - http://anonsvn.jboss.org/repos/jbossas/projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/access-mode-beans.xml View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193726#4193726 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193726 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Microcontainer] - Re: Injecting a field value
...and, I also would need to know the programmatic equivalent as well. Though I am starting to suspect that there is no support for this currently. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193614#4193614 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193614 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user