public class ClassLoadingCodeRunnerClient<TMessage> extends Object
MessageHandlingServerCode with a bi-directional
message-channel and remote class loading on the server.
Message sending
After the ServerCode is started using the CodeRunnerClient, a thread
is started which takes messages from a local queue and sends them to the
server code. The thread which initiated the remote code execution enters a
loop requesting messages from the server and handling them, until the remote
code exited.
Server Code Exit
When the server code completes, a message is sent to the client which will
confirm reception and return to the caller. Upon reception of the
confirmation, the server code exits, too. This makes sure that all messages
are exchanged between client and server before exit, since the messages are
delivered in order.
Class Loading
When the ServerCode requires a class, the
class loader first checks if
the class can be found on the server. Otherwise it requests the corresponding
class from the client using a ClassLoadingCodeRunnerClient.RequestResourceMessage. The class
loader then enters a loop waiting for the resource to become available.
The client checks if the resource is part of a jar. In this case the whole
jar is sent (ClassLoadingCodeRunnerClient.SendJarsMessage), otherwise only the requested resource
(ClassLoadingCodeRunnerClient.SendResourceMessage). The message handling code on the server side
adds the resource to the class loader. The class loader detects this, loads
the class and returns.

| Constructor and Description |
|---|
ClassLoadingCodeRunnerClient() |
| Modifier and Type | Method and Description |
|---|---|
CodeRunnerClient |
getClient() |
ParentClassLoaderSupplier |
getParentClassLoaderSupplier() |
void |
runCode(MessageHandlingServerCode<TMessage> code,
BiConsumer<TMessage,Consumer<TMessage>> clientMessageHandler) |
void |
runCode(MessageHandlingServerCode<TMessage> code,
BiConsumer<TMessage,Consumer<TMessage>> clientMessageHandler,
CodeRunnerClient.ClassMapBuilder bootstrapClasses) |
void |
setParentClassLoaderSupplier(ParentClassLoaderSupplier parentClassLoaderSupplier) |
void |
setRunnerClient(CodeRunnerClient client) |
public void runCode(MessageHandlingServerCode<TMessage> code, BiConsumer<TMessage,Consumer<TMessage>> clientMessageHandler)
public void runCode(MessageHandlingServerCode<TMessage> code, BiConsumer<TMessage,Consumer<TMessage>> clientMessageHandler, CodeRunnerClient.ClassMapBuilder bootstrapClasses)
code - code to be executedclientMessageHandler - handler for messages sent from the server back to the clientbootstrapClasses - classes to be sent along with the code, used to deserialize
the codepublic ParentClassLoaderSupplier getParentClassLoaderSupplier()
public void setParentClassLoaderSupplier(ParentClassLoaderSupplier parentClassLoaderSupplier)
public CodeRunnerClient getClient()
public void setRunnerClient(CodeRunnerClient client)
Copyright © 2016. All rights reserved.