Search in sources :

Example 1 with ClassCollectingHCRListener

use of org.jboss.ide.eclipse.as.core.util.ClassCollectingHCRListener in project jbosstools-openshift by jbosstools.

the class OpenShiftLaunchController method getHotCodeReplaceListener.

protected IJavaHotCodeReplaceListener getHotCodeReplaceListener(final IServer server, final ILaunch launch) {
    return new ClassCollectingHCRListener(server, launch) {

        protected void prePublish(IJavaDebugTarget target, IModule[] modules) {
            try {
                getLaunch().terminate();
            } catch (DebugException de) {
                OpenShiftCoreActivator.pluginLog().logError(toCoreException("Unable to terminate debug session", de));
            }
        }

        @Override
        protected void postPublish(IJavaDebugTarget target, IModule[] modules) {
            IServer server = getServer();
            waitModulesStarted(modules);
            executeJMXGarbageCollection(server, modules);
            sleep(3000);
            String portAttr = launch.getAttribute(LAUNCH_DEBUG_PORT_PROP);
            int port = DebugContext.NO_DEBUG_PORT;
            try {
                port = Integer.parseInt(portAttr);
            } catch (NumberFormatException nfe) {
            // TODO
            }
            try {
                ILaunch newLaunch = attachRemoteDebugger(server, port, new NullProgressMonitor());
                if (newLaunch != null) {
                    overrideHotcodeReplace(server, newLaunch);
                }
                setLaunch(newLaunch);
            } catch (CoreException ce) {
                OpenShiftCoreActivator.pluginLog().logError(toCoreException("Unable to restart debug session", ce));
            }
        }
    };
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ClassCollectingHCRListener(org.jboss.ide.eclipse.as.core.util.ClassCollectingHCRListener) IServer(org.eclipse.wst.server.core.IServer) IJavaDebugTarget(org.eclipse.jdt.debug.core.IJavaDebugTarget) CoreException(org.eclipse.core.runtime.CoreException) OpenShiftServerUtils.toCoreException(org.jboss.tools.openshift.core.server.OpenShiftServerUtils.toCoreException) ILaunch(org.eclipse.debug.core.ILaunch) DebugException(org.eclipse.debug.core.DebugException)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 DebugException (org.eclipse.debug.core.DebugException)1 ILaunch (org.eclipse.debug.core.ILaunch)1 IJavaDebugTarget (org.eclipse.jdt.debug.core.IJavaDebugTarget)1 IServer (org.eclipse.wst.server.core.IServer)1 ClassCollectingHCRListener (org.jboss.ide.eclipse.as.core.util.ClassCollectingHCRListener)1 OpenShiftServerUtils.toCoreException (org.jboss.tools.openshift.core.server.OpenShiftServerUtils.toCoreException)1