use of org.hotswap.agent.command.Command in project HotswapAgent by HotswapProjects.
the class BeanClassRefreshCommand method executeCommand.
@Override
public void executeCommand() {
List<Command> mergedCommands = popMergedCommands();
mergedCommands.add(0, this);
do {
// First step : recreate all proxies
for (Command command : mergedCommands) {
((BeanClassRefreshCommand) command).recreateProxy(mergedCommands);
}
// Second step : reload beans
for (Command command : mergedCommands) {
((BeanClassRefreshCommand) command).reloadBean(mergedCommands);
}
mergedCommands = popMergedCommands();
} while (!mergedCommands.isEmpty());
}
use of org.hotswap.agent.command.Command in project HotswapAgent by HotswapProjects.
the class ClassPathBeanRefreshCommand method isDeleteEvent.
/**
* Check all merged events for delete and create events. If delete without create is found, than assume
* file was deleted.
*/
private boolean isDeleteEvent() {
// for all merged commands including this command
List<ClassPathBeanRefreshCommand> mergedCommands = new ArrayList<ClassPathBeanRefreshCommand>();
for (Command command : getMergedCommands()) {
mergedCommands.add((ClassPathBeanRefreshCommand) command);
}
mergedCommands.add(this);
boolean createFound = false;
boolean deleteFound = false;
for (ClassPathBeanRefreshCommand command : mergedCommands) {
if (command.event != null) {
if (command.event.getEventType().equals(FileEvent.DELETE))
deleteFound = true;
if (command.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 BeanClassRefreshCommand method executeCommand.
@Override
public void executeCommand() {
List<Command> mergedCommands = popMergedCommands();
mergedCommands.add(0, this);
do {
// First step : recreate all proxies
for (Command command : mergedCommands) {
((BeanClassRefreshCommand) command).recreateProxy(mergedCommands);
}
// Second step : reload beans
for (Command command : mergedCommands) {
((BeanClassRefreshCommand) command).reloadBean(mergedCommands);
}
mergedCommands = popMergedCommands();
} while (!mergedCommands.isEmpty());
}
use of org.hotswap.agent.command.Command in project HotswapAgent by HotswapProjects.
the class OsgiEquinoxPlugin method initOsgiEquinox.
public void initOsgiEquinox() {
if (hotswapCommand != null)
return;
LOGGER.debug("Init OsgiEquinoxPlugin.");
extraClasspath = pluginConfiguration.getProperty("extraClasspath");
if (extraClasspath != null) {
String debugMode = pluginConfiguration.getProperty("osgiEquinox.debugMode");
isDebugMode = "true".equals(debugMode);
if (!isDebugMode) {
URL resource = null;
try {
resource = resourceNameToURL(extraClasspath.trim());
URI uri = resource.toURI();
LOGGER.info("Initialize hotswap on URL {}.", uri);
listener = new AutoHotswapPathEventListener(this);
watcher.addEventListener(null, uri, listener);
} catch (URISyntaxException e) {
LOGGER.error("Unable to watch path '{}' for changes.", e, resource);
} catch (Exception e) {
LOGGER.warning("initOsgiEquinox() exception : {}", e.getMessage());
}
if (resource != null) {
hotswapCommand = new Command() {
@Override
public void executeCommand() {
pluginManager.hotswap(reloadMap);
}
@Override
public String toString() {
return "pluginManager.hotswap(" + Arrays.toString(reloadMap.keySet().toArray()) + ")";
}
};
}
}
}
}
use of org.hotswap.agent.command.Command 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);
}
}
Aggregations