Solved

PropertyUtils  java

Posted on 2014-02-26
4
297 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
print map entry 34 72
tomcat startup error 5 102
Error in @AspectJ Based AOP with Spring 2 18
Fast way to search item into Java Array (Rhino compatible) 2 31
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

861 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