public SshConnector(IServer server) { super(); this.server = server; this.behaviorDelegate = (IControllableServerBehavior) server.loadAdapter(IControllableServerBehavior.class, new NullProgressMonitor()); IKarafServerDelegate config = (IKarafServerDelegate) server.loadAdapter(IKarafServerDelegate.class, new NullProgressMonitor()); this.host = server.getHost(); this.port = config.getPortNumber(); this.userName = config.getUserName(); this.passwd = config.getPassword(); }
public void serverChanged(ServerEvent event) { final IServer server = event.getServer(); JBossServer jbs = (JBossServer) server.loadAdapter(JBossServer.class, new NullProgressMonitor()); if (jbs != null && serverSwitchesToState(event, IServer.STATE_STARTING)) { // do not launch console for remotes, for now String type = ServerProfileModel.getProfile(server); if (!ServerProfileModel.DEFAULT_SERVER_PROFILE.equals(type)) return; new Thread() { public void run() { try { // delay to insure the server gets a chance to actually launch Thread.sleep(3000); } catch (InterruptedException ie) { } Display.getDefault() .asyncExec( new Runnable() { public void run() { ILaunch launch = server.getLaunch(); if (launch != null && launch.getProcesses().length > 0) new ShowInConsoleAction(getNullSelectionProvider()).perform(server); } }); } }.start(); } }
public static IRemoteServer getRemoteServer(IServer server) { if (server != null) { return (IRemoteServer) server.loadAdapter(IRemoteServer.class, null); } return null; }
private boolean hasURL() { IServer server = getServer(); ServerExtendedProperties props = (ServerExtendedProperties) server.loadAdapter(ServerExtendedProperties.class, new NullProgressMonitor()); if (props != null) return props.hasWelcomePage(); return false; }
private String getPath(IServer server, IModule rootMod) { URL url = ((IURLProvider) server.loadAdapter(IURLProvider.class, null)).getModuleRootURL(rootMod); String surl = ""; try { surl = url.toURI().getPath().toString(); } catch (URISyntaxException e) { } return surl; }
public void serverChanged(ServerEvent event) { IServer s = event.getServer(); JBossExtendedProperties props = (JBossExtendedProperties) s.loadAdapter(JBossExtendedProperties.class, null); if (props != null && props.getMultipleDeployFolderSupport() == ServerExtendedProperties.DEPLOYMENT_SCANNER_AS7_MANAGEMENT_SUPPORT) { if (serverSwitchesToState(event, IServer.STATE_STARTED)) { // Don't do any potentially long-running tasks here. launchJob(s); } } }
private String getUrl() throws CoreException { String urlString = null; IServer server = getServer(); if (server != null && server.getServerState() == IServer.STATE_STARTED) { // When a module is selected, behave as you would during run-on-server for project-level // selection ModuleServer ms = getModuleServer(); if (ms != null) { // Go through the wtp framework to find the proper launchable adapter for the project JBTCustomHttpLaunchable launchable = getCustomLaunchable(server, ms.getModule()); // IF its one we provide, return its url directly if (launchable != null) { return (launchable).getURL().toString(); } // Otherwise, do the magic we did in the past to try our best to come up with a url IModule[] mss = ms.getModule(); IModule m = getWebModule(mss); if (m != null) { IServer s = getServer(); Object o = s.loadAdapter(IURLProvider.class, null); if (o instanceof IURLProvider) { URL url = ((IURLProvider) o).getModuleRootURL(m); if (url != null) { urlString = url.toString(); } } } } else { // When no module is selected,use welcome page url ServerExtendedProperties props = (ServerExtendedProperties) server.loadAdapter(ServerExtendedProperties.class, new NullProgressMonitor()); if (props != null) urlString = props.getWelcomePageUrl(); } } return urlString; }
/** * @param serverID unique ID of the server. This should not just be the name of the server, but * the full id (e.g. for V2, it should include the space name) * @return CloudFoundry server that corresponds to the given ID, or null if not found */ public static CloudFoundryServer getCloudServer(String serverID) { IServer[] servers = ServerCore.getServers(); if (servers == null) { return null; } CloudFoundryServer cfServer = null; for (IServer server : servers) { cfServer = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, null); if (cfServer != null && cfServer.getServerId().equals(serverID)) { break; } } return cfServer; }
/** * Returns list of cloud foundry server instances. May be emtpy, but not null. * * @return returns a non-null list of cloud foundry server instances. May be empty. */ public static List<CloudFoundryServer> getCloudServers() { IServer[] servers = ServerCore.getServers(); Set<CloudFoundryServer> matchedServers = new HashSet<CloudFoundryServer>(); if (servers != null) { for (IServer server : servers) { CloudFoundryServer cfServer = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, null); if (cfServer != null) { matchedServers.add(cfServer); } } } return new ArrayList<CloudFoundryServer>(matchedServers); }
@Override public void doSave(IProgressMonitor monitor) { if (standardOptions != null) standardOptions.updateListeners(); if (perModuleOptions != null) perModuleOptions.updateListeners(); IServer s = getServer(); if (s.getServerState() == IServer.STATE_STARTED) { JBossExtendedProperties properties = (JBossExtendedProperties) s.loadAdapter(JBossExtendedProperties.class, null); if (properties != null) { IDeploymentScannerModifier modifier = properties.getDeploymentScannerModifier(); if (modifier != null) { Job scannerJob = modifier.getUpdateDeploymentScannerJob(s); if (scannerJob != null) scannerJob.schedule(); } } } }
@Test public void testNoAdditionsRemovalsFromSettings() { // This test ensures that 'remote' servers are not handled by the standard listeners IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType); try { IServerWorkingCopy wc = s.createWorkingCopy(); wc.setAttribute(IJBossToolingConstants.PROPERTY_ADD_DEPLOYMENT_SCANNERS, false); wc.setAttribute(IJBossToolingConstants.PROPERTY_REMOVE_DEPLOYMENT_SCANNERS, false); s = wc.save(true, null); } catch (CoreException ce) { fail("Could not set server mode to non-local"); } // Accepts will also check if the proper server type is here ServerExtendedProperties props = (ServerExtendedProperties) s.loadAdapter(ServerExtendedProperties.class, null); boolean usesManagement = props != null && props.getMultipleDeployFolderSupport() == ServerExtendedProperties.DEPLOYMENT_SCANNER_AS7_MANAGEMENT_SUPPORT; boolean usesJMX = props != null && props.getMultipleDeployFolderSupport() == ServerExtendedProperties.DEPLOYMENT_SCANNER_JMX_SUPPORT; boolean accepts = new LocalJBoss7DeploymentScannerAdditions().accepts(s); assertEquals(accepts, usesManagement); accepts = new JMXServerDeploymentScannerAdditions().accepts(s); assertEquals(accepts, usesJMX); Job j1 = new LocalJBoss7DeploymentScannerAdditions().getUpdateDeploymentScannerJob(s); assertNull(j1); Job j2 = new JMXServerDeploymentScannerAdditions().getUpdateDeploymentScannerJob(s); assertNull(j2); Job j3 = new LocalJBoss7DeploymentScannerAdditions().getRemoveDeploymentScannerJob(s); assertNull(j3); Job j4 = new JMXServerDeploymentScannerAdditions().getRemoveDeploymentScannerJob(s); assertNull(j4); }
@Override protected IStatus run(final IProgressMonitor monitor) { CloudFoundryServer cf = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, monitor); if (cf.getPassword() == null) { // configuration has not been saved, yet, ignore return Status.CANCEL_STATUS; } if (cf != null && cf.getUsername().equals(originalServer.getUsername()) && cf.getPassword().equals(originalServer.getPassword()) && cf.getUrl().equals(originalServer.getUrl())) { CloudFoundryServerBehaviour behaviour = cf.getBehaviour(); if (behaviour != null) { try { behaviour.connect(monitor); } catch (CoreException e) { CloudFoundryServerUiPlugin.getDefault().getLog().log(e.getStatus()); } } } return Status.OK_STATUS; }
public void launch( ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { IServer server = ServerUtil.getServer(configuration); if (server == null) { Trace.trace(Trace.FINEST, "Launch configuration could not find server"); // throw CoreException(); return; } if (server.shouldPublish() && ServerCore.isAutoPublishing()) server.publish(IServer.PUBLISH_INCREMENTAL, monitor); PreviewServerBehaviour previewServer = (PreviewServerBehaviour) server.loadAdapter(PreviewServerBehaviour.class, null); int size = REQUIRED_BUNDLE_IDS.length; String[] jars = new String[size]; for (int i = 0; i < size; i++) { Bundle b = Platform.getBundle(REQUIRED_BUNDLE_IDS[i]); IPath path = null; if (b != null) path = PreviewRuntime.getJarredPluginPath(b); if (path == null) throw new CoreException( new Status( IStatus.ERROR, PreviewPlugin.PLUGIN_ID, "Could not find required bundle " + REQUIRED_BUNDLE_IDS[i])); jars[i] = path.toOSString(); } // Appending the bin onto the classpath is to support running from the workbench // when org.eclipse.wst.server.preview is checked out Trace.trace(Trace.FINEST, jars[CLASSPATH_BIN_INDEX_PREVIEW_SERVER] + File.separator + "bin"); if (new File(jars[CLASSPATH_BIN_INDEX_PREVIEW_SERVER] + File.separator + "bin").exists()) jars[CLASSPATH_BIN_INDEX_PREVIEW_SERVER] = jars[CLASSPATH_BIN_INDEX_PREVIEW_SERVER] + File.separator + "bin"; IVMInstall vm = verifyVMInstall(configuration); IVMRunner runner = vm.getVMRunner(mode); if (runner == null) runner = vm.getVMRunner(ILaunchManager.RUN_MODE); File workingDir = verifyWorkingDirectory(configuration); String workingDirName = null; if (workingDir != null) workingDirName = workingDir.getAbsolutePath(); // Program & VM args String pgmArgs = "\"" + previewServer.getTempDirectory().append("preview.xml").toOSString() + "\""; // getProgramArguments(configuration); String vmArgs = getVMArguments(configuration); String[] envp = getEnvironment(configuration); ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs); // VM-specific attributes Map vmAttributesMap = getVMSpecificAttributesMap(configuration); // Classpath String[] classpath2 = getClasspath(configuration); String[] classpath = new String[classpath2.length + REQUIRED_BUNDLE_IDS.length]; System.arraycopy(jars, 0, classpath, 0, REQUIRED_BUNDLE_IDS.length); System.arraycopy(classpath2, 0, classpath, REQUIRED_BUNDLE_IDS.length, classpath2.length); // Create VM config VMRunnerConfiguration runConfig = new VMRunnerConfiguration(MAIN_CLASS, classpath); runConfig.setProgramArguments(execArgs.getProgramArgumentsArray()); runConfig.setVMArguments(execArgs.getVMArgumentsArray()); runConfig.setWorkingDirectory(workingDirName); runConfig.setEnvironment(envp); runConfig.setVMSpecificAttributesMap(vmAttributesMap); // Bootpath String[] bootpath = getBootpath(configuration); if (bootpath != null && bootpath.length > 0) runConfig.setBootClassPath(bootpath); setDefaultSourceLocator(launch, configuration); // Launch the configuration previewServer.setupLaunch(launch, mode, monitor); if (ILaunchManager.PROFILE_MODE.equals(mode)) ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor); try { runner.run(runConfig, launch, monitor); previewServer.addProcessListener(launch.getProcesses()[0]); } catch (Exception e) { // ignore - process failed } }
@Override protected IStatus run(IProgressMonitor monitor) { IStatus retval = Status.OK_STATUS; if (monitor != null) { monitor.beginTask(Msgs.runningCleanAppServerTask, IProgressMonitor.UNKNOWN); } try { IRuntime runtime = ServerUtil.getRuntime(project); IServer[] servers = ServerUtil.getServersForRuntime(runtime); for (IServer server : servers) { String mode = server.getServerState() == IServer.STATE_STARTED ? server.getMode() : null; if (mode != null) { LiferayTomcatUtil.syncStopServer(server); } } ILiferayTomcatRuntime portalTomcatRuntime = LiferayTomcatUtil.getLiferayTomcatRuntime(runtime); IPath bundleZipLocation = portalTomcatRuntime.getBundleZipLocation(); Map<String, String> appServerProperties = ServerUtil.configureAppServerProperties(project); String appServerDir = ServerUtil.getAppServerPropertyKey( ISDKConstants.PROPERTY_APP_SERVER_DIR, portalTomcatRuntime); IStatus status = getSDK() .cleanAppServer( project, bundleZipLocation, appServerDir, appServerProperties, monitor); assertStatus(status); for (IServer server : servers) { // need to mark all other server modules at needing republishing since ext will wipe out // webapps folder IModule[] modules = server.getModules(); for (IModule mod : modules) { IModule[] m = new IModule[] {mod}; ((LiferayTomcatServerBehavior) server.loadAdapter(LiferayTomcatServerBehavior.class, monitor)) .setModulePublishState2(m, IServer.PUBLISH_STATE_FULL); } } } catch (Exception ex) { retval = LiferayTomcatPlugin.createErrorStatus(ex); } if (monitor != null) { monitor.done(); } return retval; }