protected void validateServerStructure(IServer server) throws CoreException { IControllableServerBehavior jbsBehavior = JBossServerBehaviorUtils.getControllableBehavior(server); Trace.trace(Trace.STRING_FINEST, "Verifying server structure"); // $NON-NLS-1$ JBossExtendedProperties props = ExtendedServerPropertiesAdapterFactory.getJBossExtendedProperties(server); IStatus status = props.verifyServerStructure(); if (!status.isOK()) { ((ControllableServerBehavior) jbsBehavior).setServerStopped(); throw new CoreException(status); } Trace.trace( Trace.STRING_FINEST, "Verifying jdk is available if server requires jdk"); // $NON-NLS-1$ boolean requiresJDK = props.requiresJDK(); if (requiresJDK) { IRuntime rt = server.getRuntime(); IJBossServerRuntime rt2 = RuntimeUtils.getJBossServerRuntime(rt); IVMInstall vm = rt2.getVM(); if (!JavaUtils.isJDK(vm)) { // JBIDE-14568 do not BLOCK launch, but log error Trace.trace( Trace.STRING_FINEST, "The VM to launch server '" + //$NON-NLS-1$ server.getName() + "' does not appear to be a JDK: " + vm.getInstallLocation().getAbsolutePath()); // $NON-NLS-1$ IStatus stat = new Status( IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, NLS.bind( Messages.launch_requiresJDK, server.getName(), vm.getInstallLocation().getAbsolutePath())); logStatus(server, stat); } } }
/** * Return a -1 if no idea what happened, or the actual status code from the shutdown command * * @param initialWorkingDirectory * @param command * @param environment * @param monitor * @param delay * @param exit * @return * @throws CoreException */ public int executeRemoteCommandGetStatus( String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor, int delay, boolean exit) throws CoreException { executeRemoteCommand(initialWorkingDirectory, command, environment, monitor); final String[] statusLine = new String[2]; // [0] is last, [1] is new final boolean[] done = new boolean[1]; done[0] = false; statusLine[0] = null; IHostShellOutputListener statusListener = new IHostShellOutputListener() { public void shellOutputChanged(IHostShellChangeEvent event) { IHostOutput[] lines = event.getLines(); for (int i = 0; i < lines.length; i++) { // shift if (!done[0]) { statusLine[0] = statusLine[1]; statusLine[1] = lines[i].getString(); System.out.println("RSEHostShellModel debug out: " + lines[i].getString()); } if (serverId.equals(statusLine[1])) // Then the real answer is the line before this one... statusLine[0] done[0] = true; } } }; singleUseShell.getStandardOutputReader().addOutputListener(statusListener); singleUseShell.writeToShell("echo $? && echo \"" + serverId + "\""); ThreadUtils.sleepFor(delay); if (exit && singleUseShell != null && singleUseShell.isActive()) { singleUseShell.exit(); singleUseShell = null; } String s = statusLine[0]; done[0] = true; // ensure a cleanup if (s != null) { try { Integer i = Integer.parseInt(s); return i.intValue(); } catch (NumberFormatException nfe) { } } Trace.trace( Trace.STRING_FINER, NLS.bind("Command {0} exited with status {1}", command, statusLine[0])); return -1; }