Skip to content

Java Hotswap

Fred Eisele edited this page Apr 18, 2019 · 4 revisions

Cytoscape Hotswap

Java supports and Cytoscape makes use of a very nice feature called Hotswap. When the App jar file is generated into the ~/CytoscapeConfiguration/3/apps/installed/ folder (either by symlink or some other means) Cytoscape will detect that change and update the App. Cytoscape update the App This can be observed by watching the Cytoscape status bar. You do need to make sure your App can survive being reloaded though. You can use the CyActivator.shutDown() method to save data and dispose resources.

IDE

The IDE debugger allows you to make changes to your code, compile them and run them without leaving the debugger or needing to restart Cytoscape. Keep in mind that this only works with edits that do not change top level declarations. For example if you add a parameter to a public method or add a field to a class then the debugger will inform you that it cannot replace the old code. When this happens you will have start a new debug session.

CyActivator.shutdown()

Each App should implement CyActivator and its shutdown() Here is an example frin ...

...
import org.cytoscape.service.util.AbstractCyActivator;
...
public class CyActivator extends AbstractCyActivator {
private Injector injector;
...
@Override
	public void shutDown() {
		// MKTODO make this smarter like how EM does it
		try {
			ModelTablePersistor persistor = injector.getInstance(ModelTablePersistor.class);
			persistor.exportModel();
			ModelManager modelManager = injector.getInstance(ModelManager.class);
			modelManager.dispose();
		} finally {
			super.shutDown();
		}
You can’t perform that action at this time.