Solved

PropertyUtils  java

Posted on 2014-02-26
4
286 Views
Last Modified: 2014-04-11
Hi,

I am going through below link on property utils

http://commons.apache.org/proper/commons-beanutils/apidocs/org/apache/commons/beanutils/PropertyUtils.html#getPropertyDescriptor(java.lang.Object


What for they used and why and when. How they are related to collections.
please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 3
4 Comments
 
LVL 21

Accepted Solution

by:
Amitkumar Panchal earned 500 total points
ID: 39891467
PropertyUtils is written using java reflection api and provides you ability to modify properties of Java object at runtime. Hence, it make you to write highly configurable code where you can provide name of bean properties and there values from configuration rather than coded in Java program.

For more details : http://javarevisited.blogspot.com/2012/04/java-propertyutils-example-getting-and.html

Like propertyutils, Spring is also written on top of reflection api of java.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39891869
PropertyUtils is written using java reflection api and provides you ability to modify properties of Java object at runtime.

In the link
 http://javarevisited.blogspot.com/2012/04/java-propertyutils-example-getting-and.html
it was mentioned as below
Remember we don’t know anything about Object on compile time. On runtime Object is provided to program along with name of property to retrieve or modify:

Read more: http://javarevisited.blogspot.com/2012/04/java-propertyutils-example-getting-and.html#ixzz2uX3g47Zr




Why we do not know anything about object at compile time but  runtime Object is provided to program along with name of property to retrieve or modify.

I am not clear on those statements.
I ran above program in the javarevisited link, I got output as below
PropertyUtils Example property value: blue

what is the meaning of output

I see we are setting and getting colr from PropertyUtils
   
  //here color and blue strings can come from variety or sources
        //e.g. configuration files, database, any upstream system or via HTTP Request
        PropertyUtils.setProperty(flexiColor, "color", "blue");
        String value = (String) PropertyUtils.getProperty(flexiColor, "color");
        System.out.println("PropertyUtils Example property value: " + value);

How is it different from regular getter and setter from a bean.

 PropertyUtils.setProperty(flexiColor, "color", "blue");

Where is this setter defined.

please advise
0
 
LVL 7

Author Comment

by:gudii9
ID: 39893860
I see code as below

    PropertyUtils.getPropertyDescriptor(obj, fieldName).getWriteMethod().invoke(obj, list);

What is the meaning of above code while parsing a text document which has not only primitives but also list kind of objects before sending to one other system.
please advise
0
 
LVL 7

Author Comment

by:gudii9
ID: 39954568
How the reflection on class, method, field are different.
Any practical example to understand this reflection concept end to end better with set up on eclipse. please advise
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now