this.displayName = displayName;
this.serverAddress = serverAddress;
}
public void execute(final WorkerContext workerContext) {
final MessagingClient client = createClient();
try {
LOGGER.debug("Starting {}.", displayName);
WorkerProcessContext context = new WorkerProcessContext() {
public ObjectConnection getServerConnection() {
return client.getConnection();
}
public ClassLoader getApplicationClassLoader() {
return workerContext.getApplicationClassLoader();
}
public Object getWorkerId() {
return workerId;
}
public String getDisplayName() {
return displayName;
}
};
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(action.getClass().getClassLoader());
try {
action.execute(context);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
LOGGER.debug("Completed {}.", displayName);
} finally {
LOGGER.debug("Stopping client connection.");
client.stop();
}
}