use of org.hotswap.agent.command.Command in project HotswapAgent by HotswapProjects.
the class BeanClassRefreshCommand method isCreateEvent.
/**
* Check all merged events with same className for create events.
* @param mergedCommands
*/
private boolean isCreateEvent(List<Command> mergedCommands) {
boolean createFound = false;
for (Command cmd : mergedCommands) {
BeanClassRefreshCommand refreshCommand = (BeanClassRefreshCommand) cmd;
if (className.equals(refreshCommand.className)) {
if (refreshCommand.event != null) {
if (refreshCommand.event.getEventType().equals(FileEvent.CREATE))
createFound = true;
}
}
}
LOGGER.trace("isCreateEvent result {}: createFound={}", createFound);
return createFound;
}
use of org.hotswap.agent.command.Command in project HotswapAgent by HotswapProjects.
the class BeanClassRefreshCommand method isDeleteEvent.
/**
* Check all merged events with same className for delete and create events. If delete without create is found, than assume
* file was deleted.
* @param mergedCommands
*/
private boolean isDeleteEvent(List<Command> mergedCommands) {
boolean createFound = false;
boolean deleteFound = false;
for (Command cmd : mergedCommands) {
BeanClassRefreshCommand refreshCommand = (BeanClassRefreshCommand) cmd;
if (className.equals(refreshCommand.className)) {
if (refreshCommand.event != null) {
if (refreshCommand.event.getEventType().equals(FileEvent.DELETE))
deleteFound = true;
if (refreshCommand.event.getEventType().equals(FileEvent.CREATE))
createFound = true;
}
}
}
LOGGER.trace("isDeleteEvent result {}: createFound={}, deleteFound={}", createFound, deleteFound);
return !createFound && deleteFound;
}
use of org.hotswap.agent.command.Command in project HotswapAgent by HotswapProjects.
the class SchedulerImpl method processCommands.
/**
* One cycle of the scheduler agent. Process all commands which are not currently
* running and time lower than current milliseconds.
*
* @return true if the agent should continue (false for fatal error)
*/
private boolean processCommands() {
Long currentTime = System.currentTimeMillis();
synchronized (scheduledCommands) {
for (Iterator<Map.Entry<Command, DuplicateScheduleConfig>> it = scheduledCommands.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<Command, DuplicateScheduleConfig> entry = it.next();
DuplicateScheduleConfig config = entry.getValue();
Command command = entry.getKey();
// if timeout
if (config.getTime() < currentTime) {
// command is currently running
if (runningCommands.contains(command)) {
if (config.getBehaviour().equals(DuplicateSheduleBehaviour.SKIP)) {
LOGGER.debug("Skipping duplicate running command {}", command);
it.remove();
} else if (config.getBehaviour().equals(DuplicateSheduleBehaviour.RUN_DUPLICATE)) {
executeCommand(command);
it.remove();
}
} else {
executeCommand(command);
it.remove();
}
}
}
}
return true;
}
Aggregations