Java reflection discussing the integration of reflection, JavaBeans,
Java reflection discussing the integration of reflection, JavaBeans, and custom tags, a quick look at the Java reflection API is in order. This will not be an in-depth description of reflection or method invocation by using reflection, but will provide a helpful explanation of the technology, its advantages, and the API that can put it to good use. 8.1.1 What is reflection? Javasoft describes the purpose of the reflection API as to enable Java code to discover information about the fields, methods, and constructors of loaded classes, and to use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions. Quite a mouthful, so what does all that mean? In brief, the reflection API lets us learn about a particular Java class and then use that knowledge to properly call methods, get and set fields, or call the constructor of any instance of that class. The reflection API is particularly useful for debuggers and development tools that need to browse classes and display certain information from the classes to the user. The API is also useful when parts of your Java program have to interact with any type of Java object and need to learn about it at runtime. The tags we create in this chapter will have this requirement, since they will be designed to work with any and all JavaBeans. This definition can be clarified with a few examples of programs that use Java reflection. Reflection and development tools Consider the case of an environment wherein a developer manipulates program components through the GUI of a Java IDE (like JBuilder, Visual Caf , etc.). We recognize that the development environment knows nothing about the components in advance, yet it must be able to present the developer with the possible methods that can be used in each component. Spying on the component to discern the interfaces, methods, and properties they expose can be accomplished using the reflection API, and is better known as Introspection. Reflection and scripting engines Another case is one wherein a user employs a JavaBean-capable scripting engine to create an application. Since a script is not usually precompiled with all its components, it does not know anything in advance about the different JavaBeans components with which it will interact at runtime (not even their type); yet, during runtime it should be able to perform the following: Introspect the components to find the method that it should execute. Dynamically execute the method on the scripted object. Both of these functions are available through the reflection API.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services