Search in sources :

Example 1 with MergeableCommand

use of org.hotswap.agent.command.MergeableCommand in project HotswapAgent by HotswapProjects.

the class SchedulerImpl method scheduleCommand.

@Override
public void scheduleCommand(Command command, int timeout, DuplicateSheduleBehaviour behaviour) {
    synchronized (scheduledCommands) {
        Command targetCommand = command;
        if (scheduledCommands.containsKey(command) && (command instanceof MergeableCommand)) {
            // get existing equals command and merge it
            for (Command scheduledCommand : scheduledCommands.keySet()) {
                if (command.equals(scheduledCommand)) {
                    targetCommand = ((MergeableCommand) command).merge(scheduledCommand);
                    break;
                }
            }
        }
        // map may already contain equals command, put will replace it and reset timer
        scheduledCommands.put(targetCommand, new DuplicateScheduleConfig(System.currentTimeMillis() + timeout, behaviour));
        LOGGER.trace("{} scheduled for execution in {}ms", targetCommand, timeout);
    }
}
Also used : MergeableCommand(org.hotswap.agent.command.MergeableCommand) WatchEventCommand(org.hotswap.agent.annotation.handler.WatchEventCommand) Command(org.hotswap.agent.command.Command) MergeableCommand(org.hotswap.agent.command.MergeableCommand)

Aggregations

WatchEventCommand (org.hotswap.agent.annotation.handler.WatchEventCommand)1 Command (org.hotswap.agent.command.Command)1 MergeableCommand (org.hotswap.agent.command.MergeableCommand)1