Lab 10 - Reflection

Java Reflection API

Reflection

Use project https://gitlab.vsb.cz/jez04-vyuka/java2/labs/java2lab10v1

Modify the lab.gui.EditController class so that you can edit properties of any class using Java Reflection.

  • In the setObjectToEdit method, use the Introspector to get the BeanInfo to detect the java properties (a combination of getter and setter methods) and add a dialog for each property
  • In the btnOkAction method, transfer the data from the text fields back to the java properties object
  • Create an @MyEdit annotation to allow you to set the readOnly and visible attributes of each java bean property
  • Use the MyEdit annotation to display only those properties, that have the same name as an instance variable with the @MyEdit annotation, and use the settings from the @MyEdit annotation to hide the property or set it to read-only.
  • Set the id property to hidden.
  • Set the name property to read-only
  • Use java localization (ResourceBundle, Locale) to translate the property name in the dialog. Create a "resource bundle" named msg for multiple languages.
  • For example, use the parameters -Duser.language=en -Duser.country=EN

Method of submission

Submit the homework solution to the Kelvin system as the "Java 2 - Homework 1 - Maven" assignment. Upload the entire contents of the src folder and the pom.xml (and run script) file to the system. Follow the attached video below.

The project will then be compiled and Unit Tests will be performed. Due to the nature of the project and the provisional testing use of the Kelvin system in the Java 2 course, do not despair in case of failure.

This is an auxiliary test, everything will still be evaluated manually. It is important to upload the files so that everything can be evaluated and analyzed for plagiarism. I believe this is a formality and all of you are creating your own code.