0% found this document useful (0 votes)
3 views2 pages

Java Bean Introspection Example

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Bean Introspection Example

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

package introspectiondemo;

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

class EmployeeBean implements Serializable { //1. Implementing serializable


//2. Private members
private int id;
private String name;

//3. public no-args constructors


public EmployeeBean(){};

//4. Create getter and setter methods


public void setId(int id)
{
[Link] = id;
}

public int getId()


{
return id;
}

public void setName(String name)


{
[Link] = name;
}

public String getName()


{
return name;
}

public void Hello()


{
[Link]("Hello Java Bean...");
}

public void Bye()


{
[Link]("Bye bye Java Bean...");
}
}
public class IntrospectionExample {
public static void main(String[] args) {
//EmployeeBean emp = new EmployeeBean();
try {
// Get the BeanInfo for a class
BeanInfo beanInfo = [Link]([Link]);
// Get the property descriptors
PropertyDescriptor[] propertyDescriptors =
[Link]();
[Link]("Properties:");
for (PropertyDescriptor descriptor : propertyDescriptors) {
[Link]([Link]());
}

// Get the method descriptors


Method[] methods = [Link]();
[Link]("\nMethods:");
for (Method method : methods) {
[Link]([Link]());
}
}
catch(IntrospectionException e)
{
[Link]();
}

}
}

You might also like