Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
6.3. Using an Advanced Externalizer
- Define and implement the
readObject()andwriteObject()methods. - Link externalizers with marshaller classes.
- Register the advanced externalizer.
6.3.1. Implement the Methods Link kopierenLink in die Zwischenablage kopiert!
readObject() and writeObject() methods. The following is a sample definition:
Example 6.2. Define and Implement the Methods
Note
6.3.2. Link Externalizers with Marshaller Classes Link kopierenLink in die Zwischenablage kopiert!
getTypeClasses() to discover the classes that this externalizer can marshall and to link the readObject() and writeObject() classes.
ReplicableCommandExternalizer indicates that it can externalize several command types. This sample marshalls all commands that extend the ReplicableCommand interface but the framework only supports class equality comparison so it is not possible to indicate that the classes marshalled are all children of a particular class or interface.
@Override
public Set<Class<? extends List>> getTypeClasses() {
return Util.<Class<? extends List>>asSet(
Util.<List>loadClass("java.util.Collections$SingletonList", null));
}
@Override
public Set<Class<? extends List>> getTypeClasses() {
return Util.<Class<? extends List>>asSet(
Util.<List>loadClass("java.util.Collections$SingletonList", null));
}
6.3.3. Register the Advanced Externalizer (Declaratively) Link kopierenLink in die Zwischenablage kopiert!
Procedure 6.1. Register the Advanced Externalizer
- Add the
globalelement to theinfinispanelement. - Add the
serializationelement to theglobalelement. - Add the
advancedExternalizerselement to add information about the new advanced externalizer. - Define the externalizer class using the
externalizerClassattributes. Replace the $IdViaAnnotationObj and $AdvancedExternalizer values as required.
6.3.4. Register the Advanced Externalizer (Programmatically) Link kopierenLink in die Zwischenablage kopiert!
Example 6.3. Registering the Advanced Externalizer Programmatically
GlobalConfigurationBuilder builder = ... builder.serialization() .addAdvancedExternalizer(new Person.PersonExternalizer());
GlobalConfigurationBuilder builder = ...
builder.serialization()
.addAdvancedExternalizer(new Person.PersonExternalizer());
6.3.5. Register Multiple Externalizers Link kopierenLink in die Zwischenablage kopiert!
GlobalConfiguration.addExternalizer() accepts varargs. Before registering the new externalizers, ensure that their IDs are already defined using the @Marshalls annotation.
Example 6.4. Registering Multiple Externalizers
builder.serialization()
.addAdvancedExternalizer(new Person.PersonExternalizer(),
new Address.AddressExternalizer());
builder.serialization()
.addAdvancedExternalizer(new Person.PersonExternalizer(),
new Address.AddressExternalizer());