Class InvokeMessageCompiler
- java.lang.Object
-
- net.sf.eBus.messages.type.InvokeMessageCompiler
-
- All Implemented Interfaces:
IMessageCompiler
public final class InvokeMessageCompiler extends java.lang.Object implements IMessageCompiler
Generates aInvokeMessageType
to serialize/de-serialize a specificEMessage
orEField
class.InvokeMessageType
usesjava.lang.invoke
package to access the message object fields and the message object's builder class.In terms of performance
InvokeMessageType
serialization/de-serialization can be thought of running in interpreted mode. Compare this withJavaMessageCompiler
which dynamically generates and compiles a class specifically for serializing/de-serializing the target message class. This can be thought of as JIT'd code.JavaMessageCompiler
is the default message compiler which usesjavassist
to generate Java code at run-time. Ifjavassist
is unavailable or cannot be used, then an application must set the message compiler type at application start. This is done by setting the propertymessageCompiler = JAVA_INVOKE
in an eBus configuration file and then passing that file in the command line option-Dnet.sf.eBus.config.jsonFile=<file>
.Note: when running on an Android virtual machine the
InvokeMessageCompiler
is always used since it is not feasible to generate and load a Java class at run-time given Android security restrictions.- Author:
- Charles W. Rapp
- See Also:
JavaMessageCompiler
,DataType
-
-
Constructor Summary
Constructors Constructor Description InvokeMessageCompiler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataType
compile(ConcreteMessageType mt)
Returns a specificInvokeMessageType
for serializing/de-serializing the given message type.
-
-
-
Method Detail
-
compile
public DataType compile(ConcreteMessageType mt) throws MessageCompileException
Returns a specificInvokeMessageType
for serializing/de-serializing the given message type. The returned message type usesjava.lang.invoke
to access message fields when serializing and message builder methods when de-serializing. The returned data type performs serialization/de-serialization notably slower than the data type returned byJavaMessageCompiler.compile(ConcreteMessageType)
.- Specified by:
compile
in interfaceIMessageCompiler
- Parameters:
mt
- createInvokeMessageCompiler
for this eBus message or field type.- Returns:
InvokeMessageCompiler
for the given message type.- Throws:
MessageCompileException
- if specific data type formt
could not be generated.- See Also:
JavaMessageCompiler
-
-