Information Technology Reference
In-Depth Information
The Javassist API allows for both source code and bytecode level manipula-
tion of Java class files. While the bytecode level API allows for the manipulation
of a class file at the bytecode level, the source code level API allows the user to
manipulate the bytecode of a class by providing Java source code statements that
are compiled by the library into bytecode before the class is manipulated. Users
therefore do not need to have detailed knowledge of bytecode or the internal Java
class file structures [19].
The library provides an object-oriented structure of a class file with ob-
jects representing classes, methods and fields. Once a class file is loaded, a class,
CtClass , is available to the user, which contains an object-oriented view of the
loaded class. Users may then obtain objects representing the fields and methods
of the class and manipulate them by adding advice code before, around or after
a method, introducing new methods or fields, altering the class to implement an
interface and so on.
Once changes have been made to the class, the altered class may be written
to either the existing class file, thereby overwriting it, or to a different directory
structure, thereby preserving the original class file. The RemoteJ compiler/gener-
ator preserves the original class file, thereby simplifying the testing of application
code, as the system may be tested as a non-distributed application, using testing
tools such as JUnit [11] and run as a distributed application using any supported
protocol.
The RemoteJ compiler/generator uses the source code level API for all byte-
code manipulation with the exception of identifying synchronized blocks of code,
which uses the bytecode level API.
5.3 Recovery Implementation
The RemoteJ DDL supports four recovery scenarios:
• A user-defined recovery statement that may consist of any valid Java code.
In addition, the programmer has access to the Transfer object, illustrated
in Figure 5.5, which provides access to the current system state. We also
provide access to various helper methods that allows the user to explicitly
define a list of available hosts or a particular alternate host to switch to in
the event of an error. In addition, we provide the serverPlugin statement,
which may be used to provide advanced recovery scenarios, which is described
below 1 .
•The abort statement, which simply causes the application to terminate.
•The continue statement, which causes the application to ignore the error
and continue execution.
•The nextServer statement, which causes the client to switch to the next
available server.
1 A recovery implementation illustrating the usage of this statement is provided in Section 6.4.2.
Search WWH ::




Custom Search