swimming certificate (A & B), shoelaces diploma, and some useless java ones.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Originally posted by Ali Pope:
Some usages:
- bytecode generation (using either BCEL or ASM)
./pope
Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1932394184/ref=jranch-20" target="_blank" rel="nofollow">Java Reflection in Action</a>
Originally posted by Surasak Leenapongpanit:
I used reflections to implement an XML mapping inside my web framework.
Originally posted by Ali Pope:
You mean serializing/deserializing objects to xml?
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Originally posted by Ko Ko Naing:
I think Surasak is talking about creating classes on-the-fly using the elements specified in XML file... Or not?
If so, it is simple, isn't it? We just fetch the element values from the XML and then create the classes accordingly using reflection API...
Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1932394184/ref=jranch-20" target="_blank" rel="nofollow">Java Reflection in Action</a>
Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1932394184/ref=jranch-20" target="_blank" rel="nofollow">Java Reflection in Action</a>
Originally posted by Nate Forman:
Remembered last night--sometimes I'll use setAccessible() to do things that really need to get done, but for some reason, are not available.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Jeanne Boyarsky:
EasyMock matcher (similar to equality)
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Originally posted by Ali Pope:
I do not think so. It would be kindda performance problem for a web application.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Originally posted by Jeanne Boyarsky:
Struts does something similar to creating classes on the fly with DynaForms. In an XML file, you say what fields are needed. I don't think Struts actually builds a class, but it is pseudo-reflection.
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Originally posted by Ko Ko Naing:
I'm not quite clear about the word "pseudo-reflection"... Does the fact, that Struts creates classes on-the-fly without actually building a class, mean "pseudo-reflection"? What is the main difference between reflection that we have been discussing with Nate, one of the authors, and "pseudo-reflection" that you talked about in the above post?
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Jeanne Boyarsky:
Struts does something similar to creating classes on the fly with DynaForms. In an XML file, you say what fields are needed. I don't think Struts actually builds a class, but it is pseudo-reflection.
Originally posted by Jitesh Sinha:
Disadvantages:
1.)Hard to debug->This can kill too much of time in case of a big project.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
[...] generate beans from them and parse the configuration files.
.
What I did was writing a reflection algorithm which traversed the bean and copied the values to the parent bean.
Originally posted by Lasse Koskela:
The difference is that Struts doesn't make use of the Reflection API in implementing the DynaActionForm class. It just uses a Map to store an arbitrary set of "parameters" and only validates them according to the struts-config.xml. So, there's no Reflection involved at all but the outcome is similar to what could be achieved with Reflection as well -- no Java code needs to be written in order to support one more parameter.
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Originally posted by Ali Pope:
Is this refering to populating/setting beans values or really creating new classes?
Is this solution somehow similar to Castor solution?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ali Pope:
Jeanne afaik DynaForms is just a different name for DynaBeans (dynamic beans). Almost always DynaBeans implementation is based on a Map where the bean properties and values are stored with the addition of a validation against the set of available properties. So I wouldn't say here is something related to reflection.
--
./pope
[the_mindstorm]
Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1932394184/ref=jranch-20" target="_blank" rel="nofollow">Java Reflection in Action</a>
Originally posted by Nate Forman:
Many of my usages have become examples in the book. They include:
- persistance
- stubbing
- remote proxying
- logging
- plug-in loading
- deferred initialization
er... and probably some others that I'm forgetting. Many of the above have to do with applications of the Proxy pattern, or other synergies with delegation. (I'm a real patterns enthusiast.) If I think of some others that I've done more recently, I'll be sure to post...
Best Regards,
Nate
Kishore
SCJP, blog
Dynamic class loading.Originally posted by Kishore Dandu:
Can u be more specific about how plug-in loading can use the reflection.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Ali Pope:
You can read Matt's description (of the same algo) here
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Ali Pope:
Jeanne afaik DynaForms is just a different name for DynaBeans (dynamic beans). Almost always DynaBeans implementation is based on a Map where the bean properties and values are stored with the addition of a validation against the set of available properties. So I wouldn't say here is something related to reflection.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Originally posted by Lasse Koskela:
I wonder if it would be significantly more difficult to do the same for a J2EE application... Any idea about that?
Originally posted by Ilja Preuss:
From the little I know about Castor, I'd say that its XML binding is somewhat similar to JAXB, though probably more flexible, as it allows mappings between arbitrary existing beans and XML files.
Originally posted by Ilja Preuss:
I'm not aware of Castor providing a way to populate beans from other beans, but that might just show my lack of knowledge about it.
Originally posted by Ali Pope:
JBoss is using this mechanism to add functionality to their container. The core is very simple (hehe - not quite), every other part of the spec being added by a different sar.
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Originally posted by Ali Pope:
JBoss is using this mechanism to add functionality to their container. The core is very simple (hehe - not quite)
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Let me tell you a story about a man named Jed. He made this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|