Defining ClassAlias and FieldAlias annotations to correlate Java classes
To enable sharing of objects in the data
grid between different Java™ classes,
use ClassAlias and FieldAlias annotations. When two classes are correlated,
the fields and field types are matched between the classes, even if
the class names are different.
Use ClassAlias and FieldAlias annotations when you are running
two different classes within different application scopes, or run
times. The data that is stored in the data grid can be shared and
reused across two different application run times. As a result, you
do not need to maintain two different metadata descriptors. If your
classes are within the same application scope, or run time, it can
be confusing from the application provider or development point of
view to have two classes be correlated.
Use ClassAlias and FieldAlias annotations
to correlate objects between two different Java classes.
In the following
example classes, the @ClassAlias("ACME_Customer") Java annotation is specified. Some
fields have a @FieldAlias("") annotation. Because
both of these classes have the same ClassAlias annotation and FieldAlias
definitions, the objects are maintained with the same class type ID
by XDF. The same XDF metadata is used when these objects are serialized
or deserialized during the get and put operations.
Optional: Specify the class alias discovery
path, so that the class alias can be used to correlate with an equivalent
class in the client class path.
Set the discovery path
if the deserialization process does not find the equivalent class
from the client. Set the discovery path if you have another class
in your client that defines the same class alias, but is not loaded
in your current class loader.
Enable a Java application
to scan and load classes that match with the specified ClassAlias
value from the application class path.
When you start the application,
specify the -Dwxs.classalias.discovery.path Java virtual machine (JVM) argument.
The list of Java archive (JAR)
files or specific folders that contain the Java classes to match with a class alias that
is defined in the user-defined classes are scanned.
For example,
you might specify: -Dwxs.classalias.discovery.path=c:\myApp\lib\customer1.jar;c:\myApp\lib\customer2.jar;c:\myApp\classes The
scan operation scans all the specified JAR files and class path folders
to find all the available Java classes.
The Java class that is matched
first in the client application environment is based on the class
alias is loaded during the get operation.